actual working Senica Rvo code 09/2024
This commit is contained in:
parent
f4ffef94b9
commit
8929cc3a53
7 changed files with 810 additions and 429 deletions
|
|
@ -280,30 +280,20 @@ function processNodeProfile(node)
|
|||
try{
|
||||
nodeProfile = JSON.parse( profile );
|
||||
if(Object.keys(nodeProfile).length === 0) throw ("profile is not defined");
|
||||
} catch (error) {}
|
||||
|
||||
//test reset profilu
|
||||
//nodeProfile = undefined;
|
||||
} catch (error) {
|
||||
logger.debug("Error parsing node profile", error);
|
||||
}
|
||||
|
||||
logger.debug("processNodeProfile", node, line, nodeObj, nodeProfile);
|
||||
//return;
|
||||
|
||||
//let timestamp = PRIORITY_TYPES.node_cmd;
|
||||
|
||||
//let now = new Date();
|
||||
//now.setSeconds(now.getSeconds() + 10);
|
||||
//let timestamp = now.getTime();
|
||||
|
||||
let timestamp = PRIORITY_TYPES.node_cmd;
|
||||
|
||||
//nodeProfile = undefined;
|
||||
removeTask({type: "set_node_profile", address: node});
|
||||
cmdNOKNodeCounter[node] = 0;
|
||||
|
||||
//co ked sa prave spracovava?
|
||||
//if(cmdNOKNodeCounter[params.address] < 5) saveToTb = false;
|
||||
|
||||
|
||||
if(nodeProfile === undefined)
|
||||
{
|
||||
//vypneme profil nodu, posleme cmd
|
||||
|
|
@ -318,7 +308,7 @@ function processNodeProfile(node)
|
|||
params.byte1 = 0;
|
||||
params.byte2 = 0;
|
||||
params.byte3 = 0;
|
||||
params.byte4 = 32;
|
||||
params.byte4 = 96;
|
||||
params.recipient = 1;
|
||||
params.register = 8;
|
||||
params.rw = 1;//write
|
||||
|
|
@ -347,7 +337,7 @@ function processNodeProfile(node)
|
|||
params.byte1 = 0;
|
||||
params.byte2 = 0;
|
||||
params.byte3 = 0;
|
||||
params.byte4 = 32;
|
||||
params.byte4 = 96;
|
||||
params.recipient = 1;
|
||||
params.register = 8;
|
||||
params.rw = 1;//write
|
||||
|
|
@ -615,7 +605,7 @@ function processNodeProfile(node)
|
|||
else bits.push(0);
|
||||
|
||||
//Bit 1 - riadenie úsvitu podľa lux senzoru (1 – zapnuté). Úsvit sa môže posúvať v rámci času v registri 97 podľa intenzity osvetlenia
|
||||
if(profile.dawn_lux_sensor == true)//usvit
|
||||
if(nodeProfile.dawn_lux_sensor == true)//usvit
|
||||
{
|
||||
bits.push(1);
|
||||
}
|
||||
|
|
@ -765,7 +755,7 @@ exports.install = function(instance) {
|
|||
if(key == "0") continue;
|
||||
if(line != undefined)
|
||||
{
|
||||
//ak sa jedna o update profilu linie - pozor di_co_controller posiela command pre loadRelaysData
|
||||
//ak sa jedna o update profilu linie - pozor dido_controller posiela command pre loadRelaysData
|
||||
if(line != value.line ) continue;
|
||||
}
|
||||
|
||||
|
|
@ -1254,28 +1244,20 @@ exports.install = function(instance) {
|
|||
|
||||
{
|
||||
//run broadcast Time of dusk
|
||||
// addMinutesToTimestamp = 60*5;
|
||||
addMinutesToTimestamp = 60 * 3; //kazde 3 hodiny zisti novy dusk
|
||||
|
||||
let params = getParams(PRIORITY_TYPES.node_broadcast);
|
||||
|
||||
let recipient = 2;//2 broadcast, address = 0
|
||||
let address = 0;//0
|
||||
if(recipient === 2)
|
||||
{
|
||||
address = 0xffffffff;//Broadcast
|
||||
}
|
||||
|
||||
let sunCalcResult = calculateDuskDawn();
|
||||
let dusk_hours = sunCalcResult["dusk_hours"];
|
||||
let dusk_minutes = sunCalcResult["dusk_minutes"];
|
||||
|
||||
params.address = address;//broadcast
|
||||
params.address = 0xffffffff;//broadcast
|
||||
params.byte1 = dusk_hours;//h
|
||||
params.byte2 = dusk_minutes;//m
|
||||
params.byte3 = 0;//s
|
||||
params.byte4 = 0;
|
||||
params.recipient = recipient;
|
||||
params.recipient = 2;//2 broadcast,
|
||||
params.register = 6;//Time of dusk - Reg 6
|
||||
params.rw = 1;//write
|
||||
|
||||
|
|
@ -1300,23 +1282,16 @@ exports.install = function(instance) {
|
|||
|
||||
let params = getParams(PRIORITY_TYPES.node_broadcast);
|
||||
|
||||
let recipient = 2;//2 broadcast, address = 0
|
||||
let address = 0;//0
|
||||
if(recipient === 2)
|
||||
{
|
||||
address = 0xffffffff;//Broadcast
|
||||
}
|
||||
|
||||
let sunCalcResult = calculateDuskDawn();
|
||||
let dawn_hours = sunCalcResult["dawn_hours"];
|
||||
let dawn_minutes = sunCalcResult["dawn_minutes"];
|
||||
|
||||
params.address = address;//broadcast
|
||||
params.address = 0xffffffff;//broadcast
|
||||
params.byte1 = dawn_hours;//h
|
||||
params.byte2 = dawn_minutes;//m
|
||||
params.byte3 = 0;//s
|
||||
params.byte4 = 0;
|
||||
params.recipient = recipient;
|
||||
params.recipient = 2; //2 broadcast
|
||||
params.register = 7;//Time of dawn - Reg 6
|
||||
params.rw = 1;//write
|
||||
|
||||
|
|
@ -1332,31 +1307,23 @@ exports.install = function(instance) {
|
|||
tasks.push(params);
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
//run broadcast //Actual time
|
||||
addMinutesToTimestamp = 5;
|
||||
|
||||
let params = getParams(PRIORITY_TYPES.node_broadcast);
|
||||
|
||||
let recipient = 2;//2 broadcast, address = 0
|
||||
let address = 0;//0
|
||||
if(recipient === 2)
|
||||
{
|
||||
address = 0xffffffff;//Broadcast
|
||||
}
|
||||
|
||||
var d = new Date();
|
||||
let hours = d.getHours();
|
||||
let minutes = d.getMinutes();
|
||||
let seconds = d.getSeconds();
|
||||
|
||||
params.address = address;//broadcast
|
||||
params.address = 0xffffffff;//broadcast
|
||||
params.byte1 = hours;//h
|
||||
params.byte2 = minutes;//m
|
||||
params.byte3 = seconds;//s
|
||||
params.byte4 = 0;
|
||||
params.recipient = recipient;
|
||||
params.recipient = 2; //2 broadcast
|
||||
params.register = 87;//Actual time
|
||||
params.rw = 1;//write
|
||||
|
||||
|
|
@ -1370,37 +1337,8 @@ exports.install = function(instance) {
|
|||
params.info = "run broadcast: Actual time";
|
||||
|
||||
tasks.push(params);
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
//run broadcast Actual Lux level from cabinet
|
||||
|
||||
//Do tohto registra posiela riadiaca jednotka hodnotu intenzity osvetlenia ktorú meria jej senzor pre potreby riadenia časov súmraku resp. úsvitu podľa intenzity osvetlenia.
|
||||
//Byty 0 (LSB) a 1 obsahujú 16 bitový integer s luxami.
|
||||
|
||||
let params = getParams(PRIORITY_TYPES.node_broadcast);
|
||||
|
||||
addMinutesToTimestamp = 15;
|
||||
|
||||
let recipient = 2;//2 broadcast, address = 0
|
||||
let address = 0;//0
|
||||
if(recipient === 2)
|
||||
{
|
||||
address = 0xffffffff;//Broadcast
|
||||
}
|
||||
|
||||
//TODO
|
||||
//16 bitový integer s luxami
|
||||
params.byte3 = lux_sensor;
|
||||
params.byte4 = lux_sensor;
|
||||
params.timestamp = PRIORITY_TYPES.node_broadcast;
|
||||
params.addMinutesToTimestamp = addMinutesToTimestamp;
|
||||
params.info = "run broadcast: Actual Lux level from cabinet";
|
||||
params.register = 95;//Actual Lux level from cabinet
|
||||
params.rw = 1;//write
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//process nodes & tasks
|
||||
|
|
@ -1909,7 +1847,7 @@ exports.install = function(instance) {
|
|||
tasks[0].timestamp = currentTimestamp + tasks[0].addMinutesToTimestamp * 60000;
|
||||
}
|
||||
|
||||
let info = "aplikovaný bod profilu";
|
||||
let info = "aplikovany bod profilu";
|
||||
let message = "";
|
||||
if(value == 1)
|
||||
{
|
||||
|
|
@ -2099,8 +2037,9 @@ exports.install = function(instance) {
|
|||
|
||||
let resp = com_generic(params.address, params.recipient, params.rw, params.register, params.name, params.byte1, params.byte2, params.byte3, params.byte4);
|
||||
let readBytes = 11;
|
||||
let timeout = 5000;
|
||||
|
||||
await writeData(rsPort, resp, readBytes).then(function (data) {
|
||||
await writeData(rsPort, resp, readBytes, timeout).then(function (data) {
|
||||
|
||||
endTime = new Date();
|
||||
var timeDiff = endTime - startTime;
|
||||
|
|
@ -2690,8 +2629,31 @@ exports.install = function(instance) {
|
|||
{
|
||||
lux_sensor = parseInt(flowdata.data.value);
|
||||
|
||||
//process profiles
|
||||
turnOnOffLinesAccordingToLuxSensor(lux_sensor);
|
||||
// POSSIBLE SOURCE OF PROBLEMS, IF USER SETS LUX TRESHOLD LEVEL GREATER THAN 100 - WE SHOULD BE CHECKING "DUSK/DAWN_LUX_SENSOR_VALUE" IN PROFILE MAYBE ??
|
||||
if(lux_sensor < 100)
|
||||
{
|
||||
|
||||
// we send lux_sensor value to all nodes:
|
||||
let params = getParams(PRIORITY_TYPES.node_broadcast);
|
||||
|
||||
params.recipient = 2;//2 broadcast, address = 0
|
||||
params.address = 0xffffffff;//Broadcast
|
||||
|
||||
let ba = longToByteArray(lux_sensor);
|
||||
|
||||
params.byte3 = ba[1];//msb
|
||||
params.byte4 = ba[0];
|
||||
params.timestamp = PRIORITY_TYPES.node_broadcast;
|
||||
params.info = "run broadcast: Actual Lux level from cabinet";
|
||||
params.register = 95;//Actual Lux level from cabinet
|
||||
params.rw = 1;//write
|
||||
|
||||
tasks.push(params);
|
||||
|
||||
|
||||
//process profiles
|
||||
turnOnOffLinesAccordingToLuxSensor(lux_sensor);
|
||||
}
|
||||
}
|
||||
else if(cmd == "state_of_breaker")
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue