Infrastruction modification
[smartthings-infrastructure.git] / ImageCapture / ImageCaptures.groovy
index 05880352588f563ef1d425ddd71f4f0a1da5e165..0b6c44756cf44ff092c57eccbefc7413f8b3fe14 100644 (file)
@@ -1,66 +1,21 @@
 //Create a class for image capture sensor
 package ImageCapture
-import Timer.SimulatedTimer
+import SmartThing.SmartThings
 
-public class ImageCaptures {
-       private int deviceNumbers
-       private List imageCaptureSensors
-       def sendEvent
+public class ImageCaptures extends SmartThings {
+       List imageCaptureSensors = new ArrayList()
 
-       //For one device(We cannot have obj.id)-> We should have obj[0].id
-       private String id = "imageCaptureID0"
-       private String label = "imageCapture0"
-       private String displayName = "imageCapture0"
-       private String image = "imageData"
-       private String alarmState = "armed"
+       ImageCaptures(Closure sendEvent, boolean init) {
+               // Only initialize one time since we only have one device for each capability
+               imageCaptureSensors = smartThings
 
-               
-       ImageCaptures(Closure sendEvent, int deviceNumbers, boolean init) {
-               this.sendEvent = sendEvent              
-               this.deviceNumbers = deviceNumbers
-               this.imageCaptureSensors = []
+               // Initialization
+               StringBuilder id = new StringBuilder("imageCaptureID0")
+               StringBuilder label = new StringBuilder("imageCapture")
+               StringBuilder displayName = new StringBuilder("imageCapture0")
+               StringBuilder image = new StringBuilder("image0")
 
-               if (init) {
-                       this.alarmState = "armed"
-               } else {
-                       this.alarmState = "not armed"
-               }
-               imageCaptureSensors.add(new ImageCapture(id, label, displayName, this.image, this.alarmState))
-       }
-
-
-       //Methods for closures
-       def count(Closure Input) {
-               imageCaptureSensors.count(Input)
-       }
-       def size() {
-               imageCaptureSensors.size()
-       }
-       def each(Closure Input) {
-               imageCaptureSensors.each(Input)
-       }
-       def find(Closure Input) {
-               imageCaptureSensors.find(Input)
-       }
-       def sort(Closure Input) {
-               imageCaptureSensors.sort(Input)
-       }
-       def collect(Closure Input) {
-               imageCaptureSensors.collect(Input)
-       }
-
-       def alarmOn() {
-               if (alarmState != "armed") {
-                       this.alarmState = "armed"
-                       imageCaptureSensors[0].alarmOn()
-               }
-       }
-
-       def alarmOff() {
-               if (alarmState != "not armed") {
-                       this.alarmState = "not armed"
-                       imageCaptureSensors[0].alarmOff()
-               }
+               imageCaptureSensors.add(new ImageCapture(sendEvent, id, label, displayName, image))
        }
 
        def take() {
@@ -68,10 +23,13 @@ public class ImageCaptures {
        }
 
        def take(LinkedHashMap metaData) {
-               imageCaptureSensors[0].take(metaData)
-       }
-
-       def getAt(int ix) {
-               imageCaptureSensors[ix]
+               take()
+       }
+       
+       // Methods to return values
+       def getCurrentImage() {
+               List tmpValues = new ArrayList()
+               tmpValues.add(imageCaptureSensors[0].getCurrentImage())
+               return tmpValues
        }
 }