add buildTasks function to dido_controller and handle 7 lines with state_of_braker
This commit is contained in:
parent
ac2ccc1c61
commit
86c7b3a942
3 changed files with 5940 additions and 5907 deletions
7965
flow/cmd_manager.js
7965
flow/cmd_manager.js
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -3,7 +3,7 @@ exports.title = 'Modbus reader';
|
||||||
exports.version = '2.0.0';
|
exports.version = '2.0.0';
|
||||||
exports.group = 'Worksys';
|
exports.group = 'Worksys';
|
||||||
exports.color = '#2134B0';
|
exports.color = '#2134B0';
|
||||||
exports.output = ["red", "white"];
|
exports.output = ["red", "white", "yellow"];
|
||||||
exports.click = false;
|
exports.click = false;
|
||||||
exports.author = 'Rastislav Kovac';
|
exports.author = 'Rastislav Kovac';
|
||||||
exports.icon = 'bolt';
|
exports.icon = 'bolt';
|
||||||
|
|
@ -24,16 +24,18 @@ const errorHandler = new ErrorToServiceHandler();
|
||||||
|
|
||||||
const { sendNotification } = require('./helper/notification_reporter');
|
const { sendNotification } = require('./helper/notification_reporter');
|
||||||
|
|
||||||
|
const DELAY_BETWEEN_DEVICES = 10000;
|
||||||
|
|
||||||
const instanceSendTo = {
|
const instanceSendTo = {
|
||||||
debug: 0,
|
debug: 0,
|
||||||
dido_controller: 1,
|
dido_controller: 1,
|
||||||
|
tb: 2
|
||||||
};
|
};
|
||||||
|
|
||||||
//to handle NOK and OK sendNotifications s
|
//to handle NOK and OK sendNotifications s
|
||||||
const numberOfNotResponding = {};
|
const numberOfNotResponding = {};
|
||||||
let tbName = null;
|
let tbName = null;
|
||||||
|
|
||||||
|
|
||||||
exports.install = function(instance) {
|
exports.install = function(instance) {
|
||||||
|
|
||||||
class SocketWithClients {
|
class SocketWithClients {
|
||||||
|
|
@ -86,7 +88,7 @@ exports.install = function(instance) {
|
||||||
this.socket.on('open', function () {
|
this.socket.on('open', function () {
|
||||||
console.log("socket connected");
|
console.log("socket connected");
|
||||||
obj.getActualStreamAndDevice();
|
obj.getActualStreamAndDevice();
|
||||||
obj.timeoutInterval = timeoutInterval;
|
obj.timeoutInterval = timeoutInterval - DELAY_BETWEEN_DEVICES; // to make sure readout always runs in timeoutinterval we substract DELAY_BETWEEN_DEVICES
|
||||||
})
|
})
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
@ -101,7 +103,7 @@ exports.install = function(instance) {
|
||||||
this.device = dev.device; //em340, twilight_sensor
|
this.device = dev.device; //em340, twilight_sensor
|
||||||
|
|
||||||
if(this.indexInDeviceConfig == 0) setTimeout(this.readRegisters, this.timeoutInterval);
|
if(this.indexInDeviceConfig == 0) setTimeout(this.readRegisters, this.timeoutInterval);
|
||||||
else setTimeout(this.readRegisters, 2000);
|
else setTimeout(this.readRegisters, DELAY_BETWEEN_DEVICES);
|
||||||
}
|
}
|
||||||
|
|
||||||
readRegisters = () => {
|
readRegisters = () => {
|
||||||
|
|
@ -139,9 +141,7 @@ exports.install = function(instance) {
|
||||||
|
|
||||||
obj.error = 0;
|
obj.error = 0;
|
||||||
obj.index++;
|
obj.index++;
|
||||||
|
obj.readAnotherRegister();
|
||||||
if(obj.index < obj.lengthOfActualDeviceStream) setTimeout(obj.readRegisters, 0);
|
|
||||||
else obj.setNewStream();
|
|
||||||
|
|
||||||
}).catch (function () {
|
}).catch (function () {
|
||||||
|
|
||||||
|
|
@ -177,12 +177,16 @@ exports.install = function(instance) {
|
||||||
}))
|
}))
|
||||||
|
|
||||||
obj.index++;
|
obj.index++;
|
||||||
if(obj.index < obj.lengthOfActualDeviceStream) setTimeout(obj.readRegisters, 0);
|
obj.readAnotherRegister();
|
||||||
else obj.setNewStream();
|
|
||||||
})
|
})
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
readAnotherRegister = () => {
|
||||||
|
if(this.index < this.lengthOfActualDeviceStream) setTimeout(this.readRegisters, 0);
|
||||||
|
else this.setNewStream();
|
||||||
|
}
|
||||||
|
|
||||||
transformResponse = (response, register, deviceAddress) => {
|
transformResponse = (response, register, deviceAddress) => {
|
||||||
|
|
||||||
for (let i = 0; i < this.lengthOfActualDeviceStream; i++) {
|
for (let i = 0; i < this.lengthOfActualDeviceStream; i++) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue