Updating global variable app list.
[smartthings-infrastructure.git] / SleepSensor / SleepSensors.groovy
index 32895c804919fcd27475f0d3539d24f227415268..0db103302ed0869fbc2c8170ec124d9b34645f4a 100644 (file)
@@ -2,9 +2,6 @@
 package SleepSensor
 import Timer.SimulatedTimer
 
-//JPF's Verify API
-import gov.nasa.jpf.vm.Verify
-
 public class SleepSensors {
        private int deviceNumbers
        private List sleepSensors
@@ -17,25 +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 = []
 
-               /*def init = Verify.getBoolean()
                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)
                }
        }
@@ -53,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)
        }