1 //Create a class for beacon sensor
3 import Timer.SimulatedTimer
6 import gov.nasa.jpf.vm.Verify
8 public class BeaconSensors {
9 private int deviceNumbers
10 private List beaconSensors
13 //For one device(We cannot have obj.id)-> We should have obj[0].id
14 private String id = "beaconSensorID0"
15 private String label = "beaconSensor0"
16 private String displayName = "beaconSensor0"
17 private String presence = "not present"
18 private String currentPresence = "not present"
19 private String presenceLatestValue = "not present"
22 BeaconSensors(Closure sendEvent, int deviceNumbers) {
23 this.sendEvent = sendEvent
24 this.deviceNumbers = deviceNumbers
25 this.beaconSensors = []
27 /*def init = Verify.getBoolean()
29 this.presence = "not present"
30 this.presenceLatestValue = "not present"
32 this.presence = "present"
33 this.presenceLatestValue = "present"
35 beaconSensors.add(new BeaconSensor(id, label, displayName, this.presence, this.presenceLatestValue))
39 def setValue(LinkedHashMap eventDataMap) {
40 if (eventDataMap["value"] != beaconSensors[0].presence) {
41 this.presenceLatestValue = eventDataMap["value"]
42 this.presence = eventDataMap["value"]
43 this.currentPresence = eventDataMap["value"]
44 beaconSensors[0].setValue(eventDataMap["value"])
45 sendEvent(eventDataMap)
49 //Methods for closures
50 def count(Closure Input) {
51 beaconSensors.count(Input)
56 def each(Closure Input) {
57 beaconSensors.each(Input)
59 def sort(Closure Input) {
60 beaconSensors.sort(Input)
62 def find(Closure Input) {
63 beaconSensors.find(Input)
65 def collect(Closure Input) {
66 beaconSensors.collect(Input)
70 def currentValue(String deviceFeature) {
71 beaconSensors[0].currentValue(deviceFeature)//It is called if we have only one device
74 def latestValue(String deviceFeature) {
75 beaconSensors[0].latestValue(deviceFeature)//It is called if we have only one device