1 //Create a class for three axis
4 public class ThreeAxis {
5 // id, label, and display name of the device
11 LinkedHashMap currentThreeAxis
14 ThreeAxis(Closure sendEvent, String id, String label, String displayName, LinkedHashMap currentThreeAxis) {
18 this.displayName = displayName
19 this.currentThreeAxis = currentThreeAxis
20 this.sendEvent = sendEvent
23 // Methods to set values
24 def setValue(LinkedHashMap eventDataMap) {
25 currentThreeAxis = new groovy.json.JsonSlurper().parseText(eventDataMap["value"])
26 println("the three axis with id:$id of cube is chagned to $currentThreeAxis!")
27 sendEvent(eventDataMap)
30 // Methods to return values
31 def getCurrentThreeAxis() {
32 return currentThreeAxis
35 def currentState(String deviceFeature) {
36 currentValue(deviceFeature)
39 def latestValue(String deviceFeature) {
40 currentValue(deviceFeature)
43 def currentValue(String deviceFeature) {
44 if (deviceFeature == "threeAxis" || deviceFeature == "status")
45 return currentThreeAxis