mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-04 02:09:30 +02:00
bugfix - ordering is oposite in events page and mqtt publish
This commit is contained in:
parent
086c3dfa29
commit
eb901da385
4 changed files with 14 additions and 5 deletions
|
@ -266,7 +266,7 @@ void publish_events() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Sort events by timestamp
|
// Sort events by timestamp
|
||||||
std::sort(order_events.begin(), order_events.end(), compareEventsByTimestamp);
|
std::sort(order_events.begin(), order_events.end(), compareEventsByTimestampAsc);
|
||||||
|
|
||||||
for (const auto& event : order_events) {
|
for (const auto& event : order_events) {
|
||||||
|
|
||||||
|
|
|
@ -463,14 +463,22 @@ static void update_bms_status(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to compare events by timestamp
|
// Function to compare events by timestamp descending
|
||||||
bool compareEventsByTimestamp(const EventData& a, const EventData& b) {
|
bool compareEventsByTimestampDesc(const EventData& a, const EventData& b) {
|
||||||
if (a.event_pointer->millisrolloverCount != b.event_pointer->millisrolloverCount) {
|
if (a.event_pointer->millisrolloverCount != b.event_pointer->millisrolloverCount) {
|
||||||
return a.event_pointer->millisrolloverCount > b.event_pointer->millisrolloverCount;
|
return a.event_pointer->millisrolloverCount > b.event_pointer->millisrolloverCount;
|
||||||
}
|
}
|
||||||
return a.event_pointer->timestamp > b.event_pointer->timestamp;
|
return a.event_pointer->timestamp > b.event_pointer->timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Function to compare events by timestamp ascending
|
||||||
|
bool compareEventsByTimestampAsc(const EventData& a, const EventData& b) {
|
||||||
|
if (a.event_pointer->millisrolloverCount != b.event_pointer->millisrolloverCount) {
|
||||||
|
return a.event_pointer->millisrolloverCount < b.event_pointer->millisrolloverCount;
|
||||||
|
}
|
||||||
|
return a.event_pointer->timestamp < b.event_pointer->timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
static void update_event_level(void) {
|
static void update_event_level(void) {
|
||||||
EVENTS_LEVEL_TYPE temporary_level = EVENT_LEVEL_INFO;
|
EVENTS_LEVEL_TYPE temporary_level = EVENT_LEVEL_INFO;
|
||||||
for (uint8_t i = 0u; i < EVENT_NOF_EVENTS; i++) {
|
for (uint8_t i = 0u; i < EVENT_NOF_EVENTS; i++) {
|
||||||
|
|
|
@ -157,6 +157,7 @@ void run_event_handling(void);
|
||||||
|
|
||||||
void run_sequence_on_target(void);
|
void run_sequence_on_target(void);
|
||||||
|
|
||||||
bool compareEventsByTimestamp(const EventData& a, const EventData& b);
|
bool compareEventsByTimestampAsc(const EventData& a, const EventData& b);
|
||||||
|
bool compareEventsByTimestampDesc(const EventData& a, const EventData& b);
|
||||||
|
|
||||||
#endif // __MYTIMER_H__
|
#endif // __MYTIMER_H__
|
||||||
|
|
|
@ -30,7 +30,7 @@ String events_processor(const String& var) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Sort events by timestamp
|
// Sort events by timestamp
|
||||||
std::sort(order_events.begin(), order_events.end(), compareEventsByTimestamp);
|
std::sort(order_events.begin(), order_events.end(), compareEventsByTimestampDesc);
|
||||||
unsigned long timestamp_now = millis();
|
unsigned long timestamp_now = millis();
|
||||||
|
|
||||||
// Generate HTML and debug output
|
// Generate HTML and debug output
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue