Commit #8: New version of extractor with running the preferences method make things...
[smartthings-infrastructure.git] / eventSimulator / eventSimulator.groovy
index c414b3abbd45224a1d8b17349455c9bd5409839e..56b32b7e16b324afb603ca0891d701a8c5eab672 100644 (file)
@@ -1,68 +1,45 @@
-// Generate a random variable
-Random random = new Random(1131)
-int nextRandom = 10
+def events = [1,2,3,4,5,6,7]
+def list = events.permutations()
+int count = Verify.getInt(0,list.size()-1)
+println "COUNT: " + count
 
-// Touch events
-new Thread() {
-       @Override
-       public void run() {
-               while(true) {
-                       appObject.setValue([name: "Touched", value: "Touched", deviceId: 0, descriptionText: "",
+list[count].each {
+  switch(it) {
+    case 1:
+      appObject.setValue([name: "Touched", value: "Touched", deviceId: 0, descriptionText: "",
                                           displayed: true, linkText: "", isStateChange: false, unit: "", data: []])
-                       Thread.sleep(random.nextInt(nextRandom));       
-                       
-               }
-       }
-}.start()
-
-// Lock events
-new Thread() {
-       
-       @Override
-       public void run() {
-               while(true) {
-                       lockObject.setValue([name: "lock", value: "locked", deviceId: 0, descriptionText: "",
+      println "1"
+      break
+    case 2:
+      lockObject.setValue([name: "lock0", value: "locked", deviceId: 0, descriptionText: "",
                                           displayed: true, linkText: "", isStateChange: false, unit: "", data: []])
-                       Thread.sleep(random.nextInt(nextRandom));       
-               }
-       }
-}.start()
-
-new Thread() {
-       
-       @Override
-       public void run() {
-               while(true) {
-                       lockObject.setValue([name: "unlock", value: "unlocked", deviceId: 0, descriptionText: "",
+      println "   2"
+                       break
+    case 3:
+      lockObject.setValue([name: "lock0", value: "unlocked", deviceId: 0, descriptionText: "",
                                           displayed: true, linkText: "", isStateChange: false, unit: "", data: []])
-                       Thread.sleep(random.nextInt(nextRandom));       
-               }
-       }
-}.start()
-
-// Contact sensor events
-new Thread() {
-       
-       @Override
-       public void run() {
-               while(true) {
-                       contactObject.setValue([name: "contact.open", value: "open", deviceId: 0, descriptionText: "",
+      println "      3"
+      break
+    case 4:
+      contactObject.setValue([name: "contact0", value: "open", deviceId: 0, descriptionText: "",
                                           displayed: true, linkText: "", isStateChange: false, unit: "", data: []])
-                       Thread.sleep(random.nextInt(nextRandom));       
-                       
-               }
-       }
-}.start()
-
-new Thread() {
-       
-       @Override
-       public void run() {
-               while(true) {
-                       contactObject.setValue([name: "contact.closed", value: "closed", deviceId: 0, descriptionText: "",
+      println "         4"
+      break
+    case 5:
+      contactObject.setValue([name: "contact0", value: "closed", deviceId: 0, descriptionText: "",
+                                          displayed: true, linkText: "", isStateChange: false, unit: "", data: []])
+      println "            5"
+      break
+    case 6:
+      switchObject.setValue([name: "switch0", value: "on", deviceId: 0, descriptionText: "",
+                                          displayed: true, linkText: "", isStateChange: false, unit: "", data: []])
+      println "               6"
+      break
+    case 7:
+      switchObject.setValue([name: "switch0", value: "off", deviceId: 0, descriptionText: "",
                                           displayed: true, linkText: "", isStateChange: false, unit: "", data: []])
-                       Thread.sleep(random.nextInt(nextRandom));       
-                       
-               }
-       }
-}.start()
+      println "                   7"
+    default:
+      break
+  }
+}