Adjusting setLocationMode for global-variable conflict detection.
[smartthings-infrastructure.git] / ImageCapture / ImageCapture.groovy
index 5d9f94569d0656af0725703e8aaed4de61ddbaec..0672e60cf63d1d732fe87108c05a3b8bacc6c9d8 100644 (file)
@@ -8,6 +8,7 @@ public class ImageCapture {
        private String displayName
        private String image
        private String alarmState
+       def timers
 
        ImageCapture(String id, String label, String displayName, String image, String alarmState) {
                this.id = id
@@ -15,19 +16,30 @@ public class ImageCapture {
                this.displayName = displayName
                this.image = image
                this.alarmState = alarmState
+               this.timers = new SimulatedTimer()
        }
        
        def alarmOn() {
-               println("The camera with id:$id is armed!")
-               this.alarmState = "armed"
+               if (alarmState != "armed") {
+                       println("The camera with id:$id is armed!")
+                       this.alarmState = "armed"
+               }
        }
 
        def alarmOff() {
-               println("The camera with id:$id is not armed!")
-               this.alarmState = "not armed"
+               if (alarmState != "not armed") {
+                       println("The camera with id:$id is not armed!")
+                       this.alarmState = "not armed"
+               }
        }
 
        def take() {
                println("The camera with id:$id is taken a picture!")
        }
+
+       def take(LinkedHashMap metaData) {
+               def task = timers.runAfter(metaData["delay"]) {
+                       println("The camera with id:$id is taken a picture!")
+               }
+       }
 }