eive-obsw/mission/tmtc/PersistentLogTmStoreTask.cpp

45 lines
1.4 KiB
C++
Raw Normal View History

2023-03-09 17:44:05 +01:00
#include "PersistentLogTmStoreTask.h"
2023-03-09 19:42:20 +01:00
#include <fsfw/tasks/TaskFactory.h>
2023-03-10 02:05:51 +01:00
#include <fsfw/timemanager/Stopwatch.h>
2023-03-09 19:42:20 +01:00
PersistentLogTmStoreTask::PersistentLogTmStoreTask(object_id_t objectId, StorageManagerIF& ipcStore,
LogStores stores, VirtualChannel& channel,
SdCardMountedIF& sdcMan)
: TmStoreTaskBase(objectId, ipcStore, channel, sdcMan), stores(stores) {}
2023-03-09 19:42:20 +01:00
ReturnValue_t PersistentLogTmStoreTask::performOperation(uint8_t opCode) {
while (true) {
if (not cyclicStoreCheck()) {
continue;
}
2023-03-09 19:42:20 +01:00
bool someonesBusy = false;
bool busy = false;
2023-03-10 19:01:31 +01:00
busy = handleOneStore(stores.okStore, persTmStore::DUMP_OK_STORE_DONE);
2023-03-09 19:42:20 +01:00
if (busy) {
someonesBusy = true;
}
2023-03-10 19:01:31 +01:00
busy = handleOneStore(stores.notOkStore, persTmStore::DUMP_NOK_STORE_DONE);
2023-03-09 19:42:20 +01:00
if (busy) {
someonesBusy = true;
}
2023-03-10 19:01:31 +01:00
busy = handleOneStore(stores.miscStore, persTmStore::DUMP_MISC_STORE_DONE);
2023-03-09 19:42:20 +01:00
if (busy) {
someonesBusy = true;
}
if (not someonesBusy) {
2023-03-10 02:05:51 +01:00
TaskFactory::delayTask(40);
2023-03-09 19:42:20 +01:00
}
}
}
2023-03-10 02:05:51 +01:00
bool PersistentLogTmStoreTask::initStoresIfPossible() {
if (sdcMan.isSdCardUsable(std::nullopt)) {
stores.okStore.initializeTmStore();
stores.miscStore.initializeTmStore();
stores.notOkStore.initializeTmStore();
2023-03-10 02:05:51 +01:00
return true;
}
2023-03-10 02:05:51 +01:00
return false;
}