UNPKG

homebridge-boschcontrolpanel_bgseries

Version:
143 lines 5.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BGArea = void 0; const BGConst_1 = require("./BGConst"); class BGArea { constructor(AreaNumber) { this.AreaText = ''; this.AreaStatus = BGConst_1.BGAreaStatus.Unknown; this.ReadyToBecomeAllOn = false; this.ReadyToBecomePartOn = false; this.FaultNumber = 0; this.Alarms = []; this.AreaNumber = AreaNumber; } SetAreaStatus(AreaStatus) { this.AreaStatus = AreaStatus; } SetAreaReadyState(ReadyToBecomeAllOn, ReadyToBecomePartOn, FaultNumber) { this.ReadyToBecomeAllOn = ReadyToBecomeAllOn; this.ReadyToBecomePartOn = ReadyToBecomePartOn; this.FaultNumber = FaultNumber; } GetAlarmDetected() { if (this.Alarms.indexOf(BGConst_1.BGAlarmPriority.BurgAlarm) !== -1 || this.Alarms.indexOf(BGConst_1.BGAlarmPriority.FireAlarm) !== -1 || this.Alarms.indexOf(BGConst_1.BGAlarmPriority.PersonalEmergency) !== -1 || this.Alarms.indexOf(BGConst_1.BGAlarmPriority.GasAlarm) !== -1) { return true; } return false; } AddAlarm(Alarm) { if (this.Alarms.indexOf(Alarm) === -1) { this.Alarms.push(Alarm); return true; } return false; } RemoveAlarm(Alarm) { const index = this.Alarms.indexOf(Alarm); if (index !== -1) { this.Alarms.splice(index, 1); return true; } return false; } GetIsAlarmNominal() { if (this.Alarms.length === 0) { return true; } return false; } GetFireAlarm() { const response = []; if (this.Alarms.indexOf(BGConst_1.BGAlarmPriority.FireAlarm) !== -1) { response.push(BGConst_1.BGAlarmPriority.FireAlarm); } if (this.Alarms.indexOf(BGConst_1.BGAlarmPriority.FireTrouble) !== -1) { response.push(BGConst_1.BGAlarmPriority.FireTrouble); } if (this.Alarms.indexOf(BGConst_1.BGAlarmPriority.FireSupervisory) !== -1) { response.push(BGConst_1.BGAlarmPriority.FireSupervisory); } return response; } GetGazAlarm() { const response = []; if (this.Alarms.indexOf(BGConst_1.BGAlarmPriority.GasAlarm) !== -1) { response.push(BGConst_1.BGAlarmPriority.GasAlarm); } if (this.Alarms.indexOf(BGConst_1.BGAlarmPriority.GasTrouble) !== -1) { response.push(BGConst_1.BGAlarmPriority.GasTrouble); } if (this.Alarms.indexOf(BGConst_1.BGAlarmPriority.GasSupervisory) !== -1) { response.push(BGConst_1.BGAlarmPriority.GasSupervisory); } return response; } GetPersonnalAlarm() { const response = []; if (this.Alarms.indexOf(BGConst_1.BGAlarmPriority.PersonalEmergency) !== -1) { response.push(BGConst_1.BGAlarmPriority.PersonalEmergency); } return response; } GetBurglaryAlarm() { const response = []; if (this.Alarms.indexOf(BGConst_1.BGAlarmPriority.BurgAlarm) !== -1) { response.push(BGConst_1.BGAlarmPriority.BurgAlarm); } if (this.Alarms.indexOf(BGConst_1.BGAlarmPriority.BurgTrouble) !== -1) { response.push(BGConst_1.BGAlarmPriority.BurgTrouble); } if (this.Alarms.indexOf(BGConst_1.BGAlarmPriority.BurgSupervisory) !== -1) { response.push(BGConst_1.BGAlarmPriority.BurgSupervisory); } return response; } ClearAlarm() { if (this.Alarms.length !== 0) { this.Alarms = []; // Alarms array was clear, return true to indicate a change. return true; } // Alarms array was allready empty, no change done. return false; } SetAlarm(AlarmAnnunciationPriority) { this.ClearAlarm(); if (AlarmAnnunciationPriority & 0x0200) { this.Alarms.push(BGConst_1.BGAlarmPriority.FireAlarm); } if (AlarmAnnunciationPriority & 0x0020) { this.Alarms.push(BGConst_1.BGAlarmPriority.FireSupervisory); } if (AlarmAnnunciationPriority & 0x0010) { this.Alarms.push(BGConst_1.BGAlarmPriority.FireTrouble); } if (AlarmAnnunciationPriority & 0x0100) { this.Alarms.push(BGConst_1.BGAlarmPriority.GasAlarm); } if (AlarmAnnunciationPriority & 0x0008) { this.Alarms.push(BGConst_1.BGAlarmPriority.GasSupervisory); } if (AlarmAnnunciationPriority & 0x0004) { this.Alarms.push(BGConst_1.BGAlarmPriority.GasTrouble); } if (AlarmAnnunciationPriority & 0x0080) { this.Alarms.push(BGConst_1.BGAlarmPriority.PersonalEmergency); } if (AlarmAnnunciationPriority & 0x0040) { this.Alarms.push(BGConst_1.BGAlarmPriority.BurgAlarm); } if (AlarmAnnunciationPriority & 0x0002) { this.Alarms.push(BGConst_1.BGAlarmPriority.BurgSupervisory); } if (AlarmAnnunciationPriority & 0x0001) { this.Alarms.push(BGConst_1.BGAlarmPriority.BurgTrouble); } } } exports.BGArea = BGArea; //# sourceMappingURL=BGArea.js.map