public class switching{
List switches
int count
+ def Timers
switching(int count) {
+ this.Timers = new Timer()
this.count = count
if (count == 1) {
switches = [new switches(0, "switch0", "off", "off")]
def on(LinkedHashMap LHM) {
if (count == 1) {
- sleep(LHM["delay"])
- switches[0].on()
+ def task = Timers.runAfter(LHM["delay"]) {
+ switches[0].on()
+ }
} else {
- sleep(LHM["delay"])
- switches*.on()
+ def task = Timers.runAfter(LHM["delay"]) {
+ switches*.on()
+ }
}
}
def off(LinkedHashMap LHM) {
if (count == 1) {
- sleep(LHM["delay"])
- switches[0].off()
+ def task = Timers.runAfter(LHM["delay"]) {
+ switches[0].off()
+ }
} else {
- sleep(LHM["delay"])
- switches*.off()
+ def task = Timers.runAfter(LHM["delay"]) {
+ switches*.off()
+ }
}
}