Fixing some bugs
[smartthings-infrastructure.git] / ContactSensor / ContactSensors.groovy
index c691853aad4c3ea157ff65cc8b90ac4ff290f3f0..c4136e301a843a3f836dea903abddf68a4c1940f 100644 (file)
@@ -2,9 +2,6 @@
 package ContactSensor
 import Timer.SimulatedTimer
 
-//JPF's Verify API
-import gov.nasa.jpf.vm.Verify
-
 public class ContactSensors {
        private int deviceNumbers
        private List contacts
@@ -20,28 +17,23 @@ public class ContactSensors {
        private String alarmState = "armed"
 
                
-       ContactSensors(Closure sendEvent, int deviceNumbers) {
+       ContactSensors(Closure sendEvent, int deviceNumbers, boolean init) {
                this.sendEvent = sendEvent              
                this.deviceNumbers = deviceNumbers
                this.contacts = []
-
-               /*def initSensor = Verify.getBoolean()
-               if (initSensor) {
+               
+               if (init) {
                        this.contactState = "closed"
                        this.currentContact = "closed"
                        this.latestValue = "closed"
+                       this.alarmState = "armed"
                } else {
                        this.contactState = "open"
                        this.currentContact = "open"
                        this.latestValue = "open"
+                       this.alarmState = "not armed"
                }
 
-               def initAlarm = Verify.getBoolean()
-               if (initAlarm) {
-                       this.alarmState = "armed"
-               } else {
-                       this.alarmState = "not armed"
-               }*/
                contacts.add(new ContactSensor(id, label, displayName, this.contactState, this.currentContact, this.alarmState, this.latestValue))
        }
 
@@ -76,6 +68,10 @@ public class ContactSensors {
                }
        }
 
+       def eventsSince(Date dateObj) {
+               return contacts[0].eventsSince()
+       }
+
        def on() {
                this.alarmState = "armed"
                contacts[0].on()