diff --git a/inc/ErrorHandler.hpp b/inc/ErrorHandler.hpp index 6f6d4a326ee89e59516eb79e86ff4e9e0a543575..0fc021edd5467b51c8d4b035b44668351bdb8612 100644 --- a/inc/ErrorHandler.hpp +++ b/inc/ErrorHandler.hpp @@ -86,7 +86,7 @@ public: /** * Cannot parse a Message, because there is an error in its secondary header */ - UnacceptableMessage = 5, + UnacceptableMessage = 5, }; /** @@ -109,6 +109,16 @@ public: UnknownProgressExecutionError = 0, }; + /** + * This enumeration type corresponds with reports about the progress of the execution + * of a request. For example if the execution of a request is a long process, then we can divide + * the process into steps and take feedback that depends on the step identifier + * @todo configure step ID for the suitable requests + */ + enum stepID { + UnknownStepID = 0 + }; + /** * The error code for failed completion of execution reports, as specified in ECSS 5.3.5.2.3g @@ -154,7 +164,7 @@ public: * Report a failure and, if applicable, store a failure report message * * @tparam ErrorType The Type struct of the error; can be AcceptanceErrorType, - * ExecutionErrorType, or RoutingErrorType. + * StartExecutionErrorType,CompletionExecutionErrorType, or RoutingErrorType. * @param message The incoming message that prompted the failure * @param errorCode The error's code, as defined in ErrorHandler * @todo See if this needs to include InternalErrorType @@ -162,6 +172,20 @@ public: template<typename ErrorType> static void reportError(const Message &message, ErrorType errorCode); + /** + * Report a failure about the progress of the execution of a request + * + * Note:This function is different from reportError, because we need one more /p(stepID) + * to call the proper function for reporting the progress of the execution of a request + * + * @param message The incoming message that prompted the failure + * @param errorCode The error's code, when a failed progress of the execution of a request + * occurs + * @param step Step identifier + */ + static void reportProgressError(const Message &message, ProgressExecutionErrorType errorCode, + stepID step); + /** * Report a failure that occurred internally, not due to a failure of a received packet. * diff --git a/inc/Message.hpp b/inc/Message.hpp index 0d4aa67d8e47cd6ee6045a48015991f93d78bf3d..17f64e3615899edebed5b4f3603d3fd0d7f1c9f3 100644 --- a/inc/Message.hpp +++ b/inc/Message.hpp @@ -1,6 +1,7 @@ #ifndef ECSS_SERVICES_PACKET_H #define ECSS_SERVICES_PACKET_H + // Forward declaration of the Message class, needed for the ErrorHandler class Message; diff --git a/inc/Services/RequestVerificationService.hpp b/inc/Services/RequestVerificationService.hpp index 9bd354823fd809486799e74cb0080df00297a967..8da73dd3874546de8346d6187bb2a513248b6281 100644 --- a/inc/Services/RequestVerificationService.hpp +++ b/inc/Services/RequestVerificationService.hpp @@ -70,7 +70,7 @@ public: * The data is actually some data members of Message that contain the basic info * of the telecommand packet that its progress of execution is successful */ - void successProgressExecutionVerification(const Message &request); + void successProgressExecutionVerification(const Message &request, ErrorHandler::stepID step); /** * TM[1,6] failed progress of execution verification report @@ -81,7 +81,7 @@ public: * @param errorCode The cause of creating this type of report */ void failProgressExecutionVerification(const Message &request, - ErrorHandler::ProgressExecutionErrorType errorCode); + ErrorHandler::ProgressExecutionErrorType errorCode, ErrorHandler::stepID step); /** * TM[1,7] successful completion of execution verification report diff --git a/src/ErrorHandler.cpp b/src/ErrorHandler.cpp index b17123f153289e599caac5196c767491db4506c7..0c9f69b23841213c6a9892f6e7bf4da3f48524cc 100644 --- a/src/ErrorHandler.cpp +++ b/src/ErrorHandler.cpp @@ -1,9 +1,9 @@ #include <iostream> #include <cxxabi.h> #include <ErrorHandler.hpp> - #include "Services/RequestVerificationService.hpp" + // TODO: Use service singleton, as soon as singletons are ready static RequestVerificationService requestVerificationService; @@ -21,9 +21,9 @@ void ErrorHandler::reportError(const Message &message, StartExecutionErrorType e logError(message, errorCode); } -template<> -void ErrorHandler::reportError(const Message &message, ProgressExecutionErrorType errorCode) { - requestVerificationService.failProgressExecutionVerification(message, errorCode); +void ErrorHandler::reportProgressError(const Message &message, ProgressExecutionErrorType +errorCode, stepID step) { + requestVerificationService.failProgressExecutionVerification(message, errorCode, step); logError(message, errorCode); } diff --git a/src/Services/RequestVerificationService.cpp b/src/Services/RequestVerificationService.cpp index dcc6b107596b2d7f804b9d4de70126bd7dc43673..8b001216c5d20bfa04060bad709ec18d6e723d95 100644 --- a/src/Services/RequestVerificationService.cpp +++ b/src/Services/RequestVerificationService.cpp @@ -66,7 +66,8 @@ void RequestVerificationService::failStartExecutionVerification(const Message &r storeMessage(report); } -void RequestVerificationService::successProgressExecutionVerification(const Message &request) { +void RequestVerificationService::successProgressExecutionVerification(const Message &request, + ErrorHandler::stepID step) { // TM[1,5] successful progress of execution verification report Message report = createTM(5); @@ -77,12 +78,13 @@ void RequestVerificationService::successProgressExecutionVerification(const Mess report.appendEnumerated(11, request.applicationId); // application process ID report.appendEnumerated(2, ECSS_SEQUENCE_FLAGS); // sequence flags(not implemented) report.appendBits(14, 0); // packet sequence count(not implemented) + report.appendEnum16(step); // step ID storeMessage(report); } void RequestVerificationService::failProgressExecutionVerification(const Message &request, - ErrorHandler::ProgressExecutionErrorType errorCode) { + ErrorHandler::ProgressExecutionErrorType errorCode, ErrorHandler::stepID step) { // TM[1,6] failed progress of execution verification report Message report = createTM(6); @@ -93,6 +95,7 @@ void RequestVerificationService::failProgressExecutionVerification(const Message report.appendEnumerated(11, request.applicationId); // application process ID report.appendEnumerated(2, ECSS_SEQUENCE_FLAGS); // sequence flags(not implemented) report.appendBits(14, 0); // packet sequence count(not implemented) + report.appendEnum16(step); // step ID report.appendEnum16(errorCode); // error code storeMessage(report); diff --git a/src/main.cpp b/src/main.cpp index 4201d756874abc1bd78c81f0de16dbf4e4c4ce36..de0632cc0e0ab82925a82569901dc4cf3748a3a6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -127,11 +127,12 @@ int main() { ErrorHandler::UnknownStartExecutionError); receivedMessage = Message(1, 5, Message::TC, 3); - reqVerifService.successProgressExecutionVerification(receivedMessage); + reqVerifService.successProgressExecutionVerification(receivedMessage, + ErrorHandler::UnknownStepID); receivedMessage = Message(1, 6, Message::TC, 3); reqVerifService.failProgressExecutionVerification(receivedMessage, - ErrorHandler::UnknownProgressExecutionError); + ErrorHandler::UnknownProgressExecutionError, ErrorHandler::UnknownStepID); receivedMessage = Message(1, 7, Message::TC, 3); reqVerifService.successCompletionExecutionVerification(receivedMessage);