1 //Create a class for image capture sensor
3 import Timer.SimulatedTimer
5 public class ImageCaptures {
6 private int deviceNumbers
7 private List imageCaptureSensors
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"
18 ImageCaptures(Closure sendEvent, int deviceNumbers, boolean init) {
19 this.sendEvent = sendEvent
20 this.deviceNumbers = deviceNumbers
21 this.imageCaptureSensors = []
24 this.alarmState = "armed"
26 this.alarmState = "not armed"
28 imageCaptureSensors.add(new ImageCapture(id, label, displayName, this.image, this.alarmState))
32 //Methods for closures
33 def count(Closure Input) {
34 imageCaptureSensors.count(Input)
37 imageCaptureSensors.size()
39 def each(Closure Input) {
40 imageCaptureSensors.each(Input)
42 def find(Closure Input) {
43 imageCaptureSensors.find(Input)
45 def sort(Closure Input) {
46 imageCaptureSensors.sort(Input)
48 def collect(Closure Input) {
49 imageCaptureSensors.collect(Input)
53 if (alarmState != "armed") {
54 this.alarmState = "armed"
55 imageCaptureSensors[0].alarmOn()
60 if (alarmState != "not armed") {
61 this.alarmState = "not armed"
62 imageCaptureSensors[0].alarmOff()
67 imageCaptureSensors[0].take()
70 def take(LinkedHashMap metaData) {
71 imageCaptureSensors[0].take(metaData)
75 imageCaptureSensors[ix]