more fixes and improvements
This commit is contained in:
parent
2d72942d47
commit
8ee6a23229
@ -10,9 +10,9 @@ 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, currentTv, sdcMan),
|
miscStore(objects::MISC_STORE, "tm", "misc", RolloverInterval::HOURLY, 8, currentTv, sdcMan),
|
||||||
okStore(objects::OK_STORE, "event", RolloverInterval::MINUTELY, 30, currentTv, sdcMan),
|
okStore(objects::OK_STORE, "tm", "ok", RolloverInterval::MINUTELY, 30, currentTv, sdcMan),
|
||||||
notOkStore(objects::NOT_OK_STORE, "event", RolloverInterval::MINUTELY, 30, currentTv, sdcMan),
|
notOkStore(objects::NOT_OK_STORE,"tm", "nok", RolloverInterval::MINUTELY, 30, currentTv, sdcMan),
|
||||||
sdcMan(sdcMan) {
|
sdcMan(sdcMan) {
|
||||||
Clock::getClock_timeval(¤tTv);
|
Clock::getClock_timeval(¤tTv);
|
||||||
Clock::getUptime(&lastTvUpdate);
|
Clock::getUptime(&lastTvUpdate);
|
||||||
@ -20,6 +20,11 @@ PusTmFunnel::PusTmFunnel(object_id_t objectId, TimeReaderIF &timeReader, Storage
|
|||||||
miscStore.addService(17);
|
miscStore.addService(17);
|
||||||
okStore.addApid(config::EIVE_PUS_APID);
|
okStore.addApid(config::EIVE_PUS_APID);
|
||||||
okStore.addServiceSubservice(5, 1);
|
okStore.addServiceSubservice(5, 1);
|
||||||
|
okStore.addApid(config::EIVE_PUS_APID);
|
||||||
|
okStore.addServiceSubservice(1, 1);
|
||||||
|
okStore.addServiceSubservice(1, 3);
|
||||||
|
okStore.addServiceSubservice(1, 5);
|
||||||
|
okStore.addServiceSubservice(1, 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
PusTmFunnel::~PusTmFunnel() = default;
|
PusTmFunnel::~PusTmFunnel() = default;
|
||||||
|
@ -10,9 +10,9 @@
|
|||||||
|
|
||||||
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 baseDir, std::string baseName,
|
||||||
uint32_t intervalCount, timeval& currentTv, SdCardMountedIF& sdcMan)
|
RolloverInterval intervalUnit, uint32_t intervalCount, timeval& currentTv, SdCardMountedIF& sdcMan)
|
||||||
: SystemObject(objectId), baseName(std::move(baseName)), currentTv(currentTv), sdcMan(sdcMan) {
|
: SystemObject(objectId), baseDir(std::move(baseDir)), baseName(std::move(baseName)), currentTv(currentTv), sdcMan(sdcMan) {
|
||||||
calcDiffSeconds(intervalUnit, intervalCount);
|
calcDiffSeconds(intervalUnit, intervalCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,16 +99,16 @@ void TmStore::calcDiffSeconds(RolloverInterval intervalUnit, uint32_t intervalCo
|
|||||||
void TmStore::updateBaseDir() {
|
void TmStore::updateBaseDir() {
|
||||||
using namespace std::filesystem;
|
using namespace std::filesystem;
|
||||||
std::string currentPrefix = sdcMan.getCurrentMountPrefix();
|
std::string currentPrefix = sdcMan.getCurrentMountPrefix();
|
||||||
baseDir = path(currentPrefix) / baseName;
|
basePath = path(currentPrefix) / baseDir / baseName;
|
||||||
if (not exists(baseDir)) {
|
if (not exists(basePath)) {
|
||||||
create_directory(baseDir);
|
create_directories(basePath);
|
||||||
}
|
}
|
||||||
baseDirUninitialized = false;
|
baseDirUninitialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
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(basePath)) {
|
||||||
if (file.is_directory()) {
|
if (file.is_directory()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -135,13 +135,14 @@ void TmStore::assignAndOrCreateMostRecentFile() {
|
|||||||
}
|
}
|
||||||
if (not mostRecentFile) {
|
if (not mostRecentFile) {
|
||||||
unsigned currentIdx = 0;
|
unsigned currentIdx = 0;
|
||||||
memcpy(fileBuf.data() + currentIdx, baseName.data(), baseName.size());
|
path pathStart = basePath / baseName;
|
||||||
|
memcpy(fileBuf.data() + currentIdx, pathStart.c_str(), pathStart.string().length());
|
||||||
currentIdx += baseName.size();
|
currentIdx += baseName.size();
|
||||||
Clock::TimeOfDay_t tod;
|
Clock::TimeOfDay_t tod;
|
||||||
Clock::convertTimevalToTimeOfDay(¤tTv, &tod);
|
Clock::convertTimevalToTimeOfDay(¤tTv, &tod);
|
||||||
currentIdx += sprintf(reinterpret_cast<char*>(fileBuf.data() + currentIdx),
|
currentIdx += sprintf(reinterpret_cast<char*>(fileBuf.data() + currentIdx),
|
||||||
"%4" SCNu32 "-%2" SCNu32 "-%2" SCNu32 "T%2" SCNu32 ":%2" SCNu32
|
"_%4" PRIu32 "-%2" PRIu32 "-%2" PRIu32 "T%2" PRIu32 ":%2" PRIu32
|
||||||
":%2" SCNu32 "Z.bin",
|
":%2" PRIu32 "Z.bin",
|
||||||
tod.year, tod.month, tod.day, tod.hour, tod.minute, tod.second);
|
tod.year, tod.month, tod.day, tod.hour, tod.minute, tod.second);
|
||||||
path newPath(std::string(reinterpret_cast<const char*>(fileBuf.data()), currentIdx));
|
path newPath(std::string(reinterpret_cast<const char*>(fileBuf.data()), currentIdx));
|
||||||
std::ofstream of(newPath, std::ios::binary);
|
std::ofstream of(newPath, std::ios::binary);
|
||||||
|
@ -19,7 +19,7 @@ enum class RolloverInterval { MINUTELY, 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 baseDir, std::string baseName, RolloverInterval intervalUnit,
|
||||||
uint32_t intervalCount, timeval& currentTv, SdCardMountedIF& sdcMan);
|
uint32_t intervalCount, timeval& currentTv, SdCardMountedIF& sdcMan);
|
||||||
|
|
||||||
void addApid(uint16_t apid);
|
void addApid(uint16_t apid);
|
||||||
@ -39,8 +39,9 @@ class TmStore : public SystemObject {
|
|||||||
MessageQueueId_t getCommandQueue();
|
MessageQueueId_t getCommandQueue();
|
||||||
PacketFilter filter;
|
PacketFilter filter;
|
||||||
bool baseDirUninitialized = true;
|
bool baseDirUninitialized = true;
|
||||||
|
std::string baseDir;
|
||||||
std::string baseName;
|
std::string baseName;
|
||||||
std::filesystem::path baseDir;
|
std::filesystem::path basePath;
|
||||||
uint32_t rolloverDiffSeconds = 0;
|
uint32_t rolloverDiffSeconds = 0;
|
||||||
std::array<uint8_t, MAX_FILESIZE> fileBuf{};
|
std::array<uint8_t, MAX_FILESIZE> fileBuf{};
|
||||||
timeval& currentTv;
|
timeval& currentTv;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user