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