Infrastruction modification
[smartthings-infrastructure.git] / WaterSensor / WaterSensor.groovy
index 19576845ce7e6a9367541ca90d6ae4a4bfc2ea70..8c4e921fccaf4d4baaca2e46796b145e9a7ddcec 100644 (file)
@@ -1,23 +1,35 @@
 //Create a class for water sensor
 package WaterSensor
-import Timer.SimulatedTimer
+import SmartThing.SmartThing
 
-public class WaterSensor {
-       private String id
-       private String label
-       private String displayName
-       private String water
+public class WaterSensor extends SmartThing {
+       // id, label, and display name of the device
+       StringBuilder id = new StringBuilder()
+       StringBuilder label = new StringBuilder()
+       StringBuilder displayName = new StringBuilder()
+       // Features with string values
+       StringBuilder currentWater = new StringBuilder()
+       // Maps from features to values
+       HashMap<String, StringBuilder> deviceValuesMap = new HashMap<String, StringBuilder>()
 
-       WaterSensor(String id, String label, String displayName, String water) {
+       WaterSensor(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, StringBuilder currentWater) {
+               deviceValuesMap = deviceValueSmartThing
+               idSmartThing = id
+               labelSmartThing = label
+               displayNameSmartThing = displayName
+               sendEventSmartThings = sendEvent
+
+               // Initialization
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.water = water
+               this.currentWater = currentWater
+
+               deviceValuesMap.put("water", currentWater)
        }
 
-       //By Model Checker
-       def setValue(String value) {
-               println("the water state is changed to $value!")
-               this.water = value
+       // Methods to return values
+       def getCurrentWater() {
+               return currentWater.toString()
        }
 }