this might be over-engineered

This commit is contained in:
2023-02-24 18:10:43 +01:00
parent 1744f1aff0
commit 95ce2c79b9
5 changed files with 48 additions and 33 deletions

View File

@ -31,7 +31,7 @@ class PersistentTmStore : public TmStoreFrontendSimpleIF, public SystemObject {
static constexpr Event POSSIBLE_FILE_CORRUPTION =
event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW);
PersistentTmStore(object_id_t objectId, const char* baseDir, std::string baseName,
RolloverInterval intervalUnit, uint32_t intervalCount, timeval& currentTv,
RolloverInterval intervalUnit, uint32_t intervalCount,
StorageManagerIF& tmStore, SdCardMountedIF& sdcMan);
ReturnValue_t initializeTmStore();
@ -48,6 +48,7 @@ class PersistentTmStore : public TmStoreFrontendSimpleIF, public SystemObject {
ReturnValue_t passPacket(PusTmReader& reader);
private:
static constexpr uint8_t MAX_FILES_IN_ONE_SECOND = 10;
static constexpr size_t MAX_FILESIZE = 8192;
// ISO8601 timestamp.
static constexpr char FILE_DATE_FORMAT[] = "%FT%H%M%SZ";
@ -58,10 +59,11 @@ class PersistentTmStore : public TmStoreFrontendSimpleIF, public SystemObject {
bool baseDirUninitialized = true;
const char* baseDir;
std::string baseName;
uint8_t currentSameSecNumber = 0;
std::filesystem::path basePath;
uint32_t rolloverDiffSeconds = 0;
std::array<uint8_t, MAX_FILESIZE> fileBuf{};
timeval& currentTv;
timeval currentTv;
timeval activeFileTv{};
std::optional<std::filesystem::path> activeFile;
SdCardMountedIF& sdcMan;
@ -74,7 +76,7 @@ class PersistentTmStore : public TmStoreFrontendSimpleIF, public SystemObject {
[[nodiscard]] MessageQueueId_t getCommandQueue() const override;
void calcDiffSeconds(RolloverInterval intervalUnit, uint32_t intervalCount);
ReturnValue_t createMostRecentFile();
ReturnValue_t createMostRecentFile(std::optional<uint8_t> suffix);
static ReturnValue_t pathToTm(const std::filesystem::path& path, struct tm& time);
void fileToPackets(const std::filesystem::path& path, uint32_t unixStamp, TmFunnelBase& funnel);
bool updateBaseDir();