mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 11:59:12 +03:00
Отремантировал uptime
This commit is contained in:
@@ -22,4 +22,4 @@
|
|||||||
0;count-down;cntid;anydata;Таймер;Обратный#отчет;order*
|
0;count-down;cntid;anydata;Таймер;Обратный#отчет;order*
|
||||||
0;inoutput;txtid;anydata;Вывод;Вывод#uart;order*
|
0;inoutput;txtid;anydata;Вывод;Вывод#uart;order*
|
||||||
0;logging;crtid;chart;Графики;История;order;val[any];int[60];cnt[100]*
|
0;logging;crtid;chart;Графики;История;order;val[any];int[60];cnt[100]*
|
||||||
0;uptime;uptid;anydataTime;Системные;%name%#uptime;order*
|
0;uptime;uptid;anydataTime;Системные;%name%#uptime;order;int[60]*
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
extern void sysUptime();
|
|
||||||
extern void uptimeReading();
|
|
||||||
33
include/items/vSensorUptime.h
Normal file
33
include/items/vSensorUptime.h
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
#include "Global.h"
|
||||||
|
#include "GyverFilters.h"
|
||||||
|
|
||||||
|
class SensorUptime;
|
||||||
|
|
||||||
|
typedef std::vector<SensorUptime> MySensorUptimeVector;
|
||||||
|
|
||||||
|
struct paramsUptime {
|
||||||
|
String key;
|
||||||
|
unsigned long interval;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SensorUptime {
|
||||||
|
public:
|
||||||
|
SensorUptime(const paramsUptime& paramsUpt);
|
||||||
|
~SensorUptime();
|
||||||
|
|
||||||
|
void loop();
|
||||||
|
void read();
|
||||||
|
|
||||||
|
private:
|
||||||
|
paramsUptime _paramsUpt;
|
||||||
|
|
||||||
|
unsigned long prevMillis;
|
||||||
|
unsigned long difference;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern MySensorUptimeVector* mySensorUptime;
|
||||||
|
|
||||||
|
extern void uptimeSensor();
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "SoftUART.h"
|
#include "SoftUART.h"
|
||||||
//
|
//
|
||||||
#include "items/sysUptime.h"
|
#include "items/vSensorUptime.h"
|
||||||
#include "items/vSensorDallas.h"
|
#include "items/vSensorDallas.h"
|
||||||
#include "items/vSensorUltrasonic.h"
|
#include "items/vSensorUltrasonic.h"
|
||||||
#include "items/vButtonOut.h"
|
#include "items/vButtonOut.h"
|
||||||
@@ -92,7 +92,7 @@ void csvCmdExecute(String& cmdStr) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else if (order == F("uptime")) {
|
else if (order == F("uptime")) {
|
||||||
sCmd.addCommand(order.c_str(), sysUptime);
|
sCmd.addCommand(order.c_str(), uptimeSensor);
|
||||||
}
|
}
|
||||||
else if (order == F("logging")) {
|
else if (order == F("logging")) {
|
||||||
sCmd.addCommand(order.c_str(), logging);
|
sCmd.addCommand(order.c_str(), logging);
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "Utils/WiFiUtils.h"
|
#include "Utils/WiFiUtils.h"
|
||||||
#include "items/sysUptime.h"
|
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
|
|
||||||
void routerConnect() {
|
void routerConnect() {
|
||||||
@@ -141,7 +140,6 @@ uint8_t RSSIquality() {
|
|||||||
void wifiSignalInit() {
|
void wifiSignalInit() {
|
||||||
ts.add(
|
ts.add(
|
||||||
SYGNAL, 1000 * 60, [&](void*) {
|
SYGNAL, 1000 * 60, [&](void*) {
|
||||||
//uptimeReading();
|
|
||||||
SerialPrint("I", "System", printMemoryStatus());
|
SerialPrint("I", "System", printMemoryStatus());
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
getFSInfo();
|
getFSInfo();
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
#include "items/sysUptime.h"
|
|
||||||
#include "Class/LineParsing.h"
|
|
||||||
#include "BufferExecute.h"
|
|
||||||
#include "Global.h"
|
|
||||||
#include <Arduino.h>
|
|
||||||
|
|
||||||
void sysUptime() {
|
|
||||||
myLineParsing.update();
|
|
||||||
String key = myLineParsing.gkey();
|
|
||||||
sCmd.addCommand(key.c_str(), uptimeReading);
|
|
||||||
myLineParsing.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void uptimeReading() {
|
|
||||||
String key = sCmd.order();
|
|
||||||
String uptime = timeNow->getUptime();
|
|
||||||
jsonWriteStr(configLiveJson, key, uptime);
|
|
||||||
publishStatus(key, uptime);
|
|
||||||
SerialPrint("I", "Sensor", "'" + key + "' data: " + uptime);
|
|
||||||
}
|
|
||||||
49
src/items/vSensorUptime.cpp
Normal file
49
src/items/vSensorUptime.cpp
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
#include "items/vSensorUptime.h"
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
#include "BufferExecute.h"
|
||||||
|
#include "Class/LineParsing.h"
|
||||||
|
#include "Global.h"
|
||||||
|
|
||||||
|
SensorUptime::SensorUptime(const paramsUptime& paramsUpt) {
|
||||||
|
_paramsUpt = paramsUptime(paramsUpt);
|
||||||
|
}
|
||||||
|
|
||||||
|
SensorUptime::~SensorUptime() {}
|
||||||
|
|
||||||
|
void SensorUptime::loop() {
|
||||||
|
difference = millis() - prevMillis;
|
||||||
|
if (difference >= _paramsUpt.interval) {
|
||||||
|
prevMillis = millis();
|
||||||
|
read();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SensorUptime::read() {
|
||||||
|
String upt = timeNow->getUptime();
|
||||||
|
|
||||||
|
eventGen2(_paramsUpt.key, upt);
|
||||||
|
jsonWriteStr(configLiveJson, _paramsUpt.key, upt);
|
||||||
|
publishStatus(_paramsUpt.key, upt);
|
||||||
|
SerialPrint("I", "Sensor", "'" + _paramsUpt.key + "' data: " + upt);
|
||||||
|
}
|
||||||
|
|
||||||
|
MySensorUptimeVector* mySensorUptime = nullptr;
|
||||||
|
|
||||||
|
void uptimeSensor() {
|
||||||
|
myLineParsing.update();
|
||||||
|
String key = myLineParsing.gkey();
|
||||||
|
String interval = myLineParsing.gint();
|
||||||
|
myLineParsing.clear();
|
||||||
|
|
||||||
|
static paramsUptime paramsUpt;
|
||||||
|
|
||||||
|
paramsUpt.key = key;
|
||||||
|
paramsUpt.interval = interval.toInt() * 1000;
|
||||||
|
|
||||||
|
static bool firstTime = true;
|
||||||
|
if (firstTime) mySensorUptime = new MySensorUptimeVector();
|
||||||
|
firstTime = false;
|
||||||
|
mySensorUptime->push_back(SensorUptime(paramsUpt));
|
||||||
|
}
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "Utils/Timings.h"
|
#include "Utils/Timings.h"
|
||||||
#include "Utils/WebUtils.h"
|
#include "Utils/WebUtils.h"
|
||||||
#include "items/ButtonInClass.h"
|
#include "items/ButtonInClass.h"
|
||||||
|
#include "items/vSensorUptime.h"
|
||||||
#include "items/vCountDown.h"
|
#include "items/vCountDown.h"
|
||||||
#include "items/vImpulsOut.h"
|
#include "items/vImpulsOut.h"
|
||||||
#include "items/vLogging.h"
|
#include "items/vLogging.h"
|
||||||
@@ -153,4 +154,9 @@ void loop() {
|
|||||||
mySensorBmp280->at(i).loop();
|
mySensorBmp280->at(i).loop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (mySensorUptime != nullptr) {
|
||||||
|
for (unsigned int i = 0; i < mySensorUptime->size(); i++) {
|
||||||
|
mySensorUptime->at(i).loop();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user