Infrastructure compatible for all groups instead of switches.
[smartthings-infrastructure.git] / ThreeAxis / ThreeAxis.groovy
diff --git a/ThreeAxis/ThreeAxis.groovy b/ThreeAxis/ThreeAxis.groovy
new file mode 100644 (file)
index 0000000..83c1a59
--- /dev/null
@@ -0,0 +1,36 @@
+//Create a class for three axis
+package ThreeAxis
+import Timer.SimulatedTimer
+import groovy.json.JsonSlurper
+
+//JPF's Verify API
+import gov.nasa.jpf.vm.Verify
+
+public class ThreeAxis {
+       private String id
+       private String label
+       private String displayName
+       private LinkedHashMap threeAxis
+
+       ThreeAxis(String id, String label, String displayName, LinkedHashMap threeAxis) {
+               this.id = id
+               this.label = label
+               this.displayName = displayName
+               this.threeAxis = threeAxis
+       }
+
+       def setValue(LinkedHashMap eventDataMap) {
+               threeAxis = new groovy.json.JsonSlurper().parseText(eventDataMap["value"])
+               println("the three axis of cube is chagned to $threeAxis!")
+       }
+
+       def currentValue(String deviceFeature) {
+               if (deviceFeature == "threeAxis")
+                       return threeAxis
+       }
+
+       def latestValue(String deviceFeature) {
+               if (deviceFeature == "threeAxis")
+                       return threeAxis
+       }
+}