Merge branch 'master' of ssh://plrg.eecs.uci.edu/home/git/smartthings-infrastructure
[smartthings-infrastructure.git] / RelativeHumidityMeasurement / RelativeHumidityMeasurement.groovy
1 //Create a class for relative humidity measurement
2 package RelativeHumidityMeasurement
3 import Timer.SimulatedTimer
4
5 public class RelativeHumidityMeasurement {
6         private String id
7         private String label
8         private String displayName
9         private int humidity
10         private int currentHumidity
11
12         RelativeHumidityMeasurement(String id, String label, String displayName, int humidity) {
13                 this.id = id
14                 this.label = label
15                 this.displayName = displayName
16                 this.humidity = humidity
17         }
18
19         //By Model Checker
20         def setValue(String value) {
21                 println("the humidity is changed to $value!")
22                 this.humidity = value.toInteger()
23                 this.currentHumidity = value.toInteger()
24         }
25
26         def currentValue(String deviceFeature) {
27                 if (deviceFeature == "humidity") {
28                         return humidity
29                 }
30         }
31
32         def latestValue(String deviceFeature) {
33                 if (deviceFeature == "humidity") {
34                         return humidity
35                 }
36         }
37 }