Rvo status handled just in dido_controller

This commit is contained in:
rasta5man 2024-09-22 22:18:46 +02:00
parent 1b4b9ca973
commit ca39e1266c
6 changed files with 166 additions and 318 deletions

View file

@ -142,7 +142,6 @@ let nodesData = {};//key is node, value data from db
let cmdCounter = {};//key is node, value is counter
let cmdNOKNodeCounter = {};//key is node, value is counter
let testTbName = "deleteAfterTesting" //for status testing purposes;
//END OF VARIABLE SETTINGS
//--------------------------------
@ -319,8 +318,6 @@ function processNodeProfile(node)
cmdCounter[node] = 1;
tasks.push(params);
//sendNotification("CMD Manager: process cmd", relaysData[0].tbname, ERRWEIGHT.NOTICE, "Master node is working again", "", SEND_TO.tb, instance );
}
else
{
@ -1794,9 +1791,7 @@ exports.install = function(instance) {
message = "off";
}
//sendNotification("CMD Manager: process cmd", relaysData[0].tbname, ERRWEIGHT.INFO, "aplikovaný bod profilu línie " + params.line + " - stav: " + message, "", SEND_TO.tb, instance, null );
sendNotification("CMD Manager: process cmd", FLOW.OMS_edgeName, "switching_profile_point_applied_to_line", {line: params.line, value: message}, "", SEND_TO.tb, instance );
interval = setInterval(runTasks, SHORT_INTERVAL);
return;
}
@ -1936,7 +1931,6 @@ exports.install = function(instance) {
//TODO astrohodiny
let dusk = "Time of dusk: " + sunCalcResult["dusk"];
//sendNotification("CMD Manager: calculated Time of dusk", relaysData[0].tbname, ERRWEIGHT.INFO, dusk, "", SEND_TO.tb, instance, null );
}
}
@ -1956,7 +1950,6 @@ exports.install = function(instance) {
//TODO astrohodiny
let dawn = "Time of dawn: " + sunCalcResult["dawn"];
//sendNotification("CMD Manager: calculated Time of dusk", relaysData[0].tbname, ERRWEIGHT.INFO, dawn, "", SEND_TO.tb, instance, null );
}
}
@ -1968,7 +1961,7 @@ exports.install = function(instance) {
startTime = new Date();
let saveToTb = true;
if(!tbname) saveToTb = false;
if(!tbname) saveToTb = false;
let itIsNodeCommand = listOfCommands.includes(register); //reading data from node (voltage, current, dimming, status)
let resp = com_generic(nodeAddress, params.recipient, params.rw, register, params.name, params.byte1, params.byte2, params.byte3, params.byte4);
@ -1993,13 +1986,6 @@ exports.install = function(instance) {
let message_type = result.type;
let error = result.error;
//testing purpose node 638, tbname rDbQ84xzwgdqEoPm3kbJQWk9anOZY1RXyBv2LVM6
if(tbname == testTbName) {
message = "NOK";
message_type = "ERROR";
error = "type is: ERROR";
}
if(params.debug != "generated cmd")
{
//debug("writeData: done " + message_type + " duration: " + timeDiff + " message_type: " + params.debug, params);
@ -2057,24 +2043,16 @@ exports.install = function(instance) {
}
//master node
if(nodeAddress == 0 && register == 4)
{
values.status = "OK";
values["edge_fw_version"] = FLOW.OMS_edge_fw_version;
}
if(nodeAddress == 0)
{
//sendNotification("CMD Manager: process cmd", relaysData[0].tbname, ERRWEIGHT.NOTICE, "Master node is working again", "", SEND_TO.tb, instance, "rvo_status" );
//sendNotification("CMD Manager: process cmd", relaysData[0].tbname, "master_node_is_responding_again", {}, "", SEND_TO.tb, instance, "rvo_status" );
sendNotification("CMD Manager: process cmd", FLOW.OMS_edgeName, "master_node_is_responding_again", {}, "", SEND_TO.tb, instance, "rvo_status" );
FLOW.OMS_masterNodeIsResponding = true;
if(register == 4) values["edge_fw_version"] = FLOW.OMS_edge_fw_version;
}
//odoslanie príkazu z terminálu - dáta
if(type == "cmd-terminal")
{
//sendNotification("CMD Manager: process cmd", relaysData[0].tbname, ERRWEIGHT.DEBUG, "odoslanie príkazu z terminálu", params, SEND_TO.tb, instance, null );
sendNotification("CMD Manager: process cmd", FLOW.OMS_edgeName, "command_was_sent_from_terminal_interface", {}, params, SEND_TO.tb, instance );
}
@ -2169,23 +2147,23 @@ exports.install = function(instance) {
let values = {};
console.log(message);
// console.log(message);
let updateStatus = updateNodeStatus(node, false);
//master node
if(node == 0)
{
//sendNotification("CMD Manager: process cmd", relaysData[0].tbname, ERRWEIGHT.ALERT, "Master node not responding", "", SEND_TO.tb, instance, "rvo_status");
sendNotification("CMD Manager: process cmd", FLOW.OMS_edgeName, "master_node_is_not_responding", {}, "", SEND_TO.tb, instance, "rvo_status");
logger.debug("master_node_is_not_responding", params);
FLOW.OMS_masterNodeIsResponding = false;
if(register == 4) values["master_node_version"] = "NOK";
}
if(type == "set_node_profile")
{
delete cmdCounter[node];
logger.debug( "profil nebol úspešne odoslaný na node č. ", params, resp);
//sendNotification("CMD Manager: process cmd", tbname, ERRWEIGHT.ALERT, "odosielanie profilu na node č. " + node + " zlyhalo", "", SEND_TO.tb, instance, null );
logger.debug( "profil nebol úspešne odoslaný na node č. ", params);
sendNotification("CMD Manager: process cmd", tbName, "configuration_of_dimming_profile_to_node_failed", {node: node}, "", SEND_TO.tb, instance );
}
@ -2199,14 +2177,7 @@ exports.install = function(instance) {
values.status = "NOK";
}
//master node
if(node == 0 && register == 4)
{
values.status = "NOK";
values["master_node_version"] = "NOK";
}
console.log("------",node, register, type, itIsNodeCommand, updateStatus, saveToTb, values);
// console.log("------",node, register, type, itIsNodeCommand, updateStatus, saveToTb, values);
if(saveToTb && Object.keys(values).length > 0 && tbName)
{
@ -2391,12 +2362,6 @@ exports.install = function(instance) {
rsPort.close();
});
instance.on("1", function(flowdata){
if(flowdata.data.hasOwnProperty("testTbName"))
{
testTbName = flowdata.data.testTbName;
}
})
instance.on("data", async function(flowdata) {
@ -2535,7 +2500,6 @@ exports.install = function(instance) {
tasks.push(params);
//process profiles
turnOnOffLinesAccordingToLuxSensor(lux_sensor);
}
@ -2552,14 +2516,7 @@ exports.install = function(instance) {
state_of_breaker[line] = value;
let status = "OK";
let weight = ERRWEIGHT.NOTICE;
let message = `zapnutý istič línie č. ${line}`;
if(value == "Off")
{
weight = ERRWEIGHT.ERROR;
message = `vypnutý istič línie č. ${line}`;
status = "NOK";
}
if(value == "Off") status = "NOK";
if(dataChanged) {
@ -2588,11 +2545,7 @@ exports.install = function(instance) {
tbHandler.sendToTb(dataToTb, instance);
//current value
if(value == "Off")
{
//vyreportovat vsetky svietdla na linii
reportOfflineNodeStatus(line);
}
if(value == "Off") reportOfflineNodeStatus(line); //vyreportovat vsetky svietidla na linii
else reportOnlineNodeStatus(line);
}
@ -2788,7 +2741,6 @@ exports.install = function(instance) {
if(profile === "") logger.debug("worksys - update node profile done - profile is empty");
//profil úspešne prijatý pre node č. xx
//sendNotification("CMD manager", tbname, ERRWEIGHT.INFO, `profil úspešne poslaný z platformy na RVO pre node č. ${node}`, profile, SEND_TO.tb, instance, null );
sendNotification("CMD manager", tbname, "dimming_profile_was_processed_for_node", {node: node}, profile, SEND_TO.tb, instance );
nodesData[node].processed = false;