refactored throttle handling
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good

This commit is contained in:
2023-10-13 10:57:58 +02:00
parent 031be000d4
commit 9f600a24ff
6 changed files with 37 additions and 21 deletions

View File

@ -15,7 +15,8 @@
using namespace returnvalue;
using namespace cfdp;
CfdpHandler::CfdpHandler(const FsfwHandlerParams& fsfwHandlerParams, const CfdpHandlerCfg& cfdpCfg)
CfdpHandler::CfdpHandler(const FsfwHandlerParams& fsfwHandlerParams, const CfdpHandlerCfg& cfdpCfg,
const std::atomic_bool& throttleSignal)
: SystemObject(fsfwHandlerParams.objectId),
pduQueue(fsfwHandlerParams.tmtcQueue),
cfdpRequestQueue(fsfwHandlerParams.cfdpQueue),
@ -28,7 +29,8 @@ CfdpHandler::CfdpHandler(const FsfwHandlerParams& fsfwHandlerParams, const CfdpH
this->fsfwParams),
srcHandler(SourceHandlerParams(localCfg, cfdpCfg.userHandler, seqCntProvider),
this->fsfwParams),
ipcStore(fsfwHandlerParams.ipcStore) {}
ipcStore(fsfwHandlerParams.ipcStore),
throttleSignal(throttleSignal) {}
[[nodiscard]] const char* CfdpHandler::getName() const { return "CFDP Handler"; }
@ -69,20 +71,11 @@ ReturnValue_t CfdpHandler::initialize() {
fsmCount++;
}
fsmCount = 0;
if (signals::CFDP_CHANNEL_THROTTLE_SIGNAL) {
throttlePeriodSourceHandler.resetTimer();
if (throttleSignal) {
throttlePeriodOngoing = true;
signals::CFDP_CHANNEL_THROTTLE_SIGNAL = false;
}
if (throttlePeriodOngoing) {
if (throttlePeriodSourceHandler.hasTimedOut()) {
throttlePeriodOngoing = false;
} else {
shortDelay = true;
}
}
// CFDP can be throttled by the slowest live TM handler to handle back pressure in a sensible
// way without requiring huge amounts of memory for large files.
if (!throttlePeriodOngoing) {

View File

@ -62,7 +62,8 @@ struct CfdpHandlerCfg {
class CfdpHandler : public SystemObject, public ExecutableObjectIF, public AcceptsTelecommandsIF {
public:
explicit CfdpHandler(const FsfwHandlerParams& fsfwParams, const CfdpHandlerCfg& cfdpCfg);
explicit CfdpHandler(const FsfwHandlerParams& fsfwParams, const CfdpHandlerCfg& cfdpCfg,
const std::atomic_bool& throttleSignal);
[[nodiscard]] const char* getName() const override;
[[nodiscard]] uint32_t getIdentifier() const override;
@ -74,7 +75,6 @@ class CfdpHandler : public SystemObject, public ExecutableObjectIF, public Accep
private:
MessageQueueIF& pduQueue;
MessageQueueIF& cfdpRequestQueue;
Countdown throttlePeriodSourceHandler = Countdown(80);
bool throttlePeriodOngoing = false;
cfdp::LocalEntityCfg localCfg;
@ -89,6 +89,8 @@ class CfdpHandler : public SystemObject, public ExecutableObjectIF, public Accep
StorageManagerIF* tcStore = nullptr;
StorageManagerIF* tmStore = nullptr;
const std::atomic_bool& throttleSignal;
ReturnValue_t handlePduPacketMessages();
ReturnValue_t handlePduPacket(TmTcMessage& msg);
ReturnValue_t handleCfdpRequest(CommandMessage& msg);