Persistent TM Store #320

Merged
muellerr merged 109 commits from mueller/pus-15-tm-storage into develop 2023-02-24 19:03:39 +01:00
5 changed files with 40 additions and 29 deletions
Showing only changes of commit a1cb4fb549 - Show all commits

View File

@ -3,7 +3,8 @@
#include <mission/devices/devicedefinitions/GomspaceDefinitions.h>
PduDummy::PduDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie)
: DeviceHandlerBase(objectId, comif, comCookie) {}
: DeviceHandlerBase(objectId, comif, comCookie),
coreHk(this, static_cast<uint32_t>(P60System::SetIds::CORE)) {}
PduDummy::~PduDummy() {}
@ -38,5 +39,7 @@ uint32_t PduDummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return
ReturnValue_t PduDummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) {
localDataPoolMap.emplace(PDU::pool::PDU_TEMPERATURE, new PoolEntry<float>({0}));
localDataPoolMap.emplace(PDU::pool::PDU_VOLTAGES, &pduVoltages);
localDataPoolMap.emplace(PDU::pool::PDU_CURRENTS, &pduCurrents);
return returnvalue::OK;
}

View File

@ -3,6 +3,8 @@
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
#include "mission/devices/devicedefinitions/GomspaceDefinitions.h"
class PduDummy : public DeviceHandlerBase {
public:
static const DeviceCommandId_t SIMPLE_COMMAND = 1;
@ -15,6 +17,10 @@ class PduDummy : public DeviceHandlerBase {
virtual ~PduDummy();
protected:
PDU::PduCoreHk coreHk;
PoolEntry<int16_t> pduVoltages = PoolEntry<int16_t>(9);
PoolEntry<int16_t> pduCurrents = PoolEntry<int16_t>(9);
void doStartUp() override;
void doShutDown() override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override;

View File

@ -14,9 +14,10 @@
using namespace returnvalue;
TmStore::TmStore(object_id_t objectId, const char* baseDir, std::string baseName,
RolloverInterval intervalUnit, uint32_t intervalCount, timeval& currentTv,
StorageManagerIF& tmStore, SdCardMountedIF& sdcMan)
PersistentTmStore::PersistentTmStore(object_id_t objectId, const char* baseDir,
muellerr marked this conversation as resolved
Review

I don't get why the stores need a reference to a central time. They can look that up by their own I think. Is it necessary to have all stores working on the exact same time?

I don't get why the stores need a reference to a central time. They can look that up by their own I think. Is it necessary to have all stores working on the exact same time?
Review

No. I'll probably update the code so each persistent store calls `Clock::getClock_timeval

No. I'll probably update the code so each persistent store calls `Clock::getClock_timeval
std::string baseName, RolloverInterval intervalUnit,
uint32_t intervalCount, timeval& currentTv,
StorageManagerIF& tmStore, SdCardMountedIF& sdcMan)
: SystemObject(objectId),
baseDir(baseDir),
baseName(std::move(baseName)),
@ -27,7 +28,8 @@ TmStore::TmStore(object_id_t objectId, const char* baseDir, std::string baseName
calcDiffSeconds(intervalUnit, intervalCount);
}
ReturnValue_t TmStore::handleCommandQueue(StorageManagerIF& ipcStore, TmFunnelBase& tmFunnel) {
ReturnValue_t PersistentTmStore::handleCommandQueue(StorageManagerIF& ipcStore,
TmFunnelBase& tmFunnel) {
CommandMessage cmdMessage;
ReturnValue_t result = tcQueue->receiveMessage(&cmdMessage);
if (result == MessageQueueIF::EMPTY) {
@ -63,7 +65,7 @@ ReturnValue_t TmStore::handleCommandQueue(StorageManagerIF& ipcStore, TmFunnelBa
return returnvalue::OK;
}
ReturnValue_t TmStore::passPacket(PusTmReader& reader) {
ReturnValue_t PersistentTmStore::passPacket(PusTmReader& reader) {
bool inApidList = false;
if (filter.apid) {
auto& apidFilter = filter.apid.value();
@ -98,11 +100,11 @@ ReturnValue_t TmStore::passPacket(PusTmReader& reader) {
return returnvalue::OK;
}
void TmStore::dumpFrom(uint32_t fromUnixSeconds, TmFunnelBase& tmFunnel) {
void PersistentTmStore::dumpFrom(uint32_t fromUnixSeconds, TmFunnelBase& tmFunnel) {
return dumpFromUpTo(fromUnixSeconds, currentTv.tv_sec, tmFunnel);
}
ReturnValue_t TmStore::storePacket(PusTmReader& reader) {
ReturnValue_t PersistentTmStore::storePacket(PusTmReader& reader) {
using namespace std::filesystem;
if (baseDirUninitialized) {
updateBaseDir();
@ -137,9 +139,9 @@ ReturnValue_t TmStore::storePacket(PusTmReader& reader) {
return returnvalue::OK;
}
MessageQueueId_t TmStore::getCommandQueue() const { return tcQueue->getId(); }
MessageQueueId_t PersistentTmStore::getCommandQueue() const { return tcQueue->getId(); }
void TmStore::calcDiffSeconds(RolloverInterval intervalUnit, uint32_t intervalCount) {
void PersistentTmStore::calcDiffSeconds(RolloverInterval intervalUnit, uint32_t intervalCount) {
if (intervalUnit == RolloverInterval::MINUTELY) {
rolloverDiffSeconds = 60 * intervalCount;
} else if (intervalUnit == RolloverInterval::HOURLY) {
@ -149,7 +151,7 @@ void TmStore::calcDiffSeconds(RolloverInterval intervalUnit, uint32_t intervalCo
}
}
void TmStore::updateBaseDir() {
void PersistentTmStore::updateBaseDir() {
using namespace std::filesystem;
std::string currentPrefix = sdcMan.getCurrentMountPrefix();
basePath = path(currentPrefix) / baseDir / baseName;
@ -159,7 +161,7 @@ void TmStore::updateBaseDir() {
baseDirUninitialized = false;
}
void TmStore::assignAndOrCreateMostRecentFile() {
void PersistentTmStore::assignAndOrCreateMostRecentFile() {
using namespace std::filesystem;
for (auto const& file : directory_iterator(basePath)) {
if (file.is_directory()) {
@ -204,7 +206,7 @@ void TmStore::assignAndOrCreateMostRecentFile() {
}
}
void TmStore::addApid(uint16_t apid) {
void PersistentTmStore::addApid(uint16_t apid) {
if (not filter.apid) {
filter.apid = std::vector<uint16_t>({apid});
return;
@ -212,7 +214,7 @@ void TmStore::addApid(uint16_t apid) {
filter.apid.value().push_back(apid);
}
void TmStore::addService(uint8_t service) {
void PersistentTmStore::addService(uint8_t service) {
if (not filter.services) {
filter.services = std::vector<uint8_t>({service});
return;
@ -220,7 +222,7 @@ void TmStore::addService(uint8_t service) {
filter.services.value().push_back(service);
}
void TmStore::addServiceSubservice(uint8_t service, uint8_t subservice) {
void PersistentTmStore::addServiceSubservice(uint8_t service, uint8_t subservice) {
if (not filter.serviceSubservices) {
filter.serviceSubservices =
std::vector<std::pair<uint8_t, uint8_t>>({std::pair(service, subservice)});
@ -229,7 +231,7 @@ void TmStore::addServiceSubservice(uint8_t service, uint8_t subservice) {
filter.serviceSubservices.value().emplace_back(service, subservice);
}
void TmStore::deleteUpTo(uint32_t unixSeconds) {
void PersistentTmStore::deleteUpTo(uint32_t unixSeconds) {
using namespace std::filesystem;
for (auto const& file : directory_iterator(basePath)) {
if (file.is_directory() or
@ -250,8 +252,8 @@ void TmStore::deleteUpTo(uint32_t unixSeconds) {
}
}
void TmStore::dumpFromUpTo(uint32_t fromUnixSeconds, uint32_t upToUnixSeconds,
TmFunnelBase& funnel) {
void PersistentTmStore::dumpFromUpTo(uint32_t fromUnixSeconds, uint32_t upToUnixSeconds,
TmFunnelBase& funnel) {
using namespace std::filesystem;
for (auto const& file : directory_iterator(basePath)) {
if (file.is_directory()) {
@ -277,7 +279,7 @@ void TmStore::dumpFromUpTo(uint32_t fromUnixSeconds, uint32_t upToUnixSeconds,
}
}
void TmStore::pathToTod(const std::filesystem::path& path, Clock::TimeOfDay_t& tod) {
void PersistentTmStore::pathToTod(const std::filesystem::path& path, Clock::TimeOfDay_t& tod) {
auto pathStr = path.string();
size_t splitChar = pathStr.find('_');
auto timeOnlyStr = pathStr.substr(splitChar);
@ -286,8 +288,8 @@ void TmStore::pathToTod(const std::filesystem::path& path, Clock::TimeOfDay_t& t
&tod.year, &tod.month, &tod.day, &tod.hour, &tod.minute, &tod.second);
}
void TmStore::fileToPackets(const std::filesystem::path& path, uint32_t unixStamp,
TmFunnelBase& funnel) {
void PersistentTmStore::fileToPackets(const std::filesystem::path& path, uint32_t unixStamp,
TmFunnelBase& funnel) {
store_address_t storeId;
TmTcMessage message;
size_t size = std::filesystem::file_size(path);

View File

@ -21,7 +21,7 @@ struct PacketFilter {
enum class RolloverInterval { MINUTELY, HOURLY, DAILY };
class TmStore : public TmStoreFrontendSimpleIF, public SystemObject {
class PersistentTmStore : public TmStoreFrontendSimpleIF, public SystemObject {
public:
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PERSISTENT_TM_STORE;
@ -30,9 +30,9 @@ class TmStore : public TmStoreFrontendSimpleIF, public SystemObject {
//! P2: Timestamp of possibly corrupt file as a unix timestamp.
static constexpr Event POSSIBLE_FILE_CORRUPTION =
event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW);
TmStore(object_id_t objectId, const char* baseDir, std::string baseName,
RolloverInterval intervalUnit, uint32_t intervalCount, timeval& currentTv,
StorageManagerIF& tmStore, SdCardMountedIF& sdcMan);
PersistentTmStore(object_id_t objectId, const char* baseDir, std::string baseName,
RolloverInterval intervalUnit, uint32_t intervalCount, timeval& currentTv,
StorageManagerIF& tmStore, SdCardMountedIF& sdcMan);
ReturnValue_t handleCommandQueue(StorageManagerIF& ipcStore, TmFunnelBase& tmFunnel);

View File

@ -38,10 +38,10 @@ class PusTmFunnel : public TmFunnelBase {
bool storesInitialized = false;
timeval currentTv{};
timeval lastTvUpdate{};
TmStore miscStore;
TmStore okStore;
TmStore notOkStore;
TmStore hkStore;
PersistentTmStore miscStore;
PersistentTmStore okStore;
PersistentTmStore notOkStore;
PersistentTmStore hkStore;
SdCardMountedIF &sdcMan;
ReturnValue_t handleTmPacket(TmTcMessage &message);