From 6fe17a7c11d6362d37f01fbd34771317d8de982b Mon Sep 17 00:00:00 2001 From: thodkatz <thodkatz@gmail.com> Date: Thu, 24 Jan 2019 11:06:22 +0200 Subject: [PATCH] Update the ErrorHandler so it corresponds with ST[01] --- inc/ErrorHandler.hpp | 25 +++++++++++++++++++-- inc/Services/RequestVerificationService.hpp | 7 +++--- src/ErrorHandler.cpp | 16 ++++++++++++- src/Services/RequestVerificationService.cpp | 6 ++--- src/main.cpp | 9 +++++--- 5 files changed, 51 insertions(+), 12 deletions(-) diff --git a/inc/ErrorHandler.hpp b/inc/ErrorHandler.hpp index df687ad4..781bc299 100644 --- a/inc/ErrorHandler.hpp +++ b/inc/ErrorHandler.hpp @@ -89,14 +89,35 @@ public: UnacceptableMessage = 5, }; + /** + * The error code for failed start of execution reports, as specified in ECSS 5.3.5.2.3g + * + * Note: Numbers are kept in code explicitly, so that there is no uncertainty when something + * changes. + */ + enum StartExecutionErrorType { + UnknownStartExecutionError = 0, + }; + + /** + * The error code for failed progress of execution reports, as specified in ECSS 5.3.5.2.3g + * + * Note: Numbers are kept in code explicitly, so that there is no uncertainty when something + * changes. + */ + enum ProgressExecutionErrorType { + UnknownProgressExecutionError = 0, + }; + + /** * The error code for failed completion of execution reports, as specified in ECSS 5.3.5.2.3g * * Note: Numbers are kept in code explicitly, so that there is no uncertainty when something * changes. */ - enum ExecutionErrorType { - UnknownExecutionError = 0, + enum CompletionExecutionErrorType { + UnknownCompletionExecutionError = 0, /** * Checksum comparison failed */ diff --git a/inc/Services/RequestVerificationService.hpp b/inc/Services/RequestVerificationService.hpp index 6fef8a64..a1a62922 100644 --- a/inc/Services/RequestVerificationService.hpp +++ b/inc/Services/RequestVerificationService.hpp @@ -57,7 +57,8 @@ public: * The data is actually some data members of Message that contain the basic info * of the telecommand packet that its start of execution has failed */ - void failStartExecutionVerification(const Message &request, ErrorHandler::ExecutionErrorType + void failStartExecutionVerification(const Message &request, + ErrorHandler::StartExecutionErrorType errorCode); /** @@ -77,7 +78,7 @@ public: * of the telecommand packet that its progress of execution has failed */ void failProgressExecutionVerification(const Message &request, - ErrorHandler::ExecutionErrorType errorCode); + ErrorHandler::ProgressExecutionErrorType errorCode); /** * TM[1,7] successful completion of execution verification report @@ -96,7 +97,7 @@ public: * telecommand packet that failed to be executed completely */ void failCompletionExecutionVerification(const Message &request, - ErrorHandler::ExecutionErrorType errorCode); + ErrorHandler::CompletionExecutionErrorType errorCode); /** * TM[1,10] failed routing verification report diff --git a/src/ErrorHandler.cpp b/src/ErrorHandler.cpp index 1cb8e686..b17123f1 100644 --- a/src/ErrorHandler.cpp +++ b/src/ErrorHandler.cpp @@ -15,7 +15,21 @@ void ErrorHandler::reportError(const Message &message, AcceptanceErrorType error } template<> -void ErrorHandler::reportError(const Message &message, ExecutionErrorType errorCode) { +void ErrorHandler::reportError(const Message &message, StartExecutionErrorType errorCode) { + requestVerificationService.failStartExecutionVerification(message, errorCode); + + logError(message, errorCode); +} + +template<> +void ErrorHandler::reportError(const Message &message, ProgressExecutionErrorType errorCode) { + requestVerificationService.failProgressExecutionVerification(message, errorCode); + + logError(message, errorCode); +} + +template<> +void ErrorHandler::reportError(const Message &message, CompletionExecutionErrorType errorCode) { requestVerificationService.failCompletionExecutionVerification(message, errorCode); logError(message, errorCode); diff --git a/src/Services/RequestVerificationService.cpp b/src/Services/RequestVerificationService.cpp index 3a2ed7b7..dcc6b107 100644 --- a/src/Services/RequestVerificationService.cpp +++ b/src/Services/RequestVerificationService.cpp @@ -50,7 +50,7 @@ void RequestVerificationService::successStartExecutionVerification(const Message } void RequestVerificationService::failStartExecutionVerification(const Message &request, - ErrorHandler::ExecutionErrorType errorCode) { + ErrorHandler::StartExecutionErrorType errorCode) { // TM[1,4] failed start of execution verification report Message report = createTM(4); @@ -82,7 +82,7 @@ void RequestVerificationService::successProgressExecutionVerification(const Mess } void RequestVerificationService::failProgressExecutionVerification(const Message &request, - ErrorHandler::ExecutionErrorType errorCode) { + ErrorHandler::ProgressExecutionErrorType errorCode) { // TM[1,6] failed progress of execution verification report Message report = createTM(6); @@ -115,7 +115,7 @@ void RequestVerificationService::successCompletionExecutionVerification(const Me void RequestVerificationService::failCompletionExecutionVerification(const Message &request, - ErrorHandler::ExecutionErrorType errorCode) { + ErrorHandler::CompletionExecutionErrorType errorCode) { // TM[1,8] failed completion of execution verification report Message report = createTM(8); diff --git a/src/main.cpp b/src/main.cpp index 1b395c00..4201d756 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -123,19 +123,22 @@ int main() { reqVerifService.successStartExecutionVerification(receivedMessage); receivedMessage = Message(1, 4, Message::TC, 3); - reqVerifService.failStartExecutionVerification(receivedMessage, ErrorHandler::UnknownExecutionError); + reqVerifService.failStartExecutionVerification(receivedMessage, + ErrorHandler::UnknownStartExecutionError); receivedMessage = Message(1, 5, Message::TC, 3); reqVerifService.successProgressExecutionVerification(receivedMessage); receivedMessage = Message(1, 6, Message::TC, 3); - reqVerifService.failProgressExecutionVerification(receivedMessage, ErrorHandler::UnknownExecutionError); + reqVerifService.failProgressExecutionVerification(receivedMessage, + ErrorHandler::UnknownProgressExecutionError); receivedMessage = Message(1, 7, Message::TC, 3); reqVerifService.successCompletionExecutionVerification(receivedMessage); receivedMessage = Message(1, 8, Message::TC, 3); - reqVerifService.failCompletionExecutionVerification(receivedMessage, ErrorHandler::UnknownExecutionError); + reqVerifService.failCompletionExecutionVerification(receivedMessage, + ErrorHandler::UnknownCompletionExecutionError); receivedMessage = Message(1, 10, Message::TC, 3); reqVerifService.failRoutingVerification(receivedMessage, ErrorHandler::UnknownRoutingError); -- GitLab