mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
графики в веб интерфейсе
This commit is contained in:
@@ -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(const String& topic, String& json);
|
void publishStatusWsJson(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);
|
||||||
|
|
||||||
|
|||||||
@@ -215,9 +215,7 @@ void publishStatusWs(const String& topic, const String& data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//публикация статус сообщений уже готовых
|
//публикация статус сообщений уже готовых
|
||||||
void publishStatusWsJson(const String& topic, String& json) {
|
void publishStatusWsJson(String& json) {
|
||||||
String path = mqttRootDevice + "/" + topic;
|
|
||||||
jsonWriteStr(json, "topic", path);
|
|
||||||
standWebSocket.broadcastTXT(json);
|
standWebSocket.broadcastTXT(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,7 +96,6 @@ class Loging : public IoTItem {
|
|||||||
String reqUnixTimeStr = "27.08.2022"; //нужно получить эту дату из окна ввода под графиком.
|
String reqUnixTimeStr = "27.08.2022"; //нужно получить эту дату из окна ввода под графиком.
|
||||||
unsigned long reqUnixTime = strDateToUnix(reqUnixTimeStr);
|
unsigned long reqUnixTime = strDateToUnix(reqUnixTimeStr);
|
||||||
|
|
||||||
String oneSingleJson;
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
String directory = "lg";
|
String directory = "lg";
|
||||||
@@ -124,7 +123,7 @@ class Loging : public IoTItem {
|
|||||||
// if (fileUnixTime > reqUnixTime && fileUnixTime < reqUnixTime + 86400) {
|
// if (fileUnixTime > reqUnixTime && fileUnixTime < reqUnixTime + 86400) {
|
||||||
SerialPrint("i", F("Loging"), "'" + id + "' matching file found '" + fname + "'");
|
SerialPrint("i", F("Loging"), "'" + id + "' matching file found '" + fname + "'");
|
||||||
//выгрузка по частям, по одному файлу
|
//выгрузка по частям, по одному файлу
|
||||||
publishJsonPartly("/lg/" + fname, calculateMaxCount(), i, mqtt);
|
createJson("/lg/" + fname, i, mqtt);
|
||||||
//}
|
//}
|
||||||
//удаление старых файлов
|
//удаление старых файлов
|
||||||
if ((fileUnixTime + (points * interval)) < (unixTime - (keepdays * 86400))) {
|
if ((fileUnixTime + (points * interval)) < (unixTime - (keepdays * 86400))) {
|
||||||
@@ -144,7 +143,7 @@ class Loging : public IoTItem {
|
|||||||
SerialPrint("i", F("Loging"), "'" + id + "'--------------'" + String(i) + "'--------------");
|
SerialPrint("i", F("Loging"), "'" + id + "'--------------'" + String(i) + "'--------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
void publishJsonPartly(String file, int maxCount, int &i, bool mqtt) {
|
void createJson(String file, int &i, bool mqtt) {
|
||||||
File configFile = FileFS.open(file, "r");
|
File configFile = FileFS.open(file, "r");
|
||||||
if (!configFile) {
|
if (!configFile) {
|
||||||
SerialPrint("E", F("Loging"), "'" + id + "' open file error");
|
SerialPrint("E", F("Loging"), "'" + id + "' open file error");
|
||||||
@@ -152,7 +151,7 @@ class Loging : public IoTItem {
|
|||||||
}
|
}
|
||||||
configFile.seek(0, SeekSet);
|
configFile.seek(0, SeekSet);
|
||||||
String buf = "{}";
|
String buf = "{}";
|
||||||
String dividedJson;
|
String oneSingleJson;
|
||||||
String unix_time;
|
String unix_time;
|
||||||
String value;
|
String value;
|
||||||
unsigned int psn;
|
unsigned int psn;
|
||||||
@@ -166,22 +165,24 @@ class Loging : public IoTItem {
|
|||||||
value = deleteBeforeDelimiter(line, " ");
|
value = deleteBeforeDelimiter(line, " ");
|
||||||
jsonWriteFloat(buf, "y1", value.toFloat());
|
jsonWriteFloat(buf, "y1", value.toFloat());
|
||||||
if (unix_time != "" || value != "") {
|
if (unix_time != "" || value != "") {
|
||||||
dividedJson += buf + ",";
|
oneSingleJson += buf + ",";
|
||||||
}
|
}
|
||||||
} while (psn < sz);
|
} while (psn < sz);
|
||||||
|
|
||||||
configFile.close();
|
configFile.close();
|
||||||
|
|
||||||
publishJson(dividedJson, maxCount, mqtt);
|
String topic = mqttRootDevice + "/" + id;
|
||||||
|
oneSingleJson = "{\"maxCount\":" + String(calculateMaxCount()) + ",\"topic\":\"" + topic + "\",\"status\":[" + oneSingleJson + "]}";
|
||||||
|
oneSingleJson.replace("},]}", "}]}");
|
||||||
|
|
||||||
|
publishJson(oneSingleJson, mqtt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void publishJson(String & oneSingleJson, int &maxCount, bool mqtt) {
|
void publishJson(String & oneSingleJson, bool mqtt) {
|
||||||
oneSingleJson = "{\"maxCount\":" + String(maxCount) + ",\"status\":[" + oneSingleJson + "]}";
|
|
||||||
oneSingleJson.replace("},]}", "}]}");
|
|
||||||
if (mqtt) {
|
if (mqtt) {
|
||||||
publishChart(id, oneSingleJson);
|
publishChart(id, oneSingleJson);
|
||||||
} else {
|
} else {
|
||||||
publishStatusWsJson(id, oneSingleJson);
|
publishStatusWsJson(oneSingleJson);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user