private String displayName
private String currentSwitch
private String switchLatestValue
+ def Timers
switches(int id, String displayName, String currentSwitch, String switchLatestValue) {
+ this.Timers = new Timer()
this.id = id
this.displayName = displayName
this.currentSwitch = currentSwitch
}
def on(LinkedHashMap LHM) {
- sleep(LHM["delay"])
- println("the switch with id:$id is on!")
- this.switchLatestValue = this.currentSwitch
- this.currentSwitch = "on"
+ def task = Timers.runAfter(LHM["delay"]) {
+ println("the switch with id:$id is on!")
+ this.switchLatestValue = this.currentSwitch
+ this.currentSwitch = "on"
+ }
}
def off() {
}
def off(LinkedHashMap LHM) {
- sleep(LHM["delay"])
- println("the switch with id:$id is off!")
- this.switchLatestValue = this.currentSwitch
- this.currentSwitch = "off"
+ def task = Timers.runAfter(LHM["delay"]) {
+ println("the switch with id:$id is off!")
+ this.switchLatestValue = this.currentSwitch
+ this.currentSwitch = "off"
+ }
}
def currentValue(String S) {