fsfw/src/fsfw/tcdistribution/PusDistributor.h

96 lines
3.2 KiB
C
Raw Normal View History

2020-10-01 13:23:06 +02:00
#ifndef FSFW_TCDISTRIBUTION_PUSDISTRIBUTOR_H_
#define FSFW_TCDISTRIBUTION_PUSDISTRIBUTOR_H_
2022-09-14 20:10:41 +02:00
#include <map>
#include "PusDistributorIF.h"
2022-07-19 18:13:25 +02:00
#include "PusPacketChecker.h"
2022-09-14 20:10:41 +02:00
#include "TcDistributorBase.h"
2022-08-16 12:48:22 +02:00
#include "fsfw/returnvalues/returnvalue.h"
2022-02-02 10:29:30 +01:00
#include "fsfw/tmtcpacket/pus/tc.h"
2021-07-13 20:22:54 +02:00
#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h"
#include "fsfw/tmtcservices/VerificationReporter.h"
2022-09-14 20:10:41 +02:00
class CcsdsDistributorIF;
2022-07-19 18:13:25 +02:00
/**
2020-10-01 13:23:06 +02:00
* This class accepts PUS Telecommands and forwards them to Application
* services. In addition, the class performs a formal packet check and
* sends acceptance success or failure messages.
* @ingroup tc_distribution
*/
2022-09-14 20:10:41 +02:00
class PusDistributor : public TcDistributorBase,
public PusDistributorIF,
public AcceptsTelecommandsIF {
2022-02-02 10:29:30 +01: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.
2022-09-14 20:10:41 +02:00
* Must implement CcsdsDistributorIF.
2022-02-02 10:29:30 +01:00
*/
2022-09-14 20:10:41 +02:00
PusDistributor(uint16_t setApid, object_id_t setObjectId, CcsdsDistributorIF* packetSource,
2022-07-27 11:26:47 +02:00
StorageManagerIF* store = nullptr);
2022-09-14 20:10:41 +02:00
[[nodiscard]] const char* getName() const override;
2022-02-02 10:29:30 +01:00
/**
* The destructor is empty.
*/
2022-07-19 18:13:25 +02:00
~PusDistributor() override;
2022-09-14 20:10:41 +02:00
ReturnValue_t registerService(const AcceptsTelecommandsIF& service) override;
[[nodiscard]] MessageQueueId_t getRequestQueue() const override;
2022-02-02 10:29:30 +01:00
ReturnValue_t initialize() override;
2022-09-14 20:10:41 +02:00
[[nodiscard]] uint32_t getIdentifier() const override;
2020-10-01 13:23:06 +02:00
2022-02-02 10:29:30 +01:00
protected:
2022-09-14 20:10:41 +02:00
struct ServiceInfo {
ServiceInfo(const char* name, MessageQueueId_t destId) : name(name), destId(destId) {}
const char* name;
MessageQueueId_t destId;
};
/// PUS recipient map. The key value will generally be the PUS Service
using PusReceiverMap = std::map<uint8_t, ServiceInfo>;
PusReceiverMap receiverMap;
2022-07-19 18:13:25 +02:00
StorageManagerIF* store;
2022-02-02 10:29:30 +01:00
/**
* This attribute contains the class, that performs a formal packet check.
*/
2022-07-19 18:13:25 +02:00
PusPacketChecker checker;
2022-02-02 10:29:30 +01:00
/**
* With this class, verification messages are sent to the
* TC Verification service.
*/
2022-07-26 13:59:09 +02:00
VerificationReporterIF* verifyChannel = nullptr;
2022-07-27 14:40:51 +02:00
//! Cached for initialization
2022-09-14 20:10:41 +02:00
CcsdsDistributorIF* ccsdsDistributor = nullptr;
2022-07-19 18:13:25 +02:00
PusTcReader reader;
2021-06-13 16:29:13 +02:00
2022-02-02 10:29:30 +01:00
/**
* With this variable, the current check status is stored to generate
* acceptance messages later.
*/
ReturnValue_t tcStatus;
2022-02-02 10:29:30 +01:00
/**
* This method reads the packet service, checks if such a service is
* registered and forwards the packet to the destination.
* It also initiates the formal packet check and sending of verification
* messages.
* @return Iterator to map entry of found service id
* or iterator to @c map.end().
*/
2022-09-14 20:10:41 +02:00
ReturnValue_t selectDestination(MessageQueueId_t& destId) override;
2022-02-02 10:29:30 +01:00
/**
* The callback here handles the generation of acceptance
* success/failure messages.
*/
ReturnValue_t callbackAfterSending(ReturnValue_t queueStatus) override;
2022-07-27 17:00:43 +02:00
void checkerFailurePrinter() const;
};
2020-10-01 13:23:06 +02:00
#endif /* FSFW_TCDISTRIBUTION_PUSDISTRIBUTOR_H_ */