From fd2c0b69c0115d6a421965e63c19da232e63a211 Mon Sep 17 00:00:00 2001 From: athatheocsd <athatheo@csd.auth.gr> Date: Tue, 11 Dec 2018 16:35:57 +0200 Subject: [PATCH] Added disabling of report generation --- inc/Services/EventReportService.hpp | 12 +++++-- src/Services/EventReportService.cpp | 56 +++++++++++++++++------------ 2 files changed, 42 insertions(+), 26 deletions(-) diff --git a/inc/Services/EventReportService.hpp b/inc/Services/EventReportService.hpp index e597047a..f859dc53 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 8c8833c9..a75d35b0 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) { -- GitLab