X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=SmokeDetector%2FSmokeDetector.groovy;h=b9ebeced6cde48e402b0f147a3e3d186ae5c8d71;hb=HEAD;hp=3182cc3a62442c831e2e8fa7e8a8886cda90a078;hpb=16ebbcf5da0fa9989acb5b03129b9706331066c5;p=smartthings-infrastructure.git diff --git a/SmokeDetector/SmokeDetector.groovy b/SmokeDetector/SmokeDetector.groovy index 3182cc3..b9ebece 100644 --- a/SmokeDetector/SmokeDetector.groovy +++ b/SmokeDetector/SmokeDetector.groovy @@ -1,41 +1,27 @@ //Create a class for smoke detector package SmokeDetector -import Timer.SimulatedTimer +import SmartThing.SmartThing -public class SmokeDetector { - private String id - private String label - private String displayName - private String smoke - private String currentSmokeValue - private String smokeLatestValue +public class SmokeDetector extends SmartThing { + // id, label, and display name of the device + String id + String label + String displayName + // Maps from features to values + HashMap deviceValuesMap = new HashMap() - SmokeDetector(String id, String label, String displayName, String smoke, String smokeLatestValue) { + SmokeDetector(Closure sendEvent, String id, String label, String displayName, String currentSmoke) { + deviceValueSmartThing = deviceValuesMap + idSmartThing = id + labelSmartThing = label + displayNameSmartThing = displayName + sendEventSmartThings = sendEvent + + // Initialization 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 - } + deviceValuesMap.put("smoke", currentSmoke) } }