Adding another value for illuminance measurement event.
[smartthings-infrastructure.git] / BeaconSensor / BeaconSensors.groovy
index b2b5e1a8379ab3d32ffdef4a29f219fe830f1a84..4550965ad876a28d4c30425ee5fb257a4914d145 100644 (file)
@@ -2,9 +2,6 @@
 package BeaconSensor
 import Timer.SimulatedTimer
 
-//JPF's Verify API
-import gov.nasa.jpf.vm.Verify
-
 public class BeaconSensors {
        private int deviceNumbers
        private List beaconSensors
@@ -19,29 +16,30 @@ public class BeaconSensors {
        private String presenceLatestValue = "not present"
 
                
-       BeaconSensors(Closure sendEvent, int deviceNumbers) {
+       BeaconSensors(Closure sendEvent, int deviceNumbers, boolean init) {
                this.sendEvent = sendEvent              
                this.deviceNumbers = deviceNumbers
                this.beaconSensors = []
 
-               /*def init = Verify.getBoolean()
                if (init) {
                        this.presence = "not present"
+                       this.currentPresence = "not present"
                        this.presenceLatestValue = "not present"
                } else {
                        this.presence = "present"
+                       this.currentPresence = "present"
                        this.presenceLatestValue = "present"
-               }*/
+               }
                beaconSensors.add(new BeaconSensor(id, label, displayName, this.presence, this.presenceLatestValue))
        }
 
        //By Model Checker
        def setValue(LinkedHashMap eventDataMap) {
                if (eventDataMap["value"] != beaconSensors[0].presence) {
+                       this.presenceLatestValue = eventDataMap["value"]
+                       this.presence = eventDataMap["value"]
+                       this.currentPresence = eventDataMap["value"]
                        beaconSensors[0].setValue(eventDataMap["value"])
-                       this.presenceLatestValue = beaconSensors[0].presenceLatestValue
-                       this.presence = beaconSensors[0].presence
-                       this.currentPresence = beaconSensors[0].presence
                        sendEvent(eventDataMap)
                }
        }
@@ -56,6 +54,9 @@ public class BeaconSensors {
        def each(Closure Input) {
                beaconSensors.each(Input)
        }
+       def sort(Closure Input) {
+               beaconSensors.sort(Input)
+       }
        def find(Closure Input) {
                beaconSensors.find(Input)
        }