diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index 0e58e1ec..ddd29bb9 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -80,6 +80,7 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFun auto* timeStamper = new CdsShortTimeStamper(objects::TIME_STAMPER); StorageManagerIF* tcStore; StorageManagerIF* tmStore; + StorageManagerIF* ipcStore; { PoolManager::LocalPoolConfig poolCfg = {{250, 16}, {250, 32}, {250, 64}, {150, 128}, {120, 1024}, {120, 2048}}; @@ -95,7 +96,7 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFun { PoolManager::LocalPoolConfig poolCfg = {{300, 16}, {200, 32}, {150, 64}, {150, 128}, {100, 256}, {50, 512}, {50, 1024}, {10, 2048}}; - new PoolManager(objects::IPC_STORE, poolCfg); + ipcStore = new PoolManager(objects::IPC_STORE, poolCfg); } #if OBSW_ADD_TCPIP_SERVERS == 1 @@ -121,8 +122,10 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFun new CcsdsDistributor(config::EIVE_PUS_APID, objects::CCSDS_PACKET_DISTRIBUTOR); new PusDistributor(config::EIVE_PUS_APID, objects::PUS_PACKET_DISTRIBUTOR, ccsdsDistrib); - *cfdpFunnel = new CfdpTmFunnel(objects::CFDP_TM_FUNNEL, config::EIVE_CFDP_APID, *tmStore, 50, 15); - *pusFunnel = new PusTmFunnel(objects::PUS_TM_FUNNEL, *timeStamper, *tmStore, sdcMan, 80, 15); + *cfdpFunnel = new CfdpTmFunnel(objects::CFDP_TM_FUNNEL, config::EIVE_CFDP_APID, *tmStore, 50, 15, + *ipcStore); + *pusFunnel = + new PusTmFunnel(objects::PUS_TM_FUNNEL, *timeStamper, *tmStore, sdcMan, 80, 15, *ipcStore); #if OBSW_ADD_TCPIP_SERVERS == 1 #if OBSW_ADD_TMTC_UDP_SERVER == 1 (*cfdpFunnel)->addDestination(*udpBridge, 0); diff --git a/mission/tmtc/CfdpTmFunnel.cpp b/mission/tmtc/CfdpTmFunnel.cpp index e5080b71..f2d31a92 100644 --- a/mission/tmtc/CfdpTmFunnel.cpp +++ b/mission/tmtc/CfdpTmFunnel.cpp @@ -5,8 +5,10 @@ #include "fsfw/tmtcservices/TmTcMessage.h" CfdpTmFunnel::CfdpTmFunnel(object_id_t objectId, uint16_t cfdpInCcsdsApid, - StorageManagerIF& tmStore, uint32_t tmMsgDepth, uint32_t tcMsgDepth) - : TmFunnelBase(objectId, tmStore, tmMsgDepth, tcMsgDepth), cfdpInCcsdsApid(cfdpInCcsdsApid) {} + StorageManagerIF& tmStore, uint32_t tmMsgDepth, uint32_t tcMsgDepth, + StorageManagerIF& ipcStore) + : TmFunnelBase(objectId, tmStore, tmMsgDepth, tcMsgDepth, ipcStore), + cfdpInCcsdsApid(cfdpInCcsdsApid) {} const char* CfdpTmFunnel::getName() const { return "CFDP TM Funnel"; } diff --git a/mission/tmtc/CfdpTmFunnel.h b/mission/tmtc/CfdpTmFunnel.h index 32d16975..55917727 100644 --- a/mission/tmtc/CfdpTmFunnel.h +++ b/mission/tmtc/CfdpTmFunnel.h @@ -13,7 +13,7 @@ class CfdpTmFunnel : public TmFunnelBase { public: CfdpTmFunnel(object_id_t objectId, uint16_t cfdpInCcsdsApid, StorageManagerIF& tmStore, - uint32_t tmMsgDepth, uint32_t tcMsgDepth); + uint32_t tmMsgDepth, uint32_t tcMsgDepth, StorageManagerIF& ipcStore); [[nodiscard]] const char* getName() const override; ReturnValue_t performOperation(uint8_t opCode); ReturnValue_t initialize() override; diff --git a/mission/tmtc/PusTmFunnel.cpp b/mission/tmtc/PusTmFunnel.cpp index a3e6f144..ff662afd 100644 --- a/mission/tmtc/PusTmFunnel.cpp +++ b/mission/tmtc/PusTmFunnel.cpp @@ -9,8 +9,9 @@ #include "fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h" PusTmFunnel::PusTmFunnel(object_id_t objectId, TimeReaderIF &timeReader, StorageManagerIF &tmStore, - SdCardMountedIF &sdcMan, uint32_t tmMsgDepth, uint32_t tcMsgDepth) - : TmFunnelBase(objectId, tmStore, tmMsgDepth, tcMsgDepth), + SdCardMountedIF &sdcMan, uint32_t tmMsgDepth, uint32_t tcMsgDepth, + StorageManagerIF &ipcStore) + : TmFunnelBase(objectId, tmStore, tmMsgDepth, tcMsgDepth, ipcStore), timeReader(timeReader), miscStore(objects::MISC_TM_STORE, "tm", "misc", RolloverInterval::HOURLY, 2, currentTv, sdcMan), @@ -51,24 +52,43 @@ ReturnValue_t PusTmFunnel::performOperation(uint8_t) { CommandMessage cmdMessage; ReturnValue_t status = tcQueue->receiveMessage(&cmdMessage); while (status == returnvalue::OK) { - if (cmdMessage.getCommand() == messagetypes::TM_STORE) { + if (cmdMessage.getMessageType() == messagetypes::TM_STORE) { + Command_t cmd = cmdMessage.getCommand(); object_id_t objectId = TmStoreMessage::getObjectId(&cmdMessage); + TmStore *tmStore = nullptr; switch (objectId) { case (objects::HK_TM_STORE): { + tmStore = &hkStore; break; } case (objects::OK_TM_STORE): { + tmStore = &okStore; break; } case (objects::NOT_OK_TM_STORE): { + tmStore = ¬OkStore; break; } case (objects::MISC_TM_STORE): { + tmStore = &miscStore; break; } default: { } } + if (tmStore == nullptr) { + continue; + } + if (cmd == TmStoreMessage::DELETE_STORE_CONTENT_TIME) { + store_address_t storeId = TmStoreMessage::getStoreId(&cmdMessage); + auto accessor = ipcStore.getData(storeId); + uint32_t deleteUpToUnixSeconds = 0; + size_t size = accessor.second.size(); + SerializeAdapter::deSerialize(&deleteUpToUnixSeconds, accessor.second.data(), &size, + SerializeIF::Endianness::NETWORK); + tmStore->deleteUpTo(deleteUpToUnixSeconds); + } else if (cmd == TmStoreMessage::DOWNLINK_STORE_CONTENT_TIME) { + } } } TmTcMessage currentMessage; diff --git a/mission/tmtc/PusTmFunnel.h b/mission/tmtc/PusTmFunnel.h index a54093c2..464db37c 100644 --- a/mission/tmtc/PusTmFunnel.h +++ b/mission/tmtc/PusTmFunnel.h @@ -23,7 +23,8 @@ class PusTmFunnel : public TmFunnelBase { public: explicit PusTmFunnel(object_id_t objectId, TimeReaderIF &timeReader, StorageManagerIF &tmStore, - SdCardMountedIF &sdcMan, uint32_t tmMsgDepth, uint32_t tcMsgDepth); + SdCardMountedIF &sdcMan, uint32_t tmMsgDepth, uint32_t tcMsgDepth, + StorageManagerIF &ipcStore); [[nodiscard]] const char *getName() const override; ~PusTmFunnel() override; diff --git a/mission/tmtc/TmFunnelBase.cpp b/mission/tmtc/TmFunnelBase.cpp index 156e4664..b4bf6c62 100644 --- a/mission/tmtc/TmFunnelBase.cpp +++ b/mission/tmtc/TmFunnelBase.cpp @@ -3,8 +3,8 @@ #include "fsfw/ipc/QueueFactory.h" TmFunnelBase::TmFunnelBase(object_id_t objectId, StorageManagerIF &tmStore, uint32_t tmMsgDepth, - uint32_t tcMsgDepth) - : SystemObject(objectId), tmStore(tmStore) { + uint32_t tcMsgDepth, StorageManagerIF &ipcStore) + : SystemObject(objectId), tmStore(tmStore), ipcStore(ipcStore) { tmQueue = QueueFactory::instance()->createMessageQueue(tmMsgDepth); tcQueue = QueueFactory::instance()->createMessageQueue(tcMsgDepth); } diff --git a/mission/tmtc/TmFunnelBase.h b/mission/tmtc/TmFunnelBase.h index 271c17c0..12453cc2 100644 --- a/mission/tmtc/TmFunnelBase.h +++ b/mission/tmtc/TmFunnelBase.h @@ -13,7 +13,7 @@ class TmFunnelBase : public TmStoreFrontendSimpleIF, public SystemObject { public: TmFunnelBase(object_id_t objectId, StorageManagerIF& tmStore, uint32_t tmMsgDepth, - uint32_t tcMsgDepth); + uint32_t tcMsgDepth, StorageManagerIF& ipcStore); void addDestination(const AcceptsTelemetryIF& downlinkDestination, uint8_t vcid = 0); [[nodiscard]] MessageQueueId_t getCommandQueue() const override; @@ -23,6 +23,7 @@ class TmFunnelBase : public TmStoreFrontendSimpleIF, protected: StorageManagerIF& tmStore; + StorageManagerIF& ipcStore; std::vector> destinations; MessageQueueIF* tcQueue = nullptr; MessageQueueIF* tmQueue = nullptr;