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_serial_port = responseSettings[0]["serial_port"];
|
||||
|
||||
//logger.log("", "settings", responseSettings[0], "-------------------------------------");
|
||||
logger.debug('settings', responseSettings[0]);
|
||||
//logger.debug('settings', responseSettings[0]);
|
||||
|
||||
//FLOW.OMS_tem
|
||||
//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("----------------------------");
|
||||
|
||||
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")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -311,6 +311,7 @@ exports.install = function(instance) {
|
|||
}, time);
|
||||
}
|
||||
|
||||
|
||||
// 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
|
||||
let sendRebuildTasksAt11 = null;
|
||||
|
|
@ -1463,22 +1464,51 @@ exports.install = function(instance) {
|
|||
{
|
||||
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"))
|
||||
//vyreportujeme a ohandlujeme liniu na tom istom istici ako paralelna linia
|
||||
const lineOnSameBraker = line + 3 + "";
|
||||
//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")
|
||||
// ak je 7 linii, na 1 istici je linia 1,4,7
|
||||
|
||||
if(relaysData.hasOwnProperty(lineOnSameBraker)) {
|
||||
instance.send(instanceSendTo.cmd_manager, {sender: "dido_controller", cmd: "state_of_breaker", value: value, line: line + 3});
|
||||
if(line == 1)
|
||||
{
|
||||
|
||||
deviceStatuses["state_of_breaker"][line + 3] = value;
|
||||
reportLineStatus(line + 3);
|
||||
const lineOnSameBraker = [4,7];
|
||||
|
||||
values[type] = value;
|
||||
const tbname = relaysData[lineOnSameBraker].tbname;
|
||||
sendTelemetry(values, tbname);
|
||||
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];
|
||||
}
|
||||
|
||||
delete values[type];
|
||||
}
|
||||
else
|
||||
{
|
||||
const lineOnSameBraker = line + 3 + "";
|
||||
|
||||
if(relaysData.hasOwnProperty(lineOnSameBraker))
|
||||
{
|
||||
instance.send(instanceSendTo.cmd_manager, {sender: "dido_controller", cmd: "state_of_breaker", value: value, line: line + 3});
|
||||
|
||||
deviceStatuses["state_of_breaker"][line + 3] = value;
|
||||
reportLineStatus(line + 3);
|
||||
|
||||
values[type] = value;
|
||||
const tbname = relaysData[lineOnSameBraker].tbname;
|
||||
sendTelemetry(values, tbname);
|
||||
|
||||
delete values[type];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(value == "Off") values["status"] = "NOK";
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ exports.title = 'Modbus reader';
|
|||
exports.version = '2.0.0';
|
||||
exports.group = 'Worksys';
|
||||
exports.color = '#2134B0';
|
||||
exports.output = ["red", "white"];
|
||||
exports.output = ["red", "white", "yellow"];
|
||||
exports.click = false;
|
||||
exports.author = 'Rastislav Kovac';
|
||||
exports.icon = 'bolt';
|
||||
|
|
@ -24,16 +24,18 @@ const errorHandler = new ErrorToServiceHandler();
|
|||
|
||||
const { sendNotification } = require('./helper/notification_reporter');
|
||||
|
||||
const DELAY_BETWEEN_DEVICES = 10000;
|
||||
|
||||
const instanceSendTo = {
|
||||
debug: 0,
|
||||
dido_controller: 1,
|
||||
tb: 2
|
||||
};
|
||||
|
||||
//to handle NOK and OK sendNotifications s
|
||||
const numberOfNotResponding = {};
|
||||
let tbName = null;
|
||||
|
||||
|
||||
exports.install = function(instance) {
|
||||
|
||||
class SocketWithClients {
|
||||
|
|
@ -86,7 +88,7 @@ exports.install = function(instance) {
|
|||
this.socket.on('open', function () {
|
||||
console.log("socket connected");
|
||||
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
|
||||
|
||||
if(this.indexInDeviceConfig == 0) setTimeout(this.readRegisters, this.timeoutInterval);
|
||||
else setTimeout(this.readRegisters, 2000);
|
||||
else setTimeout(this.readRegisters, DELAY_BETWEEN_DEVICES);
|
||||
}
|
||||
|
||||
readRegisters = () => {
|
||||
|
|
@ -139,9 +141,7 @@ exports.install = function(instance) {
|
|||
|
||||
obj.error = 0;
|
||||
obj.index++;
|
||||
|
||||
if(obj.index < obj.lengthOfActualDeviceStream) setTimeout(obj.readRegisters, 0);
|
||||
else obj.setNewStream();
|
||||
obj.readAnotherRegister();
|
||||
|
||||
}).catch (function () {
|
||||
|
||||
|
|
@ -177,12 +177,16 @@ exports.install = function(instance) {
|
|||
}))
|
||||
|
||||
obj.index++;
|
||||
if(obj.index < obj.lengthOfActualDeviceStream) setTimeout(obj.readRegisters, 0);
|
||||
else obj.setNewStream();
|
||||
obj.readAnotherRegister();
|
||||
})
|
||||
|
||||
};
|
||||
|
||||
readAnotherRegister = () => {
|
||||
if(this.index < this.lengthOfActualDeviceStream) setTimeout(this.readRegisters, 0);
|
||||
else this.setNewStream();
|
||||
}
|
||||
|
||||
transformResponse = (response, register, deviceAddress) => {
|
||||
|
||||
for (let i = 0; i < this.lengthOfActualDeviceStream; i++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue