Adding manual transaction feature to the infrastructure
authorSeyed Amir Hossein Aqajari <saqajari@circinus-38.ics.uci.edu>
Wed, 19 Feb 2020 19:40:38 +0000 (11:40 -0800)
committerSeyed Amir Hossein Aqajari <saqajari@circinus-38.ics.uci.edu>
Wed, 19 Feb 2020 19:40:38 +0000 (11:40 -0800)
Event/Event.groovy
Methods/eventHandler.groovy
Runner.py

index d7abdf490dbb9658f191c955369e06536eecf2e1..6812f5c898996918aee3e6e7dabcab2035e664b6 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 59bb059fe9086f4f9b7dfa82ef55c024e37765d8..e6bf04d4770afb3812f0ab4168845293e4b401aa 100644 (file)
@@ -9,11 +9,20 @@ 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);
+       
+       if (manualEventsName.contains(name)) {
+               previousValue = true;
+               event.setManualTransaction(true);
+       } else {
+               event.setManualTransaction(false);
+       }
 
        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,7 +35,6 @@ 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) {
                                String toCall = app1.functionList[i]
                                app1."$toCall"(event)
@@ -35,4 +43,9 @@ def eventHandler(LinkedHashMap eventDataMap) {
                                app1.functionList[i](event)
                }
        }
+
+        if (manualEventsName.contains(name))
+               previousValue = false;
+       else if (previousValue)
+               event.setManualTransaction(true);
 }
index ed4e62c38741d48a67263ebabe2a7029e3558862..4af036d054fe67f57e462fd54833820efb2c243a 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 previousValue = false\n")
 Out.write("\n")
 Out.write("//clear init flag now we are done with it\n")
 Out.write("init = false\n")