Commit #7: Events thread-based + new easier Extractor.py + our own Timer class
[smartthings-infrastructure.git] / eventSimulator / eventSimulator.groovy
1 // Generate a random variable
2 Random random = new Random(1131)
3 int nextRandom = 10
4
5 // Touch events
6 new Thread() {
7         @Override
8         public void run() {
9                 while(true) {
10                         appObject.setValue([name: "Touched", value: "Touched", deviceId: 0, descriptionText: "",
11                                            displayed: true, linkText: "", isStateChange: false, unit: "", data: []])
12                         Thread.sleep(random.nextInt(nextRandom));       
13                         
14                 }
15         }
16 }.start()
17
18 // Lock events
19 new Thread() {
20         
21         @Override
22         public void run() {
23                 while(true) {
24                         lockObject.setValue([name: "lock", value: "locked", deviceId: 0, descriptionText: "",
25                                            displayed: true, linkText: "", isStateChange: false, unit: "", data: []])
26                         Thread.sleep(random.nextInt(nextRandom));       
27                 }
28         }
29 }.start()
30
31 new Thread() {
32         
33         @Override
34         public void run() {
35                 while(true) {
36                         lockObject.setValue([name: "unlock", value: "unlocked", deviceId: 0, descriptionText: "",
37                                            displayed: true, linkText: "", isStateChange: false, unit: "", data: []])
38                         Thread.sleep(random.nextInt(nextRandom));       
39                 }
40         }
41 }.start()
42
43 // Contact sensor events
44 new Thread() {
45         
46         @Override
47         public void run() {
48                 while(true) {
49                         contactObject.setValue([name: "contact.open", value: "open", deviceId: 0, descriptionText: "",
50                                            displayed: true, linkText: "", isStateChange: false, unit: "", data: []])
51                         Thread.sleep(random.nextInt(nextRandom));       
52                         
53                 }
54         }
55 }.start()
56
57 new Thread() {
58         
59         @Override
60         public void run() {
61                 while(true) {
62                         contactObject.setValue([name: "contact.closed", value: "closed", deviceId: 0, descriptionText: "",
63                                            displayed: true, linkText: "", isStateChange: false, unit: "", data: []])
64                         Thread.sleep(random.nextInt(nextRandom));       
65                         
66                 }
67         }
68 }.start()