optimization scenario

This commit is contained in:
Dmitry Borisenko
2020-08-29 23:30:04 +03:00
parent 490a2f1f5b
commit 786468e0b9
2 changed files with 11 additions and 15 deletions

View File

@@ -1,39 +1,30 @@
#pragma once
#include <Arduino.h>
#include "Cmd.h"
#include "Global.h"
class Scenario {
protected:
String _scenarioTmp;
String _condition;
String _conditionParam;
String _conditionSign;
String _conditionValue;
String _scenBlok;
String _event;
String _eventParam;
String _eventValue;
public:
Scenario() : _scenarioTmp{""},
_condition{""},
_conditionParam{""},
_conditionSign{""},
_conditionValue{""},
_scenBlok{""},
_event{""},
_eventParam{""},
_eventValue{""}
{};
_eventValue{""} {};
void load() {
_scenarioTmp = scenario;
@@ -95,9 +86,12 @@ class Scenario {
}
void loop() {
if (!this->isScenarioEnabled()) {
return;
}
this->load(); //после этого мы получили все сценарии
while (_scenarioTmp.length() > 1) {
this->calculate1();
this->calculate1();
if (this->isIncommingEventInScenario()) { //если вошедшее событие есть в сценарии
this->calculate2();
if (this->isConditionSatisfied()) { //если вошедшее событие выполняет условие сценария
@@ -110,5 +104,9 @@ class Scenario {
}
this->delOneEvent();
}
bool isScenarioEnabled() {
return jsonReadBool(configSetupJson, "scen") && eventBuf != "";
}
};
extern Scenario* myScenario;

View File

@@ -78,10 +78,8 @@ void setup() {
SsdpInit();
ts.add(
TEST, 30000, [&](void*) {
//pm.info(printMemoryStatus());
//myScenario->loop();
TEST, 1000 * 60, [&](void*) {
pm.info(printMemoryStatus());
},
nullptr, true);