From 328a7d62dbe4abd7f538b23cdef434b1a28e2a28 Mon Sep 17 00:00:00 2001 From: rtrimana Date: Mon, 22 Jul 2019 16:34:32 -0700 Subject: [PATCH] Added physical interaction detection into the build flow. --- Extractor/ExtractorScript.py | 52 +++++++++++++++++++++++++-- eventSimulator/buttonHeldEvent.groovy | 2 ++ 2 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 eventSimulator/buttonHeldEvent.groovy diff --git a/Extractor/ExtractorScript.py b/Extractor/ExtractorScript.py index e2edcad..ec39bdb 100644 --- a/Extractor/ExtractorScript.py +++ b/Extractor/ExtractorScript.py @@ -2,6 +2,8 @@ import os readyToReturn = 0 ToReturn = "" eventMap = [] +app1Capabilities = [] +app2Capabilities = [] def GetToken(f): global readyToReturn @@ -49,7 +51,8 @@ def ExtractFunctions(F, appName): extractedFunctionsApp2.write("//Global Object for functions in subscribe method!\n") extractedFunctionsApp2.write("def %s = this.&" % NameofFunc) extractedFunctionsApp2.write("%s\n" % NameofFunc) - + + #Check subscribed events if (Temp == "subscribe"): counter = 0 while (counter < 5 and Temp != "\""): @@ -60,8 +63,53 @@ def ExtractFunctions(F, appName): if (counter >= 5): Temp = "Touched" eventMap.append(Temp) + Temp = GetToken(F) + + #Check and analyze capabilities for physical interaction + AnalyzeCapabilities(Temp, appName) Temp = GetToken(F) - + + #Warn if there is a potential for physical interaction + AnalyzePhysicalInteraction(app1Capabilities, app2Capabilities) + AnalyzePhysicalInteraction(app2Capabilities, app1Capabilities) + +def AnalyzeCapabilities(Temp, appName): + #Illuminance related + if (Temp == "capability.switch" or + Temp == "capability.switchLevel" or + Temp == "capability.illuminanceMeasurement" or + #Motion related + Temp == "capability.motionSensor" or + #Water related + Temp == "capability.valve" or + Temp == "capability.waterSensor" or + #Sound related + Temp == "capability.musicPlayer" or + Temp == "capability.alarm" or + Temp == "capability.speechSynthesis" or + Temp == "capability.soundSensor"): + if (appName == "App1"): + app1Capabilities.append(Temp) + else: + app2Capabilities.append(Temp) + +def AnalyzePhysicalInteraction(app1Capab, app2Capab): + #Light + if ("capability.illuminanceMeasurement" in app1Capab) and ("capability.switch" in app2Capab or + "capability.switchLevel" in app2Capab): + print ("\nWARNING: Potential PHYSICAL CONFLICT (light) detected between App1 and App2!\n") + #Motion + if ("capability.motionSensor" in app1Capab): + print ("\nWARNING: Potential PHYSICAL CONFLICT (motion) detected between App1 and App2!\n") + #Water + if ("capability.waterSensor" in app1Capab) and ("capability.valve" in app2Capab or + "capability.switch" in app2Capab): + print ("\nWARNING: Potential PHYSICAL CONFLICT (water) detected between App1 and App2!\n") + #Sound + if ("capability.soundSensor" in app1Capab) and ("capability.musicPlayer" in app2Capab or + "capability.alarm" in app2Capab or "capability.speechSynthesis" in app2Capab): + print ("\nWARNING: Potential PHYSICAL CONFLICT (sound) detected between App1 and App2!\n") + def ExtractEvents(extractedEvents): global eventMap extractedEvents.write("Random random = new Random(42)\n") diff --git a/eventSimulator/buttonHeldEvent.groovy b/eventSimulator/buttonHeldEvent.groovy new file mode 100644 index 0000000..b808a29 --- /dev/null +++ b/eventSimulator/buttonHeldEvent.groovy @@ -0,0 +1,2 @@ + aeonKeyFobObject.setValue([name: "button", value: "held", deviceId: 0, descriptionText: "", + displayed: true, linkText: "", isStateChange: false, unit: "", data: [value: "held"]]) -- 2.34.1