From: Seyed Amir Hossein Aqajari Date: Tue, 24 Mar 2020 20:29:23 +0000 (-0700) Subject: Adding manual transaction feature to new infrastructure X-Git-Url: http://plrg.eecs.uci.edu/git/?p=smartthings-infrastructure.git;a=commitdiff_plain;h=e9b50d79e92a7ff191bf08dab1d49d7ab23bc87e Adding manual transaction feature to new infrastructure --- diff --git a/Event/Event.groovy b/Event/Event.groovy index 83ba658..e7956c2 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..1ce9048 100644 --- a/Methods/eventHandler.groovy +++ b/Methods/eventHandler.groovy @@ -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]) } diff --git a/Runner.py b/Runner.py index ed4e62c..499a737 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 stack = []\n") Out.write("\n") Out.write("//clear init flag now we are done with it\n") Out.write("init = false\n")