readyToReturn = 0
ToReturn = ""
eventList = []
+eventAppList = [] # This list maps App1 or App2 to a specific event
eventVarMap = {}
eventVarCounterMap = {}
capabilityMap = {}
def ExtractFunctions(F, appName):
global eventList
+ global eventAppList
global app1Subscribe
global app2Subscribe
Temp = GetToken(F)
if Temp == "app" or Temp == "location":
if Temp not in eventList:
eventList.append(Temp)
+ if (appName == "App1"):
+ eventAppList.append("App1")
+ else:
+ eventAppList.append("App2")
elif Temp not in eventList or (variable in capabilityMap.keys() and capabilityMap[variable] not in capabilityList):
# We do not repeat the same capability twice
capability = capabilityMap[variable]
capabilityList.append(capability)
eventList.append(Temp)
+ if (appName == "App1"):
+ eventAppList.append("App1")
+ else:
+ eventAppList.append("App2")
if Temp in eventVarMap.keys():
listOfEvents = eventVarMap[Temp]
listOfEvents.append(variable)
def ExtractEvents(extractedEvents):
global eventList
+ global eventAppList
global eventVarMap
global capabilityMap
global eventVarCounterMap
extractedEvents.write("\tdef eventNumber = Verify.getInt(0,%d)\n" % (numOfActualEvents - 1))
extractedEvents.write("\tswitch(eventNumber) {\n")
counter = 0
- for i in range(len(eventList)):
+ indexApp1 = 0
+ indexApp2 = eventAppList.index("App2")
+ indexApp2Start = indexApp2
+ #print "DEBUG: App1: %d" % indexApp1
+ #print "DEBUG: App2: %d" % indexApp2
+ #print "DEBUG: eventList: %d" % len(eventList)
+ isApp1 = True
+ while counter < len(eventList):
+ # Interleave events from App1 and App2
+ if isApp1 is True:
+ i = indexApp1
+ indexApp1 = indexApp1 + 1
+ if indexApp2 < len(eventList):
+ isApp1 = False
+ else:
+ i = indexApp2
+ indexApp2 = indexApp2 + 1
+ if indexApp1 < indexApp2Start:
+ isApp1 = True
+ print "DEBUG: i: %d" % i
extractedEvents.write("\t\tcase %d:\n" % counter)
if eventList[i] == "lock":
#Write two events subsequently