Infrastruction modification
[smartthings-infrastructure.git] / SpeechSynthesis / SpeechSynthesises.groovy
index 2a125987d1806787f72821694a14bda378ab40fd..0c2acb8a68b85c02ce1b36a3e45067c8418811d4 100644 (file)
@@ -1,65 +1,42 @@
 //Create a class for speech synthesis
 package SpeechSynthesis
-import Timer.SimulatedTimer
-
-//JPF's Verify API
-import gov.nasa.jpf.vm.Verify
-
-public class SpeechSynthesises {
-       private int deviceNumbers
-       private List speechSynthesises
-       def sendEvent
-
-       //For one device(We cannot have obj.id)-> We should have obj[0].id
-       private String id = "speechSynthesisID0"
-       private String label = "speechSynthesis0"
-       private String displayName = "speechSynthesis0"
-       private int level = 50
+import SmartThing.SmartThings
 
+public class SpeechSynthesises extends SmartThings {
+       List speechSynthesises = new ArrayList()
                
-       SpeechSynthesises(Closure sendEvent, int deviceNumbers) {
-               this.sendEvent = sendEvent              
-               this.deviceNumbers = deviceNumbers
-               this.speechSynthesises = []
+       SpeechSynthesises(Closure sendEvent, boolean init) {
+               // Only initialize one time since we only have one device for each capability
+               speechSynthesises = smartThings
 
-               //def init = Verify.getIntFromList(30, 50, 70)
-               //this.level = init
+               // Initialization
+               StringBuilder id = new StringBuilder("speechSynthesisID0")
+               StringBuilder label = new StringBuilder("speechSynthesis")
+               StringBuilder displayName = new StringBuilder("speechSynthesis0")
+               MutableInteger level = new MutableInteger()
 
-               speechSynthesises.add(new SpeechSynthesis(id, label, displayName, this.level))
-       }
+               if (init)
+                       level.setValue(50)
+               else
+                       level.setValue(60)
 
-       //Methods for closures
-       def count(Closure Input) {
-               speechSynthesises.count(Input)
-       }
-       def size() {
-               speechSynthesises.size()
-       }
-       def each(Closure Input) {
-               speechSynthesises.each(Input)
-       }
-       def find(Closure Input) {
-               speechSynthesises.find(Input)
-       }
-       def sort(Closure Input) {
-               speechSynthesises.sort(Input)
-       }
-       def collect(Closure Input) {
-               speechSynthesises.collect(Input)
+               speechSynthesises.add(new SpeechSynthesis(sendEvent, id, label, displayName, level))
        }
 
+       // Methods to set values
        def setLevel(int level) {
-               if (level != this.level) {
-                       this.level = level
-                       speechSynthesises[0].setLevel(level)
-               }
+               speechSynthesises[0].setLevel(level)
        }
 
        def speak(String message) {
                speechSynthesises[0].speak(message)
        }
 
-       def getAt(int ix) {
-               speechSynthesises[ix]
+       // Methods to return values
+       def getCurrentLevel() {
+               List tmpValues = new ArrayList()
+               tmpValues.add(speechSynthesises[0].getCurrentLevel())
+               return tmpValues
        }
+
 }