From 6626c7d029420d4f0b4895b1de78f18a278696f1 Mon Sep 17 00:00:00 2001 From: Seyed Amir Hossein Aqajari <saqajari@circinus-38.ics.uci.edu> Date: Wed, 19 Feb 2020 11:40:38 -0800 Subject: [PATCH] Adding manual transaction feature to the infrastructure --- Event/Event.groovy | 5 +++++ Methods/eventHandler.groovy | 17 +++++++++++++++-- Runner.py | 1 + 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Event/Event.groovy b/Event/Event.groovy index d7abdf4..6812f5c 100644 --- a/Event/Event.groovy +++ b/Event/Event.groovy @@ -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; + } } diff --git a/Methods/eventHandler.groovy b/Methods/eventHandler.groovy index 59bb059..e6bf04d 100644 --- a/Methods/eventHandler.groovy +++ b/Methods/eventHandler.groovy @@ -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); } diff --git a/Runner.py b/Runner.py index ed4e62c..4af036d 100644 --- 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") -- 2.34.1