mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 11:59:12 +03:00
optimization scenario
This commit is contained in:
@@ -1,39 +1,30 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
#include "Cmd.h"
|
#include "Cmd.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
|
||||||
class Scenario {
|
class Scenario {
|
||||||
protected:
|
protected:
|
||||||
String _scenarioTmp;
|
String _scenarioTmp;
|
||||||
|
|
||||||
String _condition;
|
String _condition;
|
||||||
String _conditionParam;
|
String _conditionParam;
|
||||||
String _conditionSign;
|
String _conditionSign;
|
||||||
String _conditionValue;
|
String _conditionValue;
|
||||||
|
|
||||||
String _scenBlok;
|
String _scenBlok;
|
||||||
|
|
||||||
String _event;
|
String _event;
|
||||||
String _eventParam;
|
String _eventParam;
|
||||||
String _eventValue;
|
String _eventValue;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Scenario() : _scenarioTmp{""},
|
Scenario() : _scenarioTmp{""},
|
||||||
|
|
||||||
_condition{""},
|
_condition{""},
|
||||||
_conditionParam{""},
|
_conditionParam{""},
|
||||||
_conditionSign{""},
|
_conditionSign{""},
|
||||||
_conditionValue{""},
|
_conditionValue{""},
|
||||||
|
|
||||||
_scenBlok{""},
|
_scenBlok{""},
|
||||||
|
|
||||||
_event{""},
|
_event{""},
|
||||||
_eventParam{""},
|
_eventParam{""},
|
||||||
_eventValue{""}
|
_eventValue{""} {};
|
||||||
|
|
||||||
{};
|
|
||||||
|
|
||||||
void load() {
|
void load() {
|
||||||
_scenarioTmp = scenario;
|
_scenarioTmp = scenario;
|
||||||
@@ -95,9 +86,12 @@ class Scenario {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
if (!this->isScenarioEnabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this->load(); //после этого мы получили все сценарии
|
this->load(); //после этого мы получили все сценарии
|
||||||
while (_scenarioTmp.length() > 1) {
|
while (_scenarioTmp.length() > 1) {
|
||||||
this->calculate1();
|
this->calculate1();
|
||||||
if (this->isIncommingEventInScenario()) { //если вошедшее событие есть в сценарии
|
if (this->isIncommingEventInScenario()) { //если вошедшее событие есть в сценарии
|
||||||
this->calculate2();
|
this->calculate2();
|
||||||
if (this->isConditionSatisfied()) { //если вошедшее событие выполняет условие сценария
|
if (this->isConditionSatisfied()) { //если вошедшее событие выполняет условие сценария
|
||||||
@@ -110,5 +104,9 @@ class Scenario {
|
|||||||
}
|
}
|
||||||
this->delOneEvent();
|
this->delOneEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isScenarioEnabled() {
|
||||||
|
return jsonReadBool(configSetupJson, "scen") && eventBuf != "";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
extern Scenario* myScenario;
|
extern Scenario* myScenario;
|
||||||
@@ -78,10 +78,8 @@ void setup() {
|
|||||||
SsdpInit();
|
SsdpInit();
|
||||||
|
|
||||||
ts.add(
|
ts.add(
|
||||||
TEST, 30000, [&](void*) {
|
TEST, 1000 * 60, [&](void*) {
|
||||||
//pm.info(printMemoryStatus());
|
pm.info(printMemoryStatus());
|
||||||
|
|
||||||
//myScenario->loop();
|
|
||||||
},
|
},
|
||||||
nullptr, true);
|
nullptr, true);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user