From 6b1783554a11099e20a94d78c9cbc45625d4e6d9 Mon Sep 17 00:00:00 2001 From: kongr45gpen <electrovesta@gmail.com> Date: Wed, 18 Sep 2019 05:42:42 +0300 Subject: [PATCH] Implement selective Service compilation Closes #35 --- ci/cppcheck.sh | 2 +- inc/Logger.hpp | 1 + inc/ServicePool.hpp | 46 +++++++++++++++++---- inc/Services/EventReportService.hpp | 2 - src/ErrorHandler.cpp | 10 +++++ src/MessageParser.cpp | 24 +++++++++++ src/Services/EventActionService.cpp | 5 +++ src/Services/EventReportService.cpp | 5 +++ src/Services/FunctionManagementService.cpp | 5 +++ src/Services/LargePacketTransferService.cpp | 5 +++ src/Services/MemoryManagementService.cpp | 5 +++ src/Services/ParameterService.cpp | 5 +++ src/Services/RequestVerificationService.cpp | 5 +++ src/Services/TestService.cpp | 5 +++ src/Services/TimeBasedSchedulingService.cpp | 5 +++ src/Services/TimeManagementService.cpp | 5 +++ 16 files changed, 123 insertions(+), 12 deletions(-) diff --git a/ci/cppcheck.sh b/ci/cppcheck.sh index 2179a051..d0be486c 100755 --- a/ci/cppcheck.sh +++ b/ci/cppcheck.sh @@ -13,4 +13,4 @@ echo -e "\u001b[34;1mRunning cppcheck with default checklist...\u001b[0m" cd "$(dirname "$0")/.." cppcheck --enable=all --suppress=unusedFunction --suppress=noExplicitConstructor \ - --inline-suppr --error-exitcode=1 -I inc src test + --force --inline-suppr --error-exitcode=1 -I inc src test diff --git a/inc/Logger.hpp b/inc/Logger.hpp index 96c2101f..b5e4b7f2 100644 --- a/inc/Logger.hpp +++ b/inc/Logger.hpp @@ -4,6 +4,7 @@ #include <cstdint> #include <etl/String.hpp> #include <etl/to_string.h> +#include "ECSS_Configuration.hpp" #include "ECSS_Definitions.hpp" #if defined LOGLEVEL_TRACE diff --git a/inc/ServicePool.hpp b/inc/ServicePool.hpp index f6a7ea23..51c1fa20 100644 --- a/inc/ServicePool.hpp +++ b/inc/ServicePool.hpp @@ -1,7 +1,8 @@ #ifndef ECSS_SERVICES_SERVICEPOOL_HPP #define ECSS_SERVICES_SERVICEPOOL_HPP -#include <Services/TimeBasedSchedulingService.hpp> +#include "ECSS_Configuration.hpp" +#include "Services/TimeBasedSchedulingService.hpp" #include "Services/LargePacketTransferService.hpp" #include "Services/RequestVerificationService.hpp" #include "Services/TimeManagementService.hpp" @@ -16,8 +17,6 @@ * Defines a class that contains instances of all Services. * * All Services should be stored here and should not be instantiated in a different way. - * - * @todo Find a way to disable services which are not used */ class ServicePool { /** @@ -34,16 +33,45 @@ class ServicePool { */ uint16_t packetSequenceCounter = 0; public: - RequestVerificationService requestVerification; +#ifdef SERVICE_EVENTACTION + EventActionService eventAction; +#endif + +#ifdef SERVICE_EVENTREPORT EventReportService eventReport; +#endif + +#ifdef SERVICE_FUNCTION + FunctionManagementService functionManagement; +#endif + +#ifdef SERVICE_LARGEPACKET + LargePacketTransferService largePacketTransferService; +#endif + +#ifdef SERVICE_MEMORY MemoryManagementService memoryManagement; - TimeManagementService timeManagement; - EventActionService eventAction; - TestService testService; +#endif + +#ifdef SERVICE_PARAMETER ParameterService parameterManagement; - LargePacketTransferService largePacketTransferService; - FunctionManagementService functionManagement; +#endif + +#ifdef SERVICE_REQUESTVERIFICATION + RequestVerificationService requestVerification; +#endif + +#ifdef SERVICE_TEST + TestService testService; +#endif + +#ifdef SERVICE_TIME + TimeManagementService timeManagement; +#endif + +#ifdef SERVICE_TIMESCHEDULING TimeBasedSchedulingService timeBasedScheduling; +#endif /** * The default ServicePool constructor diff --git a/inc/Services/EventReportService.hpp b/inc/Services/EventReportService.hpp index 69b80e80..376b35d4 100644 --- a/inc/Services/EventReportService.hpp +++ b/inc/Services/EventReportService.hpp @@ -13,8 +13,6 @@ * Note: enum IDs are these just for test purposes * */ -#define CSS_EVENTS_MAX_COUNT 16 -#define ECSS_EVENTS_BITS 16 class EventReportService : public Service { private: diff --git a/src/ErrorHandler.cpp b/src/ErrorHandler.cpp index 1cba15ca..be57cb60 100644 --- a/src/ErrorHandler.cpp +++ b/src/ErrorHandler.cpp @@ -6,34 +6,44 @@ template <> void ErrorHandler::reportError(const Message& message, AcceptanceErrorType errorCode) { +#ifdef SERVICE_REQUESTVERIFICATION Services.requestVerification.failAcceptanceVerification(message, errorCode); +#endif logError(message, errorCode); } template <> void ErrorHandler::reportError(const Message& message, ExecutionStartErrorType errorCode) { +#ifdef SERVICE_REQUESTVERIFICATION Services.requestVerification.failStartExecutionVerification(message, errorCode); +#endif logError(message, errorCode); } void ErrorHandler::reportProgressError(const Message& message, ExecutionProgressErrorType errorCode, uint8_t stepID) { +#ifdef SERVICE_REQUESTVERIFICATION Services.requestVerification.failProgressExecutionVerification(message, errorCode, stepID); +#endif logError(message, errorCode); } template <> void ErrorHandler::reportError(const Message& message, ExecutionCompletionErrorType errorCode) { +#ifdef SERVICE_REQUESTVERIFICATION Services.requestVerification.failCompletionExecutionVerification(message, errorCode); +#endif logError(message, errorCode); } template <> void ErrorHandler::reportError(const Message& message, RoutingErrorType errorCode) { +#ifdef SERVICE_REQUESTVERIFICATION Services.requestVerification.failRoutingVerification(message, errorCode); +#endif logError(message, errorCode); } diff --git a/src/MessageParser.cpp b/src/MessageParser.cpp index a9dc0a42..b4eb3953 100644 --- a/src/MessageParser.cpp +++ b/src/MessageParser.cpp @@ -8,30 +8,54 @@ void MessageParser::execute(Message& message) { switch (message.serviceType) { +#ifdef SERVICE_EVENTREPORT case 5: Services.eventReport.execute(message); // ST[05] break; +#endif + +#ifdef SERVICE_MEMORY case 6: Services.memoryManagement.execute(message); // ST[06] break; +#endif + +#ifdef SERVICE_FUNCTION case 8: Services.functionManagement.execute(message); // ST[08] break; +#endif + +#ifdef SERVICE_TIME case 9: Services.timeManagement.execute(message); // ST[09] break; +#endif + +#ifdef SERVICE_TIMESCHEDULING case 11: Services.timeBasedScheduling.execute(message); // ST[11] break; +#endif + +#ifdef SERVICE_TEST case 17: Services.testService.execute(message); // ST[17] break; +#endif + +#ifdef SERVICE_EVENTACTION case 19: Services.eventAction.execute(message); // ST[19] break; +#endif + +#ifdef SERVICE_PARAMETER case 20: Services.parameterManagement.execute(message); // ST[20] break; +#endif + default: ErrorHandler::reportInternalError(ErrorHandler::OtherMessageType); } diff --git a/src/Services/EventActionService.cpp b/src/Services/EventActionService.cpp index bd06114d..f4207979 100644 --- a/src/Services/EventActionService.cpp +++ b/src/Services/EventActionService.cpp @@ -1,3 +1,6 @@ +#include "ECSS_Configuration.hpp" +#ifdef SERVICE_EVENTACTION + #include "Services/EventActionService.hpp" #include "Message.hpp" #include "MessageParser.hpp" @@ -217,3 +220,5 @@ void EventActionService::execute(Message& message) { ErrorHandler::reportInternalError(ErrorHandler::OtherMessageType); } } + +#endif \ No newline at end of file diff --git a/src/Services/EventReportService.cpp b/src/Services/EventReportService.cpp index c805a5fc..ce97f874 100644 --- a/src/Services/EventReportService.cpp +++ b/src/Services/EventReportService.cpp @@ -1,3 +1,6 @@ +#include "ECSS_Configuration.hpp" +#ifdef SERVICE_EVENTREPORT + #include <Services/EventReportService.hpp> #include <Services/EventActionService.hpp> #include "Message.hpp" @@ -144,3 +147,5 @@ void EventReportService::execute(Message& message) { ErrorHandler::reportInternalError(ErrorHandler::OtherMessageType); } } + +#endif diff --git a/src/Services/FunctionManagementService.cpp b/src/Services/FunctionManagementService.cpp index cefd9702..4cee2c0c 100644 --- a/src/Services/FunctionManagementService.cpp +++ b/src/Services/FunctionManagementService.cpp @@ -1,3 +1,6 @@ +#include "ECSS_Configuration.hpp" +#ifdef SERVICE_FUNCTION + #include "Services/FunctionManagementService.hpp" void FunctionManagementService::call(Message& msg) { @@ -57,3 +60,5 @@ void FunctionManagementService::execute(Message& message) { break; } } + +#endif diff --git a/src/Services/LargePacketTransferService.cpp b/src/Services/LargePacketTransferService.cpp index 95b3cafa..38a0a666 100644 --- a/src/Services/LargePacketTransferService.cpp +++ b/src/Services/LargePacketTransferService.cpp @@ -1,3 +1,6 @@ +#include "ECSS_Configuration.hpp" +#ifdef SERVICE_LARGEPACKET + #include <Services/LargePacketTransferService.hpp> #include "Message.hpp" #include <etl/String.hpp> @@ -88,3 +91,5 @@ void LargePacketTransferService::split(Message& message, uint16_t largeMessageTr stringPart = dataPart; lastDownlinkPartReport(largeMessageTransactionIdentifier, (parts - 1U), stringPart); } + +#endif diff --git a/src/Services/MemoryManagementService.cpp b/src/Services/MemoryManagementService.cpp index d592da57..7bee1941 100644 --- a/src/Services/MemoryManagementService.cpp +++ b/src/Services/MemoryManagementService.cpp @@ -1,3 +1,6 @@ +#include "ECSS_Configuration.hpp" +#ifdef SERVICE_MEMORY + #include "Services/MemoryManagementService.hpp" #include <iostream> #include <cerrno> @@ -236,3 +239,5 @@ void MemoryManagementService::execute(Message& message) { ErrorHandler::reportInternalError(ErrorHandler::OtherMessageType); } } + +#endif diff --git a/src/Services/ParameterService.cpp b/src/Services/ParameterService.cpp index 018de09f..aee2de5d 100644 --- a/src/Services/ParameterService.cpp +++ b/src/Services/ParameterService.cpp @@ -1,3 +1,6 @@ +#include "ECSS_Configuration.hpp" +#ifdef SERVICE_PARAMETER + #include "Services/ParameterService.hpp" #define DEMOMODE @@ -131,3 +134,5 @@ void ParameterService::execute(Message& message) { ErrorHandler::reportInternalError(ErrorHandler::OtherMessageType); } } + +#endif diff --git a/src/Services/RequestVerificationService.cpp b/src/Services/RequestVerificationService.cpp index e298a182..56bcdf07 100644 --- a/src/Services/RequestVerificationService.cpp +++ b/src/Services/RequestVerificationService.cpp @@ -1,3 +1,6 @@ +#include "ECSS_Configuration.hpp" +#ifdef SERVICE_REQUESTVERIFICATION + #include "Services/RequestVerificationService.hpp" void RequestVerificationService::successAcceptanceVerification(const Message& request) { @@ -147,3 +150,5 @@ void RequestVerificationService::failRoutingVerification(const Message& request, storeMessage(report); } + +#endif diff --git a/src/Services/TestService.cpp b/src/Services/TestService.cpp index 001726da..53a42b10 100644 --- a/src/Services/TestService.cpp +++ b/src/Services/TestService.cpp @@ -1,3 +1,6 @@ +#include "ECSS_Configuration.hpp" +#ifdef SERVICE_TEST + #include "Services/TestService.hpp" void TestService::areYouAlive(Message& request) { @@ -30,3 +33,5 @@ void TestService::execute(Message& message) { ErrorHandler::reportInternalError(ErrorHandler::OtherMessageType); } } + +#endif diff --git a/src/Services/TimeBasedSchedulingService.cpp b/src/Services/TimeBasedSchedulingService.cpp index d381318e..b88e04ec 100644 --- a/src/Services/TimeBasedSchedulingService.cpp +++ b/src/Services/TimeBasedSchedulingService.cpp @@ -1,3 +1,6 @@ +#include "ECSS_Configuration.hpp" +#ifdef SERVICE_TIMESCHEDULING + #include "Services/TimeBasedSchedulingService.hpp" TimeBasedSchedulingService::TimeBasedSchedulingService() { @@ -293,3 +296,5 @@ void TimeBasedSchedulingService::execute(Message& message) { ErrorHandler::reportInternalError(ErrorHandler::OtherMessageType); } } + +#endif diff --git a/src/Services/TimeManagementService.cpp b/src/Services/TimeManagementService.cpp index 9e281450..d1206195 100644 --- a/src/Services/TimeManagementService.cpp +++ b/src/Services/TimeManagementService.cpp @@ -1,3 +1,6 @@ +#include "ECSS_Configuration.hpp" +#ifdef SERVICE_TIME + #include "Services/TimeManagementService.hpp" void TimeManagementService::cdsTimeReport(TimeAndDate& TimeInfo) { @@ -35,3 +38,5 @@ void TimeManagementService::execute(Message& message) { break; } } + +#endif -- GitLab