mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 11:59:12 +03:00
Добавляем расширенные данные к IoTValue и отключение doByInterval при Int = 0 чтоб пользователь не создавал частые генерации событий
This commit is contained in:
@@ -6,6 +6,9 @@ struct IoTValue {
|
|||||||
float valD = 0;
|
float valD = 0;
|
||||||
String valS = "";
|
String valS = "";
|
||||||
bool isDecimal = true;
|
bool isDecimal = true;
|
||||||
|
|
||||||
|
uint8_t *extBinInfo = NULL; // дополнительные бинарные данные из модуля
|
||||||
|
size_t extBinInfoSize = 0; // размер дополнительных данных в байтах
|
||||||
};
|
};
|
||||||
|
|
||||||
class IoTItem {
|
class IoTItem {
|
||||||
@@ -29,12 +32,13 @@ class IoTItem {
|
|||||||
unsigned long prevMillis;
|
unsigned long prevMillis;
|
||||||
unsigned long difference;
|
unsigned long difference;
|
||||||
|
|
||||||
IoTValue value; // хранение основного значения, котрое обновляется из сценария, execute(), loop() или doByInterval()
|
IoTValue value; // хранение основного значения, которое обновляется из сценария, execute(), loop() или doByInterval()
|
||||||
|
|
||||||
bool iAmDead = false; // признак необходимости удалить объект из базы
|
bool iAmDead = false; // признак необходимости удалить объект из базы
|
||||||
bool iAmLocal = true; // признак локальной переменной
|
bool iAmLocal = true; // признак локальной переменной
|
||||||
|
|
||||||
bool needSave = false;
|
bool needSave = false;
|
||||||
|
bool enableDoByInt = true;
|
||||||
|
|
||||||
virtual IoTGpio* getGpioDriver();
|
virtual IoTGpio* getGpioDriver();
|
||||||
virtual iarduino_RTC_BASE* getRtcDriver();
|
virtual iarduino_RTC_BASE* getRtcDriver();
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
IoTItem::IoTItem(String parameters) {
|
IoTItem::IoTItem(String parameters) {
|
||||||
jsonRead(parameters, F("int"), _interval);
|
jsonRead(parameters, F("int"), _interval);
|
||||||
|
if (_interval == 0) enableDoByInt = false;
|
||||||
_interval = _interval * 1000;
|
_interval = _interval * 1000;
|
||||||
jsonRead(parameters, F("subtype"), _subtype);
|
jsonRead(parameters, F("subtype"), _subtype);
|
||||||
jsonRead(parameters, F("id"), _id);
|
jsonRead(parameters, F("id"), _id);
|
||||||
@@ -57,11 +58,13 @@ String IoTItem::getValue() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void IoTItem::loop() {
|
void IoTItem::loop() {
|
||||||
currentMillis = millis();
|
if (enableDoByInt) {
|
||||||
difference = currentMillis - prevMillis;
|
currentMillis = millis();
|
||||||
if (difference >= _interval) {
|
difference = currentMillis - prevMillis;
|
||||||
prevMillis = millis();
|
if (difference >= _interval) {
|
||||||
this->doByInterval();
|
prevMillis = millis();
|
||||||
|
this->doByInterval();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user