Adding manual transaction feature to new infrastructure
authorSeyed Amir Hossein Aqajari <saqajari@circinus-45.ics.uci.edu>
Tue, 24 Mar 2020 20:29:23 +0000 (13:29 -0700)
committerSeyed Amir Hossein Aqajari <saqajari@circinus-45.ics.uci.edu>
Tue, 24 Mar 2020 20:29:23 +0000 (13:29 -0700)
Event/Event.groovy
Methods/eventHandler.groovy
Runner.py

index 83ba658..e7956c2 100644 (file)
@@ -18,6 +18,7 @@ public class Event {
        private double doubleValue
        private boolean physical
        private def date
+       private boolean isManualTransaction
        
        Event(String value, String name, String deviceId, String descriptionText, boolean displayed, String linkText, String displayName, boolean isStateChange, String unit, String data) {
                this.deviceId = deviceId
@@ -41,4 +42,8 @@ public class Event {
                this.physical = true
                this.date = new Date()
        }
+
+       void setManualTransaction(boolean isTrue) {
+               isManualTransaction = isTrue;
+       }
 }
index 59bb059..1ce9048 100644 (file)
@@ -9,11 +9,16 @@ def eventHandler(LinkedHashMap eventDataMap) {
        def isStateChange = eventDataMap["isStateChange"]
        def unit = eventDataMap["unit"]
        def data = eventDataMap["data"]
+       def manualEventsName = ["Touched", "button", "nfcTouch", "threeAxis"]
 
+       def event = new Event(value, name, deviceId, descriptionText, displayed, linkText, linkText, isStateChange, unit, data)
+
+       stack.push(manualEventsName.contains(name))
+       event.setManualTransaction(stack[0])
+       
        for (int i = 0;i < app2.eventList.size();i++) {
                if (app2.eventList[i] == name &&
                    (app2.valueList[i] == "" || app2.valueList[i] == value)) {
-                       def event = new Event(value, name, deviceId, descriptionText, displayed, linkText, linkText, isStateChange, unit, data)
                        if (app2.functionList[i] instanceof String) {
                                String toCall = app2.functionList[i]
                                app2."$toCall"(event)
@@ -26,8 +31,7 @@ def eventHandler(LinkedHashMap eventDataMap) {
        for (int i = 0;i < app1.eventList.size();i++) {
                if (app1.eventList[i] == name &&
                    (app1.valueList[i] == "" || app1.valueList[i] == value)) {
-                        def event = new Event(value, name, deviceId, descriptionText, displayed, linkText, linkText, isStateChange, unit, data)
-                       if (app1.functionList[i] instanceof String) {
+                        if (app1.functionList[i] instanceof String) {
                                String toCall = app1.functionList[i]
                                app1."$toCall"(event)
                        }
@@ -35,4 +39,8 @@ def eventHandler(LinkedHashMap eventDataMap) {
                                app1.functionList[i](event)
                }
        }
+
+       stack.pop()
+       if (stack[0] != null)
+               event.setManualTransaction(stack[0])
 }
index ed4e62c..499a737 100644 (file)
--- a/Runner.py
+++ b/Runner.py
@@ -136,6 +136,7 @@ Out.write("//GlobalVariables for both Apps\n")
 Out.write("@Field def init = Verify.getBoolean()\n\n")
 for line in GlobalVariablesBothApps:
        Out.write(line)
+Out.write("@Field def stack = []\n")
 Out.write("\n")
 Out.write("//clear init flag now we are done with it\n")
 Out.write("init = false\n")