Persistent TM Store #320
@ -12,7 +12,8 @@ PusTmFunnel::PusTmFunnel(object_id_t objectId, TimeReaderIF &timeReader, Storage
|
||||
timeReader(timeReader),
|
||||
miscStore(objects::MISC_STORE, "tm", "misc", RolloverInterval::HOURLY, 8, currentTv, sdcMan),
|
||||
okStore(objects::OK_STORE, "tm", "ok", RolloverInterval::MINUTELY, 30, currentTv, sdcMan),
|
||||
notOkStore(objects::NOT_OK_STORE,"tm", "nok", RolloverInterval::MINUTELY, 30, currentTv, sdcMan),
|
||||
notOkStore(objects::NOT_OK_STORE, "tm", "nok", RolloverInterval::MINUTELY, 30, currentTv,
|
||||
sdcMan),
|
||||
sdcMan(sdcMan) {
|
||||
Clock::getClock_timeval(¤tTv);
|
||||
Clock::getUptime(&lastTvUpdate);
|
||||
|
@ -11,8 +11,13 @@
|
||||
using namespace returnvalue;
|
||||
|
||||
TmStore::TmStore(object_id_t objectId, const char* baseDir, std::string baseName,
|
||||
RolloverInterval intervalUnit, uint32_t intervalCount, timeval& currentTv, SdCardMountedIF& sdcMan)
|
||||
: SystemObject(objectId), baseDir(std::move(baseDir)), baseName(std::move(baseName)), currentTv(currentTv), sdcMan(sdcMan) {
|
||||
RolloverInterval intervalUnit, uint32_t intervalCount, timeval& currentTv,
|
||||
SdCardMountedIF& sdcMan)
|
||||
: SystemObject(objectId),
|
||||
baseDir(std::move(baseDir)),
|
||||
baseName(std::move(baseName)),
|
||||
currentTv(currentTv),
|
||||
sdcMan(sdcMan) {
|
||||
calcDiffSeconds(intervalUnit, intervalCount);
|
||||
}
|
||||
|
||||
@ -119,10 +124,10 @@ void TmStore::assignAndOrCreateMostRecentFile() {
|
||||
}
|
||||
unsigned int underscorePos = pathStr.find_last_of('_');
|
||||
std::string stampStr = pathStr.substr(underscorePos + 1);
|
||||
int count =
|
||||
sscanf(stampStr.c_str(),
|
||||
"%4" SCNu32 "-%2" SCNu32 "-%2" SCNu32 "T%2" SCNu32 ":%2" SCNu32 ":%2" SCNu32 "Z",
|
||||
&tod.year, &tod.month, &tod.day, &tod.hour, &tod.minute, &tod.second);
|
||||
int count = sscanf(stampStr.c_str(),
|
||||
"%04" SCNu32 "-%02" SCNu32 "-%02" SCNu32 "T%02" SCNu32 "-%02" SCNu32
|
||||
"-%02" SCNu32 "Z",
|
||||
&tod.year, &tod.month, &tod.day, &tod.hour, &tod.minute, &tod.second);
|
||||
if (count != 6) {
|
||||
continue;
|
||||
}
|
||||
@ -137,12 +142,12 @@ void TmStore::assignAndOrCreateMostRecentFile() {
|
||||
unsigned currentIdx = 0;
|
||||
path pathStart = basePath / baseName;
|
||||
memcpy(fileBuf.data() + currentIdx, pathStart.c_str(), pathStart.string().length());
|
||||
currentIdx += baseName.size();
|
||||
currentIdx += pathStart.string().length();
|
||||
Clock::TimeOfDay_t tod;
|
||||
Clock::convertTimevalToTimeOfDay(¤tTv, &tod);
|
||||
currentIdx += sprintf(reinterpret_cast<char*>(fileBuf.data() + currentIdx),
|
||||
"_%4" PRIu32 "-%2" PRIu32 "-%2" PRIu32 "T%2" PRIu32 ":%2" PRIu32
|
||||
":%2" PRIu32 "Z.bin",
|
||||
"_%04" PRIu32 "-%02" PRIu32 "-%02" PRIu32 "T%02" PRIu32 "-%02" PRIu32
|
||||
"-%02" PRIu32 "Z.bin",
|
||||
tod.year, tod.month, tod.day, tod.hour, tod.minute, tod.second);
|
||||
path newPath(std::string(reinterpret_cast<const char*>(fileBuf.data()), currentIdx));
|
||||
std::ofstream of(newPath, std::ios::binary);
|
||||
|
@ -19,8 +19,9 @@ 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);
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user