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