Infrastruction modification
[smartthings-infrastructure.git] / Button / Buttons.groovy
index f15a30072aeee0f4033dd80e65ee454cb4542a9f..2b94073dd8d803481ccebec58ba5a6106f556364 100644 (file)
@@ -1,67 +1,18 @@
 //Create a class for button
 package Button
-import Timer.SimulatedTimer
+import SmartThing.SmartThings
 
-public class Buttons {
-       private int deviceNumbers
-       private List buttons
-       def sendEvent
-
-       //For one device(We cannot have obj.id)-> We should have obj[0].id
-       private String id = "buttonID0"
-       private String label = "button0"
-       private String displayName = "button0"
-       private String button = "pushed"
-       private int numberOfButtons = 4
-       
+public class Buttons extends SmartThings {
+       List buttons = new ArrayList()
                
-       Buttons(Closure sendEvent, int deviceNumbers, boolean init) {
-               this.sendEvent = sendEvent              
-               this.deviceNumbers = deviceNumbers
-               this.buttons = []
-
-               if (init) {
-                       this.button = "pushed"
-               } else {
-                       this.button = "held"
-               }
-               buttons.add(new Button(id, label, displayName, button, numberOfButtons))
-       }
-
-       //By Model Checker
-       def setValue(LinkedHashMap eventDataMap) {
-               buttons[0].setValue(eventDataMap)
-               sendEvent(eventDataMap)
-       }
-
-       //Methods for closures
-       def count(Closure Input) {
-               buttons.count(Input)
-       }
-       def size() {
-               buttons.size()
-       }
-       def each(Closure Input) {
-               buttons.each(Input)
-       }
-       def sort(Closure Input) {
-               buttons.sort(Input)
-       }
-       def find(Closure Input) {
-               buttons.find(Input)
-       }
-       def collect(Closure Input) {
-               buttons.collect(Input)
-       }
-
-
-       //methods
-       def eventsSince(Date dateObj) {
-               return buttons[0].eventsSince()
-       }
+       Buttons(Closure sendEvent) {
+               buttons = smartThings
 
+               // Initialization
+               StringBuilder id = new StringBuilder("buttonID0")
+               StringBuilder label = new StringBuilder("button")
+               StringBuilder displayName = new StringBuilder("button0")
 
-       def getAt(int ix) {
-               buttons[ix]
+               buttons.add(new Button(sendEvent, id, label, displayName))
        }
 }