2a63a3e8fa806a31611a8b649496870cdfaa3229
[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                 imageCaptureSensors.add(new ImageCapture(id, label, displayName, this.image, this.alarmState))
24         }
25
26
27         //Methods for closures
28         def count(Closure Input) {
29                 imageCaptureSensors.count(Input)
30         }
31         def size() {
32                 imageCaptureSensors.size()
33         }
34         def each(Closure Input) {
35                 imageCaptureSensors.each(Input)
36         }
37         def find(Closure Input) {
38                 imageCaptureSensors.find(Input)
39         }
40         def collect(Closure Input) {
41                 imageCaptureSensors.collect(Input)
42         }
43
44         def alarmOn() {
45                 imageCaptureSensors[0].alarmOn()
46                 this.alarmState = "armed"
47         }
48
49         def alarmOff() {
50                 imageCaptureSensors[0].alarmOff()
51                 this.alarmState = "not armed"
52         }
53
54         def take() {
55                 imageCaptureSensors[0].take()
56         }
57         def getAt(int ix) {
58                 imageCaptureSensors[ix]
59         }
60 }