Refactor TM handling #450
@ -25,17 +25,19 @@ static constexpr Event POSSIBLE_FILE_CORRUPTION = event::makeEvent(SUBSYSTEM_ID,
|
||||
//! P2: Allowed file size
|
||||
static constexpr Event FILE_TOO_LARGE = event::makeEvent(SUBSYSTEM_ID, 1, severity::LOW);
|
||||
static constexpr Event BUSY_DUMPING_EVENT = event::makeEvent(SUBSYSTEM_ID, 2, severity::INFO);
|
||||
//! [EXPORT] : [COMMENT] Dump was cancelled. P1: Object ID of store.
|
||||
static constexpr Event DUMP_WAS_CANCELLED = event::makeEvent(SUBSYSTEM_ID, 3, severity::LOW);
|
||||
|
||||
//! [EXPORT] : [COMMENT] P1: Start time as UNIX seconds. P2: End time as UNIX seconds.
|
||||
static constexpr Event DUMP_OK_STORE_DONE = event::makeEvent(SUBSYSTEM_ID, 3, severity::INFO);
|
||||
static constexpr Event DUMP_OK_STORE_DONE = event::makeEvent(SUBSYSTEM_ID, 5, severity::INFO);
|
||||
//! [EXPORT] : [COMMENT] P1: Start time as UNIX seconds. P2: End time as UNIX seconds.
|
||||
static constexpr Event DUMP_NOK_STORE_DONE = event::makeEvent(SUBSYSTEM_ID, 4, severity::INFO);
|
||||
static constexpr Event DUMP_NOK_STORE_DONE = event::makeEvent(SUBSYSTEM_ID, 6, severity::INFO);
|
||||
//! [EXPORT] : [COMMENT] P1: Start time as UNIX seconds. P2: End time as UNIX seconds.
|
||||
static constexpr Event DUMP_MISC_STORE_DONE = event::makeEvent(SUBSYSTEM_ID, 5, severity::INFO);
|
||||
static constexpr Event DUMP_MISC_STORE_DONE = event::makeEvent(SUBSYSTEM_ID, 7, severity::INFO);
|
||||
//! [EXPORT] : [COMMENT] P1: Start time as UNIX seconds. P2: End time as UNIX seconds.
|
||||
static constexpr Event DUMP_HK_STORE_DONE = event::makeEvent(SUBSYSTEM_ID, 6, severity::INFO);
|
||||
static constexpr Event DUMP_HK_STORE_DONE = event::makeEvent(SUBSYSTEM_ID, 8, severity::INFO);
|
||||
//! [EXPORT] : [COMMENT] P1: Start time as UNIX seconds. P2: End time as UNIX seconds.
|
||||
static constexpr Event DUMP_CFDP_STORE_DONE = event::makeEvent(SUBSYSTEM_ID, 7, severity::INFO);
|
||||
static constexpr Event DUMP_CFDP_STORE_DONE = event::makeEvent(SUBSYSTEM_ID, 9, severity::INFO);
|
||||
}; // namespace persTmStore
|
||||
|
||||
#endif /* MISSION_PERSISTENTTMSTOREDEFS_H_ */
|
||||
|
@ -26,6 +26,11 @@ PersistentTmStore::PersistentTmStore(PersistentTmStoreArgs args)
|
||||
calcDiffSeconds(args.intervalUnit, args.intervalCount);
|
||||
}
|
||||
|
||||
ReturnValue_t PersistentTmStore::cancelDump() {
|
||||
state = State::IDLE;
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PersistentTmStore::assignAndOrCreateMostRecentFile() {
|
||||
if (not activeFile.has_value()) {
|
||||
return createMostRecentFile(std::nullopt);
|
||||
@ -33,7 +38,8 @@ ReturnValue_t PersistentTmStore::assignAndOrCreateMostRecentFile() {
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PersistentTmStore::handleCommandQueue(StorageManagerIF& ipcStore) {
|
||||
ReturnValue_t PersistentTmStore::handleCommandQueue(StorageManagerIF& ipcStore,
|
||||
Command_t& execCmd) {
|
||||
CommandMessage cmdMessage;
|
||||
ReturnValue_t result = tcQueue->receiveMessage(&cmdMessage);
|
||||
if (result != returnvalue::OK) {
|
||||
@ -49,6 +55,7 @@ ReturnValue_t PersistentTmStore::handleCommandQueue(StorageManagerIF& ipcStore)
|
||||
size_t size = accessor.second.size();
|
||||
SerializeAdapter::deSerialize(&deleteUpToUnixSeconds, accessor.second.data(), &size,
|
||||
SerializeIF::Endianness::NETWORK);
|
||||
execCmd = cmd;
|
||||
deleteUpTo(deleteUpToUnixSeconds);
|
||||
} else if (cmd == TmStoreMessage::DOWNLINK_STORE_CONTENT_TIME) {
|
||||
Clock::getClock_timeval(¤tTv);
|
||||
@ -67,10 +74,12 @@ ReturnValue_t PersistentTmStore::handleCommandQueue(StorageManagerIF& ipcStore)
|
||||
result = startDumpFromUpTo(dumpFromUnixSeconds, dumpUntilUnixSeconds);
|
||||
if (result == BUSY_DUMPING) {
|
||||
triggerEvent(persTmStore::BUSY_DUMPING_EVENT);
|
||||
} else {
|
||||
execCmd = cmd;
|
||||
}
|
||||
}
|
||||
}
|
||||
return returnvalue::OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PersistentTmStore::startDumpFrom(uint32_t fromUnixSeconds) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef MISSION_TMTC_TMSTOREBACKEND_H_
|
||||
#define MISSION_TMTC_TMSTOREBACKEND_H_
|
||||
|
||||
#include <fsfw/ipc/CommandMessageIF.h>
|
||||
#include <fsfw/objectmanager/SystemObject.h>
|
||||
#include <fsfw/storagemanager/StorageManagerIF.h>
|
||||
#include <fsfw/timemanager/CdsShortTimeStamper.h>
|
||||
@ -49,7 +50,7 @@ class PersistentTmStore : public TmStoreFrontendSimpleIF, public SystemObject {
|
||||
|
||||
ReturnValue_t initializeTmStore();
|
||||
State getState() const;
|
||||
ReturnValue_t handleCommandQueue(StorageManagerIF& ipcStore);
|
||||
ReturnValue_t handleCommandQueue(StorageManagerIF& ipcStore, Command_t& execCmd);
|
||||
|
||||
void deleteUpTo(uint32_t unixSeconds);
|
||||
ReturnValue_t startDumpFrom(uint32_t fromUnixSeconds);
|
||||
@ -66,6 +67,7 @@ class PersistentTmStore : public TmStoreFrontendSimpleIF, public SystemObject {
|
||||
|
||||
void getStartAndEndTimeCurrentOrLastDump(uint32_t& startTime, uint32_t& endTime) const;
|
||||
ReturnValue_t storePacket(PusTmReader& reader);
|
||||
ReturnValue_t cancelDump();
|
||||
|
||||
protected:
|
||||
StorageManagerIF& tmStore;
|
||||
|
@ -1,7 +1,11 @@
|
||||
#include "TmStoreTaskBase.h"
|
||||
|
||||
#include <fsfw/ipc/CommandMessageIF.h>
|
||||
#include <fsfw/tasks/TaskFactory.h>
|
||||
#include <fsfw/timemanager/Stopwatch.h>
|
||||
#include <fsfw/tmstorage/TmStoreMessage.h>
|
||||
|
||||
#include "mission/persistentTmStoreDefs.h"
|
||||
|
||||
TmStoreTaskBase::TmStoreTaskBase(object_id_t objectId, StorageManagerIF& ipcStore,
|
||||
VirtualChannel& channel, SdCardMountedIF& sdcMan)
|
||||
@ -22,6 +26,7 @@ bool TmStoreTaskBase::handleOneStore(PersistentTmStoreWithTmQueue& store, Event
|
||||
size_t dumpedLen;
|
||||
bool fileHasSwapped;
|
||||
if (not channel.isBusy()) {
|
||||
tmSinkBusyCd.resetTimer();
|
||||
// TODO: We could continously dump until a file swap during active downlink..
|
||||
result = store.dumpNextPacket(channel, dumpedLen, fileHasSwapped);
|
||||
if (result == PersistentTmStore::DUMP_DONE) {
|
||||
@ -34,10 +39,19 @@ bool TmStoreTaskBase::handleOneStore(PersistentTmStoreWithTmQueue& store, Event
|
||||
dumpsPerformed = true;
|
||||
}
|
||||
}
|
||||
if (cancelDumpCd.hasTimedOut() or tmSinkBusyCd.hasTimedOut()) {
|
||||
triggerEvent(persTmStore::DUMP_WAS_CANCELLED, store.getObjectId());
|
||||
store.cancelDump();
|
||||
}
|
||||
} else {
|
||||
Command_t execCmd;
|
||||
// Handle TC requests, for example deletion or retrieval requests.
|
||||
result = store.handleCommandQueue(ipcStore);
|
||||
result = store.handleCommandQueue(ipcStore, execCmd);
|
||||
if (result == returnvalue::OK) {
|
||||
if (execCmd == TmStoreMessage::DOWNLINK_STORE_CONTENT_TIME) {
|
||||
cancelDumpCd.resetTimer();
|
||||
tmSinkBusyCd.resetTimer();
|
||||
}
|
||||
tcRequestReceived = true;
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,10 @@ class TmStoreTaskBase : public SystemObject {
|
||||
|
||||
StorageManagerIF& ipcStore;
|
||||
Countdown sdCardCheckCd = Countdown(800);
|
||||
// 20 minutes are allowed as maximum dump time.
|
||||
Countdown cancelDumpCd = Countdown(60 * 20 * 1000);
|
||||
// If the TM sink is busy for 1 minute for whatever reason, cancel the dump.
|
||||
Countdown tmSinkBusyCd = Countdown(60 * 1000);
|
||||
VirtualChannel& channel;
|
||||
bool storesInitialized = false;
|
||||
SdCardMountedIF& sdcMan;
|
||||
|
Loading…
Reference in New Issue
Block a user