eive-obsw/mission/tmtc/PersistentSingleTmStoreTask.cpp

32 lines
1.1 KiB
C++
Raw Normal View History

2023-03-09 17:44:05 +01:00
#include <fsfw/tasks/TaskFactory.h>
2023-03-10 02:05:51 +01:00
#include <fsfw/timemanager/Stopwatch.h>
2023-03-09 17:44:05 +01:00
#include <mission/tmtc/PersistentSingleTmStoreTask.h>
PersistentSingleTmStoreTask::PersistentSingleTmStoreTask(object_id_t objectId,
StorageManagerIF& ipcStore,
PersistentTmStoreWithTmQueue& tmStore,
VirtualChannel& channel,
SdCardMountedIF& sdcMan)
: TmStoreTaskBase(objectId, ipcStore, channel, sdcMan), storeWithQueue(tmStore) {}
2023-03-09 17:44:05 +01:00
ReturnValue_t PersistentSingleTmStoreTask::performOperation(uint8_t opCode) {
while (true) {
2023-03-10 02:05:51 +01:00
// Delay done by the check
if (not cyclicStoreCheck()) {
continue;
}
2023-03-10 02:05:51 +01:00
bool busy = handleOneStore(storeWithQueue, tcHandlingCd);
2023-03-09 19:42:20 +01:00
if (not busy) {
2023-03-10 02:05:51 +01:00
TaskFactory::delayTask(40);
2023-03-09 17:44:05 +01:00
}
}
}
2023-03-10 02:05:51 +01:00
bool PersistentSingleTmStoreTask::initStoresIfPossible() {
if (sdcMan.isSdCardUsable(std::nullopt)) {
storeWithQueue.initializeTmStore();
return true;
}
return false;
}