1 //Create a class for acceleration sensor
2 package AccelerationSensor
3 import Timer.SimulatedTimer
6 import gov.nasa.jpf.vm.Verify
8 public class AccelerationSensor {
11 private String displayName
12 private String acceleration
13 private String currentAcceleration
14 private String accelerationLatestValue
16 AccelerationSensor(String id, String label, String displayName, String acceleration, String accelerationLatestValue) {
19 this.displayName = displayName
20 this.acceleration = acceleration
21 this.currentAcceleration = acceleration
22 this.accelerationLatestValue = accelerationLatestValue
25 def setValue(String value) {
26 println("the acceleration sensor with id:$id is triggered to $value!")
27 this.accelerationLatestValue = value
28 this.acceleration = value
29 this.currentAcceleration = value
33 def evtActive = [[name: "acceleration", value: "active", deviceId: "accelerationSensorID0", descriptionText: "",
34 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'],
35 [name: "acceleration.active", value: "active", deviceId: "accelerationSensorID0", descriptionText: "",
36 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}']]
37 def evtInactive = [[name: "acceleration", value: "inactive", deviceId: "accelerationSensorID0", descriptionText: "",
38 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'],
39 [name: "acceleration.inactive", value: "inactive", deviceId: "accelerationSensorID0", descriptionText: "",
40 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}']]
41 def init = Verify.getInt(0,4)
43 if (init == 0) {//return empty set
45 } else if (init == 1) {//send one active event
50 } else if (init == 2) {//send two active events
58 } else if (init == 3) {//send one inactive event
63 } else if (init == 4) {//send two inactive events
75 def evtActive = [[name: "acceleration", value: "active", deviceId: "accelerationSensorID0", descriptionText: "",
76 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'],
77 [name: "acceleration.active", value: "active", deviceId: "accelerationSensorID0", descriptionText: "",
78 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}']]
79 def evtInactive = [[name: "acceleration", value: "inactive", deviceId: "accelerationSensorID0", descriptionText: "",
80 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'],
81 [name: "acceleration.inactive", value: "inactive", deviceId: "accelerationSensorID0", descriptionText: "",
82 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}']]
83 def init = Verify.getInt(0,4)
85 if (init == 0) {//return empty set
87 } else if (init == 1) {//send one active event
92 } else if (init == 2) {//send two active events
100 } else if (init == 3) {//send one inactive event
105 } else if (init == 4) {//send two inactive events
117 def currentValue(String deviceFeature) {
118 if (deviceFeature == "acceleration") {
123 def latestValue(String deviceFeature) {
124 if (deviceFeature == "acceleration") {
125 return accelerationLatestValue