Add language notifications; Add power door handel

This commit is contained in:
rasta5man 2025-05-31 22:03:23 +02:00
parent d97d90cf95
commit 0876e73c68
12 changed files with 445 additions and 581 deletions

View file

@ -58,8 +58,7 @@ const bitwise = require('bitwise');
const DataToTbHandler = require('./helper/DataToTbHandler');
let tbHandler;
const ErrorToServiceHandler = require('./helper/ErrorToServiceHandler');
const errorHandler = new ErrorToServiceHandler();
const errorHandler = require('./helper/ErrorToServiceHandler');
let ws = null;
let rsPort = null;
@ -741,7 +740,7 @@ exports.install = function(instance) {
}
function getPins(controllerType, hasMainSwitch) {
function pinsForRvoStatus(controllerType, hasMainSwitch) {
let pins = [];
@ -774,7 +773,7 @@ exports.install = function(instance) {
if (status === "OK") {
let pinIndexes = getPins(controller_type, hasMainSwitch);
let pinIndexes = pinsForRvoStatus(controller_type, hasMainSwitch);
for (const pinIndex of pinIndexes) {
if (previousValues[pinIndex] === 0) {
@ -914,21 +913,25 @@ exports.install = function(instance) {
else if (type == "door_condition" || type === "state_of_main_switch") {
newPinValue === 0 ? value = "open" : value = "closed";
if (value === "open" && SETTINGS.maintenance_mode) {
sendNotification("switchLogic", rvoTbName, "door_opened", {}, "", SEND_TO.tb, instance, "rvo_door");
let door = "door_main";
if (type === "state_of_main_switch") door = "door_em";
if (value === "open") {
if (SETTINGS.maintenance_mode) {
sendNotification("switchLogic", rvoTbName, door + "_open", {}, "", SEND_TO.tb, instance, door);
} else {
sendNotification("switchLogic", rvoTbName, door + "_open_without_permission", {}, "", SEND_TO.tb, instance, door);
// zapneme sirenu
// ak sa otvoria dvere len na elektromeri (type === "state_of_main_switch") alarm sa nema spustit. alarm sa spusti len ked sa otvoria hlavne dvere (type === "door_condition")
if (type === "door_condition") turnAlarm("on");
}
}
if (value === "open" && !SETTINGS.maintenance_mode) {
sendNotification("switchLogic", rvoTbName, "door_opened_without_permission", {}, "", SEND_TO.tb, instance, "rvo_door");
// zapneme sirenu
// ak sa otvoria dvere len na elektromeri (type === "state_of_main_switch") alarm sa nema spustit. alarm sa spusti len ked sa otvoria hlavne dvere (type === "door_condition")
if (type === "door_condition") turnAlarm("on");
}
if (value === "closed") {
if (alarmStatus == "ON") turnAlarm("off");
sendNotification("switchLogic", rvoTbName, "door_closed", {}, "", SEND_TO.tb, instance, "rvo_door");
sendNotification("switchLogic", rvoTbName, door + "_close", {}, "", SEND_TO.tb, instance, door);
}
deviceStatus[type] = value;
@ -1011,34 +1014,6 @@ exports.install = function(instance) {
instance.send(SEND_TO.cmd_manager, { sender: "dido_controller", cmd: "reload_relays", line: line, value: value, dataChanged: dataChanged });
reportLineStatus(line);
//modify table relays
// dbRelays.modify({ contactor: newPinValue }).where("line", line).make(function(builder) {
// builder.callback(function(err, response) {
// if(!err)
// {
// let time = 0;
// if(value) time = 1000 * 10;//10 sekund
// let dataChanged = false;
// if(relaysData[line].contactor != newPinValue) dataChanged = true;
// relaysData[line].contactor = newPinValue; // 0,1
// //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
// setTimeout(function(){
// instance.send(SEND_TO.cmd_manager, {sender: "dido_controller", cmd: "reload_relays", line: line, time: time, value: value, dataChanged: dataChanged});
// }, time);
// reportLineStatus(line);
// }
// else
// {
// errLogger.error("modify table relays failed", err);
// }
// });
// });
}
else if (type === "state_of_breaker") {