--- /dev/null
+//Create a class for smoke detector
+package SmokeDetector
+import Timer.SimulatedTimer
+
+public class SmokeDetector {
+ private String id
+ private String label
+ private String displayName
+ private String smoke
+ private String currentSmokeValue
+ private String smokeLatestValue
+
+ SmokeDetector(String id, String label, String displayName, String smoke, String smokeLatestValue) {
+ this.id = id
+ this.label = label
+ this.displayName = displayName
+ this.smoke = smoke
+ this.currentSmokeValue = smoke
+ this.smokeLatestValue = smokeLatestValue
+ }
+
+ def setValue(String value) {
+ this.smokeLatestValue = smoke
+ println("the smoke detector with id:$id is triggered to $value!")
+ this.smoke = value
+ this.currentSmokeValue = value
+ }
+
+
+ def currentValue(String deviceFeature) {
+ if (deviceFeature == "smoke") {
+ return currentSmokeValue
+ }
+ }
+
+ def latestValue(String deviceFeature) {
+ if (deviceFeature == "smoke") {
+ return smokeLatestValue
+ }
+ }
+}