eive-obsw/mission/cfdp/CfdpHandler.h

99 lines
3.4 KiB
C
Raw Normal View History

2023-04-11 16:51:49 +02:00
#ifndef FSFW_EXAMPLE_HOSTED_CFDPHANDLER_H
#define FSFW_EXAMPLE_HOSTED_CFDPHANDLER_H
2023-08-30 11:47:39 +02:00
#include <etl/queue.h>
2023-08-14 16:29:51 +02:00
#include <fsfw/cfdp/handler/SourceHandler.h>
2023-08-14 21:22:01 +02:00
#include <fsfw/ipc/CommandMessage.h>
2023-09-11 20:16:54 +02:00
#include <fsfw/timemanager/Countdown.h>
2023-08-14 16:29:51 +02:00
2023-04-11 16:51:49 +02:00
#include <utility>
#include "fsfw/cfdp/handler/DestHandler.h"
#include "fsfw/objectmanager/SystemObject.h"
#include "fsfw/tasks/ExecutableObjectIF.h"
#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h"
#include "fsfw/tmtcservices/TmTcMessage.h"
2023-08-14 16:29:51 +02:00
#include "fsfw/util/SeqCountProvider.h"
2023-04-11 16:51:49 +02:00
struct FsfwHandlerParams {
FsfwHandlerParams(object_id_t objectId, HasFileSystemIF& vfs, AcceptsTelemetryIF& packetDest,
StorageManagerIF& tcStore, StorageManagerIF& tmStore,
StorageManagerIF& ipcStore, MessageQueueIF& tmtcQueue,
2023-08-14 20:48:37 +02:00
MessageQueueIF& cfdpQueue)
2023-04-11 16:51:49 +02:00
: objectId(objectId),
vfs(vfs),
packetDest(packetDest),
tcStore(tcStore),
tmStore(tmStore),
ipcStore(ipcStore),
2023-08-14 20:48:37 +02:00
tmtcQueue(tmtcQueue),
cfdpQueue(cfdpQueue) {}
2023-04-11 16:51:49 +02:00
object_id_t objectId{};
HasFileSystemIF& vfs;
AcceptsTelemetryIF& packetDest;
StorageManagerIF& tcStore;
StorageManagerIF& tmStore;
StorageManagerIF& ipcStore;
2023-08-14 20:48:37 +02:00
MessageQueueIF& tmtcQueue;
MessageQueueIF& cfdpQueue;
2023-04-11 16:51:49 +02:00
};
struct CfdpHandlerCfg {
CfdpHandlerCfg(cfdp::EntityId localId, cfdp::IndicationCfg indicationCfg,
cfdp::UserBase& userHandler, cfdp::FaultHandlerBase& userFaultHandler,
cfdp::PacketInfoListBase& packetInfo, cfdp::LostSegmentsListBase& lostSegmentsList,
cfdp::RemoteConfigTableIF& remoteCfgProvider)
: id(std::move(localId)),
indicCfg(indicationCfg),
packetInfoList(packetInfo),
lostSegmentsList(lostSegmentsList),
remoteCfgProvider(remoteCfgProvider),
userHandler(userHandler),
faultHandler(userFaultHandler) {}
cfdp::EntityId id;
cfdp::IndicationCfg indicCfg;
cfdp::PacketInfoListBase& packetInfoList;
cfdp::LostSegmentsListBase& lostSegmentsList;
cfdp::RemoteConfigTableIF& remoteCfgProvider;
cfdp::UserBase& userHandler;
cfdp::FaultHandlerBase& faultHandler;
};
class CfdpHandler : public SystemObject, public ExecutableObjectIF, public AcceptsTelecommandsIF {
public:
explicit CfdpHandler(const FsfwHandlerParams& fsfwParams, const CfdpHandlerCfg& cfdpCfg);
[[nodiscard]] const char* getName() const override;
[[nodiscard]] uint32_t getIdentifier() const override;
[[nodiscard]] MessageQueueId_t getRequestQueue() const override;
ReturnValue_t initialize() override;
2023-09-06 13:40:38 +02:00
[[noreturn]] ReturnValue_t performOperation(uint8_t operationCode) override;
2023-04-11 16:51:49 +02:00
private:
2023-08-14 21:06:49 +02:00
MessageQueueIF& pduQueue;
2023-08-14 20:48:37 +02:00
MessageQueueIF& cfdpRequestQueue;
2023-09-11 20:16:54 +02:00
Countdown throttlePeriodSourceHandler = Countdown(80);
bool throttlePeriodOngoing = false;
2023-08-14 16:29:51 +02:00
cfdp::LocalEntityCfg localCfg;
2023-08-30 11:58:21 +02:00
cfdp::RemoteConfigTableIF& remoteCfgProvider;
2023-08-14 16:29:51 +02:00
cfdp::FsfwParams fsfwParams;
SeqCountProviderU16 seqCntProvider;
2023-04-11 16:51:49 +02:00
cfdp::DestHandler destHandler;
2023-08-14 16:29:51 +02:00
cfdp::SourceHandler srcHandler;
2023-08-30 11:47:39 +02:00
etl::queue<store_address_t, 16> putRequestQueue;
2023-08-14 16:29:51 +02:00
StorageManagerIF& ipcStore;
2023-04-11 16:51:49 +02:00
StorageManagerIF* tcStore = nullptr;
StorageManagerIF* tmStore = nullptr;
2023-08-14 21:22:01 +02:00
ReturnValue_t handlePduPacketMessages();
2023-08-14 21:06:49 +02:00
ReturnValue_t handlePduPacket(TmTcMessage& msg);
2023-08-14 21:22:01 +02:00
ReturnValue_t handleCfdpRequest(CommandMessage& msg);
ReturnValue_t handleCfdpMessages();
2023-04-11 16:51:49 +02:00
};
#endif // FSFW_EXAMPLE_HOSTED_CFDPHANDLER_H