#ifndef MISSION_TMTC_TMSTOREBACKEND_H_ #define MISSION_TMTC_TMSTOREBACKEND_H_ #include #include #include #include #include #include struct PacketFilter { std::optional> apid; std::optional> services; std::optional>> serviceSubservices; }; enum class RolloverInterval { HOURLY, DAILY }; class TmStore : public SystemObject { public: TmStore(object_id_t objectId, std::string baseName, RolloverInterval intervalUnit, uint32_t intervalCount, SdCardMountedIF& sdcMan); void addApid(uint16_t apid); void addService(uint8_t service); void updateBaseDir(); ReturnValue_t updateCurrentTimestamp(); ReturnValue_t passPacket(PusTmReader& reader); private: static constexpr size_t MAX_FILESIZE = 8192; /** * To get the queue where commands shall be sent. * @return Id of command queue. */ MessageQueueId_t getCommandQueue(); PacketFilter filter; bool baseDirUninitialized = true; std::string baseName; std::filesystem::path baseDir; uint32_t rolloverDiffSeconds = 0; std::array fileBuf{}; timeval currentTv{}; std::optional mostRecentTv; std::optional mostRecentFile; SdCardMountedIF& sdcMan; void calcDiffSeconds(RolloverInterval intervalUnit, uint32_t intervalCount); void assignAndOrCreateMostRecentFile(); ReturnValue_t storePacket(PusTmReader& reader); }; #endif /* MISSION_TMTC_TMSTOREBACKEND_H_ */