1 //Create a class for acceleration sensor
2 package AccelerationSensor
3 import Timer.SimulatedTimer
6 import gov.nasa.jpf.vm.Verify
8 public class AccelerationSensors {
9 private int deviceNumbers
10 private List accelerationSensors
13 //For one device(We cannot have obj.id)-> We should have obj[0].id
14 private String id = "accelerationSensorID0"
15 private String label = "accelerationSensor0"
16 private String displayName = "accelerationSensor0"
17 private String acceleration = "inactive"
18 private String currentAcceleration = "inactive"
19 private String accelerationLatestValue = "inactive"
22 AccelerationSensors(Closure sendEvent, int deviceNumbers) {
23 this.sendEvent = sendEvent
24 this.deviceNumbers = deviceNumbers
25 this.accelerationSensors = []
27 /*def init = Verify.getBoolean()
29 this.acceleration = "inactive"
30 this.accelerationLatestValue = "inactive"
32 this.acceleration = "active"
33 this.accelerationLatestValue = "active"
35 accelerationSensors.add(new AccelerationSensor(id, label, displayName, this.acceleration, this.accelerationLatestValue))
39 def setValue(LinkedHashMap eventDataMap) {
40 if (eventDataMap["value"] != accelerationSensors[0].acceleration) {
41 accelerationSensors[0].setValue(eventDataMap["value"])
42 this.accelerationLatestValue = accelerationSensors[0].accelerationLatestValue
43 this.acceleration = accelerationSensors[0].acceleration
44 this.currentAcceleration = accelerationSensors[0].acceleration
45 sendEvent(eventDataMap)
49 //Methods for closures
50 def count(Closure Input) {
51 accelerationSensors.count(Input)
54 accelerationSensors.size()
56 def each(Closure Input) {
57 accelerationSensors.each(Input)
59 def find(Closure Input) {
60 accelerationSensors.find(Input)
62 def collect(Closure Input) {
63 accelerationSensors.collect(Input)
67 def currentValue(String deviceFeature) {
68 accelerationSensors[0].currentValue(deviceFeature)//It is called if we have only one device
71 def latestValue(String deviceFeature) {
72 accelerationSensors[0].latestValue(deviceFeature)//It is called if we have only one device
75 def statesSince(String info, Date dateObj) {
76 return accelerationSensors[0].statesSince(info, dateObj)
80 accelerationSensors[ix]