Adding more events for button.
authorrtrimana <rtrimana@uci.edu>
Mon, 5 Aug 2019 16:16:20 +0000 (09:16 -0700)
committerrtrimana <rtrimana@uci.edu>
Mon, 5 Aug 2019 16:16:20 +0000 (09:16 -0700)
Extractor/ExtractorScript.py
eventSimulator/aeonKeyFobHeldEvent.groovy [new file with mode: 0644]
eventSimulator/aeonKeyFobPushedEvent.groovy [new file with mode: 0644]
eventSimulator/buttonHeldEvent.groovy
eventSimulator/buttonPushedEvent.groovy

index 37c294d..2281ade 100644 (file)
@@ -276,7 +276,7 @@ def ExtractEvents(extractedEvents):
                        indexApp2 = indexApp2 + 1
                        if indexApp1 < indexApp2Start:
                                isApp1 = True
-               print "DEBUG: i: %d" % i
+               #print "DEBUG: i: %d" % i
                extractedEvents.write("\t\tcase %d:\n" % counter)
                if eventList[i] == "lock":
                        #Write two events subsequently
@@ -328,15 +328,30 @@ def ExtractEvents(extractedEvents):
                                extractedEvents.write(line)
                        event.close()
                elif eventList[i] == "button":
+                       #Check which capability
+                       variable = eventVarMap[eventList[i]]
+                       if eventList[i] not in eventVarCounterMap.keys():
+                               eventVarCounterMap[eventList[i]] = 1
+                               eventVarCount = 0
+                       else:
+                               eventVarCount = eventVarCounterMap[eventList[i]]
+                               eventVarCounterMap[eventList[i]] = eventVarCount + 1
+                       capability = capabilityMap[variable[eventVarCount]]
                        #Write two events subsequently
-                       event = open("eventSimulator/buttonPushedEvent.groovy", "r")                    
+                       if capability == "capability.button":
+                               event = open("eventSimulator/buttonHeldEvent.groovy", "r")
+                       elif capability == "device.aeonKeyFob":
+                               event = open("eventSimulator/aeonKeyFobHeldEvent.groovy", "r")
                        for line in event:
                                extractedEvents.write(line)
                        event.close()
                        extractedEvents.write("\n\t\t\tbreak\n")
                        counter = counter + 1
                        extractedEvents.write("\t\tcase %d:\n" % counter)
-                       event = open("eventSimulator/buttonHeldEvent.groovy", "r")
+                       if capability == "capability.button":
+                               event = open("eventSimulator/buttonPushedEvent.groovy", "r")
+                       elif capability == "device.aeonKeyFob":
+                               event = open("eventSimulator/aeonKeyFobPushedEvent.groovy", "r")
                        for line in event:
                                extractedEvents.write(line)
                        event.close()
diff --git a/eventSimulator/aeonKeyFobHeldEvent.groovy b/eventSimulator/aeonKeyFobHeldEvent.groovy
new file mode 100644 (file)
index 0000000..3937ff6
--- /dev/null
@@ -0,0 +1,2 @@
+                       aeonKeyFobObject.setValue([name: "button", value: "held", deviceId: "aeonKeyFobID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
diff --git a/eventSimulator/aeonKeyFobPushedEvent.groovy b/eventSimulator/aeonKeyFobPushedEvent.groovy
new file mode 100644 (file)
index 0000000..889af89
--- /dev/null
@@ -0,0 +1,2 @@
+                       aeonKeyFobObject.setValue([name: "button", value: "pushed", deviceId: "aeonKeyFobID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
index 3937ff6..29d13a0 100644 (file)
@@ -1,2 +1,2 @@
-                       aeonKeyFobObject.setValue([name: "button", value: "held", deviceId: "aeonKeyFobID0", descriptionText: "",
-                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       buttonObject.setValue([name: "button", value: "held", deviceId: "switchID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"buttonNumber": 1}'])
index 889af89..6f1a8c6 100644 (file)
@@ -1,2 +1,2 @@
-                       aeonKeyFobObject.setValue([name: "button", value: "pushed", deviceId: "aeonKeyFobID0", descriptionText: "",
-                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       buttonObject.setValue([name: "button", value: "push", deviceId: "switchID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"buttonNumber": 1}'])