From 3965c08bfb7afb2bacd37a5082d368c5ad5d2421 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 13 Dec 2022 14:19:43 +0100 Subject: [PATCH] add misc store --- bsp_q7s/fmObjectFactory.cpp | 3 ++- common/config/eive/objects.h | 1 + mission/core/GenericFactory.cpp | 4 ++-- mission/core/GenericFactory.h | 4 +++- mission/tmtc/PusTmFunnel.cpp | 7 +++++-- mission/tmtc/PusTmFunnel.h | 4 +++- mission/tmtc/TmStore.cpp | 19 ++++++++++++++++--- mission/tmtc/TmStore.h | 6 ++++-- 8 files changed, 36 insertions(+), 12 deletions(-) diff --git a/bsp_q7s/fmObjectFactory.cpp b/bsp_q7s/fmObjectFactory.cpp index c56dcf8d..e14dcbe6 100644 --- a/bsp_q7s/fmObjectFactory.cpp +++ b/bsp_q7s/fmObjectFactory.cpp @@ -18,7 +18,8 @@ void ObjectFactory::produce(void* args) { HealthTableIF* healthTable = nullptr; PusTmFunnel* pusFunnel = nullptr; CfdpTmFunnel* cfdpFunnel = nullptr; - ObjectFactory::produceGenericObjects(&healthTable, &pusFunnel, &cfdpFunnel); + ObjectFactory::produceGenericObjects(&healthTable, &pusFunnel, &cfdpFunnel, + *SdCardManager::instance()); LinuxLibgpioIF* gpioComIF = nullptr; SerialComIF* uartComIF = nullptr; diff --git a/common/config/eive/objects.h b/common/config/eive/objects.h index 9fb4aeff..0c592913 100644 --- a/common/config/eive/objects.h +++ b/common/config/eive/objects.h @@ -146,6 +146,7 @@ enum commonObjects : uint32_t { CFDP_TM_FUNNEL = 0x73000102, CFDP_HANDLER = 0x73000205, CFDP_DISTRIBUTOR = 0x73000206, + MISC_STORE = 0x73020001, }; } diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index cca48baf..c0e1eb43 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -68,7 +68,7 @@ EiveFaultHandler EIVE_FAULT_HANDLER; } // namespace cfdp void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFunnel** pusFunnel, - CfdpTmFunnel** cfdpFunnel) { + CfdpTmFunnel** cfdpFunnel, SdCardMountedIF& sdcMan) { // Framework objects new EventManager(objects::EVENT_MANAGER); auto healthTable = new HealthTable(objects::HEALTH_TABLE); @@ -122,7 +122,7 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFun new PusDistributor(config::EIVE_PUS_APID, objects::PUS_PACKET_DISTRIBUTOR, ccsdsDistrib); *cfdpFunnel = new CfdpTmFunnel(objects::CFDP_TM_FUNNEL, config::EIVE_CFDP_APID, *tmStore, 50); - *pusFunnel = new PusTmFunnel(objects::PUS_TM_FUNNEL, *timeStamper, *tmStore, 80); + *pusFunnel = new PusTmFunnel(objects::PUS_TM_FUNNEL, *timeStamper, *tmStore, sdcMan, 80); #if OBSW_ADD_TCPIP_SERVERS == 1 #if OBSW_ADD_TMTC_UDP_SERVER == 1 (*cfdpFunnel)->addDestination(*udpBridge, 0); diff --git a/mission/core/GenericFactory.h b/mission/core/GenericFactory.h index 2e2b0748..050a316d 100644 --- a/mission/core/GenericFactory.h +++ b/mission/core/GenericFactory.h @@ -1,6 +1,8 @@ #ifndef MISSION_CORE_GENERICFACTORY_H_ #define MISSION_CORE_GENERICFACTORY_H_ +#include + class HealthTableIF; class PusTmFunnel; class CfdpTmFunnel; @@ -8,7 +10,7 @@ class CfdpTmFunnel; namespace ObjectFactory { void produceGenericObjects(HealthTableIF** healthTable, PusTmFunnel** pusFunnel, - CfdpTmFunnel** cfdpFunnel); + CfdpTmFunnel** cfdpFunnel, SdCardMountedIF& sdcMan); } diff --git a/mission/tmtc/PusTmFunnel.cpp b/mission/tmtc/PusTmFunnel.cpp index 5d6bbb4d..4a3b6588 100644 --- a/mission/tmtc/PusTmFunnel.cpp +++ b/mission/tmtc/PusTmFunnel.cpp @@ -1,12 +1,15 @@ #include "PusTmFunnel.h" +#include "eive/objects.h" #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager.h" #include "fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h" PusTmFunnel::PusTmFunnel(object_id_t objectId, TimeReaderIF &timeReader, StorageManagerIF &tmStore, - uint32_t messageDepth) - : TmFunnelBase(objectId, tmStore, messageDepth), timeReader(timeReader) {} + SdCardMountedIF &sdcMan, uint32_t messageDepth) + : TmFunnelBase(objectId, tmStore, messageDepth), + timeReader(timeReader), + miscStore(objects::MISC_STORE, "misc", RolloverInterval::HOURLY, 8, sdcMan) {} PusTmFunnel::~PusTmFunnel() = default; diff --git a/mission/tmtc/PusTmFunnel.h b/mission/tmtc/PusTmFunnel.h index ca9a6016..96a9d33d 100644 --- a/mission/tmtc/PusTmFunnel.h +++ b/mission/tmtc/PusTmFunnel.h @@ -10,6 +10,7 @@ #include +#include "TmStore.h" #include "fsfw/timemanager/TimeReaderIF.h" /** @@ -26,7 +27,7 @@ class PusTmFunnel : public TmFunnelBase { public: explicit PusTmFunnel(object_id_t objectId, TimeReaderIF &timeReader, StorageManagerIF &tmStore, - uint32_t messageDepth = 10); + SdCardMountedIF &sdcMan, uint32_t messageDepth = 10); [[nodiscard]] const char *getName() const override; ~PusTmFunnel() override; @@ -35,6 +36,7 @@ class PusTmFunnel : public TmFunnelBase { private: uint16_t sourceSequenceCount = 0; TimeReaderIF &timeReader; + TmStore miscStore; ReturnValue_t handlePacket(TmTcMessage &message); }; diff --git a/mission/tmtc/TmStore.cpp b/mission/tmtc/TmStore.cpp index 8863dfe6..40dbf726 100644 --- a/mission/tmtc/TmStore.cpp +++ b/mission/tmtc/TmStore.cpp @@ -10,8 +10,8 @@ using namespace returnvalue; TmStore::TmStore(object_id_t objectId, std::string baseName, RolloverInterval intervalUnit, - uint32_t intervalCount, PacketFilter filter, SdCardMountedIF& sdcMan) - : SystemObject(objectId), filter(filter), baseName(std::move(baseName)), sdcMan(sdcMan) { + uint32_t intervalCount, SdCardMountedIF& sdcMan) + : SystemObject(objectId), baseName(std::move(baseName)), sdcMan(sdcMan) { calcDiffSeconds(intervalUnit, intervalCount); } @@ -150,4 +150,17 @@ void TmStore::assignAndOrCreateMostRecentFile() { } } -ReturnValue_t TmStore::storePacketInternal(PusTmReader& reader) { return returnvalue::OK; } +void TmStore::addApid(uint16_t apid) { + if (not filter.apid) { + filter.apid = std::vector(apid); + return; + } + filter.apid.value().push_back(apid); +} + +void TmStore::addService(uint8_t service) { + if (not filter.services) { + filter.services = std::vector(service); + } + filter.services.value().push_back(service); +} diff --git a/mission/tmtc/TmStore.h b/mission/tmtc/TmStore.h index 98e7bc62..4a873750 100644 --- a/mission/tmtc/TmStore.h +++ b/mission/tmtc/TmStore.h @@ -20,7 +20,10 @@ enum class RolloverInterval { HOURLY, DAILY }; class TmStore : public SystemObject { public: TmStore(object_id_t objectId, std::string baseName, RolloverInterval intervalUnit, - uint32_t intervalCount, PacketFilter filter, SdCardMountedIF& sdcMan); + uint32_t intervalCount, SdCardMountedIF& sdcMan); + + void addApid(uint16_t apid); + void addService(uint8_t service); void updateBaseDir(); ReturnValue_t updateCurrentTimestamp(); @@ -48,7 +51,6 @@ class TmStore : public SystemObject { void calcDiffSeconds(RolloverInterval intervalUnit, uint32_t intervalCount); void assignAndOrCreateMostRecentFile(); - ReturnValue_t storePacketInternal(PusTmReader& reader); }; #endif /* MISSION_TMTC_TMSTOREBACKEND_H_ */