X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=SleepSensor%2FSleepSensors.groovy;h=0db103302ed0869fbc2c8170ec124d9b34645f4a;hb=e9196e0f9b6d29e4f5d9fbe51e15b5a6e7fe00b7;hp=269a419e2212b28945b4514ec31cd91e0e0a9f7f;hpb=d00fd74ad7e497d6849c284c6ba69db2d3ec8e65;p=smartthings-infrastructure.git diff --git a/SleepSensor/SleepSensors.groovy b/SleepSensor/SleepSensors.groovy index 269a419..0db1033 100644 --- a/SleepSensor/SleepSensors.groovy +++ b/SleepSensor/SleepSensors.groovy @@ -14,19 +14,24 @@ public class SleepSensors { private String sleeping = "sleeping" - SleepSensors(Closure sendEvent, int deviceNumbers) { + SleepSensors(Closure sendEvent, int deviceNumbers, boolean init) { this.sendEvent = sendEvent this.deviceNumbers = deviceNumbers this.sleepSensors = [] + if (init) { + this.sleeping = "sleeping" + } else { + this.sleeping = "not sleeping" + } sleepSensors.add(new SleepSensor(id, label, displayName, this.sleeping)) } //By Model Checker def setValue(LinkedHashMap eventDataMap) { if (eventDataMap["value"] != sleepSensors[0].sleeping) { + this.sleeping = eventDataMap["value"] sleepSensors[0].setValue(eventDataMap["value"]) - this.sleeping = sleepSensors[0].sleeping sendEvent(eventDataMap) } } @@ -44,6 +49,9 @@ public class SleepSensors { def find(Closure Input) { sleepSensors.find(Input) } + def sort(Closure Input) { + sleepSensors.sort(Input) + } def collect(Closure Input) { sleepSensors.collect(Input) }