modes for VC/stores
This commit is contained in:
CHANGELOG.md
bsp_q7s/core
linux/ipcore
mission
com
CMakeLists.txtCcsdsIpCoreHandler.hLiveTmTask.cppLiveTmTask.hPersistentLogTmStoreTask.cppPersistentLogTmStoreTask.hPersistentSingleTmStoreTask.cppPersistentSingleTmStoreTask.hTmStoreTaskBase.cppTmStoreTaskBase.hVirtualChannel.cppVirtualChannel.hVirtualChannelWithQueue.cppVirtualChannelWithQueue.h
config
system
tmtc
72
mission/com/PersistentLogTmStoreTask.cpp
Normal file
72
mission/com/PersistentLogTmStoreTask.cpp
Normal file
@ -0,0 +1,72 @@
|
||||
#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),
|
||||
okStoreContext(persTmStore::DUMP_OK_STORE_DONE, persTmStore::DUMP_OK_CANCELLED),
|
||||
notOkStoreContext(persTmStore::DUMP_NOK_STORE_DONE, persTmStore::DUMP_NOK_CANCELLED),
|
||||
miscStoreContext(persTmStore::DUMP_MISC_STORE_DONE, persTmStore::DUMP_MISC_CANCELLED) {}
|
||||
|
||||
ReturnValue_t PersistentLogTmStoreTask::performOperation(uint8_t opCode) {
|
||||
bool someonesBusy = false;
|
||||
bool vcBusyDuringDump = false;
|
||||
auto stateHandlingForStore = [&](bool storeIsBusy, DumpContext& ctx) {
|
||||
if (storeIsBusy) {
|
||||
someonesBusy = true;
|
||||
}
|
||||
if (fileHasSwapped) {
|
||||
someFileWasSwapped = fileHasSwapped;
|
||||
}
|
||||
if (ctx.vcBusyDuringDump) {
|
||||
vcBusyDuringDump = true;
|
||||
}
|
||||
};
|
||||
while (true) {
|
||||
readCommandQueue();
|
||||
|
||||
if (not cyclicStoreCheck()) {
|
||||
continue;
|
||||
}
|
||||
someonesBusy = false;
|
||||
someFileWasSwapped = false;
|
||||
vcBusyDuringDump = false;
|
||||
stateHandlingForStore(handleOneStore(stores.okStore, okStoreContext), okStoreContext);
|
||||
stateHandlingForStore(handleOneStore(stores.notOkStore, notOkStoreContext), notOkStoreContext);
|
||||
stateHandlingForStore(handleOneStore(stores.miscStore, miscStoreContext), miscStoreContext);
|
||||
if (not someonesBusy) {
|
||||
TaskFactory::delayTask(100);
|
||||
} else if (vcBusyDuringDump) {
|
||||
// TODO: Might not be necessary
|
||||
TaskFactory::delayTask(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool PersistentLogTmStoreTask::initStoresIfPossible() {
|
||||
if (sdcMan.isSdCardUsable(std::nullopt)) {
|
||||
stores.okStore.initializeTmStore();
|
||||
stores.miscStore.initializeTmStore();
|
||||
stores.notOkStore.initializeTmStore();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void PersistentLogTmStoreTask::startTransition(Mode_t mode, Submode_t submode) {
|
||||
if (mode == MODE_OFF) {
|
||||
bool channelIsOn = channel.isTxOn();
|
||||
cancelDump(okStoreContext, stores.okStore, channelIsOn);
|
||||
cancelDump(notOkStoreContext, stores.notOkStore, channelIsOn);
|
||||
cancelDump(miscStoreContext, stores.miscStore, channelIsOn);
|
||||
this->mode = MODE_OFF;
|
||||
} else if (mode == MODE_ON) {
|
||||
this->mode = MODE_ON;
|
||||
}
|
||||
modeHelper.modeChanged(mode, submode);
|
||||
announceMode(false);
|
||||
}
|
Reference in New Issue
Block a user