Adding path explorations for initializations.
[smartthings-infrastructure.git] / ImageCapture / ImageCaptures.groovy
1 //Create a class for image capture sensor
2 package ImageCapture
3 import Timer.SimulatedTimer
4
5 public class ImageCaptures {
6         private int deviceNumbers
7         private List imageCaptureSensors
8         def sendEvent
9
10         //For one device(We cannot have obj.id)-> We should have obj[0].id
11         private String id = "motionSensorID0"
12         private String label = "motionSensor0"
13         private String displayName = "motionSensor0"
14         private String image = "imageData"
15         private String alarmState = "armed"
16
17                 
18         ImageCaptures(Closure sendEvent, int deviceNumbers) {
19                 this.sendEvent = sendEvent              
20                 this.deviceNumbers = deviceNumbers
21                 this.imageCaptureSensors = []
22
23                 def initAlarm = Verify.getBoolean()
24                 if (initAlarm) {
25                         this.alarmState = "armed"
26                 } else {
27                         this.alarmState = "not armed"
28                 }
29                 imageCaptureSensors.add(new ImageCapture(id, label, displayName, this.image, this.alarmState))
30         }
31
32
33         //Methods for closures
34         def count(Closure Input) {
35                 imageCaptureSensors.count(Input)
36         }
37         def size() {
38                 imageCaptureSensors.size()
39         }
40         def each(Closure Input) {
41                 imageCaptureSensors.each(Input)
42         }
43         def find(Closure Input) {
44                 imageCaptureSensors.find(Input)
45         }
46         def collect(Closure Input) {
47                 imageCaptureSensors.collect(Input)
48         }
49
50         def alarmOn() {
51                 imageCaptureSensors[0].alarmOn()
52                 this.alarmState = "armed"
53         }
54
55         def alarmOff() {
56                 imageCaptureSensors[0].alarmOff()
57                 this.alarmState = "not armed"
58         }
59
60         def take() {
61                 imageCaptureSensors[0].take()
62         }
63         def getAt(int ix) {
64                 imageCaptureSensors[ix]
65         }
66 }