Merge branch 'master' of ssh://plrg.eecs.uci.edu/home/git/smartthings-infrastructure
[smartthings-infrastructure.git] / ThreeAxis / ThreeAxis.groovy
1 //Create a class for three axis
2 package ThreeAxis
3 import Timer.SimulatedTimer
4 import groovy.json.JsonSlurper
5
6 //JPF's Verify API
7 import gov.nasa.jpf.vm.Verify
8
9 public class ThreeAxis {
10         private String id
11         private String label
12         private String displayName
13         private LinkedHashMap threeAxis
14
15         ThreeAxis(String id, String label, String displayName, LinkedHashMap threeAxis) {
16                 this.id = id
17                 this.label = label
18                 this.displayName = displayName
19                 this.threeAxis = threeAxis
20         }
21
22         def setValue(LinkedHashMap eventDataMap) {
23                 threeAxis = new groovy.json.JsonSlurper().parseText(eventDataMap["value"])
24                 println("the three axis of cube is chagned to $threeAxis!")
25         }
26
27         def currentValue(String deviceFeature) {
28                 if (deviceFeature == "threeAxis")
29                         return threeAxis
30         }
31
32         def latestValue(String deviceFeature) {
33                 if (deviceFeature == "threeAxis")
34                         return threeAxis
35         }
36 }