eive-obsw/mission/tmtc/CCSDSHandler.h
2021-11-01 12:41:20 +01:00

87 lines
2.5 KiB
C++

#ifndef CCSDSHANDLER_H_
#define CCSDSHANDLER_H_
#include "OBSWConfig.h"
#include "fsfw/objectmanager/SystemObject.h"
#include "fsfw/tasks/ExecutableObjectIF.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h"
#include "fsfw/parameters/ParameterHelper.h"
#include "VirtualChannel.h"
#include <unordered_map>
/**
* @brief This class handles the data exchange with the CCSDS IP cores implemented in the
* programmable logic of the Q7S.
*
* @author J. Meier
*/
class CCSDSHandler: public SystemObject,
public ExecutableObjectIF,
public AcceptsTelemetryIF,
public AcceptsTelecommandsIF,
public HasReturnvaluesIF,
public ReceivesParameterMessagesIF {
public:
using VcId_t = uint8_t;
/**
* @brief Constructor
*
* @param objectId Object ID of the CCSDS handler
* @param ptmeId Object ID of the PTME object providing access to the PTME IP Core.
* @param tcDestination Object ID of object handling received TC space packets
*/
CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination);
~CCSDSHandler();
ReturnValue_t performOperation(uint8_t operationCode = 0) override;
ReturnValue_t initialize();
MessageQueueId_t getCommandQueue() const;
/**
* @brief Function to add a virtual channel
*
* @param virtualChannelId ID of the virtual channel to add
* @param virtualChannel Pointer to virtual channel object
*/
void addVirtualChannel(VcId_t virtualChannelId, VirtualChannel* virtualChannel);
MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0);
ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueIdentifier,
ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues,
uint16_t startAtIndex);
uint16_t getIdentifier() override;
MessageQueueId_t getRequestQueue() override;
private:
static const uint32_t QUEUE_SIZE = common::CCSDS_HANDLER_QUEUE_SIZE;
using VirtualChannelMap = std::unordered_map<VcId_t, VirtualChannel*>;
using VirtualChannelMapIter = VirtualChannelMap::iterator;
VirtualChannelMap virtualChannelMap;
// Object ID of PTME object
object_id_t ptmeId;
object_id_t tcDestination;
MessageQueueIF* commandQueue = nullptr;
ParameterHelper parameterHelper;
MessageQueueId_t tcDistributorQueueId;
void readCommandQueue(void);
void handleTelemetry();
void handleTelecommands();
};
#endif /* CCSDSHANDLER_H_ */