Added physical interaction detection into the build flow.
authorrtrimana <rtrimana@uci.edu>
Mon, 22 Jul 2019 23:34:32 +0000 (16:34 -0700)
committerrtrimana <rtrimana@uci.edu>
Mon, 22 Jul 2019 23:34:32 +0000 (16:34 -0700)
Extractor/ExtractorScript.py
eventSimulator/buttonHeldEvent.groovy [new file with mode: 0644]

index e2edcad4f22a8d81c585ffd1532c44171edcf826..ec39bdb42d133ab8bf2ae0c83bf0c79a6030cc40 100644 (file)
@@ -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 (file)
index 0000000..b808a29
--- /dev/null
@@ -0,0 +1,2 @@
+                       aeonKeyFobObject.setValue([name: "button", value: "held", deviceId: 0, descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: [value: "held"]])