убираем баги окна ввода даты

This commit is contained in:
Dmitry Borisenko
2022-09-11 14:13:58 +02:00
parent 9c5624eddf
commit d121414e65
5 changed files with 17 additions and 15 deletions

View File

@@ -17,7 +17,7 @@ void mqttSubscribe();
boolean publish(const String& topic, const String& data); boolean publish(const String& topic, const String& data);
boolean publishData(const String& topic, const String& data); boolean publishData(const String& topic, const String& data);
boolean publishChart(const String& topic, const String& data); boolean publishChartMqtt(const String& topic, const String& data);
boolean publishControl(String id, String topic, String state); boolean publishControl(String id, String topic, String state);
boolean publishChart_test(const String& topic, const String& data); boolean publishChart_test(const String& topic, const String& data);
boolean publishStatusMqtt(const String& topic, const String& data); boolean publishStatusMqtt(const String& topic, const String& data);

View File

@@ -15,7 +15,7 @@ extern void hexdump(const void* mem, uint32_t len, uint8_t cols);
void sendFileToWs(const char* filename, uint8_t num, size_t frameSize); void sendFileToWs(const char* filename, uint8_t num, size_t frameSize);
void publishStatusWs(const String& topic, const String& data); void publishStatusWs(const String& topic, const String& data);
void publishStatusWsJson(String& json); void publishChartWs(String& json);
void periodicWsSend(); void periodicWsSend();
void sendStringToWs(const String& msg, uint8_t num, String name); void sendStringToWs(const String& msg, uint8_t num, String name);

View File

@@ -222,7 +222,7 @@ boolean publishData(const String& topic, const String& data) {
return true; return true;
} }
boolean publishChart(const String& topic, const String& data) { boolean publishChartMqtt(const String& topic, const String& data) {
String path = mqttRootDevice + "/" + topic + "/status"; String path = mqttRootDevice + "/" + topic + "/status";
if (!publish(path, data)) { if (!publish(path, data)) {
SerialPrint("E", F("MQTT"), F("on publish chart")); SerialPrint("E", F("MQTT"), F("on publish chart"));

View File

@@ -59,7 +59,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length)
sendFileToWs("/layout.json", num, 1024); sendFileToWs("/layout.json", num, 1024);
String json = getParamsJson(); String json = getParamsJson();
standWebSocket.sendTXT(num, json); standWebSocket.sendTXT(num, json);
//отправка данных графиков //отправка данных графиков (нехватает передачи номера сокетов)
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)->sendChart(2); (*it)->sendChart(2);
@@ -250,8 +250,8 @@ void publishStatusWs(const String& topic, const String& data) {
} }
//публикация статус сообщений уже готовых //публикация статус сообщений уже готовых
void publishStatusWsJson(String& json) { void publishChartWs(String& data) {
standWebSocket.broadcastTXT(json); standWebSocket.broadcastTXT(data);
} }
//данные которые мы отправляем в сокеты переодически //данные которые мы отправляем в сокеты переодически

View File

@@ -5,7 +5,6 @@
void *getAPI_Date(String params); void *getAPI_Date(String params);
String date;
class Loging : public IoTItem { class Loging : public IoTItem {
private: private:
String logid; String logid;
@@ -158,7 +157,7 @@ class Loging : public IoTItem {
// SerialPrint("i", F("Loging"), "file '" + buf + "' too old, deleted"); // SerialPrint("i", F("Loging"), "file '" + buf + "' too old, deleted");
// removeFile(buf); // removeFile(buf);
//} else { //} else {
unsigned long reqUnixTime = strDateToUnix(date); unsigned long reqUnixTime = strDateToUnix(getItemValue(id + "-date"));
if (fileUnixTimeLocal > reqUnixTime && fileUnixTimeLocal < reqUnixTime + 86400) { if (fileUnixTimeLocal > reqUnixTime && fileUnixTimeLocal < reqUnixTime + 86400) {
noData = false; noData = false;
createJson(buf, i, type); createJson(buf, i, type);
@@ -229,12 +228,12 @@ class Loging : public IoTItem {
void publishJson(String &oneSingleJson, int type) { void publishJson(String &oneSingleJson, int type) {
if (type == 1) { if (type == 1) {
publishChart(id, oneSingleJson); publishChartMqtt(id, oneSingleJson);
} else if (type == 2) { } else if (type == 2) {
publishStatusWsJson(oneSingleJson); publishChartWs(oneSingleJson);
} else if (type == 3) { } else if (type == 3) {
publishChart(id, oneSingleJson); publishChartMqtt(id, oneSingleJson);
publishStatusWsJson(oneSingleJson); publishChartWs(oneSingleJson);
} }
} }
@@ -257,7 +256,7 @@ class Loging : public IoTItem {
generateEvent(_id, value); generateEvent(_id, value);
publishStatusMqtt(_id, value); publishStatusMqtt(_id, value);
String json = createSingleJson(_id, value); String json = createSingleJson(_id, value);
publishStatusWsJson(json); publishChartWs(json);
SerialPrint("i", "Sensor " + consoleInfo, "'" + _id + "' data: " + value + "'"); SerialPrint("i", "Sensor " + consoleInfo, "'" + _id + "' data: " + value + "'");
} }
@@ -298,16 +297,19 @@ class Date : public IoTItem {
void setValue(String valStr) { void setValue(String valStr) {
value.valS = valStr; value.valS = valStr;
date = valStr;
setValue(value); setValue(value);
} }
void setValue(IoTValue Value) { void setValue(IoTValue Value) {
value = Value; value = Value;
regEvent(value.valS, ""); regEvent(value.valS, "");
//отправка данных при изменении даты
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)->sendChart(3); //отправляем только свои данные
if ((*it)->getID() == selectToMarker(id, "-")) {
(*it)->sendChart(3);
}
} }
} }
} }