From 613d846dbe17284d7a50be267357c41d1a32d1b9 Mon Sep 17 00:00:00 2001 From: rasta5man Date: Thu, 9 Jan 2025 22:21:50 +0100 Subject: [PATCH] Handle NOK master_node --- flow/cmd_manager.js | 42 ++++++++++++++++------------------------- flow/dido_controller.js | 4 ++-- 2 files changed, 18 insertions(+), 28 deletions(-) diff --git a/flow/cmd_manager.js b/flow/cmd_manager.js index 6e0bd42..a960aaa 100644 --- a/flow/cmd_manager.js +++ b/flow/cmd_manager.js @@ -1239,7 +1239,7 @@ exports.install = function(instance) { params.address = 0; params.timestamp = Date.now() + 60000; params.addMinutesToTimestamp = 5; - params.tbname = rvoTbName; + params.tbname = SETTINGS.rvoTbName; params.info = "Master node FW verzia"; //params.debug = true; @@ -1590,14 +1590,14 @@ exports.install = function(instance) { return; } } - - let contactorStatus = 1; - if(relaysData[line] != undefined) contactorStatus = relaysData[line].contactor; - - if (line == 0 || contactorStatus == 0) { - interval = setInterval(runTasks, LONG_INTERVAL); - return; - } + + let contactorStatus = 1; + if (relaysData[line] != undefined) contactorStatus = relaysData[line].contactor; + + if (line == 0 || contactorStatus == 0) { + interval = setInterval(runTasks, LONG_INTERVAL); + return; + } // TODO: -> status offline for rvo if rotary_switch_state is OFF, this is source of errors // @@ -1629,13 +1629,9 @@ exports.install = function(instance) { //set actual time for broadcast if (register == 87 && params.recipient === 2) { var d = new Date(); - let hours = d.getHours(); - let minutes = d.getMinutes(); - let seconds = d.getSeconds(); - - params.byte1 = hours;//h - params.byte2 = minutes;//m - params.byte3 = seconds;//s + params.byte1 = d.getHours();//h + params.byte2 = d.getMinutes();//m + params.byte3 = 0;//s params.byte4 = 0; } @@ -1645,11 +1641,8 @@ exports.install = function(instance) { if (type != "cmd-terminal") { let sunCalcResult = calculateDuskDawn(); - let dusk_hours = sunCalcResult["dusk_hours"]; - let dusk_minutes = sunCalcResult["dusk_minutes"]; - - params.byte1 = dusk_hours;//h - params.byte2 = dusk_minutes;//m + params.byte1 = sunCalcResult["dusk_hours"];//h + params.byte2 = sunCalcResult["dusk_minutes"];//m params.byte3 = 0;//s params.byte4 = 0; @@ -1662,11 +1655,8 @@ exports.install = function(instance) { if (register == 7 && params.recipient === 2) { if (type != "cmd-terminal") { let sunCalcResult = calculateDuskDawn(); - let dawn_hours = sunCalcResult["dawn_hours"]; - let dawn_minutes = sunCalcResult["dawn_minutes"]; - - params.byte1 = dawn_hours;//h - params.byte2 = dawn_minutes;//m + params.byte1 = sunCalcResult["dawn_hours"];//h + params.byte2 = sunCalcResult["dawn_minutes"];//m params.byte3 = 0;//s params.byte4 = 0; diff --git a/flow/dido_controller.js b/flow/dido_controller.js index 3a24f87..8415921 100644 --- a/flow/dido_controller.js +++ b/flow/dido_controller.js @@ -742,6 +742,7 @@ exports.install = function(instance) { async function sendRvoStatus() { if (SETTINGS === undefined) return; + SETTINGS.masterNodeIsResponding ? deviceStatus["master_node"] = "OK" : deviceStatus["master_node"] = "NOK"; const table = { "OK": 1, @@ -776,7 +777,7 @@ exports.install = function(instance) { let status = "OK"; for (const [key, value] of Object.entries(deviceStatus)) { - if (["em", "twilight_sensor", "temperature"].includes(key) && value == "NOK") status = "NOK"; + if (["em", "twilight_sensor", "temperature", "master_node"].includes(key) && value == "NOK") status = "NOK"; } if (status == "OK") { @@ -794,7 +795,6 @@ exports.install = function(instance) { // battery status. If value is 1 - battery is NOK if (previousValues[5] === 1) status = "NOK"; - if (!SETTINGS.masterNodeIsResponding) status = "NOK"; if (SETTINGS.no_voltage.size > 0) status = "NOK"; // console.log("rvo status",status)