Deleting files and completing event generation.
authorrtrimana <rtrimana@uci.edu>
Mon, 22 Jul 2019 19:38:48 +0000 (12:38 -0700)
committerrtrimana <rtrimana@uci.edu>
Mon, 22 Jul 2019 19:38:48 +0000 (12:38 -0700)
21 files changed:
Extractor/ExtractorScript.py
eventSimulator/appTouchEvent.groovy [new file with mode: 0644]
eventSimulator/buttonPushedEvent.groovy [new file with mode: 0644]
eventSimulator/contactClosedEvent.groovy [new file with mode: 0644]
eventSimulator/contactOpenEvent.groovy [new file with mode: 0644]
eventSimulator/doorClosedEvent.groovy [new file with mode: 0644]
eventSimulator/doorOpenEvent.groovy [new file with mode: 0644]
eventSimulator/eventAppTouch.groovy [deleted file]
eventSimulator/eventContactClosed.groovy [deleted file]
eventSimulator/eventContactOpen.groovy [deleted file]
eventSimulator/eventLocked.groovy [deleted file]
eventSimulator/eventNfcTouch.groovy [deleted file]
eventSimulator/eventSimulator.groovy [deleted file]
eventSimulator/eventSwitchOff.groovy [new file with mode: 0644]
eventSimulator/eventSwitchOn.groovy [new file with mode: 0644]
eventSimulator/eventUnlocked.groovy [deleted file]
eventSimulator/lockEvent.groovy [new file with mode: 0644]
eventSimulator/nfcTouchEvent.groovy [new file with mode: 0644]
eventSimulator/presenceLeftEvent.groovy [new file with mode: 0644]
eventSimulator/presencePresentEvent.groovy [new file with mode: 0644]
eventSimulator/unlockEvent.groovy [new file with mode: 0644]

index 40fa93d..e2edcad 100644 (file)
@@ -58,7 +58,7 @@ def ExtractFunctions(F, appName):
                        Temp = GetToken(F)
                        #If counter >= 5 that means it is not found, so it must be appTouch
                        if (counter >= 5):
-                               Temp = "appTouch"
+                               Temp = "Touched"
                        eventMap.append(Temp)
                Temp = GetToken(F)
                
@@ -69,38 +69,90 @@ def ExtractEvents(extractedEvents):
        extractedEvents.write("while(counter > 0) {\n")
        extractedEvents.write("\tdef eventNumber = random.nextInt(%d)\n" % (len(eventMap) - 1))
        extractedEvents.write("\tswitch(eventNumber) {\n")
+       eventCounter = 0;
        for i in range(len(eventMap)):
-               extractedEvents.write("\t\tcase %d:\n" % i)
+               extractedEvents.write("\t\tcase %d:\n" % eventCounter)
                if eventMap[i] == "lock":
-                       event = open("eventSimulator/eventLocked.groovy", "r")
+                       event = open("eventSimulator/lockEvent.groovy", "r")
                        for line in event:
                                extractedEvents.write(line)
                        event.close()
                elif eventMap[i] == "unlock":
-                       event = open("eventSimulator/eventUnlocked.groovy", "r")
+                       event = open("eventSimulator/unlockEvent.groovy", "r")
                        for line in event:
                                extractedEvents.write(line)
                        event.close()
                elif eventMap[i] == "contact.open":
-                       event = open("eventSimulator/eventContactOpen.groovy", "r")
+                       event = open("eventSimulator/contactOpenEvent.groovy", "r")
                        for line in event:
                                extractedEvents.write(line)
                        event.close()
                elif eventMap[i] == "contact.closed":
-                       event = open("eventSimulator/eventContactClosed.groovy", "r")
+                       event = open("eventSimulator/contactClosedEvent.groovy", "r")
+                       for line in event:
+                               extractedEvents.write(line)
+                       event.close()
+               elif eventMap[i] == "switch.on":
+                       event = open("eventSimulator/switchOnEvent.groovy", "r")
+                       for line in event:
+                               extractedEvents.write(line)
+                       event.close()
+               elif eventMap[i] == "switch.off":
+                       event = open("eventSimulator/switchOffEvent.groovy", "r")
                        for line in event:
                                extractedEvents.write(line)
                        event.close()
                elif eventMap[i] == "nfcTouch":
-                       event = open("eventSimulator/eventNfcTouch.groovy", "r")
+                       event = open("eventSimulator/nfcTouchEvent.groovy", "r")
                        for line in event:
                                extractedEvents.write(line)
                        event.close()
-               elif eventMap[i] == "appTouch":
-                       event = open("eventSimulator/eventAppTouch.groovy", "r")
+               elif eventMap[i] == "Touched":
+                       event = open("eventSimulator/appTouchEvent.groovy", "r")
                        for line in event:
                                extractedEvents.write(line)
                        event.close()
+               elif eventMap[i] == "button":
+                       #Write two events subsequently
+                       event = open("eventSimulator/buttonPushedEvent.groovy", "r")
+                       for line in event:
+                               extractedEvents.write(line)
+                       event.close()
+                       extractedEvents.write("\t\t\tbreak\n")
+                       eventCounter = eventCounter + 1
+                       extractedEvents.write("\t\tcase %d:\n" % eventCounter)
+                       event = open("eventSimulator/buttonHeldEvent.groovy", "r")
+                       for line in event:
+                               extractedEvents.write(line)
+                       event.close()
+               elif eventMap[i] == "presence":
+                       #Write two events subsequently
+                       event = open("eventSimulator/presencePresentEvent.groovy", "r")
+                       for line in event:
+                               extractedEvents.write(line)
+                       event.close()
+                       extractedEvents.write("\t\t\tbreak\n")
+                       eventCounter = eventCounter + 1
+                       extractedEvents.write("\t\tcase %d:\n" % eventCounter)
+                       event = open("eventSimulator/presenceLeftEvent.groovy", "r")
+                       for line in event:
+                               extractedEvents.write(line)
+                       event.close()
+               elif eventMap[i] == "doorState":
+                       #Write two events subsequently
+                       event = open("eventSimulator/doorOpenEvent.groovy", "r")
+                       for line in event:
+                               extractedEvents.write(line)
+                       event.close()
+                       extractedEvents.write("\t\t\tbreak\n")
+                       eventCounter = eventCounter + 1
+                       extractedEvents.write("\t\tcase %d:\n" % eventCounter)
+                       event = open("eventSimulator/doorClosedEvent.groovy", "r")
+                       for line in event:
+                               extractedEvents.write(line)
+                       event.close()
+               eventCounter = eventCounter + 1
+
                ###TODO: Add more events later
                extractedEvents.write("\n\t\t\tbreak\n")
        extractedEvents.write("\t}\n")
diff --git a/eventSimulator/appTouchEvent.groovy b/eventSimulator/appTouchEvent.groovy
new file mode 100644 (file)
index 0000000..025f036
--- /dev/null
@@ -0,0 +1,2 @@
+                       appObject.setValue([name: "Touched", value: "Touched", deviceId: 0, descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: []])
diff --git a/eventSimulator/buttonPushedEvent.groovy b/eventSimulator/buttonPushedEvent.groovy
new file mode 100644 (file)
index 0000000..52e74cc
--- /dev/null
@@ -0,0 +1,2 @@
+                       aeonKeyFobObject.setValue([name: "button", value: "pushed", deviceId: 0, descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: [value: "pushed"]])
diff --git a/eventSimulator/contactClosedEvent.groovy b/eventSimulator/contactClosedEvent.groovy
new file mode 100644 (file)
index 0000000..505a2e8
--- /dev/null
@@ -0,0 +1,2 @@
+                       contactObject.setValue([name: "contact.closed", value: "closed", deviceId: 0, descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: [value: "closed"]])
diff --git a/eventSimulator/contactOpenEvent.groovy b/eventSimulator/contactOpenEvent.groovy
new file mode 100644 (file)
index 0000000..15bface
--- /dev/null
@@ -0,0 +1,2 @@
+                       contactObject.setValue([name: "contact.open", value: "closed", deviceId: 0, descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: [value: "open"]])
diff --git a/eventSimulator/doorClosedEvent.groovy b/eventSimulator/doorClosedEvent.groovy
new file mode 100644 (file)
index 0000000..91e3e5a
--- /dev/null
@@ -0,0 +1,2 @@
+                       doorControlObject.setValue([name: "doorState", value: "closed", deviceId: 0, descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: [value: "closed"]])
diff --git a/eventSimulator/doorOpenEvent.groovy b/eventSimulator/doorOpenEvent.groovy
new file mode 100644 (file)
index 0000000..aa841c6
--- /dev/null
@@ -0,0 +1,2 @@
+                       doorControlObject.setValue([name: "doorState", value: "open", deviceId: 0, descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: [value: "open"]])
diff --git a/eventSimulator/eventAppTouch.groovy b/eventSimulator/eventAppTouch.groovy
deleted file mode 100644 (file)
index 15589c3..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-      appObject.setValue([name: "Touched", value: "Touched", deviceId: 0, descriptionText: "",
-                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: []])
\ No newline at end of file
diff --git a/eventSimulator/eventContactClosed.groovy b/eventSimulator/eventContactClosed.groovy
deleted file mode 100644 (file)
index 8f5e73c..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-      contactObject.setValue([name: "contact0", value: "closed", deviceId: 0, descriptionText: "",
-                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: []])
\ No newline at end of file
diff --git a/eventSimulator/eventContactOpen.groovy b/eventSimulator/eventContactOpen.groovy
deleted file mode 100644 (file)
index 6aa2110..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-                       contactObject.setValue([name: "contact0", value: "open", deviceId: 0, descriptionText: "",
-                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: []])
\ No newline at end of file
diff --git a/eventSimulator/eventLocked.groovy b/eventSimulator/eventLocked.groovy
deleted file mode 100644 (file)
index c58dd0c..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-                       lockObject.setValue([name: "lock0", value: "locked", deviceId: 0, descriptionText: "",
-                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: []])
\ No newline at end of file
diff --git a/eventSimulator/eventNfcTouch.groovy b/eventSimulator/eventNfcTouch.groovy
deleted file mode 100644 (file)
index cd05147..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-      appObject.setValue([name: "NfcTouch", value: "NfcTouch", deviceId: 0, descriptionText: "",
-                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: []])
\ No newline at end of file
diff --git a/eventSimulator/eventSimulator.groovy b/eventSimulator/eventSimulator.groovy
deleted file mode 100644 (file)
index 56b32b7..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-def events = [1,2,3,4,5,6,7]
-def list = events.permutations()
-int count = Verify.getInt(0,list.size()-1)
-println "COUNT: " + count
-
-list[count].each {
-  switch(it) {
-    case 1:
-      appObject.setValue([name: "Touched", value: "Touched", deviceId: 0, descriptionText: "",
-                                          displayed: true, linkText: "", isStateChange: false, unit: "", data: []])
-      println "1"
-      break
-    case 2:
-      lockObject.setValue([name: "lock0", value: "locked", deviceId: 0, descriptionText: "",
-                                          displayed: true, linkText: "", isStateChange: false, unit: "", data: []])
-      println "   2"
-                       break
-    case 3:
-      lockObject.setValue([name: "lock0", value: "unlocked", deviceId: 0, descriptionText: "",
-                                          displayed: true, linkText: "", isStateChange: false, unit: "", data: []])
-      println "      3"
-      break
-    case 4:
-      contactObject.setValue([name: "contact0", value: "open", deviceId: 0, descriptionText: "",
-                                          displayed: true, linkText: "", isStateChange: false, unit: "", data: []])
-      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: []])
-      println "                   7"
-    default:
-      break
-  }
-}
diff --git a/eventSimulator/eventSwitchOff.groovy b/eventSimulator/eventSwitchOff.groovy
new file mode 100644 (file)
index 0000000..4593a0a
--- /dev/null
@@ -0,0 +1,2 @@
+                       switchObject.setValue([name: "switch.off", value: "off", deviceId: 0, descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: [value: "off"]])
diff --git a/eventSimulator/eventSwitchOn.groovy b/eventSimulator/eventSwitchOn.groovy
new file mode 100644 (file)
index 0000000..90b096e
--- /dev/null
@@ -0,0 +1,2 @@
+                       switchObject.setValue([name: "switch.on", value: "on", deviceId: 0, descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: [value: "on"]])
diff --git a/eventSimulator/eventUnlocked.groovy b/eventSimulator/eventUnlocked.groovy
deleted file mode 100644 (file)
index 56dfdbc..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-                       lockObject.setValue([name: "lock0", value: "unlocked", deviceId: 0, descriptionText: "",
-                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: []])
\ No newline at end of file
diff --git a/eventSimulator/lockEvent.groovy b/eventSimulator/lockEvent.groovy
new file mode 100644 (file)
index 0000000..ec825e4
--- /dev/null
@@ -0,0 +1,2 @@
+                       lockObject.setValue([name: "lock", value: "locked", deviceId: 0, descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: [value: "locked"]])
diff --git a/eventSimulator/nfcTouchEvent.groovy b/eventSimulator/nfcTouchEvent.groovy
new file mode 100644 (file)
index 0000000..00dbe6d
--- /dev/null
@@ -0,0 +1,2 @@
+                       appObject.setValue([name: "nfcTouch", value: "Touched", deviceId: 0, descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: [value: "Touched"]])
diff --git a/eventSimulator/presenceLeftEvent.groovy b/eventSimulator/presenceLeftEvent.groovy
new file mode 100644 (file)
index 0000000..dc5cc86
--- /dev/null
@@ -0,0 +1,2 @@
+                       presenceSensorObject.setValue([name: "presence", value: "not present", deviceId: 0, descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: [value: "not present"]])
diff --git a/eventSimulator/presencePresentEvent.groovy b/eventSimulator/presencePresentEvent.groovy
new file mode 100644 (file)
index 0000000..fc814e7
--- /dev/null
@@ -0,0 +1,2 @@
+                       presenceSensorObject.setValue([name: "presence", value: "present", deviceId: 0, descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: [value: "present"]])
diff --git a/eventSimulator/unlockEvent.groovy b/eventSimulator/unlockEvent.groovy
new file mode 100644 (file)
index 0000000..189e4d2
--- /dev/null
@@ -0,0 +1,2 @@
+                       lockObject.setValue([name: "unlock", value: "unlocked ", deviceId: 0, descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: [value: "locked"]])