eive-obsw/mission/tmtc/PersistentSingleTmStoreTask.cpp
Robin Mueller fb324516bb
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
this is insane
2023-03-27 21:23:09 +02:00

53 lines
1.7 KiB
C++

#include <fsfw/tasks/TaskFactory.h>
#include <fsfw/timemanager/Stopwatch.h>
#include <mission/tmtc/PersistentSingleTmStoreTask.h>
#include <unistd.h>
PersistentSingleTmStoreTask::PersistentSingleTmStoreTask(
object_id_t objectId, StorageManagerIF& ipcStore, PersistentTmStoreWithTmQueue& tmStore,
VirtualChannel& channel, Event eventIfDumpDone, SdCardMountedIF& sdcMan)
: TmStoreTaskBase(objectId, ipcStore, channel, sdcMan),
storeWithQueue(tmStore),
dumpContext(eventIfDumpDone) {}
ReturnValue_t PersistentSingleTmStoreTask::performOperation(uint8_t opCode) {
uint32_t dummy = 0;
while (true) {
// Delay done by the check
if (not cyclicStoreCheck()) {
continue;
}
bool busy = handleOneStore(storeWithQueue, dumpContext);
if (not busy) {
TaskFactory::delayTask(100);
} else if(dumpContext.vcBusyDuringDump) {
TaskFactory::delayTask(30);
} else if (fileHasSwapped) {
TaskFactory::delayTask(30);
} else if(dumpContext.packetWasDumped and dumpContext.numberOfDumpedPackets % 5 == 0) {
TaskFactory::delayTask(30);
} else {
// dummy++;
// if(dummy % 2000 == 0) {
// sif::warning << "persistent tm store is stupid" << std::endl;
// }
TaskFactory::delayTask(2);
// continue;
}
dummy = 0;
//else if(dumpContext.numberOfDumpedPackets % 20 == 0) {
// Manual load management because I don't know what the scheduler is doing..
// Removing this delay can lead to evil side effects.
//TaskFactory::delayTask(5);
//}
}
}
bool PersistentSingleTmStoreTask::initStoresIfPossible() {
if (sdcMan.isSdCardUsable(std::nullopt)) {
storeWithQueue.initializeTmStore();
return true;
}
return false;
}