//Create a class for three axis package ThreeAxis public class ThreeAxis { // id, label, and display name of the device String id String label String displayName // Other variables def sendEvent LinkedHashMap currentThreeAxis ThreeAxis(Closure sendEvent, String id, String label, String displayName, LinkedHashMap currentThreeAxis) { // Initialization this.id = id this.label = label this.displayName = displayName this.currentThreeAxis = currentThreeAxis this.sendEvent = sendEvent } // Methods to set values def setValue(LinkedHashMap eventDataMap) { currentThreeAxis = new groovy.json.JsonSlurper().parseText(eventDataMap["value"]) println("the three axis with id:$id of cube is chagned to $currentThreeAxis!") sendEvent(eventDataMap) } // Methods to return values def getCurrentThreeAxis() { return currentThreeAxis } def currentState(String deviceFeature) { currentValue(deviceFeature) } def latestValue(String deviceFeature) { currentValue(deviceFeature) } def currentValue(String deviceFeature) { if (deviceFeature == "threeAxis" || deviceFeature == "status") return currentThreeAxis } }