1
0

Fetch eMgr metadata, add saveControlPoints function

This commit is contained in:
2024-01-07 14:46:20 +01:00
parent a52eac4309
commit 80051fde21

View File

@@ -31,8 +31,18 @@ class Equipment {
// Initialization of properties // Initialization of properties
this.name = this.equipmentItem.name; 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 // Check if equipment has LowBat item
if (this.hasProperty('LowBat')) { if (this.hasProperty('LowBat')) {
@@ -92,6 +102,17 @@ class Equipment {
return true; 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() { #notifyLowBat() {
log.warn(`${this.name} has a low battery level.`); log.warn(`${this.name} has a low battery level.`);
} }
@@ -395,8 +416,12 @@ class Window extends Equipment {
const watches = new watch.Watch(); 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) })) { for (let equipmentItem of items.getItems().filter(element => { return (element.semantics.isEquipment == true) && (element.semantics.equipment == null) })) {
// Get equipmentType // 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(() => { require('@runtime').lifecycleTracker.addDisposeHook(() => {
log.info('Deinitialization of equipmentMgr'); log.info('Deinitialization of equipmentMgr');