diff --git a/src/fsfw/tmtcservices/VerificationReporter.cpp b/src/fsfw/tmtcservices/VerificationReporter.cpp index 25d7cd4af..9c38b3a7a 100644 --- a/src/fsfw/tmtcservices/VerificationReporter.cpp +++ b/src/fsfw/tmtcservices/VerificationReporter.cpp @@ -5,6 +5,7 @@ #include "fsfw/tmtcservices/PusVerificationReport.h" object_id_t VerificationReporter::DEFAULT_RECEIVER = objects::PUS_SERVICE_1_VERIFICATION; +object_id_t VerificationReporter::DEFAULT_REPORTER = objects::TC_VERIFICATOR; VerificationReporter::VerificationReporter(AcceptsVerifyMessageIF* receiver, object_id_t objectId) : SystemObject(objectId) { diff --git a/src/fsfw/tmtcservices/VerificationReporter.h b/src/fsfw/tmtcservices/VerificationReporter.h index 8b224808a..78c60962d 100644 --- a/src/fsfw/tmtcservices/VerificationReporter.h +++ b/src/fsfw/tmtcservices/VerificationReporter.h @@ -8,6 +8,10 @@ #include "fsfw/tmtcpacket/pus/tc/PusTcCreator.h" #include "fsfw/tmtcservices/AcceptsVerifyMessageIF.h" +namespace Factory { +void setStaticFrameworkObjectIds(); +} + /** * @brief This helper object is used to forward verification messages * which are generated by the Flight Software Framework. @@ -20,9 +24,11 @@ * */ class VerificationReporter : public SystemObject, public VerificationReporterIF { + friend void Factory::setStaticFrameworkObjectIds(); + public: explicit VerificationReporter(AcceptsVerifyMessageIF* receiver, - object_id_t objectId = objects::TC_VERIFICATOR); + object_id_t objectId = DEFAULT_REPORTER); ~VerificationReporter() override; void setReceiver(AcceptsVerifyMessageIF& receiver); @@ -33,6 +39,7 @@ class VerificationReporter : public SystemObject, public VerificationReporterIF ReturnValue_t sendFailureReport(VerifFailureParams params) override; + static object_id_t DEFAULT_REPORTER; static object_id_t DEFAULT_RECEIVER; ReturnValue_t initialize() override; diff --git a/unittests/mocks/PusVerificationReporterMock.cpp b/unittests/mocks/PusVerificationReporterMock.cpp index 87b37a5a0..c811d38ed 100644 --- a/unittests/mocks/PusVerificationReporterMock.cpp +++ b/unittests/mocks/PusVerificationReporterMock.cpp @@ -1,5 +1,13 @@ #include "PusVerificationReporterMock.h" +#include "fsfw/objectmanager/frameworkObjects.h" + +PusVerificationReporterMock::PusVerificationReporterMock() + : SystemObject(objects::NO_OBJECT, false) {} + +PusVerificationReporterMock::PusVerificationReporterMock(object_id_t registeredId) + : SystemObject(registeredId) {} + size_t PusVerificationReporterMock::successCallCount() const { return successParams.size(); } size_t PusVerificationReporterMock::failCallCount() const { return failParams.size(); } diff --git a/unittests/mocks/PusVerificationReporterMock.h b/unittests/mocks/PusVerificationReporterMock.h index 5bbd36cc4..dedfd30e8 100644 --- a/unittests/mocks/PusVerificationReporterMock.h +++ b/unittests/mocks/PusVerificationReporterMock.h @@ -3,13 +3,15 @@ #include +#include "fsfw/objectmanager/SystemObject.h" #include "fsfw/tmtcservices/VerificationReporterIF.h" -class PusVerificationReporterMock : public VerificationReporterIF { +class PusVerificationReporterMock : public SystemObject, public VerificationReporterIF { public: std::queue successParams; std::queue failParams; - + PusVerificationReporterMock(); + explicit PusVerificationReporterMock(object_id_t registeredId); [[nodiscard]] size_t successCallCount() const; VerifSuccessParams& getNextSuccessCallParams(); void popNextSuccessParams(); diff --git a/unittests/tmtcservices/testPsb.cpp b/unittests/tmtcservices/testPsb.cpp index 53b84b3c4..ea1991f01 100644 --- a/unittests/tmtcservices/testPsb.cpp +++ b/unittests/tmtcservices/testPsb.cpp @@ -161,6 +161,15 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") { REQUIRE(sendHelper.getDefaultDestination() == msgQueue.getDefaultDestination()); } + SECTION("TM Store And Send Helper Initializer") { + TmStoreHelper storeHelper(0); + TmSendHelper sendHelper; + psb.initializeTmHelpers(sendHelper, storeHelper); + REQUIRE(sendHelper.getMsgQueue() == &msgQueue); + REQUIRE(sendHelper.getDefaultDestination() == msgQueue.getDefaultDestination()); + REQUIRE(storeHelper.getApid() == apid); + } + SECTION("TM Send Helper Initializer With Error Reporter") { TmSendHelper sendHelper; auto errReporter = InternalErrorReporterMock(); @@ -195,4 +204,19 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") { auto& p = psb2.getParams(); REQUIRE(p.tmReceiver == &packetDest); } + + SECTION("Auto Initialize Verification Reporter") { + psbParams.verifReporter = nullptr; + psbParams.objectId = 1; + object_id_t reporterId = objects::TC_VERIFICATOR; + PusVerificationReporterMock otherReporter(reporterId); + auto psb2 = PsbMock(psbParams); + REQUIRE(psb2.initialize() == retval::OK); + auto& p = psb2.getParams(); + REQUIRE(p.verifReporter == &otherReporter); + } + + SECTION("Auto Initialize TC Pool") {} + + SECTION("Invalid Verification Reporter") {} }