2023-03-09 17:44:05 +01:00
|
|
|
#include "PersistentLogTmStoreTask.h"
|
2023-03-09 19:42:20 +01:00
|
|
|
|
|
|
|
#include <fsfw/tasks/TaskFactory.h>
|
|
|
|
|
|
|
|
PersistentLogTmStoreTask::PersistentLogTmStoreTask(object_id_t objectId, StorageManagerIF& ipcStore,
|
2023-03-09 20:16:00 +01:00
|
|
|
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) {
|
2023-03-09 20:16:00 +01:00
|
|
|
if (not cyclicStoreCheck()) {
|
|
|
|
continue;
|
|
|
|
}
|
2023-03-09 19:42:20 +01:00
|
|
|
bool someonesBusy = false;
|
2023-03-09 20:16:00 +01:00
|
|
|
bool busy = false;
|
|
|
|
busy = handleOneStore(stores.okStore);
|
2023-03-09 19:42:20 +01:00
|
|
|
if (busy) {
|
|
|
|
someonesBusy = true;
|
|
|
|
}
|
2023-03-09 20:16:00 +01:00
|
|
|
busy = handleOneStore(stores.notOkStore);
|
2023-03-09 19:42:20 +01:00
|
|
|
if (busy) {
|
|
|
|
someonesBusy = true;
|
|
|
|
}
|
2023-03-09 20:16:00 +01:00
|
|
|
|
2023-03-09 19:42:20 +01:00
|
|
|
busy = handleOneStore(stores.miscStore);
|
|
|
|
if (busy) {
|
|
|
|
someonesBusy = true;
|
|
|
|
}
|
|
|
|
if (not someonesBusy) {
|
|
|
|
TaskFactory::delayTask(5);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-03-09 20:16:00 +01:00
|
|
|
|
|
|
|
void PersistentLogTmStoreTask::initStoresIfPossible() {
|
|
|
|
if (sdcMan.isSdCardUsable(std::nullopt)) {
|
|
|
|
stores.okStore.initializeTmStore();
|
|
|
|
stores.miscStore.initializeTmStore();
|
|
|
|
stores.notOkStore.initializeTmStore();
|
|
|
|
storesInitialized = true;
|
|
|
|
}
|
|
|
|
}
|