loadRelaysData function removed from rsPort, DataToTbHandler-send data if broker not connected
This commit is contained in:
parent
ca39e1266c
commit
1c131d0b63
4 changed files with 19 additions and 47 deletions
|
|
@ -275,17 +275,19 @@ function processNodeProfile(node)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let profile = nodeObj.profile;
|
|
||||||
|
|
||||||
logger.debug("processNodeProfile: start - set profile for ", node, profile);
|
logger.debug("processNodeProfile: start - set profile for ", node, profile);
|
||||||
|
|
||||||
let nodeProfile;
|
let nodeProfile = nodeObj.profile;
|
||||||
try {
|
if(nodeProfile) {
|
||||||
nodeProfile = JSON.parse(profile);
|
|
||||||
if(Object.keys(nodeProfile).length === 0) throw ("profile is not defined");
|
try {
|
||||||
} catch (error) {
|
nodeProfile = JSON.parse(nodeProfile);
|
||||||
logger.debug("Error parsing node profile", error);
|
if(Object.keys(nodeProfile).length === 0) throw ("profile is not defined");
|
||||||
}
|
} catch (error) {
|
||||||
|
logger.debug("Error parsing node profile", error);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
logger.debug("processNodeProfile", node, line, nodeObj, nodeProfile);
|
logger.debug("processNodeProfile", node, line, nodeObj, nodeProfile);
|
||||||
|
|
||||||
|
|
@ -293,7 +295,7 @@ function processNodeProfile(node)
|
||||||
|
|
||||||
removeTask({type: "set_node_profile", address: node});
|
removeTask({type: "set_node_profile", address: node});
|
||||||
|
|
||||||
if(nodeProfile === undefined)
|
if(nodeProfile === "")
|
||||||
{
|
{
|
||||||
//vypneme profil nodu, posleme cmd
|
//vypneme profil nodu, posleme cmd
|
||||||
//Pokiaľ je hodnota rovná 1 – Profil sa zapne, ostatné bity sa nezmenia.
|
//Pokiaľ je hodnota rovná 1 – Profil sa zapne, ostatné bity sa nezmenia.
|
||||||
|
|
@ -1709,33 +1711,6 @@ exports.install = function(instance) {
|
||||||
{
|
{
|
||||||
tasks[0].timestamp = currentTimestamp + tasks[0].addMinutesToTimestamp * 60000;
|
tasks[0].timestamp = currentTimestamp + tasks[0].addMinutesToTimestamp * 60000;
|
||||||
|
|
||||||
//select nespracovane nody
|
|
||||||
//node:number|tbname:string|line:number|profile:string|processed:boolean|status:boolean
|
|
||||||
|
|
||||||
//buildTasks({processLineProfiles: true, line: line});
|
|
||||||
|
|
||||||
/*
|
|
||||||
let keys = Object.keys(nodesData);
|
|
||||||
for(let i = 0; i < keys.length; i++)
|
|
||||||
{
|
|
||||||
let node = keys[i];
|
|
||||||
let line = node.line;
|
|
||||||
|
|
||||||
if(node.processed) continue;
|
|
||||||
|
|
||||||
if(relaysData[line] != undefined)
|
|
||||||
{
|
|
||||||
let relayStatus = relaysData[line].contactor;
|
|
||||||
if(relayStatus == 1)
|
|
||||||
{
|
|
||||||
//linia je zapnuta
|
|
||||||
//await loadRelaysData(flowdata.data.line);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
//vsetky linie kt. su zapnute, a spracuju sa nespracovane profily nodov
|
//vsetky linie kt. su zapnute, a spracuju sa nespracovane profily nodov
|
||||||
loadRelaysData();
|
loadRelaysData();
|
||||||
|
|
||||||
|
|
@ -2143,7 +2118,7 @@ exports.install = function(instance) {
|
||||||
let register = params.register;
|
let register = params.register;
|
||||||
let type = params.type;
|
let type = params.type;
|
||||||
let tbName = params.tbname;
|
let tbName = params.tbname;
|
||||||
tbName && (tbName = nodesData[node].tbname);
|
if(!tbName) return;
|
||||||
|
|
||||||
let values = {};
|
let values = {};
|
||||||
|
|
||||||
|
|
@ -2178,7 +2153,7 @@ exports.install = function(instance) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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)
|
if(saveToTb && Object.keys(values).length > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
let dataToTb = {
|
let dataToTb = {
|
||||||
|
|
@ -2318,7 +2293,7 @@ exports.install = function(instance) {
|
||||||
|
|
||||||
logger.debug("CMD manager - rsPort opened sucess");
|
logger.debug("CMD manager - rsPort opened sucess");
|
||||||
|
|
||||||
loadRelaysData();
|
//loadRelaysData();
|
||||||
|
|
||||||
await runSyncExec(`stty -F /dev/${FLOW.OMS_serial_port} 115200 min 1 time 5 ignbrk -brkint -icrnl -imaxbel -opost -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke`).then(function (status) {
|
await runSyncExec(`stty -F /dev/${FLOW.OMS_serial_port} 115200 min 1 time 5 ignbrk -brkint -icrnl -imaxbel -opost -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke`).then(function (status) {
|
||||||
instance.send(SEND_TO.debug, "RPC runSyncExec - Promise Resolved:" + status);
|
instance.send(SEND_TO.debug, "RPC runSyncExec - Promise Resolved:" + status);
|
||||||
|
|
@ -2353,7 +2328,6 @@ exports.install = function(instance) {
|
||||||
rsPort.close();
|
rsPort.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
//loadRelaysData();
|
|
||||||
rsPort.open();
|
rsPort.open();
|
||||||
|
|
||||||
instance.on("close", () => {
|
instance.on("close", () => {
|
||||||
|
|
|
||||||
|
|
@ -235,7 +235,7 @@ exports.install = function(instance) {
|
||||||
let responseStatus = await promisifyBuilder(dbStatus.find());
|
let responseStatus = await promisifyBuilder(dbStatus.find());
|
||||||
statusData = responseStatus[0]; // {thermometer: 'OK', em: 'OK', twilight_sensor: 'OK'}
|
statusData = responseStatus[0]; // {thermometer: 'OK', em: 'OK', twilight_sensor: 'OK'}
|
||||||
deviceStatus["temperature"] = statusData.thermometer;
|
deviceStatus["temperature"] = statusData.thermometer;
|
||||||
|
|
||||||
FLOW.OMS_rvo_tbname = relaysData[0].tbname;
|
FLOW.OMS_rvo_tbname = relaysData[0].tbname;
|
||||||
|
|
||||||
if(controller_type === "lm")
|
if(controller_type === "lm")
|
||||||
|
|
@ -1367,7 +1367,6 @@ exports.install = function(instance) {
|
||||||
|
|
||||||
//ak bola predchadzajuci stav off a novy stav je on, budu sa nastavovat nespracovane node profiles
|
//ak bola predchadzajuci stav off a novy stav je on, budu sa nastavovat nespracovane node profiles
|
||||||
//a budu sa odosielat commandy, tie vsak mozu zlyhat, a preto potrebujeme ich spusti trochu neskor
|
//a budu sa odosielat commandy, tie vsak mozu zlyhat, a preto potrebujeme ich spusti trochu neskor
|
||||||
|
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
instance.send(SEND_TO.cmd_manager, {sender: "dido_controller", cmd: "reload_relays", line: line, time: time, value: value, dataChanged: dataChanged});
|
instance.send(SEND_TO.cmd_manager, {sender: "dido_controller", cmd: "reload_relays", line: line, time: time, value: value, dataChanged: dataChanged});
|
||||||
}, time);
|
}, time);
|
||||||
|
|
@ -1439,7 +1438,6 @@ exports.install = function(instance) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(value == "Off") values["status"] = "NOK";
|
if(value == "Off") values["status"] = "NOK";
|
||||||
|
|
||||||
deviceStatus["state_of_breaker"][line] = value;
|
deviceStatus["state_of_breaker"][line] = value;
|
||||||
|
|
||||||
reportLineStatus(line);
|
reportLineStatus(line);
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,8 @@ class DataToTbHandler {
|
||||||
|
|
||||||
if(!FLOW.OMS_brokerready)
|
if(!FLOW.OMS_brokerready)
|
||||||
{
|
{
|
||||||
return dataToTb;
|
instance.send(this.index, dataToTb);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let keys = Object.keys(dataToTb);
|
let keys = Object.keys(dataToTb);
|
||||||
|
|
@ -92,7 +93,6 @@ class DataToTbHandler {
|
||||||
|
|
||||||
//console.log(this.sender + " DATA SEND TO TB ", tbname, this.messageCounter, new Date(ts), dataToTbModified[tbname][0].values, this.instance);
|
//console.log(this.sender + " DATA SEND TO TB ", tbname, this.messageCounter, new Date(ts), dataToTbModified[tbname][0].values, this.instance);
|
||||||
//if(this.debug) console.log(this.sender + " DATA SEND TO TB ", this.index, tbname, arrayOfValuesToSend);
|
//if(this.debug) console.log(this.sender + " DATA SEND TO TB ", this.index, tbname, arrayOfValuesToSend);
|
||||||
|
|
||||||
instance.send(this.index, dataToTbModified);
|
instance.send(this.index, dataToTbModified);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ exports.install = function(instance) {
|
||||||
|
|
||||||
}).catch (function () {
|
}).catch (function () {
|
||||||
|
|
||||||
console.log("errors pri citani modbus registra", register, obj.indexInDeviceConfig, tbName, tbAttribute);
|
//console.log("errors pri citani modbus registra", register, obj.indexInDeviceConfig, tbName, tbAttribute);
|
||||||
|
|
||||||
obj.errors++;
|
obj.errors++;
|
||||||
if(obj.errors == obj.lengthOfActualDeviceStream)
|
if(obj.errors == obj.lengthOfActualDeviceStream)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue