1 //Create a class for step sensor
3 import Timer.SimulatedTimer
5 public class StepSensor {
8 private String displayName
12 StepSensor(String id, String label, String displayName, int steps, int goal) {
15 this.displayName = displayName
21 def setValue(String value, String name) {
22 if (name == "steps") {
23 println("the number of steps is changed to $value!")
24 this.steps = value.toInteger()
25 } else if (name == "goal") {
26 println("the goal is changed to $value!")
27 this.goal = value.toInteger()
31 def currentValue(String deviceFeature) {
32 if (deviceFeature == "steps")
34 else if (deviceFeature == "goal")
38 def latestValue(String deviceFeature) {
39 if (deviceFeature == "steps")
41 else if (deviceFeature == "goal")