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 83ba658355e5d838fa72c10b92f1c184b57bba5b..e7956c2a35c2f0f6762d3e38afc942c8574212cb 100644 (file)
@@ -18,6 +18,7 @@ public class Event {
        private double doubleValue
        private boolean physical
        private def date
        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
        
        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()
        }
                this.physical = true
                this.date = new Date()
        }
+
+       void setManualTransaction(boolean isTrue) {
+               isManualTransaction = isTrue;
+       }
 }
 }
index 59bb059fe9086f4f9b7dfa82ef55c024e37765d8..1ce9048273acf8d3bf91ca3c137d31fc861a5c25 100644 (file)
@@ -9,11 +9,16 @@ def eventHandler(LinkedHashMap eventDataMap) {
        def isStateChange = eventDataMap["isStateChange"]
        def unit = eventDataMap["unit"]
        def data = eventDataMap["data"]
        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)) {
        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)
                        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)) {
        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)
                        }
                                String toCall = app1.functionList[i]
                                app1."$toCall"(event)
                        }
@@ -35,4 +39,8 @@ def eventHandler(LinkedHashMap eventDataMap) {
                                app1.functionList[i](event)
                }
        }
                                app1.functionList[i](event)
                }
        }
+
+       stack.pop()
+       if (stack[0] != null)
+               event.setManualTransaction(stack[0])
 }
 }
index ed4e62c38741d48a67263ebabe2a7029e3558862..499a7372f22952da37f30a094a0f11c959ed912e 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 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")
 Out.write("\n")
 Out.write("//clear init flag now we are done with it\n")
 Out.write("init = false\n")