- // IN PINS 21, 20, 19, 18, 16
- // OUT PINS 13, 12, 11, 10, 9
- // process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
- // SETUP
- // const Settings = require('./settings.js');
- // const Core = new (require('./core.js'));
- // PACKAGES
- const ON = 0;
- const OFF = 1;
- const Gpio = require('onoff').Gpio;
- const devices = {
- dilim1: {
- in: new Gpio(22, 'in', 'both'),
- out: new Gpio(5, 'out'),
- },
- dilim2: {
- in: new Gpio(18, 'in', 'both'),
- out: new Gpio(21, 'out'),
- },
- dilim3: {
- in: new Gpio(23, 'in', 'both'),
- out: new Gpio(20, 'out'),
- },
- semiRot2: {
- in: new Gpio(24, 'in', 'both'),
- out: new Gpio(16, 'out'),
- },
- flat3: {
- in: new Gpio(17, 'in', 'both'),
- out: new Gpio(13, 'out'),
- },
- flat4: {
- in: new Gpio(27, 'in', 'both'),
- out: new Gpio(6, 'out'),
- },
- flat2: {
- in: new Gpio(15, 'in', 'both'),
- out: new Gpio(19, 'out'),
- },
- flat1: {
- in: new Gpio(14, 'in', 'both'),
- out: new Gpio(26, 'out'),
- },
- };
- // const DELAY = 60000; // 60 second
- setTimeout(function () {
- /*devices.dilim1.out.writeSync(OFF);
- devices.dilim2.out.writeSync(OFF);
- devices.dilim3.out.writeSync(OFF);
- devices.semiRot2.out.writeSync(OFF);
- devices.flat2.out.writeSync(OFF);
- devices.flat3.out.writeSync(OFF);
- devices.flat4.out.writeSync(OFF);
- devices.flat1.out.writeSync(OFF);*/
- console.log('dilim1 - ' + devices.dilim1.out.readSync());
- console.log('dilim2 - ' + devices.dilim2.out.readSync());
- console.log('dilim3 - ' + devices.dilim3.out.readSync());
- console.log('semiRot2 - ' + devices.semiRot2.out.readSync());
- console.log('flat2 - ' + devices.flat2.out.readSync());
- console.log('flat3 - ' + devices.flat3.out.readSync());
- console.log('flat4 - ' + devices.flat4.out.readSync());
- console.log('flat1 - ' + devices.flat1.out.readSync());
- /*devices.dilim2.out.writeSync(OFF);
- devices.dilim3.out.writeSync(OFF);
- devices.semiRot2.out.writeSync(OFF);
- devices.flat2.out.writeSync(OFF);
- devices.flat3.out.writeSync(OFF);
- devices.flat4.out.writeSync(OFF);
- devices.flat1.out.writeSync(OFF);*/
- }, 3000);
- setTimeout(function () {
- devices.dilim1.in.watch(function (err, value) {
- if (err) { throw err; }
- console.log('DİLİM 1 - ' + value);
- devices.dilim1.out.writeSync(value ? ON : OFF);
- });
- devices.dilim2.in.watch(function (err, value) {
- if (err) { throw err; }
- console.log('DİLİM 2 - ' + value);
- devices.dilim2.out.writeSync(value ? ON : OFF);
- });
- devices.dilim3.in.watch(function (err, value) {
- if (err) { throw err; }
- console.log('DİLİM 3 - ' + value);
- devices.dilim3.out.writeSync(value ? ON : OFF);
- });
- devices.semiRot2.in.watch(function (err, value) {
- if (err) { throw err; }
- console.log('DEMİ ROT 2 - ' + value);
- devices.semiRot2.out.writeSync(value ? ON : OFF);
- });
- devices.flat3.in.watch(function (err, value) {
- if (err) { throw err; }
- console.log('FLAT 3 - ' + value);
- devices.flat3.out.writeSync(value ? ON : OFF);
- });
- devices.flat4.in.watch(function (err, value) {
- if (err) { throw err; }
- console.log('FLAT 4 - ' + value);
- devices.flat4.out.writeSync(value ? ON : OFF);
- });
- devices.flat1.in.watch(function (err, value) {
- if (err) { throw err; }
- console.log('FLAT 1 - ' + value);
- devices.flat1.out.writeSync(value ? ON : OFF);
- });
- devices.flat2.in.watch(function (err, value) {
- if (err) { throw err; }
- console.log('FLAT 2 - ' + value);
- devices.flat2.out.writeSync(value ? ON : OFF);
- });
- }, 5000);