Merge branch 'master' of ssh://plrg.eecs.uci.edu/home/git/smartthings-infrastructure
[smartthings-infrastructure.git] / SpeechSynthesis / SpeechSynthesises.groovy
1 //Create a class for speech synthesis
2 package SpeechSynthesis
3 import Timer.SimulatedTimer
4
5 //JPF's Verify API
6 import gov.nasa.jpf.vm.Verify
7
8 public class SpeechSynthesises {
9         private int deviceNumbers
10         private List speechSynthesises
11         def sendEvent
12
13         //For one device(We cannot have obj.id)-> We should have obj[0].id
14         private String id = "speechSynthesisID0"
15         private String label = "speechSynthesis0"
16         private String displayName = "speechSynthesis0"
17         private int level = 50
18
19                 
20         SpeechSynthesises(Closure sendEvent, int deviceNumbers) {
21                 this.sendEvent = sendEvent              
22                 this.deviceNumbers = deviceNumbers
23                 this.speechSynthesises = []
24
25                 //def init = Verify.getIntFromList(30, 50, 70)
26                 //this.level = init
27
28                 speechSynthesises.add(new SpeechSynthesis(id, label, displayName, this.level))
29         }
30
31         //Methods for closures
32         def count(Closure Input) {
33                 speechSynthesises.count(Input)
34         }
35         def size() {
36                 speechSynthesises.size()
37         }
38         def each(Closure Input) {
39                 speechSynthesises.each(Input)
40         }
41         def find(Closure Input) {
42                 speechSynthesises.find(Input)
43         }
44         def sort(Closure Input) {
45                 speechSynthesises.sort(Input)
46         }
47         def collect(Closure Input) {
48                 speechSynthesises.collect(Input)
49         }
50
51         def setLevel(int level) {
52                 if (level != this.level) {
53                         this.level = level
54                         speechSynthesises[0].setLevel(level)
55                 }
56         }
57
58         def speak(String message) {
59                 speechSynthesises[0].speak(message)
60         }
61
62         def getAt(int ix) {
63                 speechSynthesises[ix]
64         }
65 }