Merge branch 'master' of ssh://plrg.eecs.uci.edu/home/git/smartthings-infrastructure
authoramiraj <amiraj.95@uci.edu>
Sat, 3 Aug 2019 22:51:13 +0000 (15:51 -0700)
committeramiraj <amiraj.95@uci.edu>
Sat, 3 Aug 2019 22:51:13 +0000 (15:51 -0700)
Extractor/ExtractorScript.py
eventSimulator/eventSimulator.groovy [deleted file]
run.sh

index eb7fa99..2c53c56 100644 (file)
@@ -2,6 +2,7 @@ import os
 readyToReturn = 0
 ToReturn = ""
 eventList = []
+eventAppList = [] # This list maps App1 or App2 to a specific event
 eventVarMap = {}
 eventVarCounterMap = {}
 capabilityMap = {}
@@ -103,6 +104,7 @@ def GetToken(f):
 
 def ExtractFunctions(F, appName):
        global eventList
+       global eventAppList
        global app1Subscribe
        global app2Subscribe
        Temp = GetToken(F)
@@ -154,11 +156,19 @@ def ExtractFunctions(F, appName):
                        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)
@@ -235,6 +245,7 @@ def CountEvents():
 
 def ExtractEvents(extractedEvents):
        global eventList
+       global eventAppList
        global eventVarMap
        global capabilityMap
        global eventVarCounterMap
@@ -244,7 +255,26 @@ def ExtractEvents(extractedEvents):
        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
diff --git a/eventSimulator/eventSimulator.groovy b/eventSimulator/eventSimulator.groovy
deleted file mode 100644 (file)
index ed62239..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-while(true) {
-       def eventNumber = Verify.getInt(0,9)
-       switch(eventNumber) {
-               case 0:
-                       def event = Verify.getInt(0,2)
-                       if (event == 0) {
-                                       locationObject.setValue([name: "Location", value: "home", deviceId: "locationID0", descriptionText: "",
-                                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-                       } else if (event == 1) {
-                                       locationObject.setValue([name: "Location", value: "away", deviceId: "locationID0", descriptionText: "",
-                                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-                       } else {
-                                       locationObject.setValue([name: "Location", value: "night", deviceId: "locationID0", descriptionText: "",
-                                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-                       }
-                       break
-               case 1:
-                       contactObject.setValue([name: "contact.open", value: "open", deviceId: "contactSensorID0", descriptionText: "",
-                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-                       break
-               case 2:
-                       break
-               case 3:
-                       break
-               case 4:
-                       break
-               case 5:
-                       break
-               case 6:
-                       break
-               case 7:
-                       break
-               case 8:
-                       break
-               case 9:
-                       def event = Verify.getInt(0,1)
-                       if (event == 0) {
-                                       aeonKeyFobObject.setValue([name: "button", value: "pushed", deviceId: "aeonKeyFobID0", descriptionText: "",
-                                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-                       } else {
-                                       aeonKeyFobObject.setValue([name: "button", value: "held", deviceId: "aeonKeyFobID0", descriptionText: "",
-                                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-                       }
-                       break
-       }
-}
diff --git a/run.sh b/run.sh
index c2c9cfa..d77af37 100755 (executable)
--- a/run.sh
+++ b/run.sh
@@ -1,7 +1,8 @@
 #!/bin/bash
 
 # Device conflict
-python ModelCheck.py ../jpf-core/ ../logs/alarms/ ../smartapps/ appLists/device-interaction/alarmsAppList appLists/device-interaction/alarmsAppList2
+python ModelCheck.py ../jpf-core/ ../logs/thermostats/ ../smartapps/ appLists/device-interaction/thermostatsAppList appLists/device-interaction/thermostatsAppList2
+#python ModelCheck.py ../jpf-core/ ../logs/alarms/ ../smartapps/ appLists/device-interaction/alarmsAppList appLists/device-interaction/alarmsAppList2
 #python ModelCheck.py ../jpf-core/ ../logs/locks/ ../smartapps/ appLists/device-interaction/locksAppList appLists/device-interaction/locksAppList2
 #python ModelCheck.py ../jpf-core/ ../logs/musicPlayers/ ../smartapps/ appLists/device-interaction/musicPlayersAppList
 #python ModelCheck.py ../jpf-core/ ../logs/relaySwitch/ ../smartapps/ appLists/device-interaction/relaySwitchesAppList