Merge branch 'master' of ssh://plrg.eecs.uci.edu/home/git/smartthings-infrastructure
[smartthings-infrastructure.git] / Lock / Locks.groovy
index 409058f6fe90b87e9fde1f61733562c1dc9971c9..8b73dc55ac20e393cd311655c2ddd4f03a2859c9 100644 (file)
@@ -39,30 +39,33 @@ public class Locks{
        //By Apps
        def lock() {
                if (lockState != "locked") {
        //By Apps
        def lock() {
                if (lockState != "locked") {
-                       locks[0].lock()
-                       lockLatestValue = lockState
+                       //lockLatestValue = lockState
+                       lockLatestValue = "locked"
                        lockState = "locked"
                        currentLock = "locked"
                        lockState = "locked"
                        currentLock = "locked"
+                       locks[0].lock()
                }
        }
 
        def lock(LinkedHashMap metaData) {
                if (lockState != "locked") {
                        def task = timers.runAfter(metaData["delay"]) {
                }
        }
 
        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"
                                lockState = "locked"
                                currentLock = "locked"
+                               locks[0].lock()
                        }
                }
        }
 
        def unlock() {
                if (lockState != "unlocked") {
                        }
                }
        }
 
        def unlock() {
                if (lockState != "unlocked") {
-                       locks[0].unlock()
-                       lockLatestValue = lockState
+                       //lockLatestValue = lockState
+                       lockLatestValue = "unlocked"
                        lockState = "unlocked"
                        currentLock = "unlocked"
                        lockState = "unlocked"
                        currentLock = "unlocked"
+                       locks[0].unlock()
                }
        }
 
                }
        }
 
@@ -70,10 +73,11 @@ public class Locks{
        def unlock(LinkedHashMap metaData) {
                if (lockState != "unlocked") {
                        def task = timers.runAfter(metaData["delay"]) {
        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"
                                lockState = "unlocked"
                                currentLock = "unlocked"
+                               locks[0].unlock()
                        }
                }
        }
                        }
                }
        }