Robin Mueller
74f116f2fa
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
64 lines
2.0 KiB
C++
64 lines
2.0 KiB
C++
#ifndef MISSION_TMTC_TMSTOREBACKEND_H_
|
|
#define MISSION_TMTC_TMSTOREBACKEND_H_
|
|
|
|
#include <fsfw/objectmanager/SystemObject.h>
|
|
#include <fsfw/tmstorage/TmStoreFrontendIF.h>
|
|
#include <fsfw/tmtcpacket/pus/tm/PusTmReader.h>
|
|
#include <fsfw/tmtcservices/AcceptsTelemetryIF.h>
|
|
#include <mission/memory/SdCardMountedIF.h>
|
|
|
|
#include <filesystem>
|
|
|
|
struct PacketFilter {
|
|
std::optional<std::vector<uint16_t>> apid;
|
|
std::optional<std::vector<uint8_t>> services;
|
|
std::optional<std::vector<std::pair<uint8_t, uint8_t>>> serviceSubservices;
|
|
};
|
|
|
|
enum class RolloverInterval { MINUTELY, HOURLY, DAILY };
|
|
|
|
class TmStore : public SystemObject {
|
|
public:
|
|
TmStore(object_id_t objectId, const char* baseDir, std::string baseName,
|
|
RolloverInterval intervalUnit, uint32_t intervalCount, timeval& currentTv,
|
|
SdCardMountedIF& sdcMan);
|
|
|
|
void addApid(uint16_t apid);
|
|
void addService(uint8_t service);
|
|
void addServiceSubservice(uint8_t service, uint8_t subservice);
|
|
|
|
void deleteUpTo(uint32_t unixSeconds);
|
|
void dumpFromUpTo(uint32_t fromUnixSeconds, uint32_t upToUnixSeconds,
|
|
std::vector<std::pair<MessageQueueId_t, uint8_t>>& destinations,
|
|
MessageQueueIF* tmQueue);
|
|
|
|
void updateBaseDir();
|
|
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;
|
|
const char* baseDir;
|
|
std::string baseName;
|
|
std::filesystem::path basePath;
|
|
uint32_t rolloverDiffSeconds = 0;
|
|
std::array<uint8_t, MAX_FILESIZE> fileBuf{};
|
|
timeval& currentTv;
|
|
std::optional<timeval> mostRecentTv;
|
|
std::optional<std::filesystem::path> mostRecentFile;
|
|
SdCardMountedIF& sdcMan;
|
|
|
|
void calcDiffSeconds(RolloverInterval intervalUnit, uint32_t intervalCount);
|
|
void assignAndOrCreateMostRecentFile();
|
|
ReturnValue_t storePacket(PusTmReader& reader);
|
|
};
|
|
|
|
#endif /* MISSION_TMTC_TMSTOREBACKEND_H_ */
|