mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 11:59:12 +03:00
добавил смену даты во всех графиках при смене даты
This commit is contained in:
@@ -134,6 +134,8 @@ struct Time_t {
|
|||||||
|
|
||||||
extern unsigned long unixTime;
|
extern unsigned long unixTime;
|
||||||
extern unsigned long unixTimeShort;
|
extern unsigned long unixTimeShort;
|
||||||
|
extern String prevDate;
|
||||||
|
extern bool firstTimeInit;
|
||||||
|
|
||||||
extern bool isTimeSynch;
|
extern bool isTimeSynch;
|
||||||
extern Time_t _time_local;
|
extern Time_t _time_local;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ extern void breakEpochToTime(unsigned long epoch, Time_t& tm);
|
|||||||
extern void ntpInit();
|
extern void ntpInit();
|
||||||
extern time_t getSystemTime();
|
extern time_t getSystemTime();
|
||||||
extern void synchTime();
|
extern void synchTime();
|
||||||
|
extern bool onDayChange();
|
||||||
extern const String getTimeLocal_hhmm();
|
extern const String getTimeLocal_hhmm();
|
||||||
extern const String getTimeLocal_hhmmss();
|
extern const String getTimeLocal_hhmmss();
|
||||||
extern const String getDateTimeDotFormated();
|
extern const String getDateTimeDotFormated();
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ String mqttRootDevice = "";
|
|||||||
// Time
|
// Time
|
||||||
unsigned long unixTime = 0;
|
unsigned long unixTime = 0;
|
||||||
unsigned long unixTimeShort = 0;
|
unsigned long unixTimeShort = 0;
|
||||||
|
String prevDate = "";
|
||||||
|
bool firstTimeInit = true;
|
||||||
|
|
||||||
// unsigned long loopPeriod;
|
// unsigned long loopPeriod;
|
||||||
|
|
||||||
|
|||||||
20
src/NTP.cpp
20
src/NTP.cpp
@@ -29,6 +29,7 @@ void ntpInit() {
|
|||||||
dateAndTime = deleteToMarkerLast(dateAndTime, ":");
|
dateAndTime = deleteToMarkerLast(dateAndTime, ":");
|
||||||
jsonWriteStr_(errorsHeapJson, F("timenow"), dateAndTime);
|
jsonWriteStr_(errorsHeapJson, F("timenow"), dateAndTime);
|
||||||
SerialPrint("I", F("NTP"), "✔ " + dateAndTime);
|
SerialPrint("I", F("NTP"), "✔ " + dateAndTime);
|
||||||
|
onDayChange();
|
||||||
}
|
}
|
||||||
_time_isTrust = true; // доверяем значению времени
|
_time_isTrust = true; // доверяем значению времени
|
||||||
},
|
},
|
||||||
@@ -41,6 +42,25 @@ void synchTime() {
|
|||||||
configTime(0, 0, "pool.ntp.org", "ru.pool.ntp.org", "pool.ntp.org");
|
configTime(0, 0, "pool.ntp.org", "ru.pool.ntp.org", "pool.ntp.org");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//событие смены даты
|
||||||
|
bool onDayChange() {
|
||||||
|
bool changed = false;
|
||||||
|
String currentDate = getTodayDateDotFormated();
|
||||||
|
if (!firstTimeInit) {
|
||||||
|
if (prevDate != currentDate) {
|
||||||
|
changed = true;
|
||||||
|
SerialPrint("i", F("NTP"), F("Change day core event"));
|
||||||
|
//установим новую дату во всех графиках системы
|
||||||
|
for (std::list<IoTItem*>::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) {
|
||||||
|
(*it)->setTodayDate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
firstTimeInit = false;
|
||||||
|
prevDate = currentDate;
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned long gmtTimeToLocal(unsigned long gmtTimestamp) {
|
unsigned long gmtTimeToLocal(unsigned long gmtTimestamp) {
|
||||||
return gmtTimestamp + (jsonReadInt(settingsFlashJson, F("timezone")) * 60 * 60);
|
return gmtTimestamp + (jsonReadInt(settingsFlashJson, F("timezone")) * 60 * 60);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class Loging : public IoTItem {
|
|||||||
IoTItem *dateIoTItem;
|
IoTItem *dateIoTItem;
|
||||||
|
|
||||||
String prevDate = "";
|
String prevDate = "";
|
||||||
bool firstTimeDate = true;
|
bool firstTimeInit = true;
|
||||||
|
|
||||||
long interval;
|
long interval;
|
||||||
|
|
||||||
@@ -188,12 +188,10 @@ class Loging : public IoTItem {
|
|||||||
bool hasDayChanged() {
|
bool hasDayChanged() {
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
String currentDate = getTodayDateDotFormated();
|
String currentDate = getTodayDateDotFormated();
|
||||||
if (!firstTimeDate) {
|
if (!firstTimeInit) {
|
||||||
if (prevDate != currentDate) {
|
if (prevDate != currentDate) {
|
||||||
changed = true;
|
changed = true;
|
||||||
SerialPrint("i", F("NTP"), "Change day event");
|
SerialPrint("i", F("NTP"), F("Change day event"));
|
||||||
//установим дату на изменившуюся при смене суток
|
|
||||||
dateIoTItem->setTodayDate();
|
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
FileFS.gc();
|
FileFS.gc();
|
||||||
#endif
|
#endif
|
||||||
@@ -201,7 +199,7 @@ class Loging : public IoTItem {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
firstTimeDate = false;
|
firstTimeInit = false;
|
||||||
prevDate = currentDate;
|
prevDate = currentDate;
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class LogingDaily : public IoTItem {
|
|||||||
IoTItem *dateIoTItem;
|
IoTItem *dateIoTItem;
|
||||||
|
|
||||||
String prevDate = "";
|
String prevDate = "";
|
||||||
bool firstTimeDate = true;
|
bool firstTimeInit = true;
|
||||||
|
|
||||||
long interval;
|
long interval;
|
||||||
|
|
||||||
@@ -138,7 +138,7 @@ class LogingDaily : public IoTItem {
|
|||||||
bool hasDayChanged() {
|
bool hasDayChanged() {
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
String currentDate = getTodayDateDotFormated();
|
String currentDate = getTodayDateDotFormated();
|
||||||
if (!firstTimeDate) {
|
if (!firstTimeInit) {
|
||||||
if (prevDate != currentDate) {
|
if (prevDate != currentDate) {
|
||||||
changed = true;
|
changed = true;
|
||||||
SerialPrint("i", F("NTP"), "Change day event");
|
SerialPrint("i", F("NTP"), "Change day event");
|
||||||
@@ -149,7 +149,7 @@ class LogingDaily : public IoTItem {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
firstTimeDate = false;
|
firstTimeInit = false;
|
||||||
prevDate = currentDate;
|
prevDate = currentDate;
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user