diff --git a/inc/ECSS_Definitions.hpp b/inc/ECSS_Definitions.hpp index 0434ced3d95102858bd374c941e84d27e0519ae1..7487b2cfa6e0d8bda7a8adb13d676dab47e40e20 100644 --- a/inc/ECSS_Definitions.hpp +++ b/inc/ECSS_Definitions.hpp @@ -120,7 +120,7 @@ inline const uint8_t ECSSEventDataAuxiliaryMaxSize = 64; * @brief Size of the multimap that holds every event-action definition * @see EventActionService */ -inline const uint16_t ECSSEventActionStructMapSize = 256; +inline const uint16_t ECSSEventActionStructMapSize = 100; /** * The maximum delta between the specified release time and the actual release time @@ -183,7 +183,7 @@ inline const uint16_t ECSSMaxPacketStoreSizeInBytes = 1000; /** * @brief the max number of TM packets that a packet store in ST[15] can store */ -inline const uint16_t ECSSMaxPacketStoreSize = 20; +inline const uint16_t ECSSMaxPacketStoreSize = 10; /** * @brief the max number of packet stores that a packet selection subservice can handle in ST[15] diff --git a/inc/Services/EventActionService.hpp b/inc/Services/EventActionService.hpp index f5ab24d05b3bacf1b9ed3f1fcbf841d68ed57c29..0fd3dd04294fac86a27cdb2900f8486a178f959f 100644 --- a/inc/Services/EventActionService.hpp +++ b/inc/Services/EventActionService.hpp @@ -54,12 +54,11 @@ public: }; struct EventActionDefinition { - // TODO: APID = 0 is the Ground Station APID. This should be changed - uint16_t applicationId = ApplicationId; - uint16_t eventDefinitionID = 65535; // The ID of the event that might take place - uint16_t eventActionDefinitionID = 0; // The ID of the event-action - String<64> request = ""; bool enabled = false; + uint16_t applicationId = ApplicationId; + uint16_t eventDefinitionID = 65535; + uint16_t eventActionDefinitionID = 0; + String<ECSSTCRequestStringSize> request = ""; }; friend EventReportService; diff --git a/src/Services/EventActionService.cpp b/src/Services/EventActionService.cpp index 0963cf942b8a2dbd57a0a60fd972be37c78793a1..427987bc8bc111c05ccae2a55c12f288bcda45df 100644 --- a/src/Services/EventActionService.cpp +++ b/src/Services/EventActionService.cpp @@ -1,13 +1,12 @@ #include "ECSS_Configuration.hpp" #ifdef SERVICE_EVENTACTION -#include "Services/EventActionService.hpp" #include "Message.hpp" #include "MessageParser.hpp" +#include "Services/EventActionService.hpp" void EventActionService::addEventActionDefinitions(Message& message) { - // TC[19,1] message.assertTC(EventActionService::ServiceType, EventActionService::MessageType::AddEventAction); uint16_t applicationID = message.readEnum16(); uint16_t eventDefinitionID = message.readEnum16(); @@ -28,7 +27,7 @@ void EventActionService::addEventActionDefinitions(Message& message) { ErrorHandler::reportInternalError(ErrorHandler::MessageTooLarge); } if (canBeAdded) { - char data[ECSSTCRequestStringSize] = { 0 }; + char data[ECSSTCRequestStringSize] = {0}; message.readString(data, message.dataSize - 6); EventActionDefinition temp; temp.enabled = false; @@ -37,7 +36,7 @@ void EventActionService::addEventActionDefinitions(Message& message) { temp.eventActionDefinitionID = eventActionDefinitionID; temp.request = String<ECSSTCRequestStringSize>(data); if (eventActionDefinitionMap.size() == ECSSEventActionStructMapSize) { - ErrorHandler::reportError(message,ErrorHandler::EventActionDefinitionsMapIsFull); + ErrorHandler::reportError(message, ErrorHandler::EventActionDefinitionsMapIsFull); } else { eventActionDefinitionMap.insert(std::make_pair(eventDefinitionID, temp)); } @@ -74,7 +73,6 @@ void EventActionService::deleteEventActionDefinitions(Message& message) { } void EventActionService::deleteAllEventActionDefinitions(Message& message) { - // TC[19,3] message.assertTC(EventActionService::ServiceType, EventActionService::MessageType::DeleteAllEventAction); setEventActionFunctionStatus(false); @@ -82,7 +80,6 @@ void EventActionService::deleteAllEventActionDefinitions(Message& message) { } void EventActionService::enableEventActionDefinitions(Message& message) { - // TC[19,4] message.assertTC(EventActionService::ServiceType, EventActionService::MessageType::EnableEventAction); uint16_t numberOfEventActionDefinitions = message.readUint16(); if (numberOfEventActionDefinitions != 0U) { @@ -108,14 +105,13 @@ void EventActionService::enableEventActionDefinitions(Message& message) { } } } else { - for (auto& element : eventActionDefinitionMap) { + for (auto& element: eventActionDefinitionMap) { element.second.enabled = true; } } } void EventActionService::disableEventActionDefinitions(Message& message) { - // TC[19,5] message.assertTC(EventActionService::ServiceType, EventActionService::MessageType::DisableEventAction); uint16_t numberOfEventActionDefinitions = message.readUint16(); if (numberOfEventActionDefinitions != 0U) { @@ -140,25 +136,23 @@ void EventActionService::disableEventActionDefinitions(Message& message) { } } } else { - for (auto& element : eventActionDefinitionMap) { + for (auto& element: eventActionDefinitionMap) { element.second.enabled = false; } } } void EventActionService::requestEventActionDefinitionStatus(Message& message) { - // TC[19,6] message.assertTC(EventActionService::ServiceType, EventActionService::MessageType::ReportStatusOfEachEventAction); eventActionStatusReport(); } void EventActionService::eventActionStatusReport() { - // TM[19,7] Message report = createTM(EventActionStatusReport); uint16_t count = eventActionDefinitionMap.size(); report.appendUint16(count); - for (const auto& element : eventActionDefinitionMap) { + for (const auto& element: eventActionDefinitionMap) { report.appendEnum16(element.second.applicationId); report.appendEnum16(element.second.eventDefinitionID); report.appendEnum16(element.second.eventActionDefinitionID); @@ -168,14 +162,12 @@ void EventActionService::eventActionStatusReport() { } void EventActionService::enableEventActionFunction(Message& message) { - // TC[19,8] message.assertTC(EventActionService::ServiceType, EventActionService::MessageType::EnableEventActionFunction); setEventActionFunctionStatus(true); } void EventActionService::disableEventActionFunction(Message& message) { - // TC[19,9] message.assertTC(EventActionService::ServiceType, EventActionService::MessageType::DisableEventActionFunction); setEventActionFunctionStatus(false); @@ -215,7 +207,7 @@ void EventActionService::execute(Message& message) { case ReportStatusOfEachEventAction: requestEventActionDefinitionStatus(message); break; - case EnableEventActionFunction : + case EnableEventActionFunction: enableEventActionFunction(message); break; case DisableEventActionFunction: diff --git a/test/Services/StorageAndRetrievalServiceTests.cpp b/test/Services/StorageAndRetrievalServiceTests.cpp index 15910597e2ef7e7b49a46b619a784588bc74555b..55b2193be7bd0bbcbb9d0f94b658e0ce9c97d8c3 100644 --- a/test/Services/StorageAndRetrievalServiceTests.cpp +++ b/test/Services/StorageAndRetrievalServiceTests.cpp @@ -1,7 +1,7 @@ -#include "Services/StorageAndRetrievalService.hpp" #include <iostream> #include "Message.hpp" #include "ServiceTests.hpp" +#include "Services/StorageAndRetrievalService.hpp" #include "catch2/catch_all.hpp" StorageAndRetrievalService& storageAndRetrieval = Services.storageAndRetrieval; @@ -1728,16 +1728,16 @@ TEST_CASE("Reporting the content summary of packet stores") { CHECK(report.readUint32() == timestamps1[0]); CHECK(report.readUint32() == timestamps1[5]); CHECK(report.readUint32() == 5); - CHECK(report.readUint16() == 30); - CHECK(report.readUint16() == 20); + CHECK(report.readUint16() == 60); + CHECK(report.readUint16() == 40); // Packet store 2 report.readString(data, ECSSPacketStoreIdSize); CHECK(std::equal(std::begin(packetStoreData2), std::end(packetStoreData2), std::begin(data))); CHECK(report.readUint32() == timestamps2[0]); CHECK(report.readUint32() == timestamps2[4]); CHECK(report.readUint32() == 5); - CHECK(report.readUint16() == 25); - CHECK(report.readUint16() == 10); + CHECK(report.readUint16() == 50); + CHECK(report.readUint16() == 20); ServiceTests::reset(); Services.reset(); @@ -1782,7 +1782,7 @@ TEST_CASE("Reporting the content summary of packet stores") { CHECK(report.readUint32() == timestamps1[0]); CHECK(report.readUint32() == timestamps1[5]); CHECK(report.readUint32() == 15); - CHECK(report.readUint16() == 30); + CHECK(report.readUint16() == 60); CHECK(report.readUint16() == 0); // Packet store 2 report.readString(data, ECSSPacketStoreIdSize); @@ -1790,23 +1790,23 @@ TEST_CASE("Reporting the content summary of packet stores") { CHECK(report.readUint32() == timestamps2[0]); CHECK(report.readUint32() == timestamps2[4]); CHECK(report.readUint32() == 15); - CHECK(report.readUint16() == 25); - CHECK(report.readUint16() == 10); + CHECK(report.readUint16() == 50); + CHECK(report.readUint16() == 20); // Packet store 3 report.readString(data, ECSSPacketStoreIdSize); CHECK(std::equal(std::begin(packetStoreData3), std::end(packetStoreData3), std::begin(data))); CHECK(report.readUint32() == timestamps4[0]); CHECK(report.readUint32() == timestamps4[7]); CHECK(report.readUint32() == 20); - CHECK(report.readUint16() == 40); - CHECK(report.readUint16() == 30); + CHECK(report.readUint16() == 80); + CHECK(report.readUint16() == 60); // Packet store 4 report.readString(data, ECSSPacketStoreIdSize); CHECK(std::equal(std::begin(packetStoreData4), std::end(packetStoreData4), std::begin(data))); CHECK(report.readUint32() == timestamps3[0]); CHECK(report.readUint32() == timestamps3[3]); CHECK(report.readUint32() == 15); - CHECK(report.readUint16() == 20); + CHECK(report.readUint16() == 40); CHECK(report.readUint16() == 0); ServiceTests::reset(); @@ -1854,8 +1854,8 @@ TEST_CASE("Reporting the content summary of packet stores") { CHECK(report.readUint32() == timestamps1[0]); CHECK(report.readUint32() == timestamps1[5]); CHECK(report.readUint32() == 5); - CHECK(report.readUint16() == 30); - CHECK(report.readUint16() == 20); + CHECK(report.readUint16() == 60); + CHECK(report.readUint16() == 40); ServiceTests::reset(); Services.reset();