readyToReturn = 0
ToReturn = ""
eventMap = []
+app1Capabilities = []
+app2Capabilities = []
def GetToken(f):
global readyToReturn
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 != "\""):
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")