1 //Create a class for sleep sensor
3 import Timer.SimulatedTimer
6 import gov.nasa.jpf.vm.Verify
8 public class SleepSensors {
9 private int deviceNumbers
10 private List sleepSensors
13 //For one device(We cannot have obj.id)-> We should have obj[0].id
14 private String id = "sleepSensorID0"
15 private String label = "sleepSensor0"
16 private String displayName = "sleepSensor0"
17 private String sleeping = "sleeping"
20 SleepSensors(Closure sendEvent, int deviceNumbers) {
21 this.sendEvent = sendEvent
22 this.deviceNumbers = deviceNumbers
23 this.sleepSensors = []
25 /*def init = Verify.getBoolean()
27 this.sleeping = "sleeping"
29 this.sleeping = "not sleeping"
31 sleepSensors.add(new SleepSensor(id, label, displayName, this.sleeping))
35 def setValue(LinkedHashMap eventDataMap) {
36 if (eventDataMap["value"] != sleepSensors[0].sleeping) {
37 this.sleeping = eventDataMap["value"]
38 sleepSensors[0].setValue(eventDataMap["value"])
39 sendEvent(eventDataMap)
43 //Methods for closures
44 def count(Closure Input) {
45 sleepSensors.count(Input)
50 def each(Closure Input) {
51 sleepSensors.each(Input)
53 def find(Closure Input) {
54 sleepSensors.find(Input)
56 def sort(Closure Input) {
57 sleepSensors.sort(Input)
59 def collect(Closure Input) {
60 sleepSensors.collect(Input)