diff --git a/equipmentMgr.js b/equipmentMgr.js index de6fc8b..120ad58 100644 --- a/equipmentMgr.js +++ b/equipmentMgr.js @@ -31,8 +31,18 @@ class Equipment { // Initialization of properties this.name = this.equipmentItem.name; + this.conf = new Object(); + this.savedControlPoints = new Object(); - this.timers = new timer.Timer(); + this.timers = new timer.Timer(); + + let metadata = equipmentItem.getMetadata('eMgr'); + if (metadata != null) { + for (const [key, value] of Object.entries(metadata.configuration)) { + log.debug(`Set configuration ${key} for ${this.name} with value ${value.toString()}`); + this.conf[key] = value; + } + } // Check if equipment has LowBat item if (this.hasProperty('LowBat')) { @@ -92,6 +102,17 @@ class Equipment { return true; } + get controlPoints() { + log.debug('Fetch control points for ' + this.name); + return items[this.name].descendents.filter(element => { return (element.semantics.pointType == 'Control') }); + } + + saveControlPoints() { + for (let controlPoint of this.controlPoints) { + log.debug('Save ' + controlPoint.name + ' with state ' + controlPoint.state); + } + } + #notifyLowBat() { log.warn(`${this.name} has a low battery level.`); } @@ -395,8 +416,12 @@ class Window extends Equipment { const watches = new watch.Watch(); -const eMgr = new Object(); +// Initialization of eMgr +const eMgr = new Object(); +cache.shared.put('eMgr', eMgr); + +// Initialization of equipment items for (let equipmentItem of items.getItems().filter(element => { return (element.semantics.isEquipment == true) && (element.semantics.equipment == null) })) { // Get equipmentType @@ -416,7 +441,7 @@ for (let equipmentItem of items.getItems().filter(element => { return (element.s } } -cache.shared.put('eMgr', eMgr); + require('@runtime').lifecycleTracker.addDisposeHook(() => { log.info('Deinitialization of equipmentMgr');