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