Initial commit of files
This commit is contained in:
67
utils/equipment.js
Normal file
67
utils/equipment.js
Normal file
@@ -0,0 +1,67 @@
|
||||
console.loggerName = 'js.equipment';
|
||||
console.log('Load equipment modules');
|
||||
|
||||
class Equipment {
|
||||
constructor(equipmentItem) {
|
||||
console.info('Initialization of eqipment ' + equipmentItem.name + ' with type ' + this.constructor.name);
|
||||
|
||||
// Set equipmentItem
|
||||
this.equipmentItem = equipmentItem;
|
||||
|
||||
// Set stateItem, toDo: error when no stateItem existing
|
||||
this.stateItem = items.getItem(this.equipmentItem.name + '_State');
|
||||
|
||||
// Initialization of properties
|
||||
this.name = this.equipmentItem.name;
|
||||
this.watch = new Object();
|
||||
}
|
||||
|
||||
gc() {
|
||||
console.log('Denitialization of eqipment ' + this.name);
|
||||
|
||||
// Delete all watchObjects
|
||||
for (let watchItem of Object.keys(this.watch)) {
|
||||
this.watch[watchItem].deleteAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Irrigation extends Equipment {
|
||||
constructor(equipmentItem) {
|
||||
super(equipmentItem);
|
||||
}
|
||||
}
|
||||
|
||||
class IrrigationValve extends Equipment {
|
||||
constructor(equipmentItem) {
|
||||
super(equipmentItem);
|
||||
|
||||
this.watch['state'] = new watch.Watch(this.stateItem.name);
|
||||
this.autoOff = this.watch['state'].add({
|
||||
targetState: 'ON',
|
||||
alertFunc: () => { this.stateItem.sendCommand('OFF'); },
|
||||
alertDelay: 'PT1M'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class TowelRadiator extends Equipment {
|
||||
constructor(equipmentItem) {
|
||||
super(equipmentItem);
|
||||
|
||||
this.watch['state'] = new watch.Watch(this.stateItem.name);
|
||||
this.autoOff = this.watch['state'].add({
|
||||
targetState: 'ON',
|
||||
alertFunc: () => { this.stateItem.sendCommand('OFF'); },
|
||||
alertDelay: 'PT30M'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
Equipment,
|
||||
Irrigation,
|
||||
IrrigationValve,
|
||||
TowelRadiator
|
||||
};
|
||||
Reference in New Issue
Block a user