Merge branch 'master' of ssh://plrg.eecs.uci.edu/home/git/smartthings-infrastructure
[smartthings-infrastructure.git] / StepSensor / StepSensor.groovy
1 //Create a class for step sensor
2 package StepSensor
3 import Timer.SimulatedTimer
4
5 public class StepSensor {
6         private String id
7         private String label
8         private String displayName
9         private int goal
10         private int steps
11
12         StepSensor(String id, String label, String displayName, int steps, int goal) {
13                 this.id = id
14                 this.label = label
15                 this.displayName = displayName
16                 this.steps = steps
17                 this.goal = goal
18         }
19
20         //By Model Checker
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()
28                 }
29         }
30 }