version 2025-01-21; offline node status, do not turn lines on startup if not needed

This commit is contained in:
rasta5man 2025-01-25 14:50:44 +01:00
parent 4c59ccd095
commit 73a2620add
3 changed files with 164 additions and 251 deletions

View file

@ -50,7 +50,6 @@ state_of_contactor - podľa indexu stykača sa reportuje jeho stav, teda stykač
const { errLogger, logger, monitor } = require('./helper/logger');
const SerialPort = require('serialport');
const WebSocket = require('ws');
//const { exec } = require('child_process');
const { runSyncExec } = require('./helper/serialport_helper');
const { bytesToInt, resizeArray } = require('./helper/utils');
const { sendNotification } = require('./helper/notification_reporter');
@ -71,7 +70,6 @@ let rvoTbName;
let GLOBALS; //FLOW global GLOBALS
let SETTINGS; // GLOBALS.settings
let controller_type;
let contactorSwitchCounter = 0; //how many times line contactor switched ?
let alarmStatus = "OFF";
@ -128,7 +126,7 @@ exports.install = function(instance) {
//status for calculating Statecodes
let deviceStatus = { //key is device name: temperature,....
"state_of_main_switch": "Off", //Hlavný istič
"state_of_main_switch": "Off", //Hlavný istič (po novom druhy dverovy kontakt)
"rotary_switch_state": "Off", //Prevádzkový mód
"door_condition": "closed", //Dverový kontakt
"em": "OK", //elektromer rvo
@ -203,13 +201,10 @@ exports.install = function(instance) {
sendTelemetry(values, rvoTbName);
let time = 5 * 1000;
setTimeout(function() {
instance.send(SEND_TO.cmd_manager, { sender: "dido_controller", cmd: "buildTasks" });
instance.send(SEND_TO.cmd_manager, { sender: "dido_controller", cmd: "buildTasks" });
sendNotification("rsPort.open()", rvoTbName, "flow_start", {}, "", SEND_TO.tb, instance);
monitor.info("-->FLOW bol spustený", rvoTbName, SETTINGS.edge_fw_version);
}, time);
sendNotification("rsPort.open()", rvoTbName, "flow_start", {}, "", SEND_TO.tb, instance);
monitor.info("-->FLOW bol spustený", rvoTbName, SETTINGS.edge_fw_version);
}
@ -309,6 +304,7 @@ exports.install = function(instance) {
initialSetting();
setTimeout(function() { ws.send(JSON.stringify({ cmd: "all" })) }, 5000);
// we request dev info about neuron device from evok to keep websocket connection alive
// for some reason this request returns no data, but connection keeps alive
startRequests = setInterval(() => {
@ -574,13 +570,13 @@ exports.install = function(instance) {
sendRvoStatus();
})
// we expect array as flowdata.data
instance.on("1", flowdata => {
console.log(flowdata.data);
//console.log(flowdata.data);
if (!flowdata.data instanceof Object) return;
@ -588,11 +584,7 @@ exports.install = function(instance) {
let line = obj.line;
let force = obj.force;
let info = obj.info;
//how many times did the lines switched ? if all lines (except line 0) has switched, we request data from evok:
contactorSwitchCounter++;
if(contactorSwitchCounter == Object.keys(relaysData).length-1 && ws) setTimeout(function(){ws.send(JSON.stringify({cmd:"all"}))},5000);
if (obj.command == "on") turnLine("on", line, undefined, force, info);
else if (obj.command == "off") turnLine("off", line, undefined, force, info);
else if (obj.command == "turnOnAlarm") turnAlarm("on");
@ -815,26 +807,6 @@ exports.install = function(instance) {
let value = "On";
if (newPinValue === 0) value = "Off";
//Hlavný istič
//! po novom uz 'state of main switch' nemame. Namiesto neho je 'door_condition', kedze mame dvoje dveri
//! takze ked pride z evoku signal pre 'input1_05', handlujeme ho ako 'door_condition'
// if(type === "!!!state_of_main_switch")
// {
// if (newPinValue === 0 && newPinValue !== previousValues[pinIndex])
// {
// sendNotification("switchLogic", rvoTbName, "main_switch_has_been_turned_off", {}, "", SEND_TO.tb, instance , "state_of_main_switch");
// values["status"] = "NOK";
// deviceStatus["state_of_main_switch"] = "Off";
// }
// else if (newPinValue === 1 && newPinValue !== previousValues[pinIndex])
// {
// sendNotification("switchLogic", rvoTbName, "main_switch_has_been_turned_on", {}, "", SEND_TO.tb, instance , "state_of_main_switch");
// deviceStatus["state_of_main_switch"] = "On";
// }
// }
//Prevádzkový mód
if (type == "rotary_switch_state") {
// combination of these two pins required to get result