Merge remote-tracking branch 'origin/develop' into papb_multi_byte_write_support
Some checks failed
EIVE/eive-obsw/pipeline/pr-develop There was a failure building this commit
Some checks failed
EIVE/eive-obsw/pipeline/pr-develop There was a failure building this commit
This commit is contained in:
54
mission/com/PersistentSingleTmStoreTask.cpp
Normal file
54
mission/com/PersistentSingleTmStoreTask.cpp
Normal file
@ -0,0 +1,54 @@
|
||||
#include "PersistentSingleTmStoreTask.h"
|
||||
|
||||
#include <fsfw/tasks/TaskFactory.h>
|
||||
#include <fsfw/timemanager/Stopwatch.h>
|
||||
#include <unistd.h>
|
||||
|
||||
PersistentSingleTmStoreTask::PersistentSingleTmStoreTask(
|
||||
object_id_t objectId, StorageManagerIF& ipcStore, PersistentTmStoreWithTmQueue& tmStore,
|
||||
VirtualChannel& channel, Event eventIfDumpDone, Event eventIfCancelled, SdCardMountedIF& sdcMan,
|
||||
const std::atomic_bool& ptmeLocked)
|
||||
: TmStoreTaskBase(objectId, ipcStore, channel, sdcMan, ptmeLocked),
|
||||
storeWithQueue(tmStore),
|
||||
dumpContext(eventIfDumpDone, eventIfCancelled) {}
|
||||
|
||||
ReturnValue_t PersistentSingleTmStoreTask::performOperation(uint8_t opCode) {
|
||||
while (true) {
|
||||
readCommandQueue();
|
||||
|
||||
// Delay done by the check
|
||||
if (not cyclicStoreCheck()) {
|
||||
continue;
|
||||
}
|
||||
bool busy = handleOneStore(storeWithQueue, dumpContext);
|
||||
if (not busy) {
|
||||
TaskFactory::delayTask(100);
|
||||
} else if (dumpContext.vcBusyDuringDump) {
|
||||
sif::debug << "VC busy, delaying" << std::endl;
|
||||
// TODO: Might not be necessary
|
||||
TaskFactory::delayTask(10);
|
||||
} else {
|
||||
// TODO: Would be best to remove this, but not delaying here can lead to evil issues.
|
||||
TaskFactory::delayTask(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool PersistentSingleTmStoreTask::initStoresIfPossible() {
|
||||
if (sdcMan.isSdCardUsable(std::nullopt)) {
|
||||
storeWithQueue.initializeTmStore();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void PersistentSingleTmStoreTask::startTransition(Mode_t mode, Submode_t submode) {
|
||||
if (mode == MODE_OFF) {
|
||||
cancelDump(dumpContext, storeWithQueue, channel.isTxOn());
|
||||
this->mode = MODE_OFF;
|
||||
} else if (mode == MODE_ON) {
|
||||
this->mode = MODE_ON;
|
||||
}
|
||||
modeHelper.modeChanged(mode, submode);
|
||||
announceMode(false);
|
||||
}
|
Reference in New Issue
Block a user