From 87191fa81bc5037e212951fc179ca042fd15aa20 Mon Sep 17 00:00:00 2001 From: biver Date: Sun, 19 Dec 2021 23:08:14 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=BF=D0=B8=D1=81=D1=8B=D0=B2?= =?UTF-8?q?=D0=B0=D0=B5=D0=BC=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D1=83=20?= =?UTF-8?q?=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20=D1=81=20=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=BD=D0=BE=D0=B9=20timenow=20?= =?UTF-8?q?=D0=B2=20=D1=81=D1=86=D0=B5=D0=BD=D0=B0=D1=80=D0=B8=D1=8F=D1=85?= =?UTF-8?q?.=20=D0=A2=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20=D0=B4=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D1=83=D0=BF=D0=BD=D1=8B=20=D0=B2=D1=8B=D1=80=D0=B0=D0=B6?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B2=D0=B8=D0=B4=D0=B0=20"timenow?= =?UTF-8?q?=20>=2022:48=20&&=20timenow=20<=2023:55=20&&=20btn=20=3D=201"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/Class/ScenarioClass3.h | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/include/Class/ScenarioClass3.h b/include/Class/ScenarioClass3.h index 177fcdce..455b4615 100644 --- a/include/Class/ScenarioClass3.h +++ b/include/Class/ScenarioClass3.h @@ -12,7 +12,7 @@ class Scenario { } String allBlocks = scenario; allBlocks += "\n"; - + String incommingEvent = selectToMarker(eventBuf, ","); String incommingEventKey = selectToMarker(incommingEvent, " "); @@ -164,11 +164,12 @@ class Scenario { if (isEventExist(incommingEventKey, setEventKey)) { String setEventSign; String setEventValue; - if (type == 1) preCalculation(condition, setEventSign, setEventValue); + if (type == 1) preCalculation(condition, setEventSign, incommingEventValue, setEventValue); if (type == 2) preCalculationGisteresis(condition, setEventSign, setEventValue); if (isConditionMatch(setEventSign, incommingEventValue, setEventValue)) { res = true; } + //SerialPrint("I", "incommingEventKey", incommingEventKey); } return res; } @@ -178,8 +179,15 @@ class Scenario { String setEventKey = selectFromMarkerToMarker(condition, " ", 0); String setEventSign; String setEventValue; - preCalculation(condition, setEventSign, setEventValue); - String jsonValue = getValue(setEventKey); + String jsonValue; + + if (setEventKey == "timeNow") { + jsonValue = timeNow->getTimeWOsec(); + } else { + jsonValue = getValue(setEventKey); + } + + preCalculation(condition, setEventSign, jsonValue, setEventValue); //warning тут не уверен что jsonValue можно использовать if (isConditionMatch(setEventSign, jsonValue, setEventValue)) { res = true; } @@ -200,11 +208,22 @@ class Scenario { // return res; //} - void preCalculation(String &condition, String &setEventSign, String &setEventValue) { + void preCalculation(String &condition, String &setEventSign, String &incommingEventValue, String &setEventValue) { setEventSign = selectFromMarkerToMarker(condition, " ", 1); setEventValue = selectFromMarkerToMarker(condition, " ", 2); + if (!isDigitDotCommaStr(setEventValue)) { - setEventValue = getValue(setEventValue); + if (selectToMarker(incommingEventValue, ":") != "") { + int hhLStr = selectToMarker(incommingEventValue, ":").toInt(); + int mmLStr = selectToMarkerLast(incommingEventValue, ":").toInt(); + int hhRStr = selectToMarker(setEventValue, ":").toInt(); + int mmRStr = selectToMarkerLast(setEventValue, ":").toInt(); + + incommingEventValue = hhLStr*60 + mmLStr; + setEventValue = hhRStr*60 + mmRStr; + } else { + setEventValue = getValue(setEventValue); + } } } @@ -236,6 +255,7 @@ class Scenario { bool isConditionMatch(String &setEventSign, String &incommingEventValue, String &setEventValue) { boolean flag = false; + if (setEventSign == "=") { flag = incommingEventValue == setEventValue; } else if (setEventSign == "!=") { @@ -249,6 +269,7 @@ class Scenario { } else if (setEventSign == "<=") { flag = incommingEventValue.toFloat() <= setEventValue.toFloat(); } + return flag; } };