2022-08-03 15:12:29 +02:00
|
|
|
#ifndef FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_
|
|
|
|
#define FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_
|
|
|
|
|
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
|
|
|
|
2022-09-08 11:08:40 +02:00
|
|
|
#include "fsfw/cfdp/pdu/PduHeaderReader.h"
|
2022-08-22 16:35:53 +02:00
|
|
|
#include "fsfw/returnvalues/returnvalue.h"
|
2022-08-03 15:12:29 +02:00
|
|
|
#include "fsfw/tcdistribution/CfdpPacketChecker.h"
|
|
|
|
#include "fsfw/tcdistribution/TcDistributorBase.h"
|
|
|
|
#include "fsfw/tmtcpacket/cfdp/CfdpPacketStored.h"
|
|
|
|
#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h"
|
|
|
|
#include "fsfw/tmtcservices/VerificationReporter.h"
|
|
|
|
|
2022-08-08 17:53:42 +02:00
|
|
|
struct CfdpDistribCfg {
|
|
|
|
CfdpDistribCfg(object_id_t objectId, StorageManagerIF& tcStore, MessageQueueIF* tcQueue)
|
2022-08-08 12:31:19 +02:00
|
|
|
: objectId(objectId), tcStore(tcStore), tcQueue(tcQueue) {}
|
2022-08-03 15:12:29 +02:00
|
|
|
|
|
|
|
object_id_t objectId;
|
2022-08-03 18:14:49 +02:00
|
|
|
StorageManagerIF& tcStore;
|
2022-08-08 12:31:19 +02:00
|
|
|
MessageQueueIF* tcQueue;
|
2022-08-03 15:12:29 +02:00
|
|
|
};
|
2022-08-03 18:14:49 +02:00
|
|
|
|
2022-08-03 15:12:29 +02:00
|
|
|
/**
|
|
|
|
* This will be the primary component to perform PDU forwading procedures. This includes forwarding
|
|
|
|
* CFDP TC packets to registered source or destination handlers, and forwarding all telemetry
|
|
|
|
* generated by them to registered TM sinks.
|
|
|
|
* @ingroup tc_distribution
|
|
|
|
*/
|
2022-08-03 18:14:49 +02:00
|
|
|
class CfdpDistributor : public TcDistributorBase, public AcceptsTelecommandsIF {
|
2022-08-03 15:12:29 +02:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* The ctor passes @c set_apid to the checker class and calls the
|
|
|
|
* TcDistribution ctor with a certain object id.
|
|
|
|
* @param setApid The APID of this receiving Application.
|
|
|
|
* @param setObjectId Object ID of the distributor itself
|
|
|
|
* @param setPacketSource Object ID of the source of TC packets.
|
|
|
|
* Must implement CcsdsDistributorIF.
|
|
|
|
*/
|
2022-08-08 17:53:42 +02:00
|
|
|
explicit CfdpDistributor(CfdpDistribCfg cfg);
|
2022-08-03 15:12:29 +02:00
|
|
|
|
|
|
|
[[nodiscard]] const char* getName() const override;
|
|
|
|
[[nodiscard]] uint32_t getIdentifier() const override;
|
|
|
|
[[nodiscard]] MessageQueueId_t getRequestQueue() const override;
|
2022-08-09 13:04:23 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Register a new CFDP entity which can receive PDUs.
|
|
|
|
* @param address
|
|
|
|
* @param tcDest
|
|
|
|
* @return
|
|
|
|
* - @c RETURN_FAILED: Entry already exists for the given address
|
|
|
|
*/
|
2022-08-03 18:14:49 +02:00
|
|
|
ReturnValue_t registerTcDestination(const cfdp::EntityId& address, AcceptsTelecommandsIF& tcDest);
|
2022-08-03 15:12:29 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
struct EntityInfo {
|
|
|
|
EntityInfo(cfdp::EntityId id, const char* name, MessageQueueId_t queueId)
|
|
|
|
: id(std::move(id)), name(name), queueId(queueId) {}
|
|
|
|
cfdp::EntityId id;
|
|
|
|
const char* name;
|
|
|
|
MessageQueueId_t queueId;
|
|
|
|
};
|
2022-09-08 11:08:40 +02:00
|
|
|
PduHeaderReader pduReader;
|
2022-08-22 16:35:53 +02:00
|
|
|
ReturnValue_t lastTcError = returnvalue::OK;
|
|
|
|
ReturnValue_t lastTmError = returnvalue::OK;
|
2022-08-03 15:12:29 +02:00
|
|
|
// I don't think a regular OBSW will have more than 1 or 2 of these destinations, so I think
|
|
|
|
// it is okay to accept the overhead here
|
|
|
|
std::vector<EntityInfo> tcDestinations;
|
2022-08-08 17:53:42 +02:00
|
|
|
CfdpDistribCfg cfg;
|
2022-08-03 15:12:29 +02:00
|
|
|
|
|
|
|
ReturnValue_t selectDestination(MessageQueueId_t& destId) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_ */
|