1 //Create a class for smoke detector
3 import Timer.SimulatedTimer
5 public class SmokeDetector {
8 private String displayName
10 private String currentSmokeValue
11 private String smokeLatestValue
13 SmokeDetector(String id, String label, String displayName, String smoke, String smokeLatestValue) {
16 this.displayName = displayName
18 this.currentSmokeValue = smoke
19 this.smokeLatestValue = smokeLatestValue
22 def setValue(String value) {
23 this.smokeLatestValue = smoke
24 println("the smoke detector with id:$id is triggered to $value!")
26 this.currentSmokeValue = value
30 def currentValue(String deviceFeature) {
31 if (deviceFeature == "smoke") {
32 return currentSmokeValue
36 def latestValue(String deviceFeature) {
37 if (deviceFeature == "smoke") {
38 return smokeLatestValue