Resolving conclicts manually.
[smartthings-infrastructure.git] / PresenceSensor / PresenceSensors.groovy
index 8fb9161864606b45652e74ecf7a542a828760ace..ec24f3b0c675ebf8433a0a42b279701a5ae9c2ae 100644 (file)
@@ -2,6 +2,9 @@
 package PresenceSensor
 import Timer.SimulatedTimer
 
+//JPF's Verify API
+import gov.nasa.jpf.vm.Verify
+
 public class PresenceSensors {
        private int deviceNumbers
        private List presenceSensors
@@ -11,7 +14,7 @@ public class PresenceSensors {
        private String id = "presenceSensorID0"
        private String label = "presenceSensor0"
        private String displayName = "presenceSensor0"
-       private String presenceState = "not present"
+       private String presence = "not present"
        private String currentPresence = "not present"
        private String presenceLatestValue = "not present"
 
@@ -20,17 +23,25 @@ public class PresenceSensors {
                this.sendEvent = sendEvent              
                this.deviceNumbers = deviceNumbers
                this.presenceSensors = []
+               /*def init = Verify.getBoolean()
+               if (init) {
+                       this.presence = "not present"
+                       this.presenceLatestValue = "not present"
+               } else {
+                       this.presence = "present"
+                       this.presenceLatestValue = "present"
+               }*/
 
-               presenceSensors.add(new PresenceSensor(id, label, displayName, this.presenceState, this.presenceLatestValue))
+               presenceSensors.add(new PresenceSensor(id, label, displayName, this.presence, this.presenceLatestValue))
        }
 
        //By Model Checker
        def setValue(LinkedHashMap eventDataMap) {
-               if (eventDataMap["value"] != presenceSensors[0].presenceState) {
+               if (eventDataMap["value"] != presenceSensors[0].presence) {
+                       this.presenceLatestValue = eventDataMap["value"]
+                       this.presence = eventDataMap["value"]
+                       this.currentPresence = eventDataMap["value"]
                        presenceSensors[0].setValue(eventDataMap["value"])
-                       this.presenceLatestValue = presenceSensors[0].presenceLatestValue
-                       this.presenceState = presenceSensors[0].presenceState
-                       this.currentPresence = presenceSensors[0].presenceState
                        sendEvent(eventDataMap)
                }
        }
@@ -48,6 +59,9 @@ public class PresenceSensors {
        def find(Closure Input) {
                presenceSensors.find(Input)
        }
+       def sort(Closure Input) {
+               presenceSensors.sort(Input)
+       }
        def collect(Closure Input) {
                presenceSensors.collect(Input)
        }