Cancelling the changes for field write.
[smartthings-infrastructure.git] / Lock / Locks.groovy
index 409058f6fe90b87e9fde1f61733562c1dc9971c9..ad297ab8ed2512c5740582a8fd28324443e5bdff 100644 (file)
@@ -2,9 +2,6 @@
 package Lock
 import Timer.SimulatedTimer
 
-//JPF's Verify API
-import gov.nasa.jpf.vm.Verify
-
 public class Locks{
        int deviceNumbers       
        List locks      
@@ -19,18 +16,19 @@ public class Locks{
        private String currentLock = "locked"
        private String lockLatestValue = "locked"
 
-       Locks(Closure sendEvent, int deviceNumbers) {
+       Locks(Closure sendEvent, int deviceNumbers, boolean init) {
                this.sendEvent = sendEvent
                this.timers = new SimulatedTimer()
                this.deviceNumbers = deviceNumbers
                this.locks = []
 
-               def init = Verify.getBoolean()
                if (init) {
                        this.lockState = "locked"
+                       this.currentLock = "locked"
                        this.lockLatestValue = "locked"
                } else {
                        this.lockState = "unlocked"
+                       this.currentLock = "unlocked"
                        this.lockLatestValue = "unlocked"
                }
                locks.add(new Lock(sendEvent,id, label, displayName, this.lockState, this.lockLatestValue))
@@ -39,30 +37,33 @@ public class Locks{
        //By Apps
        def lock() {
                if (lockState != "locked") {
-                       locks[0].lock()
-                       lockLatestValue = lockState
+                       //lockLatestValue = lockState
+                       lockLatestValue = "locked"
                        lockState = "locked"
                        currentLock = "locked"
+                       locks[0].lock()
                }
        }
 
        def lock(LinkedHashMap metaData) {
                if (lockState != "locked") {
                        def task = timers.runAfter(metaData["delay"]) {
-                               locks[0].lock()
-                               lockLatestValue = lockState
+                               //lockLatestValue = lockState
+                               lockLatestValue = "locked"
                                lockState = "locked"
                                currentLock = "locked"
+                               locks[0].lock()
                        }
                }
        }
 
        def unlock() {
                if (lockState != "unlocked") {
-                       locks[0].unlock()
-                       lockLatestValue = lockState
+                       //lockLatestValue = lockState
+                       lockLatestValue = "unlocked"
                        lockState = "unlocked"
                        currentLock = "unlocked"
+                       locks[0].unlock()
                }
        }
 
@@ -70,10 +71,11 @@ public class Locks{
        def unlock(LinkedHashMap metaData) {
                if (lockState != "unlocked") {
                        def task = timers.runAfter(metaData["delay"]) {
-                               locks[0].unlock()
-                               lockLatestValue = lockState
+                               //lockLatestValue = lockState
+                               lockLatestValue = "unlocked"
                                lockState = "unlocked"
                                currentLock = "unlocked"
+                               locks[0].unlock()
                        }
                }
        }