Changes in classes: new concept for latest value + all types of events generated...
[smartthings-infrastructure.git] / IlluminanceMeasurement / IlluminanceMeasurement.groovy
1 //Create a class for illuminance measurement
2 package IlluminanceMeasurement
3 import Timer.SimulatedTimer
4
5 public class IlluminanceMeasurement {
6         private String id
7         private String label
8         private String displayName
9         private int illuminance
10         private int currentIlluminance
11
12         IlluminanceMeasurement(String id, String label, String displayName, int illuminance) {
13                 this.id = id
14                 this.label = label
15                 this.displayName = displayName
16                 this.illuminance = illuminance
17                 this.currentIlluminance = illuminance
18         }
19
20         //By Model Checker
21         def setValue(String value) {
22                 println("the illuminance level is changed to $value!")
23                 this.illuminance = value.toInteger()
24                 this.currentIlluminance = value.toInteger()
25         }
26
27         def currentValue(String deviceFeature) {
28                 if (deviceFeature == "illuminance") {
29                         return illuminance
30                 }
31         }
32
33         def latestValue(String deviceFeature) {
34                 if (deviceFeature == "illuminance") {
35                         return illuminance
36                 }
37         }
38
39 }