//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)
}
}