From fbef2c7711aa01d8bd9f86ea01f6124f3b07a7df Mon Sep 17 00:00:00 2001 From: athatheocsd <athatheo@csd.auth.gr> Date: Sat, 1 Dec 2018 20:21:12 +0200 Subject: [PATCH] Added comments in new functions and fixed typos --- inc/Services/EventReportService.hpp | 35 +++++++++++++++++++++++++++- src/Services/EventReportService.cpp | 20 ++++++++++++++++ src/main.cpp | 12 +++++----- test/Services/EventReportService.cpp | 12 +++++----- 4 files changed, 66 insertions(+), 13 deletions(-) diff --git a/inc/Services/EventReportService.hpp b/inc/Services/EventReportService.hpp index f0040037..ff2ce884 100644 --- a/inc/Services/EventReportService.hpp +++ b/inc/Services/EventReportService.hpp @@ -20,22 +20,55 @@ public: serviceType = 5; } + /** + * Type of the information event + */ enum InformationEvent { - UnknownEvent = 0, + /** + * An unknown event occured + */ + InformativeUnknownEvent = 0, + /** + * Watchdogs have reset + */ WWDGReset = 1, + /** + * Dont + */ AssertionFail = 2, + /** + * Microcontroller has started + */ MCUStart = 3, }; + /** + * Type of the low severity anomaly event + */ enum LowSeverityAnomalyEvent { + /** + * An unknown anomaly of low severity anomalyhas occurred + */ LowSeverityUnknownEvent = 1, }; + /** + * Type of the medium severity anomaly event + */ enum MediumSeverityAnomalyEvent { + /** + * An unknown anomaly of medium severity has occurred + */ MediumSeverityUnknownEvent = 2, }; + /** + * Type of the high severity anomaly event + */ enum HighSeverityAnomalyEvent { + /** + * An unknown anomaly of high severity has occurred + */ HighSeverityUnknownEvent = 3, }; diff --git a/src/Services/EventReportService.cpp b/src/Services/EventReportService.cpp index 0a89f5c9..a695db26 100644 --- a/src/Services/EventReportService.cpp +++ b/src/Services/EventReportService.cpp @@ -1,3 +1,6 @@ + +#include <Services/EventReportService.hpp> + #include "Services/EventReportService.hpp" #include "Message.hpp" @@ -44,3 +47,20 @@ EventReportService::highSeverityAnomalyReport(HighSeverityAnomalyEvent eventID, storeMessage(report); } + +void EventReportService::enableReportGeneration(uint8_t N) { + +} + +void EventReportService::disableReportGeneration(uint8_t N) { + +} + +void EventReportService::requestListOfDisabledEvents() { + +} + +void EventReportService::listOfDisabledEventsReport() { + +} + diff --git a/src/main.cpp b/src/main.cpp index d6457a5c..7263dd8d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -68,13 +68,13 @@ int main() { rcvPack.appendEnum8(MemoryManagementService::MemoryID::RAM); // Memory ID rcvPack.appendUint16(3); // Iteration count rcvPack.appendUint64(reinterpret_cast<uint64_t >(string)); // Start address - rcvPack.appendUint16(sizeof(string)/ sizeof(string[0])); // Data read length + rcvPack.appendUint16(sizeof(string) / sizeof(string[0])); // Data read length rcvPack.appendUint64(reinterpret_cast<uint64_t >(anotherStr)); - rcvPack.appendUint16(sizeof(anotherStr)/ sizeof(anotherStr[0])); + rcvPack.appendUint16(sizeof(anotherStr) / sizeof(anotherStr[0])); rcvPack.appendUint64(reinterpret_cast<uint64_t >(yetAnotherStr)); - rcvPack.appendUint16(sizeof(yetAnotherStr)/ sizeof(yetAnotherStr[0])); + rcvPack.appendUint16(sizeof(yetAnotherStr) / sizeof(yetAnotherStr[0])); memMangService.rawDataMemorySubservice.dumpRawData(rcvPack); rcvPack = Message(6, 2, Message::TC, 1); @@ -87,7 +87,7 @@ int main() { rcvPack.appendUint64(reinterpret_cast<uint64_t >(pStr + 1)); // Start address rcvPack.appendOctetString(1, data); memMangService.rawDataMemorySubservice.loadRawData(rcvPack); - + // ST[01] test // parameters take random values and works as expected @@ -101,8 +101,8 @@ int main() { // ST[05] test [works] const unsigned char eventReportData[12] = "Hello World"; EventReportService eventReportService; - eventReportService.informativeEventReport(EventReportService::UnknownEvent, eventReportData, - 11); + eventReportService.informativeEventReport(EventReportService::InformativeUnknownEvent, + eventReportData, 11); eventReportService.lowSeverityAnomalyReport(EventReportService::LowSeverityUnknownEvent, eventReportData, 11); eventReportService.mediumSeverityAnomalyReport(EventReportService::MediumSeverityUnknownEvent, diff --git a/test/Services/EventReportService.cpp b/test/Services/EventReportService.cpp index bef6e181..3d944e89 100644 --- a/test/Services/EventReportService.cpp +++ b/test/Services/EventReportService.cpp @@ -11,15 +11,15 @@ TEST_CASE("Informative Event Report TM[5,1]", "[service][st05]") { EventReportService eventReportService; const unsigned char eventReportData[] = "HelloWorld"; char checkString[255]; - eventReportService.informativeEventReport(EventReportService::UnknownEvent, eventReportData, - 10); + eventReportService.informativeEventReport(EventReportService::InformativeUnknownEvent, + eventReportData, 10); REQUIRE(ServiceTests::hasOneMessage()); Message report = ServiceTests::get(0); // Checks for the data-members of the report Message created CHECK(report.serviceType == 5); CHECK(report.messageType == 1); - CHECK(report.packetType == 0); // packet type(TM = 0, TC = 1) + CHECK(report.packetType == Message::TM); // packet type(TM = 0, TC = 1) REQUIRE(report.dataSize == 12); // Check for the value that is stored in <<data>> array(data-member of object response) CHECK(report.readEnum16() == 0); @@ -39,7 +39,7 @@ TEST_CASE("Loww Severity Anomaly Report TM[5,2]", "[service][st05]") { // Checks for the data-members of the report Message created CHECK(report.serviceType == 5); CHECK(report.messageType == 2); - CHECK(report.packetType == 0); // packet type(TM = 0, TC = 1) + CHECK(report.packetType == Message::TM); // packet type(TM = 0, TC = 1) REQUIRE(report.dataSize == 12); // Check for the value that is stored in <<data>> array(data-member of object response) CHECK(report.readEnum16() == 1); @@ -59,7 +59,7 @@ TEST_CASE("Medium Severity Anomaly Report TM[5,3]", "[service][st05]") { // Checks for the data-members of the report Message created CHECK(report.serviceType == 5); CHECK(report.messageType == 3); - CHECK(report.packetType == 0); // packet type(TM = 0, TC = 1) + CHECK(report.packetType == Message::TM); // packet type(TM = 0, TC = 1) REQUIRE(report.dataSize == 12); // Check for the value that is stored in <<data>> array(data-member of object response) CHECK(report.readEnum16() == 2); @@ -79,7 +79,7 @@ TEST_CASE("High Severity Anomaly Report TM[5,4]", "[service][st05]") { // Checks for the data-members of the report Message created CHECK(report.serviceType == 5); CHECK(report.messageType == 4); - CHECK(report.packetType == 0); // packet type(TM = 0, TC = 1) + CHECK(report.packetType == Message::TM); // packet type(TM = 0, TC = 1) REQUIRE(report.dataSize == 12); // Check for the value that is stored in <<data>> array(data-member of object response) CHECK(report.readEnum16() == 3); -- GitLab