X-Git-Url: http://plrg.eecs.uci.edu/git/?p=smartthings-infrastructure.git;a=blobdiff_plain;f=Momentary%2FMomentaries.groovy;fp=Momentary%2FMomentaries.groovy;h=f08ea0980443a00287848ca08e844a16e997182a;hp=aa4e1772dcedb8e6452deb3e795850ba338f7797;hb=d0b538d93e64c63d2673796db08570953b57f947;hpb=2932def9bb947d617975235763f7338360f0e5a4 diff --git a/Momentary/Momentaries.groovy b/Momentary/Momentaries.groovy index aa4e177..f08ea09 100644 --- a/Momentary/Momentaries.groovy +++ b/Momentary/Momentaries.groovy @@ -1,68 +1,24 @@ //Create a class for momentory switch device package Momentary -import Timer.SimulatedTimer +import SmartThing.SmartThings -//JPF's Verify API -import gov.nasa.jpf.vm.Verify +public class Momentaries extends SmartThings { + List momentaries = new ArrayList() -public class Momentaries { - int deviceNumbers - List momentaries - def sendEvent + Momentaries(Closure sendEvent) { + // Only initialize one time since we only have one device for each capability + momentaries = smartThings - //If we have only one device - private String id = "momentaryID0" - private String label = "momentary0" - private String displayName = "momentary0" + // Initialization + StringBuilder id = new StringBuilder("momentaryID0") + StringBuilder label = new StringBuilder("momentary") + StringBuilder displayName = new StringBuilder("momentary0") - Momentaries(Closure sendEvent, int deviceNumbers) { - this.sendEvent = sendEvent - this.deviceNumbers = deviceNumbers - this.momentaries = [] - - /*def init = Verify.getBoolean() - if (init) { - this.doorState = "closed" - this.doorLatestValue = "closed" - } else { - this.doorState = "open" - this.doorLatestValue = "open" - }*/ momentaries.add(new Momentary(sendEvent, id, label, displayName)) } - //Methods for closures - def count(Closure Input) { - momentaries.count(Input) - } - def size() { - momentaries.size() - } - def each(Closure Input) { - momentaries.each(Input) - } - def find(Closure Input) { - momentaries.find(Input) - } - def sort(Closure Input) { - momentaries.sort(Input) - } - def collect(Closure Input) { - momentaries.collect(Input) - } - - //By Apps + // Methods to set values def push() { momentaries[0].push() } - - //By Model Checker - def setValue(LinkedHashMap eventDataMap) { - momentaries[0].setValue(eventDataMap["value"]) - sendEvent(eventDataMap) - } - - def getAt(int ix) { - momentaries[ix] - } }