-public class AccelerationSensors {
- private int deviceNumbers
- private List accelerationSensors
- def sendEvent
-
- //For one device(We cannot have obj.id)-> We should have obj[0].id
- private String id = "accelerationSensorID0"
- private String label = "accelerationSensor0"
- private String displayName = "accelerationSensor0"
- private String acceleration = "inactive"
- private String currentAcceleration = "inactive"
- private String accelerationLatestValue = "inactive"
-
-
-
- AccelerationSensors(Closure sendEvent, int deviceNumbers, boolean init) {
- this.sendEvent = sendEvent
- this.deviceNumbers = deviceNumbers
- this.accelerationSensors = []
-
- if (init) {
- this.acceleration = "inactive"
- this.accelerationLatestValue = "inactive"
- } else {
- this.acceleration = "active"
- this.accelerationLatestValue = "active"
- }
- accelerationSensors.add(new AccelerationSensor(id, label, displayName, this.acceleration, this.accelerationLatestValue))
- }
-
- //By Model Checker
- def setValue(LinkedHashMap eventDataMap) {
- if (eventDataMap["value"] != accelerationSensors[0].acceleration) {
- this.accelerationLatestValue = eventDataMap["value"]
- this.acceleration = eventDataMap["value"]
- this.currentAcceleration = eventDataMap["value"]
- accelerationSensors[0].setValue(eventDataMap["value"])
- sendEvent(eventDataMap)
- }
- }
-
- //methods
- def eventsSince(Date dateObj) {
- return accelerationSensors[0].eventsSince()
- }