1 //Create a class for alarm device
3 import Timer.SimulatedTimer
11 //If we have only one device
12 private String id = "alarmID0"
13 private String label = "alarm0"
14 private String displayName = "alarm0"
15 private String alarm = "off"
16 private String currentAlarm = "off"
17 private String alarmLatestValue = "off"
19 Alarms(Closure sendEvent, int deviceNumbers) {
20 this.sendEvent = sendEvent
21 this.timers = new SimulatedTimer()
22 this.deviceNumbers = deviceNumbers
25 alarms.add(new Alarm(sendEvent, id, label, displayName, this.alarm, this.currentAlarm, this.alarmLatestValue))
29 def setValue(LinkedHashMap eventDataMap) {
30 if (eventDataMap["value"] != alarms[0].alarm) {
31 alarms[0].setValue(eventDataMap["value"])
32 this.alarmLatestValue = alarms[0].alarmLatestValue
33 this.alarm = alarms[0].alarm
34 this.currentAlarm = alarms[0].alarm
35 sendEvent(eventDataMap)
39 //Methods for closures
40 def count(Closure Input) {
46 def each(Closure Input) {
49 def find(Closure Input) {
52 def collect(Closure Input) {
59 alarmLatestValue = alarm
66 alarmLatestValue = alarm
77 alarmLatestValue = alarm
79 currentAlarm = "siren"
84 alarmLatestValue = alarm
86 currentAlarm = "strobe"
89 def currentValue(String deviceFeature) {
90 alarms[0].currentValue(deviceFeature)
93 def latestValue(String deviceFeature) {
94 alarms[0].latestValue(deviceFeature)