Persistent TM Store #320
@ -3,7 +3,8 @@
|
|||||||
#include <mission/devices/devicedefinitions/GomspaceDefinitions.h>
|
#include <mission/devices/devicedefinitions/GomspaceDefinitions.h>
|
||||||
|
|
||||||
PduDummy::PduDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie)
|
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() {}
|
PduDummy::~PduDummy() {}
|
||||||
|
|
||||||
@ -38,5 +39,7 @@ uint32_t PduDummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return
|
|||||||
ReturnValue_t PduDummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
|
ReturnValue_t PduDummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
|
||||||
LocalDataPoolManager &poolManager) {
|
LocalDataPoolManager &poolManager) {
|
||||||
localDataPoolMap.emplace(PDU::pool::PDU_TEMPERATURE, new PoolEntry<float>({0}));
|
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;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
|
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
|
||||||
|
|
||||||
|
#include "mission/devices/devicedefinitions/GomspaceDefinitions.h"
|
||||||
|
|
||||||
class PduDummy : public DeviceHandlerBase {
|
class PduDummy : public DeviceHandlerBase {
|
||||||
public:
|
public:
|
||||||
static const DeviceCommandId_t SIMPLE_COMMAND = 1;
|
static const DeviceCommandId_t SIMPLE_COMMAND = 1;
|
||||||
@ -15,6 +17,10 @@ class PduDummy : public DeviceHandlerBase {
|
|||||||
virtual ~PduDummy();
|
virtual ~PduDummy();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
PDU::PduCoreHk coreHk;
|
||||||
|
PoolEntry<int16_t> pduVoltages = PoolEntry<int16_t>(9);
|
||||||
|
PoolEntry<int16_t> pduCurrents = PoolEntry<int16_t>(9);
|
||||||
|
|
||||||
void doStartUp() override;
|
void doStartUp() override;
|
||||||
void doShutDown() override;
|
void doShutDown() override;
|
||||||
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override;
|
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override;
|
||||||
|
@ -14,9 +14,10 @@
|
|||||||
|
|
||||||
using namespace returnvalue;
|
using namespace returnvalue;
|
||||||
|
|
||||||
TmStore::TmStore(object_id_t objectId, const char* baseDir, std::string baseName,
|
PersistentTmStore::PersistentTmStore(object_id_t objectId, const char* baseDir,
|
||||||
muellerr marked this conversation as resolved
|
|||||||
RolloverInterval intervalUnit, uint32_t intervalCount, timeval& currentTv,
|
std::string baseName, RolloverInterval intervalUnit,
|
||||||
StorageManagerIF& tmStore, SdCardMountedIF& sdcMan)
|
uint32_t intervalCount, timeval& currentTv,
|
||||||
|
StorageManagerIF& tmStore, SdCardMountedIF& sdcMan)
|
||||||
: SystemObject(objectId),
|
: SystemObject(objectId),
|
||||||
baseDir(baseDir),
|
baseDir(baseDir),
|
||||||
baseName(std::move(baseName)),
|
baseName(std::move(baseName)),
|
||||||
@ -27,7 +28,8 @@ TmStore::TmStore(object_id_t objectId, const char* baseDir, std::string baseName
|
|||||||
calcDiffSeconds(intervalUnit, intervalCount);
|
calcDiffSeconds(intervalUnit, intervalCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t TmStore::handleCommandQueue(StorageManagerIF& ipcStore, TmFunnelBase& tmFunnel) {
|
ReturnValue_t PersistentTmStore::handleCommandQueue(StorageManagerIF& ipcStore,
|
||||||
|
TmFunnelBase& tmFunnel) {
|
||||||
CommandMessage cmdMessage;
|
CommandMessage cmdMessage;
|
||||||
ReturnValue_t result = tcQueue->receiveMessage(&cmdMessage);
|
ReturnValue_t result = tcQueue->receiveMessage(&cmdMessage);
|
||||||
if (result == MessageQueueIF::EMPTY) {
|
if (result == MessageQueueIF::EMPTY) {
|
||||||
@ -63,7 +65,7 @@ ReturnValue_t TmStore::handleCommandQueue(StorageManagerIF& ipcStore, TmFunnelBa
|
|||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t TmStore::passPacket(PusTmReader& reader) {
|
ReturnValue_t PersistentTmStore::passPacket(PusTmReader& reader) {
|
||||||
bool inApidList = false;
|
bool inApidList = false;
|
||||||
if (filter.apid) {
|
if (filter.apid) {
|
||||||
auto& apidFilter = filter.apid.value();
|
auto& apidFilter = filter.apid.value();
|
||||||
@ -98,11 +100,11 @@ ReturnValue_t TmStore::passPacket(PusTmReader& reader) {
|
|||||||
return returnvalue::OK;
|
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);
|
return dumpFromUpTo(fromUnixSeconds, currentTv.tv_sec, tmFunnel);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t TmStore::storePacket(PusTmReader& reader) {
|
ReturnValue_t PersistentTmStore::storePacket(PusTmReader& reader) {
|
||||||
using namespace std::filesystem;
|
using namespace std::filesystem;
|
||||||
if (baseDirUninitialized) {
|
if (baseDirUninitialized) {
|
||||||
updateBaseDir();
|
updateBaseDir();
|
||||||
@ -137,9 +139,9 @@ ReturnValue_t TmStore::storePacket(PusTmReader& reader) {
|
|||||||
return returnvalue::OK;
|
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) {
|
if (intervalUnit == RolloverInterval::MINUTELY) {
|
||||||
rolloverDiffSeconds = 60 * intervalCount;
|
rolloverDiffSeconds = 60 * intervalCount;
|
||||||
} else if (intervalUnit == RolloverInterval::HOURLY) {
|
} 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;
|
using namespace std::filesystem;
|
||||||
std::string currentPrefix = sdcMan.getCurrentMountPrefix();
|
std::string currentPrefix = sdcMan.getCurrentMountPrefix();
|
||||||
basePath = path(currentPrefix) / baseDir / baseName;
|
basePath = path(currentPrefix) / baseDir / baseName;
|
||||||
@ -159,7 +161,7 @@ void TmStore::updateBaseDir() {
|
|||||||
baseDirUninitialized = false;
|
baseDirUninitialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TmStore::assignAndOrCreateMostRecentFile() {
|
void PersistentTmStore::assignAndOrCreateMostRecentFile() {
|
||||||
using namespace std::filesystem;
|
using namespace std::filesystem;
|
||||||
for (auto const& file : directory_iterator(basePath)) {
|
for (auto const& file : directory_iterator(basePath)) {
|
||||||
if (file.is_directory()) {
|
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) {
|
if (not filter.apid) {
|
||||||
filter.apid = std::vector<uint16_t>({apid});
|
filter.apid = std::vector<uint16_t>({apid});
|
||||||
return;
|
return;
|
||||||
@ -212,7 +214,7 @@ void TmStore::addApid(uint16_t apid) {
|
|||||||
filter.apid.value().push_back(apid);
|
filter.apid.value().push_back(apid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TmStore::addService(uint8_t service) {
|
void PersistentTmStore::addService(uint8_t service) {
|
||||||
if (not filter.services) {
|
if (not filter.services) {
|
||||||
filter.services = std::vector<uint8_t>({service});
|
filter.services = std::vector<uint8_t>({service});
|
||||||
return;
|
return;
|
||||||
@ -220,7 +222,7 @@ void TmStore::addService(uint8_t service) {
|
|||||||
filter.services.value().push_back(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) {
|
if (not filter.serviceSubservices) {
|
||||||
filter.serviceSubservices =
|
filter.serviceSubservices =
|
||||||
std::vector<std::pair<uint8_t, uint8_t>>({std::pair(service, subservice)});
|
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);
|
filter.serviceSubservices.value().emplace_back(service, subservice);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TmStore::deleteUpTo(uint32_t unixSeconds) {
|
void PersistentTmStore::deleteUpTo(uint32_t unixSeconds) {
|
||||||
using namespace std::filesystem;
|
using namespace std::filesystem;
|
||||||
for (auto const& file : directory_iterator(basePath)) {
|
for (auto const& file : directory_iterator(basePath)) {
|
||||||
if (file.is_directory() or
|
if (file.is_directory() or
|
||||||
@ -250,8 +252,8 @@ void TmStore::deleteUpTo(uint32_t unixSeconds) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TmStore::dumpFromUpTo(uint32_t fromUnixSeconds, uint32_t upToUnixSeconds,
|
void PersistentTmStore::dumpFromUpTo(uint32_t fromUnixSeconds, uint32_t upToUnixSeconds,
|
||||||
TmFunnelBase& funnel) {
|
TmFunnelBase& funnel) {
|
||||||
using namespace std::filesystem;
|
using namespace std::filesystem;
|
||||||
for (auto const& file : directory_iterator(basePath)) {
|
for (auto const& file : directory_iterator(basePath)) {
|
||||||
if (file.is_directory()) {
|
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();
|
auto pathStr = path.string();
|
||||||
size_t splitChar = pathStr.find('_');
|
size_t splitChar = pathStr.find('_');
|
||||||
auto timeOnlyStr = pathStr.substr(splitChar);
|
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);
|
&tod.year, &tod.month, &tod.day, &tod.hour, &tod.minute, &tod.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TmStore::fileToPackets(const std::filesystem::path& path, uint32_t unixStamp,
|
void PersistentTmStore::fileToPackets(const std::filesystem::path& path, uint32_t unixStamp,
|
||||||
TmFunnelBase& funnel) {
|
TmFunnelBase& funnel) {
|
||||||
store_address_t storeId;
|
store_address_t storeId;
|
||||||
TmTcMessage message;
|
TmTcMessage message;
|
||||||
size_t size = std::filesystem::file_size(path);
|
size_t size = std::filesystem::file_size(path);
|
||||||
|
@ -21,7 +21,7 @@ struct PacketFilter {
|
|||||||
|
|
||||||
enum class RolloverInterval { MINUTELY, HOURLY, DAILY };
|
enum class RolloverInterval { MINUTELY, HOURLY, DAILY };
|
||||||
|
|
||||||
class TmStore : public TmStoreFrontendSimpleIF, public SystemObject {
|
class PersistentTmStore : public TmStoreFrontendSimpleIF, public SystemObject {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PERSISTENT_TM_STORE;
|
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.
|
//! P2: Timestamp of possibly corrupt file as a unix timestamp.
|
||||||
static constexpr Event POSSIBLE_FILE_CORRUPTION =
|
static constexpr Event POSSIBLE_FILE_CORRUPTION =
|
||||||
event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW);
|
event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW);
|
||||||
TmStore(object_id_t objectId, const char* baseDir, std::string baseName,
|
PersistentTmStore(object_id_t objectId, const char* baseDir, std::string baseName,
|
||||||
RolloverInterval intervalUnit, uint32_t intervalCount, timeval& currentTv,
|
RolloverInterval intervalUnit, uint32_t intervalCount, timeval& currentTv,
|
||||||
StorageManagerIF& tmStore, SdCardMountedIF& sdcMan);
|
StorageManagerIF& tmStore, SdCardMountedIF& sdcMan);
|
||||||
|
|
||||||
ReturnValue_t handleCommandQueue(StorageManagerIF& ipcStore, TmFunnelBase& tmFunnel);
|
ReturnValue_t handleCommandQueue(StorageManagerIF& ipcStore, TmFunnelBase& tmFunnel);
|
||||||
|
|
||||||
|
@ -38,10 +38,10 @@ class PusTmFunnel : public TmFunnelBase {
|
|||||||
bool storesInitialized = false;
|
bool storesInitialized = false;
|
||||||
timeval currentTv{};
|
timeval currentTv{};
|
||||||
timeval lastTvUpdate{};
|
timeval lastTvUpdate{};
|
||||||
TmStore miscStore;
|
PersistentTmStore miscStore;
|
||||||
TmStore okStore;
|
PersistentTmStore okStore;
|
||||||
TmStore notOkStore;
|
PersistentTmStore notOkStore;
|
||||||
TmStore hkStore;
|
PersistentTmStore hkStore;
|
||||||
SdCardMountedIF &sdcMan;
|
SdCardMountedIF &sdcMan;
|
||||||
|
|
||||||
ReturnValue_t handleTmPacket(TmTcMessage &message);
|
ReturnValue_t handleTmPacket(TmTcMessage &message);
|
||||||
|
Loading…
Reference in New Issue
Block a user
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?
No. I'll probably update the code so each persistent store calls `Clock::getClock_timeval