X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=ThreeAxis%2FThreeAxises.groovy;h=b43854244fe765de395bbd9903f235cc6b3917b0;hb=d0b538d93e64c63d2673796db08570953b57f947;hp=7077514c973e425a67b6f96433372d1deaae8c42;hpb=2932def9bb947d617975235763f7338360f0e5a4;p=smartthings-infrastructure.git diff --git a/ThreeAxis/ThreeAxises.groovy b/ThreeAxis/ThreeAxises.groovy index 7077514..b438542 100644 --- a/ThreeAxis/ThreeAxises.groovy +++ b/ThreeAxis/ThreeAxises.groovy @@ -1,71 +1,32 @@ //Create a class for three axis package ThreeAxis -import Timer.SimulatedTimer +import SmartThing.SmartThings -public class ThreeAxises { - private int deviceNumbers - private List threeAxises - def sendEvent - - //For one device(We cannot have obj.id)-> We should have obj[0].id - private String id = "threeAxisID0" - private String label = "threeAxis0" - private String displayName = "threeAxis0" - private LinkedHashMap threeAxis = [x:0, y:0, z:0] - - - ThreeAxises(Closure sendEvent, int deviceNumbers, boolean init) { - this.sendEvent = sendEvent - this.deviceNumbers = deviceNumbers - this.threeAxises = [] +public class ThreeAxises extends SmartThings { + List threeAxises = new ArrayList() - if (init) { - this.threeAxis = [x:0, y:0, z:0] - } else { - this.threeAxis = [x:1, y:2, z:3] - } - threeAxises.add(new ThreeAxis(id, label, displayName, threeAxis)) - } + ThreeAxises(Closure sendEvent, boolean init) { + // Only initialize one time since we only have one device for each capability + threeAxises = smartThings - //By Model Checker - def setValue(LinkedHashMap eventDataMap) { - threeAxises[0].setValue(eventDataMap) - sendEvent(eventDataMap) - } + // Initialization + StringBuilder id = new StringBuilder("threeAxisID0") + StringBuilder label = new StringBuilder("threeAxis") + StringBuilder displayName = new StringBuilder("threeAxis0") + LinkedHashMap threeAxis - //Methods for closures - def count(Closure Input) { - threeAxises.count(Input) - } - def size() { - threeAxises.size() - } - def each(Closure Input) { - threeAxises.each(Input) - } - def sort(Closure Input) { - threeAxises.sort(Input) - } - def find(Closure Input) { - threeAxises.find(Input) - } - def collect(Closure Input) { - threeAxises.collect(Input) - } - - def currentState(String deviceFeature) { - threeAxises[0].currentValue(deviceFeature) - } - - def currentValue(String deviceFeature) { - threeAxises[0].currentValue(deviceFeature) - } + if (init) + threeAxis = [x:0, y:0, z:0] + else + threeAxis = [x:1, y:2, z:3] - def latestValue(String deviceFeature) { - threeAxises[0].latestValue(deviceFeature) + threeAxises.add(new ThreeAxis(sendEvent, id, label, displayName, threeAxis)) } - def getAt(int ix) { - threeAxises[ix] + // Methods to return values + def getCurrentThreeAxis() { + List tmpValues = new ArrayList() + tmpValues.add(threeAxises[0].getCurrentThreeAxis()) + return tmpValues } }