it seems to work now
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
Robin Müller 2022-12-14 10:42:16 +01:00
parent 9cea0c50c3
commit 58d6b59b7c
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
3 changed files with 19 additions and 12 deletions

View File

@ -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(&currentTv);
Clock::getUptime(&lastTvUpdate);

View File

@ -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(&currentTv, &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);

View File

@ -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);