mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
Партии выгрузки в логгировании
This commit is contained in:
@@ -3,8 +3,8 @@
|
|||||||
"chipID": "",
|
"chipID": "",
|
||||||
"apssid": "IoTmanager",
|
"apssid": "IoTmanager",
|
||||||
"appass": "",
|
"appass": "",
|
||||||
"routerssid": "WLAN1-Y1GYEF",
|
"routerssid": "rise",
|
||||||
"routerpass": "2egY69YTA8DDR7En",
|
"routerpass": "hostel3333",
|
||||||
"timezone": 1,
|
"timezone": 1,
|
||||||
"ntp": "pool.ntp.org",
|
"ntp": "pool.ntp.org",
|
||||||
"mqttServer": "91.204.228.124",
|
"mqttServer": "91.204.228.124",
|
||||||
@@ -25,11 +25,12 @@
|
|||||||
"webpass": "admin",
|
"webpass": "admin",
|
||||||
"MqttIn": "0",
|
"MqttIn": "0",
|
||||||
"MqttOut": "0",
|
"MqttOut": "0",
|
||||||
"blink": "1",
|
"blink": "0",
|
||||||
"oneWirePin": "2",
|
"oneWirePin": "2",
|
||||||
"serverip": "http://206.189.49.244",
|
"serverip": "http://206.189.49.244",
|
||||||
"uart": "0",
|
"uart": "0",
|
||||||
"uartS": "9600",
|
"uartS": "9600",
|
||||||
"uartTX": "12",
|
"uartTX": "12",
|
||||||
"uartRX": "13"
|
"uartRX": "13",
|
||||||
|
"grafmax": "0"
|
||||||
}
|
}
|
||||||
Binary file not shown.
Binary file not shown.
@@ -42,6 +42,12 @@
|
|||||||
"action": "/?set.utilities",
|
"action": "/?set.utilities",
|
||||||
"class": "btn btn-block btn-default"
|
"class": "btn btn-block btn-default"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "link",
|
||||||
|
"title": "Настройки разработчика",
|
||||||
|
"action": "/?set.dev",
|
||||||
|
"class": "btn btn-block btn-default"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "link",
|
"type": "link",
|
||||||
"title": "Скачать приложение IoT Manager для android",
|
"title": "Скачать приложение IoT Manager для android",
|
||||||
|
|||||||
@@ -39,6 +39,25 @@
|
|||||||
{
|
{
|
||||||
"type": "hr"
|
"type": "hr"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "h3",
|
||||||
|
"title": "Количество точек графика выгружаемое за раз"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "input",
|
||||||
|
"title": "ip address",
|
||||||
|
"name": "graf-arg",
|
||||||
|
"state": "{{grafmax}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "button",
|
||||||
|
"title": "{{ButSave}}",
|
||||||
|
"action": "set?grafmax=[[graf-arg]]",
|
||||||
|
"class": "btn btn-block btn-default"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "hr"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "h3",
|
"type": "h3",
|
||||||
"name": "reset-block",
|
"name": "reset-block",
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class Scenario {
|
|||||||
String setEventSign = selectFromMarkerToMarker(condition, " ", 1);
|
String setEventSign = selectFromMarkerToMarker(condition, " ", 1);
|
||||||
String setEventValue = selectFromMarkerToMarker(condition, " ", 2);
|
String setEventValue = selectFromMarkerToMarker(condition, " ", 2);
|
||||||
|
|
||||||
if (!isDigitStr(setEventValue)) {
|
if (!isDigitDotCommaStr(setEventValue)) {
|
||||||
if (setEventValue.indexOf("+-") != -1) {
|
if (setEventValue.indexOf("+-") != -1) {
|
||||||
String setEventValueName = selectToMarker(setEventValue, "+-");
|
String setEventValueName = selectToMarker(setEventValue, "+-");
|
||||||
String gisteresisValue = selectToMarkerLast(setEventValue, "+-");
|
String gisteresisValue = selectToMarkerLast(setEventValue, "+-");
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ void testsPerform() {
|
|||||||
//Serial.println(isDigitDotCommaStr("-12552.5555"));
|
//Serial.println(isDigitDotCommaStr("-12552.5555"));
|
||||||
|
|
||||||
//String str = "Geeks for Geeks ";
|
//String str = "Geeks for Geeks ";
|
||||||
//
|
|
||||||
//Serial.println(itemsCount2(str, " "));
|
//Serial.println(itemsCount2(str, " "));
|
||||||
|
|
||||||
Serial.println("==========end============");
|
Serial.println("==========end============");
|
||||||
|
|||||||
15
src/Web.cpp
15
src/Web.cpp
@@ -325,13 +325,20 @@ void web_init() {
|
|||||||
serverIP = jsonReadStr(configSetupJson, "serverip");
|
serverIP = jsonReadStr(configSetupJson, "serverip");
|
||||||
request->send(200);
|
request->send(200);
|
||||||
}
|
}
|
||||||
//set?order=button_1
|
//set?order=button_1
|
||||||
if (request->hasArg("order")) {
|
if (request->hasArg("order")) {
|
||||||
String order = request->getParam("order")->value();
|
String order = request->getParam("order")->value();
|
||||||
order.replace("_"," ");
|
order.replace("_", " ");
|
||||||
orderBuf += order + ",";
|
orderBuf += order + ",";
|
||||||
request->send(200);
|
request->send(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (request->hasArg("grafmax")) {
|
||||||
|
int value = request->getParam("grafmax")->value().toInt();
|
||||||
|
jsonWriteInt(configSetupJson, "grafmax", value);
|
||||||
|
saveConfig();
|
||||||
|
request->send(200);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/order", HTTP_GET, [](AsyncWebServerRequest* request) {
|
server.on("/order", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||||
@@ -345,8 +352,6 @@ void web_init() {
|
|||||||
String msg = "";
|
String msg = "";
|
||||||
|
|
||||||
if (USE_OTA) {
|
if (USE_OTA) {
|
||||||
msg = F("Обновление невозможно, память устройства 1 мб");
|
|
||||||
} else {
|
|
||||||
if (lastVersion == FIRMWARE_VERSION) {
|
if (lastVersion == FIRMWARE_VERSION) {
|
||||||
msg = F("Актуальная версия прошивки уже установлена.");
|
msg = F("Актуальная версия прошивки уже установлена.");
|
||||||
} else if (lastVersion > FIRMWARE_VERSION) {
|
} else if (lastVersion > FIRMWARE_VERSION) {
|
||||||
@@ -358,6 +363,8 @@ void web_init() {
|
|||||||
} else if (lastVersion < FIRMWARE_VERSION) {
|
} else if (lastVersion < FIRMWARE_VERSION) {
|
||||||
msg = F("Ошибка версии. Попробуйте повторить позже...");
|
msg = F("Ошибка версии. Попробуйте повторить позже...");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
msg = F("Обновление невозможно, память устройства 1 мб");
|
||||||
}
|
}
|
||||||
|
|
||||||
String tmp = "{}";
|
String tmp = "{}";
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ void LoggingClass::execute(String keyOrValue) {
|
|||||||
} else {
|
} else {
|
||||||
SerialPrint("E", "Logging", "This value not found on this device");
|
SerialPrint("E", "Logging", "This value not found on this device");
|
||||||
}
|
}
|
||||||
} else { //прилетело из события
|
} else { //прилетело из события
|
||||||
if (isDigitStr(keyOrValue) || keyOrValue.indexOf(".") != -1) { //если это число или дробное число
|
if (isDigitDotCommaStr(keyOrValue)) { //если это число или дробное число
|
||||||
loggingValue = keyOrValue;
|
loggingValue = keyOrValue;
|
||||||
} else { //если это ключ
|
} else { //если это ключ
|
||||||
if (getValue(_loggingValueKey) != "no value") {
|
if (getValue(_loggingValueKey) != "no value") {
|
||||||
@@ -49,21 +49,22 @@ void LoggingClass::execute(String keyOrValue) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String filename = "logs/" + _key + ".txt";
|
String filename = "logs/" + _key + ".txt";
|
||||||
|
|
||||||
size_t cnt = countLines(filename);
|
size_t cnt = countLines(filename);
|
||||||
size_t sz = getFileSize(filename);
|
size_t sz = getFileSize(filename);
|
||||||
|
|
||||||
SerialPrint("I", "Logging", "http://" + WiFi.localIP().toString() + "/" + filename + " lines " + String(cnt, DEC) + ", size " + String(sz) + ", heap " + ESP.getFreeHeap());
|
SerialPrint("I", "Logging", "http://" + WiFi.localIP().toString() + "/" + filename + " lines " + String(cnt, DEC) + ", size " + String(sz));
|
||||||
|
|
||||||
if ((cnt > _maxPoints + 1) || cnt == -1) {
|
if ((cnt > _maxPoints + 1) || cnt == -1) {
|
||||||
removeFile(filename);
|
removeFile(filename);
|
||||||
SerialPrint("E", "Logging", "file been remooved: " + filename + " " + String(cnt) + ">" + String(_maxPoints));
|
SerialPrint("E", "Logging", "file been remooved: " + filename + " " + String(cnt) + ">" + String(_maxPoints));
|
||||||
cnt = 0;
|
cnt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loggingValue != "") {
|
if (loggingValue != "") {
|
||||||
if (cnt > _maxPoints) { //удаляем старую строку и добавляем новую
|
if (cnt > _maxPoints) { //удаляем старую строку и добавляем новую
|
||||||
String logData = readFile(filename, 10240);
|
String logData = readFile(filename, 20480); //10240
|
||||||
|
SerialPrint("I", "Logging", "Free heap " + ESP.getFreeHeap());
|
||||||
if (logData == "large") {
|
if (logData == "large") {
|
||||||
SerialPrint("E", "Logging", "File is very large");
|
SerialPrint("E", "Logging", "File is very large");
|
||||||
}
|
}
|
||||||
@@ -132,39 +133,6 @@ void choose_log_date_and_send() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendLogData2(String file, String topic) {
|
|
||||||
String log_date = readFile(file, 5120);
|
|
||||||
if (log_date != "failed") {
|
|
||||||
log_date.replace("\r\n", "\n");
|
|
||||||
log_date.replace("\r", "\n");
|
|
||||||
String buf = "{}";
|
|
||||||
String json_array;
|
|
||||||
String unix_time;
|
|
||||||
String value;
|
|
||||||
while (log_date.length()) {
|
|
||||||
String tmp = selectToMarker(log_date, "\n");
|
|
||||||
log_date = deleteBeforeDelimiter(log_date, "\n");
|
|
||||||
unix_time = selectToMarker(tmp, " ");
|
|
||||||
jsonWriteInt(buf, "x", unix_time.toInt());
|
|
||||||
value = deleteBeforeDelimiter(tmp, " ");
|
|
||||||
jsonWriteFloat(buf, "y1", value.toFloat());
|
|
||||||
if (log_date.length() < 3) {
|
|
||||||
json_array += buf;
|
|
||||||
} else {
|
|
||||||
json_array += buf + ",";
|
|
||||||
}
|
|
||||||
buf = "{}";
|
|
||||||
}
|
|
||||||
unix_time = "";
|
|
||||||
value = "";
|
|
||||||
log_date = "";
|
|
||||||
json_array = "{\"status\":[" + json_array + "]}";
|
|
||||||
//SerialPrint("I", "module", json_array);
|
|
||||||
|
|
||||||
publishChart(topic, json_array);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void sendLogData(String file, String topic) {
|
void sendLogData(String file, String topic) {
|
||||||
File configFile = FileFS.open(file, "r");
|
File configFile = FileFS.open(file, "r");
|
||||||
if (!configFile) {
|
if (!configFile) {
|
||||||
@@ -189,12 +157,15 @@ void sendLogData(String file, String topic) {
|
|||||||
if (unix_time != "" || value != "") {
|
if (unix_time != "" || value != "") {
|
||||||
json_array += buf + ",";
|
json_array += buf + ",";
|
||||||
}
|
}
|
||||||
if (i >= 100) {
|
int grafmax = jsonReadInt(configSetupJson, "grafmax");
|
||||||
json_array = "{\"status\":[" + json_array + "]}";
|
if (grafmax != 0) {
|
||||||
json_array.replace("},]}", "}]}");
|
if (i >= grafmax) {
|
||||||
publishChart(topic, json_array);
|
json_array = "{\"status\":[" + json_array + "]}";
|
||||||
json_array = "";
|
json_array.replace("},]}", "}]}");
|
||||||
i = 0;
|
publishChart(topic, json_array);
|
||||||
|
json_array = "";
|
||||||
|
i = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} while (psn < sz);
|
} while (psn < sz);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user