diff --git a/inc/Services/EventReportService.hpp b/inc/Services/EventReportService.hpp index e597047a47fd62940d2b03ded6cba6c01a40d644..f859dc53bc922297e72bd2ff20f9b72bfc6c5f0b 100644 --- a/inc/Services/EventReportService.hpp +++ b/inc/Services/EventReportService.hpp @@ -20,14 +20,18 @@ private: static const uint16_t numberOfEvents = 7; std::bitset<numberOfEvents> stateOfEvents; public: - // Variables that count the event occurrences per severity level + // Variables that count the event reports per severity level uint16_t lowSeverityReportsCount; uint16_t mediumSeverityReportCount; uint16_t highSeverityReportCount; + // Variables that count the event occurences per severity level + uint16_t lowSeverityEventCount; + uint16_t mediumSeverityEventCount; + uint16_t highSeverityEventCount; + uint16_t disabledEventsCount; - uint16_t lastInformativeEventReportID; uint16_t lastLowSeverityReportID; uint16_t lastMediumSeverityReportID; uint16_t lastHighSeverityReportID; @@ -39,7 +43,9 @@ public: mediumSeverityReportCount = 0; highSeverityReportCount = 0; disabledEventsCount = 0; - lastInformativeEventReportID = -1; + lowSeverityEventCount = 0; + mediumSeverityEventCount = 0; + highSeverityEventCount = 0; lastLowSeverityReportID = -1; lastMediumSeverityReportID = -1; lastHighSeverityReportID = -1; diff --git a/src/Services/EventReportService.cpp b/src/Services/EventReportService.cpp index 8c8833c9a39913730ed1361513b2b7f650079068..a75d35b0614170243e51ec9fde6c8bdeae389a15 100644 --- a/src/Services/EventReportService.cpp +++ b/src/Services/EventReportService.cpp @@ -9,50 +9,60 @@ void EventReportService::informativeEventReport(Event eventID, const uint8_t *data, uint8_t length) { // TM[5,1] - Message report = createTM(1); - report.appendEnum16(eventID); - report.appendString(length, data); - lastInformativeEventReportID = static_cast<uint16_t >(eventID); + if (stateOfEvents[static_cast<uint16_t> (eventID)] == 1){ + Message report = createTM(1); + report.appendEnum16(eventID); + report.appendString(length, data); - storeMessage(report); + storeMessage(report); + } } void EventReportService::lowSeverityAnomalyReport(Event eventID, const uint8_t *data, uint8_t length) { + lowSeverityEventCount++; // TM[5,2] - lowSeverityReportsCount++; - Message report = createTM(2); - report.appendEnum16(eventID); - report.appendString(length, data); - lastLowSeverityReportID = static_cast<uint16_t >(eventID); + if (stateOfEvents[static_cast<uint16_t> (eventID)] == 1) { + lowSeverityReportsCount++; + Message report = createTM(2); + report.appendEnum16(eventID); + report.appendString(length, data); + lastLowSeverityReportID = static_cast<uint16_t >(eventID); - storeMessage(report); + storeMessage(report); + } } void EventReportService::mediumSeverityAnomalyReport(Event eventID, const uint8_t *data, uint8_t length) { + mediumSeverityEventCount++; // TM[5,3] - mediumSeverityReportCount++; - Message report = createTM(3); - report.appendEnum16(eventID); - report.appendString(length, data); - lastMediumSeverityReportID = static_cast<uint16_t >(eventID); + if (stateOfEvents[static_cast<uint16_t> (eventID)] == 1) { + mediumSeverityReportCount++; + Message report = createTM(3); + report.appendEnum16(eventID); + report.appendString(length, data); + lastMediumSeverityReportID = static_cast<uint16_t >(eventID); - storeMessage(report); + storeMessage(report); + } } void EventReportService::highSeverityAnomalyReport(Event eventID, const uint8_t *data, uint8_t length) { + highSeverityEventCount++; // TM[5,4] - highSeverityReportCount++; - Message report = createTM(4); - report.appendEnum16(eventID); - report.appendString(length, data); - lastHighSeverityReportID = static_cast<uint16_t >(eventID); + if (stateOfEvents[static_cast<uint16_t> (eventID)] == 1) { + highSeverityReportCount++; + Message report = createTM(4); + report.appendEnum16(eventID); + report.appendString(length, data); + lastHighSeverityReportID = static_cast<uint16_t >(eventID); - storeMessage(report); + storeMessage(report); + } } void EventReportService::enableReportGeneration(uint16_t length, Event *eventID) {