более стандартные имена методов

This commit is contained in:
Dmitry Borisenko
2022-09-22 22:55:04 +02:00
parent 8a3d061bd7
commit b1fe6af04d
6 changed files with 24 additions and 22 deletions

View File

@@ -24,11 +24,6 @@ class IoTItem {
virtual void regEvent(float value, String consoleInfo); virtual void regEvent(float value, String consoleInfo);
String getSubtype(); String getSubtype();
virtual void sendChart();
virtual void cleanChart();
virtual void setPublishType(int type, int num);
virtual void cleanData();
virtual void setTodayDate();
String getID(); String getID();
virtual String getValue(); virtual String getValue();
@@ -53,6 +48,13 @@ class IoTItem {
virtual void setValue(IoTValue Value); virtual void setValue(IoTValue Value);
virtual void setValue(String valStr); virtual void setValue(String valStr);
//методы для графиков
virtual void publishValue();
virtual void clearValue();
virtual void setPublishDestination(int type, int num);
virtual void clearHistory();
virtual void setTodayDate();
protected: protected:
String _subtype; String _subtype;
String _id; String _id;

View File

@@ -137,8 +137,8 @@ void mqttCallback(char* topic, uint8_t* payload, size_t length) {
//отправка данных графиков //отправка данных графиков
for (std::list<IoTItem*>::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) { for (std::list<IoTItem*>::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) {
if ((*it)->getSubtype() == "Loging") { if ((*it)->getSubtype() == "Loging") {
(*it)->setPublishType(1, -1); (*it)->setPublishDestination(1, -1);
(*it)->sendChart(); (*it)->publishValue();
} }
} }

View File

@@ -78,8 +78,8 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length)
// (*it)->setTodayDate(); // (*it)->setTodayDate();
//} //}
if ((*it)->getSubtype() == "Loging") { if ((*it)->getSubtype() == "Loging") {
(*it)->setPublishType(2, num); (*it)->setPublishDestination(2, num);
(*it)->sendChart(); (*it)->publishValue();
} }
} }
} }

View File

@@ -128,13 +128,13 @@ String IoTItem::getSubtype() {
return _subtype; return _subtype;
} }
void IoTItem::sendChart() {} void IoTItem::publishValue() {}
void IoTItem::cleanChart() {} void IoTItem::clearValue() {}
void IoTItem::setPublishType(int publishType, int wsNum){}; void IoTItem::setPublishDestination(int publishType, int wsNum){};
void IoTItem::cleanData() {} void IoTItem::clearHistory() {}
void IoTItem::setTodayDate() {} void IoTItem::setTodayDate() {}

View File

@@ -147,7 +147,7 @@ class Loging : public IoTItem {
return changed; return changed;
} }
void sendChart() { void publishValue() {
String dir = "/lg/" + id; String dir = "/lg/" + id;
filesList = getFilesList(dir); filesList = getFilesList(dir);
@@ -183,17 +183,17 @@ class Loging : public IoTItem {
} }
//если данных нет отправляем пустой грфик //если данных нет отправляем пустой грфик
if (noData) { if (noData) {
cleanChart(); clearValue();
} }
} }
void cleanChart() { void clearValue() {
SerialPrint("i", F("Loging"), "clear chart"); SerialPrint("i", F("Loging"), "clear chart");
String cleanJson = createEmtyJson(); String cleanJson = createEmtyJson();
publishJson(cleanJson); publishJson(cleanJson);
} }
void cleanData() { void clearHistory() {
String dir = "/lg/" + id; String dir = "/lg/" + id;
cleanDirectory(dir); cleanDirectory(dir);
} }
@@ -243,7 +243,7 @@ class Loging : public IoTItem {
} }
// publishType 1 - в mqtt, 2 - в ws, 3 - mqtt и ws, wsNum = -1 => broadcast // publishType 1 - в mqtt, 2 - в ws, 3 - mqtt и ws, wsNum = -1 => broadcast
void setPublishType(int publishType, int wsNum) { void setPublishDestination(int publishType, int wsNum) {
_publishType = publishType; _publishType = publishType;
_wsNum = wsNum; _wsNum = wsNum;
} }
@@ -342,9 +342,9 @@ class Date : public IoTItem {
if ((*it)->getSubtype() == "Loging") { if ((*it)->getSubtype() == "Loging") {
//отправляем только свои данные //отправляем только свои данные
if ((*it)->getID() == selectToMarker(id, "-")) { if ((*it)->getID() == selectToMarker(id, "-")) {
(*it)->setPublishType(3, -1); (*it)->setPublishDestination(3, -1);
(*it)->cleanChart(); (*it)->clearValue();
(*it)->sendChart(); (*it)->publishValue();
} }
} }
} }

View File

@@ -217,7 +217,7 @@ void cleanLogs() {
//очистка данных всех экземпляров графиков //очистка данных всех экземпляров графиков
for (std::list<IoTItem*>::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) { for (std::list<IoTItem*>::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) {
if ((*it)->getSubtype() == "Loging") { if ((*it)->getSubtype() == "Loging") {
(*it)->cleanData(); (*it)->clearHistory();
} }
} }
} }