45 lines
1.3 KiB
C++
45 lines
1.3 KiB
C++
#include "PersistentLogTmStoreTask.h"
|
|
|
|
#include <fsfw/tasks/TaskFactory.h>
|
|
#include <fsfw/timemanager/Stopwatch.h>
|
|
|
|
PersistentLogTmStoreTask::PersistentLogTmStoreTask(object_id_t objectId, StorageManagerIF& ipcStore,
|
|
LogStores stores, VirtualChannel& channel,
|
|
SdCardMountedIF& sdcMan)
|
|
: TmStoreTaskBase(objectId, ipcStore, channel, sdcMan), stores(stores) {}
|
|
|
|
ReturnValue_t PersistentLogTmStoreTask::performOperation(uint8_t opCode) {
|
|
while (true) {
|
|
if (not cyclicStoreCheck()) {
|
|
continue;
|
|
}
|
|
bool someonesBusy = false;
|
|
bool busy = false;
|
|
busy = handleOneStore(stores.okStore, tcHandlingCd);
|
|
if (busy) {
|
|
someonesBusy = true;
|
|
}
|
|
busy = handleOneStore(stores.notOkStore, tcHandlingCd);
|
|
if (busy) {
|
|
someonesBusy = true;
|
|
}
|
|
busy = handleOneStore(stores.miscStore, tcHandlingCd);
|
|
if (busy) {
|
|
someonesBusy = true;
|
|
}
|
|
if (not someonesBusy) {
|
|
TaskFactory::delayTask(40);
|
|
}
|
|
}
|
|
}
|
|
|
|
bool PersistentLogTmStoreTask::initStoresIfPossible() {
|
|
if (sdcMan.isSdCardUsable(std::nullopt)) {
|
|
stores.okStore.initializeTmStore();
|
|
stores.miscStore.initializeTmStore();
|
|
stores.notOkStore.initializeTmStore();
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|