Changing Verify API call scheme for device handlers.
[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 = "imageCaptureID0"
12         private String label = "imageCapture0"
13         private String displayName = "imageCapture0"
14         private String image = "imageData"
15         private String alarmState = "armed"
16
17                 
18         ImageCaptures(Closure sendEvent, int deviceNumbers, boolean init) {
19                 this.sendEvent = sendEvent              
20                 this.deviceNumbers = deviceNumbers
21                 this.imageCaptureSensors = []
22
23                 if (init) {
24                         this.alarmState = "armed"
25                 } else {
26                         this.alarmState = "not armed"
27                 }
28                 imageCaptureSensors.add(new ImageCapture(id, label, displayName, this.image, this.alarmState))
29         }
30
31
32         //Methods for closures
33         def count(Closure Input) {
34                 imageCaptureSensors.count(Input)
35         }
36         def size() {
37                 imageCaptureSensors.size()
38         }
39         def each(Closure Input) {
40                 imageCaptureSensors.each(Input)
41         }
42         def find(Closure Input) {
43                 imageCaptureSensors.find(Input)
44         }
45         def sort(Closure Input) {
46                 imageCaptureSensors.sort(Input)
47         }
48         def collect(Closure Input) {
49                 imageCaptureSensors.collect(Input)
50         }
51
52         def alarmOn() {
53                 if (alarmState != "armed") {
54                         this.alarmState = "armed"
55                         imageCaptureSensors[0].alarmOn()
56                 }
57         }
58
59         def alarmOff() {
60                 if (alarmState != "not armed") {
61                         this.alarmState = "not armed"
62                         imageCaptureSensors[0].alarmOff()
63                 }
64         }
65
66         def take() {
67                 imageCaptureSensors[0].take()
68         }
69
70         def take(LinkedHashMap metaData) {
71                 imageCaptureSensors[0].take(metaData)
72         }
73
74         def getAt(int ix) {
75                 imageCaptureSensors[ix]
76         }
77 }