Merge branch 'master' of ssh://plrg.eecs.uci.edu/home/git/smartthings-infrastructure
[smartthings-infrastructure.git] / ColorTemperature / ColorTemperatures.groovy
index aea527995d14b286e5f23ca21ebca1574d0cab9b..d3826804318a6448eff9382233a52bfd1b0043e3 100644 (file)
@@ -2,9 +2,6 @@
 package ColorTemperature
 import Timer.SimulatedTimer
 
-//JPF's Verify API
-import gov.nasa.jpf.vm.Verify
-
 public class ColorTemperatures {
        private int deviceNumbers
        private List colorTemperatues
@@ -14,26 +11,25 @@ public class ColorTemperatures {
        private String id = "colorTemperatureID0"
        private String label = "colorTemperature0"
        private String displayName = "colorTemperature0"
-       private String currentSwitch = "off"
+       private String currentSwitch = "on"
        private int level = 50
        private int currentLevel = 50
        private int colorTemperature = 15000
        
 
-       ColorTemperatures(Closure sendEvent, int deviceNumbers) {
+       ColorTemperatures(Closure sendEvent, int deviceNumbers, boolean init) {
                this.sendEvent = sendEvent
                this.deviceNumbers = deviceNumbers
                this.colorTemperatues = []
 
-               def initLevel = Verify.getIntFromList(50, 70)
-               this.level = initLevel 
-               def initTemp = Verify.getIntFromList(10000, 15000)
-               this.colorTemperature = initTemp 
-               def init = Verify.getBoolean
                if (init) {
-                       this.currentSwitch = "off"
+                       this.level = 30
+                       this.currentLevel = 40
+                       this.colorTemperature = 10000
                } else {
-                       this.currentSwitch = "on"
+                       this.level = 50
+                       this.currentLevel = 50
+                       this.colorTemperature = 15000
                }
 
                colorTemperatues.add(new ColorTemperature(sendEvent, id, label, displayName, this.level, this.currentSwitch, this.colorTemperature))
@@ -85,6 +81,14 @@ public class ColorTemperatures {
 
 
        //methods
+       def setLevel(long level) {
+               if (level != this.level) {
+                       this.currentLevel = level
+                       this.level = level
+                       colorTemperatues[0].setLevel(level)
+               }
+       }
+
        def setLevel(int level) {
                if (level != this.level) {
                        this.currentLevel = level
@@ -99,6 +103,13 @@ public class ColorTemperatures {
                        colorTemperatues[0].setColorTemperature(colorTemperature)                       
                }
        }
+       
+       def setColorTemperature(int colorTemperature) {
+               if (colorTemperature != this.colorTemperature) {
+                       this.colorTemperature = colorTemperature
+                       colorTemperatues[0].setColorTemperature(colorTemperature)                       
+               }
+       }
 
        def on(String currentSwitch) {
                if (currentSwitch != this.currentSwitch) {