This commit is contained in:
parent
f0536a9d77
commit
457acc3bdb
@ -137,53 +137,68 @@ ReturnValue_t PersistentTmStore::handleCommandQueue(StorageManagerIF& ipcStore,
|
||||
if (cmdMessage.getMessageType() == messagetypes::TM_STORE) {
|
||||
Command_t cmd = cmdMessage.getCommand();
|
||||
if (cmd == TmStoreMessage::DELETE_STORE_CONTENT_TIME) {
|
||||
Clock::getClock_timeval(¤tTv);
|
||||
store_address_t storeId = TmStoreMessage::getStoreId(&cmdMessage);
|
||||
auto accessor = ipcStore.getData(storeId);
|
||||
size_t size = accessor.second.size();
|
||||
if (size < 4) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
const uint8_t* data = accessor.second.data();
|
||||
uint32_t deleteUpToUnixSeconds = 0;
|
||||
if (size == 4) {
|
||||
SerializeAdapter::deSerialize(&deleteUpToUnixSeconds, &data, &size,
|
||||
SerializeIF::Endianness::NETWORK);
|
||||
deleteUpTo(deleteUpToUnixSeconds);
|
||||
} else if (size == 8) {
|
||||
uint32_t deleteFromUnixSeconds = 0;
|
||||
SerializeAdapter::deSerialize(&deleteFromUnixSeconds, &data, &size,
|
||||
SerializeIF::Endianness::NETWORK);
|
||||
SerializeAdapter::deSerialize(&deleteUpToUnixSeconds, &data, &size,
|
||||
SerializeIF::Endianness::NETWORK);
|
||||
deleteFromUpTo(deleteFromUnixSeconds, deleteUpToUnixSeconds);
|
||||
}
|
||||
result = handleDeletionCmd(ipcStore, cmdMessage);
|
||||
execCmd = cmd;
|
||||
} else if (cmd == TmStoreMessage::DOWNLINK_STORE_CONTENT_TIME) {
|
||||
Clock::getClock_timeval(¤tTv);
|
||||
store_address_t storeId = TmStoreMessage::getStoreId(&cmdMessage);
|
||||
auto accessor = ipcStore.getData(storeId);
|
||||
if (accessor.second.size() < 8) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
uint32_t dumpFromUnixSeconds = 0;
|
||||
uint32_t dumpUntilUnixSeconds = 0;
|
||||
size_t size = 8;
|
||||
SerializeAdapter::deSerialize(&dumpFromUnixSeconds, accessor.second.data(), &size,
|
||||
SerializeIF::Endianness::NETWORK);
|
||||
SerializeAdapter::deSerialize(&dumpUntilUnixSeconds, accessor.second.data() + 4, &size,
|
||||
SerializeIF::Endianness::NETWORK);
|
||||
result = startDumpFromUpTo(dumpFromUnixSeconds, dumpUntilUnixSeconds);
|
||||
if (result == BUSY_DUMPING) {
|
||||
triggerEvent(persTmStore::BUSY_DUMPING_EVENT);
|
||||
return result;
|
||||
}
|
||||
result = handleDumpCmd(ipcStore, cmdMessage);
|
||||
execCmd = cmd;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PersistentTmStore::handleDeletionCmd(StorageManagerIF& ipcStore,
|
||||
CommandMessage& cmdMessage) {
|
||||
Clock::getClock_timeval(¤tTv);
|
||||
store_address_t storeId = TmStoreMessage::getStoreId(&cmdMessage);
|
||||
auto accessor = ipcStore.getData(storeId);
|
||||
size_t size = accessor.second.size();
|
||||
if (size < 4) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
const uint8_t* data = accessor.second.data();
|
||||
uint32_t deleteUpToUnixSeconds = 0;
|
||||
if (size == 4) {
|
||||
SerializeAdapter::deSerialize(&deleteUpToUnixSeconds, &data, &size,
|
||||
SerializeIF::Endianness::NETWORK);
|
||||
deleteUpTo(deleteUpToUnixSeconds);
|
||||
} else if (size == 8) {
|
||||
uint32_t deleteFromUnixSeconds = 0;
|
||||
SerializeAdapter::deSerialize(&deleteFromUnixSeconds, &data, &size,
|
||||
SerializeIF::Endianness::NETWORK);
|
||||
SerializeAdapter::deSerialize(&deleteUpToUnixSeconds, &data, &size,
|
||||
SerializeIF::Endianness::NETWORK);
|
||||
deleteFromUpTo(deleteFromUnixSeconds, deleteUpToUnixSeconds);
|
||||
} else {
|
||||
sif::warning << "PersistentTmStore: Unknown deletion time specification" << std::endl;
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PersistentTmStore::handleDumpCmd(StorageManagerIF& ipcStore,
|
||||
CommandMessage& cmdMessage) {
|
||||
Clock::getClock_timeval(¤tTv);
|
||||
store_address_t storeId = TmStoreMessage::getStoreId(&cmdMessage);
|
||||
auto accessor = ipcStore.getData(storeId);
|
||||
if (accessor.second.size() < 8) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
uint32_t dumpFromUnixSeconds = 0;
|
||||
uint32_t dumpUntilUnixSeconds = 0;
|
||||
size_t size = 8;
|
||||
SerializeAdapter::deSerialize(&dumpFromUnixSeconds, accessor.second.data(), &size,
|
||||
SerializeIF::Endianness::NETWORK);
|
||||
SerializeAdapter::deSerialize(&dumpUntilUnixSeconds, accessor.second.data() + 4, &size,
|
||||
SerializeIF::Endianness::NETWORK);
|
||||
ReturnValue_t result = startDumpFromUpTo(dumpFromUnixSeconds, dumpUntilUnixSeconds);
|
||||
if (result == BUSY_DUMPING) {
|
||||
triggerEvent(persTmStore::BUSY_DUMPING_EVENT);
|
||||
return result;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PersistentTmStore::startDumpFrom(uint32_t fromUnixSeconds) {
|
||||
return startDumpFromUpTo(fromUnixSeconds, currentTv.tv_sec);
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include "eive/eventSubsystemIds.h"
|
||||
#include "eive/resultClassIds.h"
|
||||
#include "fsfw/ipc/CommandMessage.h"
|
||||
|
||||
enum class RolloverInterval { MINUTELY, HOURLY, DAILY };
|
||||
|
||||
@ -146,6 +147,8 @@ class PersistentTmStore : public TmStoreFrontendSimpleIF, public SystemObject {
|
||||
std::optional<uint8_t> extractSuffix(const std::string& pathStr);
|
||||
bool updateBaseDir();
|
||||
ReturnValue_t assignAndOrCreateMostRecentFile();
|
||||
ReturnValue_t handleDeletionCmd(StorageManagerIF& ipcStore, CommandMessage& cmdMessage);
|
||||
ReturnValue_t handleDumpCmd(StorageManagerIF& ipcStore, CommandMessage& cmdMessage);
|
||||
};
|
||||
|
||||
#endif /* MISSION_TMTC_TMSTOREBACKEND_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user