Merge branch 'master' of ssh://plrg.eecs.uci.edu/home/git/smartthings-infrastructure
[smartthings-infrastructure.git] / AeonKeyFob / AeonKeyFobs.groovy
1 //Create a class for aeon key fob
2 package AeonKeyFob
3 import Timer.SimulatedTimer
4
5 public class AeonKeyFobs {
6         private int deviceNumbers
7         private List aeonKeyFobs
8         def sendEvent
9
10         //For one device(We cannot have obj.id)-> We should have obj[0].id
11         private String id = "aeonKeyFobID0"
12         private String label = "aeonKeyFob0"
13         private String displayName = "aeonKeyFob0"
14         
15                 
16         AeonKeyFobs(Closure sendEvent, int deviceNumbers) {
17                 this.sendEvent = sendEvent              
18                 this.deviceNumbers = deviceNumbers
19                 this.aeonKeyFobs = []
20
21                 aeonKeyFobs.add(new AeonKeyFob(id, label, displayName))
22         }
23
24         //By Model Checker
25         def setValue(LinkedHashMap eventDataMap) {
26                 aeonKeyFobs[0].setValue(eventDataMap)
27                 sendEvent(eventDataMap)
28         }
29
30         //Methods for closures
31         def count(Closure Input) {
32                 aeonKeyFobs.count(Input)
33         }
34         def size() {
35                 aeonKeyFobs.size()
36         }
37         def each(Closure Input) {
38                 aeonKeyFobs.each(Input)
39         }
40         def find(Closure Input) {
41                 aeonKeyFobs.find(Input)
42         }
43         def collect(Closure Input) {
44                 aeonKeyFobs.collect(Input)
45         }
46
47
48         //methods
49         def eventsSince(Date dateObj) {
50                 return aeonKeyFobs[0].eventsSince(dateObj)
51         }
52
53
54         def getAt(int ix) {
55                 aeonKeyFobs[ix]
56         }
57 }