From: rtrimana Date: Mon, 22 Jul 2019 19:38:48 +0000 (-0700) Subject: Deleting files and completing event generation. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=b0f9044f8811563aae5895e537eafccc94e067ed;p=smartthings-infrastructure.git Deleting files and completing event generation. --- diff --git a/Extractor/ExtractorScript.py b/Extractor/ExtractorScript.py index 40fa93d..e2edcad 100644 --- a/Extractor/ExtractorScript.py +++ b/Extractor/ExtractorScript.py @@ -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 index 0000000..025f036 --- /dev/null +++ b/eventSimulator/appTouchEvent.groovy @@ -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 index 0000000..52e74cc --- /dev/null +++ b/eventSimulator/buttonPushedEvent.groovy @@ -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 index 0000000..505a2e8 --- /dev/null +++ b/eventSimulator/contactClosedEvent.groovy @@ -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 index 0000000..15bface --- /dev/null +++ b/eventSimulator/contactOpenEvent.groovy @@ -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 index 0000000..91e3e5a --- /dev/null +++ b/eventSimulator/doorClosedEvent.groovy @@ -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 index 0000000..aa841c6 --- /dev/null +++ b/eventSimulator/doorOpenEvent.groovy @@ -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 index 15589c3..0000000 --- a/eventSimulator/eventAppTouch.groovy +++ /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 index 8f5e73c..0000000 --- a/eventSimulator/eventContactClosed.groovy +++ /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 index 6aa2110..0000000 --- a/eventSimulator/eventContactOpen.groovy +++ /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 index c58dd0c..0000000 --- a/eventSimulator/eventLocked.groovy +++ /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 index cd05147..0000000 --- a/eventSimulator/eventNfcTouch.groovy +++ /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 index 56b32b7..0000000 --- a/eventSimulator/eventSimulator.groovy +++ /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 index 0000000..4593a0a --- /dev/null +++ b/eventSimulator/eventSwitchOff.groovy @@ -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 index 0000000..90b096e --- /dev/null +++ b/eventSimulator/eventSwitchOn.groovy @@ -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 index 56dfdbc..0000000 --- a/eventSimulator/eventUnlocked.groovy +++ /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 index 0000000..ec825e4 --- /dev/null +++ b/eventSimulator/lockEvent.groovy @@ -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 index 0000000..00dbe6d --- /dev/null +++ b/eventSimulator/nfcTouchEvent.groovy @@ -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 index 0000000..dc5cc86 --- /dev/null +++ b/eventSimulator/presenceLeftEvent.groovy @@ -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 index 0000000..fc814e7 --- /dev/null +++ b/eventSimulator/presencePresentEvent.groovy @@ -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 index 0000000..189e4d2 --- /dev/null +++ b/eventSimulator/unlockEvent.groovy @@ -0,0 +1,2 @@ + lockObject.setValue([name: "unlock", value: "unlocked ", deviceId: 0, descriptionText: "", + displayed: true, linkText: "", isStateChange: false, unit: "", data: [value: "locked"]])