Persistent TM Store #320
@ -147,6 +147,7 @@ enum commonObjects : uint32_t {
|
||||
CFDP_HANDLER = 0x73000205,
|
||||
CFDP_DISTRIBUTOR = 0x73000206,
|
||||
MISC_STORE = 0x73020001,
|
||||
EVENT_STORE = 0x73020002,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -10,10 +10,14 @@ PusTmFunnel::PusTmFunnel(object_id_t objectId, TimeReaderIF &timeReader, Storage
|
||||
SdCardMountedIF &sdcMan, uint32_t messageDepth)
|
||||
: TmFunnelBase(objectId, tmStore, messageDepth),
|
||||
timeReader(timeReader),
|
||||
miscStore(objects::MISC_STORE, "misc", RolloverInterval::HOURLY, 8, sdcMan),
|
||||
miscStore(objects::MISC_STORE, "misc", RolloverInterval::HOURLY, 8, currentTv, sdcMan),
|
||||
eventStore(objects::EVENT_STORE, "event", RolloverInterval::HOURLY, 1, currentTv, sdcMan),
|
||||
sdcMan(sdcMan) {
|
||||
Clock::getClock_timeval(¤tTv);
|
||||
miscStore.addApid(config::EIVE_PUS_APID);
|
||||
miscStore.addService(17);
|
||||
eventStore.addApid(config::EIVE_PUS_APID);
|
||||
eventStore.addService(5);
|
||||
}
|
||||
|
||||
PusTmFunnel::~PusTmFunnel() = default;
|
||||
@ -59,10 +63,11 @@ ReturnValue_t PusTmFunnel::handlePacket(TmTcMessage &message) {
|
||||
if (sdcMan.isSdCardUsable(std::nullopt)) {
|
||||
if (not storesInitialized) {
|
||||
miscStore.updateBaseDir();
|
||||
miscStore.updateCurrentTimestamp();
|
||||
eventStore.updateBaseDir();
|
||||
storesInitialized = true;
|
||||
}
|
||||
miscStore.passPacket(packet);
|
||||
eventStore.passPacket(packet);
|
||||
}
|
||||
|
||||
for (unsigned int idx = 0; idx < destinations.size(); idx++) {
|
||||
@ -101,7 +106,7 @@ const char *PusTmFunnel::getName() const { return "PUS TM Funnel"; }
|
||||
ReturnValue_t PusTmFunnel::initialize() {
|
||||
if (not storesInitialized and sdcMan.isSdCardUsable(std::nullopt)) {
|
||||
miscStore.updateBaseDir();
|
||||
miscStore.updateCurrentTimestamp();
|
||||
eventStore.updateBaseDir();
|
||||
storesInitialized = true;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
|
@ -37,7 +37,9 @@ class PusTmFunnel : public TmFunnelBase {
|
||||
uint16_t sourceSequenceCount = 0;
|
||||
TimeReaderIF &timeReader;
|
||||
bool storesInitialized = false;
|
||||
timeval currentTv;
|
||||
TmStore miscStore;
|
||||
TmStore eventStore;
|
||||
SdCardMountedIF &sdcMan;
|
||||
|
||||
ReturnValue_t handlePacket(TmTcMessage &message);
|
||||
|
@ -10,8 +10,8 @@
|
||||
using namespace returnvalue;
|
||||
|
||||
TmStore::TmStore(object_id_t objectId, std::string baseName, RolloverInterval intervalUnit,
|
||||
uint32_t intervalCount, SdCardMountedIF& sdcMan)
|
||||
: SystemObject(objectId), baseName(std::move(baseName)), sdcMan(sdcMan) {
|
||||
uint32_t intervalCount, timeval& currentTv, SdCardMountedIF& sdcMan)
|
||||
: SystemObject(objectId), baseName(std::move(baseName)), currentTv(currentTv), sdcMan(sdcMan) {
|
||||
calcDiffSeconds(intervalUnit, intervalCount);
|
||||
}
|
||||
|
||||
@ -103,8 +103,6 @@ void TmStore::updateBaseDir() {
|
||||
baseDirUninitialized = false;
|
||||
}
|
||||
|
||||
ReturnValue_t TmStore::updateCurrentTimestamp() { return Clock::getClock_timeval(¤tTv); }
|
||||
|
||||
void TmStore::assignAndOrCreateMostRecentFile() {
|
||||
using namespace std::filesystem;
|
||||
for (auto const& file : directory_iterator(baseDir)) {
|
||||
@ -133,7 +131,6 @@ void TmStore::assignAndOrCreateMostRecentFile() {
|
||||
}
|
||||
}
|
||||
if (not mostRecentFile) {
|
||||
updateCurrentTimestamp();
|
||||
unsigned currentIdx = 0;
|
||||
memcpy(fileBuf.data() + currentIdx, baseName.data(), baseName.size());
|
||||
currentIdx += baseName.size();
|
||||
|
@ -20,13 +20,12 @@ 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);
|
||||
uint32_t intervalCount, timeval& currentTv, SdCardMountedIF& sdcMan);
|
||||
|
||||
void addApid(uint16_t apid);
|
||||
void addService(uint8_t service);
|
||||
|
||||
void updateBaseDir();
|
||||
ReturnValue_t updateCurrentTimestamp();
|
||||
ReturnValue_t passPacket(PusTmReader& reader);
|
||||
|
||||
private:
|
||||
@ -43,7 +42,7 @@ class TmStore : public SystemObject {
|
||||
std::filesystem::path baseDir;
|
||||
uint32_t rolloverDiffSeconds = 0;
|
||||
std::array<uint8_t, 8192> fileBuf{};
|
||||
timeval currentTv{};
|
||||
timeval& currentTv;
|
||||
std::optional<timeval> mostRecentTv;
|
||||
std::optional<std::filesystem::path> mostRecentFile;
|
||||
SdCardMountedIF& sdcMan;
|
||||
|
Loading…
Reference in New Issue
Block a user