Removing getXXX methods + properties. Adding getProperty feature to SmartThing(s)
[smartthings-infrastructure.git] / StepSensor / StepSensor.groovy
index 4a408ad7cca45bd119ccccef1a76490b7c5f619e..7f0faf357ff5b5d1f3fe31c56fd26ad77db37c3f 100644 (file)
@@ -1,30 +1,28 @@
 //Create a class for step sensor
 package StepSensor
-import Timer.SimulatedTimer
+import SmartThing.SmartThing
 
-public class StepSensor {
-       private String id
-       private String label
-       private String displayName
-       private int goal
-       private int steps
+public class StepSensor extends SmartThing {
+       // id, label, and display name of the device
+       String id
+       String label
+       String displayName
+       // Maps from features to values
+       HashMap<String, Integer> deviceIntValuesMap = new HashMap<String, Integer>()
 
-       StepSensor(String id, String label, String displayName, int steps, int goal) {
+       StepSensor(Closure sendEvent, String id, String label, String displayName, Integer currentSteps, Integer currentGoal) {
+               deviceIntValueSmartThing = deviceIntValuesMap
+               idSmartThing = id
+               labelSmartThing = label
+               displayNameSmartThing = displayName
+               sendEventSmartThings = sendEvent
+
+               // Initialization
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.steps = steps
-               this.goal = goal
-       }
 
-       //By Model Checker
-       def setValue(String value, String name) {
-               if (name == "steps") {
-                       println("the number of steps is changed to $value!")
-                       this.steps = value.toInteger()
-               } else if (name == "goal") {
-                       println("the goal is changed to $value!")
-                       this.goal = value.toInteger()
-               }
+               deviceIntValuesMap.put("steps", currentSteps)
+               deviceIntValuesMap.put("goal", currentGoal)
        }
 }