private int steps = 0
- StepSensors(Closure sendEvent, int deviceNumbers) {
+ StepSensors(Closure sendEvent, int deviceNumbers, boolean init) {
this.sendEvent = sendEvent
this.deviceNumbers = deviceNumbers
this.stepSensors = []
+ if (init) {
+ this.goal = 50
+ this.steps = 0
+ } else {
+ this.goal = 60
+ this.steps = 1
+ }
stepSensors.add(new StepSensor(id, label, displayName, this.steps, this.goal))
}
//By Model Checker
def setValue(LinkedHashMap eventDataMap) {
if (eventDataMap["name"] == "steps") {
- if (eventDataMap["value"] != stepSensors[0].steps) {
+ if (eventDataMap["value"].toInteger() != stepSensors[0].steps) {
+ this.steps = eventDataMap["value"].toInteger()
stepSensors[0].setValue(eventDataMap["value"], "steps")
- this.steps = stepSensors[0].steps
sendEvent(eventDataMap)
}
- } else if (eventDataMap["value"] == "goal") {
- if (eventDataMap["value"] != stepSensors[0].goal) {
+ } else if (eventDataMap["name"] == "goal") {
+ if (eventDataMap["value"].toInteger() != stepSensors[0].goal) {
+ this.goal = eventDataMap["value"].toInteger()
stepSensors[0].setValue(eventDataMap["value"], "goal")
- this.goal = stepSensors[0].goal
sendEvent(eventDataMap)
}
}
def find(Closure Input) {
stepSensors.find(Input)
}
+ def sort(Closure Input) {
+ stepSensors.sort(Input)
+ }
def collect(Closure Input) {
stepSensors.collect(Input)
}
stepSensors[0].currentValue(deviceFeature)//It is called if we have only one device
}
+ def latestValue(String deviceFeature) {
+ stepSensors[0].currentValue(deviceFeature)//It is called if we have only one device
+ }
+
def getAt(int ix) {
stepSensors[ix]
}