mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
optimization scenario
This commit is contained in:
@@ -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;
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user