Merge branch 'master' of ssh://plrg.eecs.uci.edu/home/git/smartthings-infrastructure
[smartthings-infrastructure.git] / StepSensor / StepSensors.groovy
index fa6d78cccc36225717787752409b0acd333947ff..021db256317e3006a4bf8b86ecbf2d3f8305604e 100644 (file)
@@ -23,10 +23,10 @@ public class StepSensors {
                this.deviceNumbers = deviceNumbers
                this.stepSensors = []
 
-               def initGoal = Verify.getIntFromList(1000, 2000, 3000)
+               /*def initGoal = Verify.getIntFromList(1000, 2000, 3000)
                this.goal = initGoal
                def initSteps = Verify.getIntFromList(0, 1, 2)
-               this.steps = initSteps
+               this.steps = initSteps*/
 
                stepSensors.add(new StepSensor(id, label, displayName, this.steps, this.goal))
        }
@@ -34,15 +34,15 @@ public class StepSensors {
        //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)
                        }
                }
@@ -61,6 +61,9 @@ public class StepSensors {
        def find(Closure Input) {
                stepSensors.find(Input)
        }
+       def sort(Closure Input) {
+               stepSensors.sort(Input)
+       }
        def collect(Closure Input) {
                stepSensors.collect(Input)
        }