private String displayName = "switchLevel0"
private int level = 50
private int rate = 50
+ private String switchState = "off"
+ private String currentSwitch = "off"
+ private String switchLatestValue = "off"
SwitchLevels(Closure sendEvent, int deviceNumbers) {
this.sendEvent = sendEvent
this.deviceNumbers = deviceNumbers
this.switchLevels = []
- switchLevels.add(new SwitchLevel(sendEvent, id, label, displayName, this.level))
+ switchLevels.add(new SwitchLevel(sendEvent, id, label, displayName, this.level, this.switchState, this.switchLatestValue))
}
//Methods for closures
}
}
+ def on() {
+ switchLevels[0].on()
+ switchLatestValue = switchState
+ switchState = "on"
+ currentSwitch = "on"
+ }
+
+ def on(LinkedHashMap metaData) {
+ def task = timers.runAfter(metaData["delay"]) {
+ switchLevels[0].on()
+ switchLatestValue = switchState
+ switchState = "on"
+ currentSwitch = "on"
+ }
+ }
+
+ def off() {
+ switchLevels[0].off()
+ switchLatestValue = switchState
+ switchState = "off"
+ currentSwitch = "off"
+ }
+
+ def off(LinkedHashMap metaData) {
+ def task = timers.runAfter(metaData["delay"]) {
+ switchLevels[0].off()
+ switchLatestValue = switchState
+ switchState = "off"
+ currentSwitch = "off"
+ }
+ }
+
//By Model Checker
def setValue(LinkedHashMap eventDataMap) {
if (eventDataMap["value"] != switchLevels[0].level) {