From 88bbde520b5291c5ca5f8fe336f2dbd27b12db39 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 17 Oct 2022 16:37:35 +0200 Subject: [PATCH] pus TM funnel initialize not needed anymore --- example/core/GenericFactory.cpp | 2 +- example/utility/PusTmFunnel.cpp | 28 +++++++--------------------- example/utility/PusTmFunnel.h | 9 ++++----- 3 files changed, 12 insertions(+), 27 deletions(-) diff --git a/example/core/GenericFactory.cpp b/example/core/GenericFactory.cpp index 2712ef2..9cb2ce2 100644 --- a/example/core/GenericFactory.cpp +++ b/example/core/GenericFactory.cpp @@ -63,7 +63,7 @@ void ObjectFactory::produceGenericObjects(PusTmFunnel **pusFunnel, *ccsdsDistrib = new CcsdsDistributor(common::COMMON_PUS_APID, objects::CCSDS_DISTRIBUTOR, &tcStore); new PusDistributor(common::COMMON_PUS_APID, objects::PUS_DISTRIBUTOR, *ccsdsDistrib); - *pusFunnel = new PusTmFunnel(objects::PUS_TM_FUNNEL, tmtcBridge, *stamperAndReader); + *pusFunnel = new PusTmFunnel(objects::PUS_TM_FUNNEL, tmtcBridge, *stamperAndReader, tmStore); auto *cfdpFunnel = new CfdpTmFunnel(objects::CFDP_TM_FUNNEL, tmtcBridge, tmStore); new TmFunnel(objects::TM_FUNNEL, **pusFunnel, *cfdpFunnel); #endif /* OBSW_ADD_CORE_COMPONENTS == 1 */ diff --git a/example/utility/PusTmFunnel.cpp b/example/utility/PusTmFunnel.cpp index 6e0a14f..78f0de8 100644 --- a/example/utility/PusTmFunnel.cpp +++ b/example/utility/PusTmFunnel.cpp @@ -5,8 +5,8 @@ #include "fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h" PusTmFunnel::PusTmFunnel(object_id_t objectId, const AcceptsTelemetryIF &downlinkDestination, - TimeReaderIF &timeReader, uint32_t messageDepth) - : SystemObject(objectId), timeReader(timeReader) { + TimeReaderIF &timeReader, StorageManagerIF& tmStore, uint32_t messageDepth) + : SystemObject(objectId), timeReader(timeReader), tmStore(tmStore) { tmQueue = QueueFactory::instance()->createMessageQueue(messageDepth, MessageQueueMessage::MAX_MESSAGE_SIZE); tmQueue->setDefaultDestination(downlinkDestination.getReportReceptionQueue()); @@ -22,7 +22,7 @@ ReturnValue_t PusTmFunnel::performOperation(uint8_t) { TmTcMessage currentMessage; ReturnValue_t status = tmQueue->receiveMessage(¤tMessage); while (status == returnvalue::OK) { - status = handlePacket(¤tMessage); + status = handlePacket(currentMessage); if (status != returnvalue::OK) { sif::warning << "TmFunnel packet handling failed" << std::endl; break; @@ -36,10 +36,10 @@ ReturnValue_t PusTmFunnel::performOperation(uint8_t) { return status; } -ReturnValue_t PusTmFunnel::handlePacket(TmTcMessage *message) { +ReturnValue_t PusTmFunnel::handlePacket(TmTcMessage& message) { uint8_t *packetData = nullptr; size_t size = 0; - ReturnValue_t result = tmPool->modifyData(message->getStorageId(), &packetData, &size); + ReturnValue_t result = tmStore.modifyData(message.getStorageId(), &packetData, &size); if (result != returnvalue::OK) { return result; } @@ -52,9 +52,9 @@ ReturnValue_t PusTmFunnel::handlePacket(TmTcMessage *message) { sourceSequenceCount = sourceSequenceCount % ccsds::LIMIT_SEQUENCE_COUNT; packet.updateErrorControl(); - result = tmQueue->sendToDefault(message); + result = tmQueue->sendToDefault(&message); if (result != returnvalue::OK) { - tmPool->deleteData(message->getStorageId()); + tmStore.deleteData(message.getStorageId()); #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TmFunnel::handlePacket: Error sending TM to downlink handler" << std::endl; #endif @@ -64,18 +64,4 @@ ReturnValue_t PusTmFunnel::handlePacket(TmTcMessage *message) { return result; } -ReturnValue_t PusTmFunnel::initialize() { - tmPool = ObjectManager::instance()->get(objects::TM_STORE); - if (tmPool == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "TmFunnel::initialize: TM store not set." << std::endl; - sif::error << "Make sure the tm store is set up properly and implements " - "StorageManagerIF" - << std::endl; -#endif - return ObjectManagerIF::CHILD_INIT_FAILED; - } - return SystemObject::initialize(); -} - const char *PusTmFunnel::getName() const { return "PUS TM Funnel"; } diff --git a/example/utility/PusTmFunnel.h b/example/utility/PusTmFunnel.h index c0b50f2..ae2e856 100644 --- a/example/utility/PusTmFunnel.h +++ b/example/utility/PusTmFunnel.h @@ -20,21 +20,20 @@ class PusTmFunnel : public AcceptsTelemetryIF, public SystemObject { public: explicit PusTmFunnel(object_id_t objectId, const AcceptsTelemetryIF &downlinkDestination, - TimeReaderIF &timeReader, uint32_t messageDepth = 20); + TimeReaderIF &timeReader, StorageManagerIF& tmStore, + uint32_t messageDepth = 20); [[nodiscard]] const char *getName() const override; ~PusTmFunnel() override; [[nodiscard]] MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) const override; ReturnValue_t performOperation(uint8_t operationCode); - ReturnValue_t initialize() override; private: uint16_t sourceSequenceCount = 0; TimeReaderIF &timeReader; + StorageManagerIF& tmStore; MessageQueueIF *tmQueue = nullptr; - StorageManagerIF *tmPool = nullptr; - - ReturnValue_t handlePacket(TmTcMessage *message); + ReturnValue_t handlePacket(TmTcMessage& message); }; #endif // FSFW_EXAMPLE_COMMON_PUSTMFUNNEL_H