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
|
|
@ -198,8 +198,7 @@ async function loadSettings()
|
||||||
FLOW.OMS_controller_type = responseSettings[0]["controller_type"];
|
FLOW.OMS_controller_type = responseSettings[0]["controller_type"];
|
||||||
FLOW.OMS_serial_port = responseSettings[0]["serial_port"];
|
FLOW.OMS_serial_port = responseSettings[0]["serial_port"];
|
||||||
|
|
||||||
//logger.log("", "settings", responseSettings[0], "-------------------------------------");
|
//logger.debug('settings', responseSettings[0]);
|
||||||
logger.debug('settings', responseSettings[0]);
|
|
||||||
|
|
||||||
//FLOW.OMS_tem
|
//FLOW.OMS_tem
|
||||||
//rvo_name:string|lang:string|temperature_adress:string|latitude:number|longitude:number
|
//rvo_name:string|lang:string|temperature_adress:string|latitude:number|longitude:number
|
||||||
|
|
@ -3142,7 +3141,7 @@ exports.install = function(instance) {
|
||||||
logger.debug("--->worksys", flowdata.data, data.params, entity, entity_type, command, method);
|
logger.debug("--->worksys", flowdata.data, data.params, entity, entity_type, command, method);
|
||||||
logger.debug("----------------------------");
|
logger.debug("----------------------------");
|
||||||
|
|
||||||
if(entity_type == "street_luminaire")
|
if(entity_type == "street_luminaire"|| entity_type === "street_luminaire_v4_1" || entity_type === "street_luminaire_v4_1cez" || entity_type === "street_luminaire_v4")
|
||||||
{
|
{
|
||||||
if(method == "set_command")
|
if(method == "set_command")
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -311,6 +311,7 @@ exports.install = function(instance) {
|
||||||
}, time);
|
}, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO: FIND BETTER SOLUTION, THAN REBUILDING TASKS
|
// TODO: FIND BETTER SOLUTION, THAN REBUILDING TASKS
|
||||||
// we ensure, all tasks will be rebuild twice a week on tuesday or saturday at 11. To set correct switch off and on times
|
// we ensure, all tasks will be rebuild twice a week on tuesday or saturday at 11. To set correct switch off and on times
|
||||||
let sendRebuildTasksAt11 = null;
|
let sendRebuildTasksAt11 = null;
|
||||||
|
|
@ -1463,11 +1464,37 @@ exports.install = function(instance) {
|
||||||
{
|
{
|
||||||
instance.send(instanceSendTo.cmd_manager, {sender: "dido_controller", cmd: "state_of_breaker", value: value, line: line});
|
instance.send(instanceSendTo.cmd_manager, {sender: "dido_controller", cmd: "state_of_breaker", value: value, line: line});
|
||||||
|
|
||||||
//mame 3 istice. ked je viac ako 3 linie, dalsie sa zapajaju paralelne. to znamena na istici 1 je linia 1 a 4, na istici 2 je linia 2 a 5, na istici 3 je linia 3 a 6 (key je string ("4"))
|
//mame iba 3 istice. vyreportujeme a ohandlujeme liniu na tom istom istici ako paralelna linia (napr linia 1, paralelna s nou je linia 4, key je string "4")
|
||||||
//vyreportujeme a ohandlujeme liniu na tom istom istici ako paralelna linia
|
// ak je 7 linii, na 1 istici je linia 1,4,7
|
||||||
|
|
||||||
|
if(line == 1)
|
||||||
|
{
|
||||||
|
|
||||||
|
const lineOnSameBraker = [4,7];
|
||||||
|
|
||||||
|
for (var i = 0; i < lineOnSameBraker.length; i++)
|
||||||
|
{
|
||||||
|
if(!relaysData.hasOwnProperty(lineOnSameBraker[i])) continue;
|
||||||
|
|
||||||
|
instance.send(instanceSendTo.cmd_manager, {sender: "dido_controller", cmd: "state_of_breaker", value: value, line: lineOnSameBraker[i]});
|
||||||
|
|
||||||
|
deviceStatuses["state_of_breaker"][lineOnSameBraker[i]] = value;
|
||||||
|
reportLineStatus(lineOnSameBraker[i]);
|
||||||
|
|
||||||
|
values[type] = value;
|
||||||
|
const tbname = relaysData[lineOnSameBraker[i]].tbname;
|
||||||
|
sendTelemetry(values, tbname);
|
||||||
|
|
||||||
|
delete values[type];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
const lineOnSameBraker = line + 3 + "";
|
const lineOnSameBraker = line + 3 + "";
|
||||||
|
|
||||||
if(relaysData.hasOwnProperty(lineOnSameBraker)) {
|
if(relaysData.hasOwnProperty(lineOnSameBraker))
|
||||||
|
{
|
||||||
instance.send(instanceSendTo.cmd_manager, {sender: "dido_controller", cmd: "state_of_breaker", value: value, line: line + 3});
|
instance.send(instanceSendTo.cmd_manager, {sender: "dido_controller", cmd: "state_of_breaker", value: value, line: line + 3});
|
||||||
|
|
||||||
deviceStatuses["state_of_breaker"][line + 3] = value;
|
deviceStatuses["state_of_breaker"][line + 3] = value;
|
||||||
|
|
@ -1479,6 +1506,9 @@ exports.install = function(instance) {
|
||||||
|
|
||||||
delete values[type];
|
delete values[type];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(value == "Off") values["status"] = "NOK";
|
if(value == "Off") values["status"] = "NOK";
|
||||||
|
|
|
||||||
|
|
@ -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