added missing store initialization code
EIVE/eive-obsw/pipeline/pr-develop There was a failure building this commit Details

This commit is contained in:
Robin Müller 2023-03-09 20:16:00 +01:00
parent e6aa582fcb
commit d50cbe9e5b
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
8 changed files with 82 additions and 22 deletions

View File

@ -771,7 +771,7 @@ ReturnValue_t ObjectFactory::createCcsdsComponents(CcsdsComponentArgs& args) {
auto* vcWithQueue =
new VirtualChannelWithQueue(objects::PTME_VC0_LIVE_TM, ccsds::VC0, "PTME VC0 LIVE TM", *ptme,
LINK_STATE, args.tmStore, 500);
args.liveDestination = vcWithQueue->getReportReceptionQueue(0);
args.liveDestination = vcWithQueue;
new LiveTmTask(objects::LIVE_TM_TASK, *vcWithQueue);
// Set up log store.
@ -779,17 +779,19 @@ ReturnValue_t ObjectFactory::createCcsdsComponents(CcsdsComponentArgs& args) {
LINK_STATE);
LogStores logStores(args.stores);
// Core task which handles the LOG store and takes care of dumping it as TM using a VC directly
new PersistentLogTmStoreTask(objects::LOG_STORE_TASK, args.ipcStore, logStores, *vc);
new PersistentLogTmStoreTask(objects::LOG_STORE_TASK, args.ipcStore, logStores, *vc,
*SdCardManager::instance());
vc = new VirtualChannel(objects::PTME_VC2_HK_TM, ccsds::VC2, "PTME VC2 HK TM", *ptme, LINK_STATE);
// Core task which handles the HK store and takes care of dumping it as TM using a VC directly
new PersistentSingleTmStoreTask(objects::HK_STORE_TASK, args.ipcStore, *args.stores.hkStore, *vc);
new PersistentSingleTmStoreTask(objects::HK_STORE_TASK, args.ipcStore, *args.stores.hkStore, *vc,
*SdCardManager::instance());
vc = new VirtualChannel(objects::PTME_VC3_CFDP_TM, ccsds::VC3, "PTME VC3 CFDP TM", *ptme,
LINK_STATE);
// Core task which handles the CFDP store and takes care of dumping it as TM using a VC directly
new PersistentSingleTmStoreTask(objects::CFDP_STORE_TASK, args.ipcStore, *args.stores.cfdpStore,
*vc);
*vc, *SdCardManager::instance());
ReturnValue_t result = (*args.ipCoreHandler)->connectModeTreeParent(satsystem::com::SUBSYSTEM);
if (result != returnvalue::OK) {

View File

@ -80,11 +80,9 @@ void ObjectFactory::produce(void* args) {
CcsdsComponentArgs ccsdsArgs(*gpioComIF, *ipcStore, *tmStore, stores, &ipCoreHandler);
createCcsdsComponents(ccsdsArgs);
#if OBSW_TM_TO_PTME == 1
// TODO: Remove this if not needed anymore
if (*ccsdsArgs.liveDestination != nullptr) {
if (ccsdsArgs.liveDestination != nullptr) {
pusFunnel->addLiveDestination("VC0 LIVE TM", *ccsdsArgs.liveDestination, 0);
}
// addTmtcIpCoresToFunnels(*ipCoreHandler, *pusFunnel, *cfdpFunnel);
#endif
#endif /* OBSW_ADD_CCSDS_IP_CORES == 1 */

View File

@ -3,20 +3,26 @@
#include <fsfw/tasks/TaskFactory.h>
PersistentLogTmStoreTask::PersistentLogTmStoreTask(object_id_t objectId, StorageManagerIF& ipcStore,
LogStores stores, VirtualChannel& channel)
: TmStoreTaskBase(objectId, ipcStore, channel), stores(stores) {}
LogStores stores, VirtualChannel& channel,
SdCardMountedIF& sdcMan)
: TmStoreTaskBase(objectId, ipcStore, channel, sdcMan), stores(stores) {}
ReturnValue_t PersistentLogTmStoreTask::performOperation(uint8_t opCode) {
while (true) {
bool someonesBusy = false;
bool busy = handleOneStore(stores.okStore);
if (busy) {
someonesBusy = true;
if (not cyclicStoreCheck()) {
continue;
}
bool someonesBusy = false;
bool busy = false;
busy = handleOneStore(stores.okStore);
if (busy) {
someonesBusy = true;
}
busy = handleOneStore(stores.notOkStore);
if (busy) {
someonesBusy = true;
}
busy = handleOneStore(stores.miscStore);
if (busy) {
someonesBusy = true;
@ -26,3 +32,12 @@ ReturnValue_t PersistentLogTmStoreTask::performOperation(uint8_t opCode) {
}
}
}
void PersistentLogTmStoreTask::initStoresIfPossible() {
if (sdcMan.isSdCardUsable(std::nullopt)) {
stores.okStore.initializeTmStore();
stores.miscStore.initializeTmStore();
stores.notOkStore.initializeTmStore();
storesInitialized = true;
}
}

View File

@ -22,12 +22,14 @@ struct LogStores {
class PersistentLogTmStoreTask : public TmStoreTaskBase, public ExecutableObjectIF {
public:
PersistentLogTmStoreTask(object_id_t objectId, StorageManagerIF& ipcStore, LogStores tmStore,
VirtualChannel& channel);
VirtualChannel& channel, SdCardMountedIF& sdcMan);
ReturnValue_t performOperation(uint8_t opCode) override;
private:
LogStores stores;
void initStoresIfPossible();
};
#endif /* MISSION_TMTC_PERSISTENTLOGTMSTORETASK_H_ */

View File

@ -4,14 +4,20 @@
PersistentSingleTmStoreTask::PersistentSingleTmStoreTask(object_id_t objectId,
StorageManagerIF& ipcStore,
PersistentTmStoreWithTmQueue& tmStore,
VirtualChannel& channel)
: TmStoreTaskBase(objectId, ipcStore, channel), storeWithQueue(tmStore) {}
VirtualChannel& channel,
SdCardMountedIF& sdcMan)
: TmStoreTaskBase(objectId, ipcStore, channel, sdcMan), storeWithQueue(tmStore) {}
ReturnValue_t PersistentSingleTmStoreTask::performOperation(uint8_t opCode) {
while (true) {
if (not cyclicStoreCheck()) {
continue;
}
bool busy = handleOneStore(storeWithQueue);
if (not busy) {
TaskFactory::delayTask(5);
}
}
}
void PersistentSingleTmStoreTask::initStoresIfPossible() {}

View File

@ -10,13 +10,15 @@
class PersistentSingleTmStoreTask : public TmStoreTaskBase, public ExecutableObjectIF {
public:
PersistentSingleTmStoreTask(object_id_t objectId, StorageManagerIF& ipcStore,
PersistentTmStoreWithTmQueue& storeWithQueue,
VirtualChannel& channel);
PersistentTmStoreWithTmQueue& storeWithQueue, VirtualChannel& channel,
SdCardMountedIF& sdcMan);
ReturnValue_t performOperation(uint8_t opCode) override;
private:
PersistentTmStoreWithTmQueue& storeWithQueue;
void initStoresIfPossible();
};
#endif /* MISSION_TMTC_PERSISTENTSINGLETMSTORETASK_H_ */

View File

@ -1,8 +1,10 @@
#include "TmStoreTaskBase.h"
#include <fsfw/tasks/TaskFactory.h>
TmStoreTaskBase::TmStoreTaskBase(object_id_t objectId, StorageManagerIF& ipcStore,
VirtualChannel& channel)
: SystemObject(objectId), ipcStore(ipcStore), channel(channel) {}
VirtualChannel& channel, SdCardMountedIF& sdcMan)
: SystemObject(objectId), ipcStore(ipcStore), channel(channel), sdcMan(sdcMan) {}
bool TmStoreTaskBase::handleOneStore(PersistentTmStoreWithTmQueue& store) {
bool tmToStoreReceived = true;
@ -33,3 +35,22 @@ bool TmStoreTaskBase::handleOneStore(PersistentTmStoreWithTmQueue& store) {
}
return false;
}
bool TmStoreTaskBase::cyclicStoreCheck() {
if (not storesInitialized) {
initStoresIfPossible();
if (not storesInitialized) {
TaskFactory::delayTask(400);
return false;
}
} else if (sdCardCheckCd.hasTimedOut()) {
if (not sdcMan.isSdCardUsable(std::nullopt)) {
// Might be due to imminent shutdown or SD card switch.
storesInitialized = false;
TaskFactory::delayTask(100);
return false;
}
sdCardCheckCd.resetTimer();
}
return true;
}

View File

@ -1,12 +1,16 @@
#ifndef MISSION_TMTC_TMSTORETASKBASE_H_
#define MISSION_TMTC_TMSTORETASKBASE_H_
#include <fsfw/timemanager/Countdown.h>
#include <mission/tmtc/PersistentTmStoreWithTmQueue.h>
#include <mission/tmtc/VirtualChannel.h>
class TmStoreTaskBase : public SystemObject {
public:
TmStoreTaskBase(object_id_t objectId, StorageManagerIF& ipcStore, VirtualChannel& channel);
TmStoreTaskBase(object_id_t objectId, StorageManagerIF& ipcStore, VirtualChannel& channel,
SdCardMountedIF& sdcMan);
protected:
/**
* Handling for one store. Returns if anything was done.
* @param store
@ -14,9 +18,19 @@ class TmStoreTaskBase : public SystemObject {
*/
bool handleOneStore(PersistentTmStoreWithTmQueue& store);
private:
/**
* Occasionally check whether SD card is okay to be used. If not, poll whether it is ready to
* be used again and re-initialize stores. Returns whether store is okay to be used.
*/
bool cyclicStoreCheck();
virtual void initStoresIfPossible() = 0;
StorageManagerIF& ipcStore;
Countdown sdCardCheckCd = Countdown(800);
VirtualChannel& channel;
bool storesInitialized = false;
SdCardMountedIF& sdcMan;
};
#endif /* MISSION_TMTC_TMSTORETASKBASE_H_ */