Some minor changes!
[smartthings-infrastructure.git] / Switch / Switches.groovy
index 44a275cd4bebfeb9f702d1c6bfdeea34607937c3..152096db303471cfc66dfece1098095c9ea6e478 100644 (file)
@@ -5,6 +5,7 @@ import Timer.SimulatedTimer
 //JPF's Verify API
 import gov.nasa.jpf.vm.Verify
 
+
 public class Switches {
        int deviceNumbers       
        List switches
@@ -20,25 +21,23 @@ public class Switches {
        private int currentLevel = 50
        private String switchLatestValue = "off"
 
-       Switches(Closure sendEvent, int deviceNumbers) {
+       Switches(Closure sendEvent, int deviceNumbers, boolean init) {
                this.sendEvent = sendEvent
                this.timers = new SimulatedTimer()
                this.deviceNumbers = deviceNumbers
                this.switches = []
 
-               def initLevel = Verify.getIntFromList(30, 50, 70)
-               this.currentLevel = initLevel
-               def init = Verify.getBoolean()
                if (init) {
                        this.switchState = "off"
                        this.currentSwitch = "off"
                        this.switchLatestValue = "off"
+                       this.currentLevel = 50
                } else {
                        this.switchState = "on"
                        this.currentSwitch = "on"
                        this.switchLatestValue = "on"
+                       this.currentLevel = 60
                }
-
                switches.add(new Switch(sendEvent, id, label, displayName, this.switchState, this.currentSwitch, this.currentLevel, this.switchLatestValue))
        }
 
@@ -52,6 +51,9 @@ public class Switches {
        def each(Closure Input) {
                switches.each(Input)
        }
+       def eachWithIndex(Closure Input) {
+               switches.eachWithIndex(Input)
+       }
        def find(Closure Input) {
                switches.find(Input)
        }
@@ -63,6 +65,10 @@ public class Switches {
        }
 
        //By Apps
+       def eventsSince(Date dateObj, LinkedHashMap metaData) {
+               return switches[0].eventsSince()
+       }
+
        def setLevel(int level) {
                currentLevel = level
                switches[0].setLevel(level)