Adding event for Power as variation is needed in power values.
[smartthings-infrastructure.git] / SpeechSynthesis / SpeechSynthesises.groovy
index 2ef8cec28f8b0bebfd640103524550f14e041e92..876e48d5019f3f84958adbb4eb5664a8be02c671 100644 (file)
@@ -2,9 +2,6 @@
 package SpeechSynthesis
 import Timer.SimulatedTimer
 
-//JPF's Verify API
-import gov.nasa.jpf.vm.Verify
-
 public class SpeechSynthesises {
        private int deviceNumbers
        private List speechSynthesises
@@ -15,17 +12,22 @@ public class SpeechSynthesises {
        private String label = "speechSynthesis0"
        private String displayName = "speechSynthesis0"
        private int level = 50
+       private boolean oneUser = true
 
                
-       SpeechSynthesises(Closure sendEvent, int deviceNumbers) {
+       SpeechSynthesises(Closure sendEvent, int deviceNumbers, boolean init) {
                this.sendEvent = sendEvent              
                this.deviceNumbers = deviceNumbers
                this.speechSynthesises = []
 
-               def init = Verify.getIntFromList(30, 50, 70)
-               this.level = init
-
-               speechSynthesises.add(new SpeechSynthesis(id, label, displayName, this.level))
+               if (init) {
+                       this.level = 50
+                       this.oneUser = true
+               } else {
+                       this.level = 60
+                       this.oneUser = false
+               }
+               speechSynthesises.add(new SpeechSynthesis(id, label, displayName, this.level, this.oneUser))
        }
 
        //Methods for closures
@@ -41,19 +43,28 @@ public class SpeechSynthesises {
        def find(Closure Input) {
                speechSynthesises.find(Input)
        }
+       def sort(Closure Input) {
+               speechSynthesises.sort(Input)
+       }
        def collect(Closure Input) {
                speechSynthesises.collect(Input)
        }
 
        def setLevel(int level) {
                if (level != this.level) {
-                       speechSynthesises[0].setLevel(level)
                        this.level = level
+                       speechSynthesises[0].setLevel(level)
                }
        }
 
        def speak(String message) {
                speechSynthesises[0].speak(message)
+               // As a conflict variable
+               if (oneUser) {
+                       this.oneUser = false
+               } else {
+                       this.oneUser = true
+               }
        }
 
        def getAt(int ix) {