eive-obsw/mission/tmtc/CCSDSHandler.h

109 lines
3.3 KiB
C
Raw Normal View History

2021-09-19 12:27:48 +02:00
#ifndef CCSDSHANDLER_H_
#define CCSDSHANDLER_H_
2021-09-26 08:29:30 +02:00
#include "OBSWConfig.h"
2021-09-19 12:27:48 +02:00
#include "fsfw/objectmanager/SystemObject.h"
#include "fsfw/tasks/ExecutableObjectIF.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
2021-11-01 12:41:20 +01:00
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h"
2021-09-19 12:27:48 +02:00
#include "fsfw/parameters/ParameterHelper.h"
2021-11-21 18:07:05 +01:00
#include "fsfw/action/ActionHelper.h"
#include "fsfw/action/HasActionsIF.h"
#include "linux/obc/TxRateSetterIF.h"
2021-09-26 08:29:30 +02:00
#include "VirtualChannel.h"
#include <unordered_map>
2021-09-19 12:27:48 +02:00
/**
* @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,
2021-11-01 12:41:20 +01:00
public AcceptsTelecommandsIF,
2021-09-19 12:27:48 +02:00
public HasReturnvaluesIF,
2021-11-21 18:07:05 +01:00
public ReceivesParameterMessagesIF,
public HasActionsIF {
2021-09-19 12:27:48 +02:00
public:
2021-09-26 08:29:30 +02:00
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.
2021-11-01 12:41:20 +01:00
* @param tcDestination Object ID of object handling received TC space packets
2021-11-21 18:07:05 +01:00
* @param txRateSetter Object providing the functionality to switch the input bitrate of
* the S-Band transceiver.
2021-09-26 08:29:30 +02:00
*/
2021-11-21 18:07:05 +01:00
CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination,
TxRateSetterIF* txRateSetterIF);
2021-09-26 08:29:30 +02:00
2021-09-19 12:27:48 +02:00
~CCSDSHandler();
2021-09-26 08:29:30 +02:00
ReturnValue_t performOperation(uint8_t operationCode = 0) override;
2021-09-19 12:27:48 +02:00
ReturnValue_t initialize();
MessageQueueId_t getCommandQueue() const;
2021-09-22 16:54:55 +02:00
2021-09-19 12:27:48 +02:00
/**
2021-09-22 16:54:55 +02:00
* @brief Function to add a virtual channel
*
* @param virtualChannelId ID of the virtual channel to add
* @param virtualChannel Pointer to virtual channel object
2021-09-19 12:27:48 +02:00
*/
2021-09-22 16:54:55 +02:00
void addVirtualChannel(VcId_t virtualChannelId, VirtualChannel* virtualChannel);
2021-09-19 12:27:48 +02:00
MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0);
2021-09-22 16:54:55 +02:00
ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueIdentifier,
ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues,
uint16_t startAtIndex);
2021-11-01 12:41:20 +01:00
uint16_t getIdentifier() override;
MessageQueueId_t getRequestQueue() override;
2021-11-21 18:07:05 +01:00
virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size);
2021-09-19 12:27:48 +02:00
private:
2021-09-22 16:54:55 +02:00
2021-11-21 18:07:05 +01:00
static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_HANDLER;
2021-10-11 19:34:34 +02:00
static const uint32_t QUEUE_SIZE = common::CCSDS_HANDLER_QUEUE_SIZE;
2021-09-26 08:29:30 +02:00
2021-11-21 18:07:05 +01:00
static const ActionId_t SET_LOW_RATE = 0;
static const ActionId_t SET_HIGH_RATE = 1;
//! [EXPORT] : [COMMENT] Received action message with unknown action id
static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xA0);
2021-09-26 08:29:30 +02:00
using VirtualChannelMap = std::unordered_map<VcId_t, VirtualChannel*>;
2021-09-22 16:54:55 +02:00
using VirtualChannelMapIter = VirtualChannelMap::iterator;
VirtualChannelMap virtualChannelMap;
2021-09-26 08:29:30 +02:00
// Object ID of PTME object
object_id_t ptmeId;
2021-11-01 12:41:20 +01:00
object_id_t tcDestination;
2021-09-26 08:29:30 +02:00
MessageQueueIF* commandQueue = nullptr;
ParameterHelper parameterHelper;
2021-11-21 18:07:05 +01:00
ActionHelper actionHelper;
2021-11-01 12:41:20 +01:00
MessageQueueId_t tcDistributorQueueId;
2021-11-21 18:07:05 +01:00
TxRateSetterIF* txRateSetterIF = nullptr;
2021-09-26 08:29:30 +02:00
void readCommandQueue(void);
2021-09-22 16:54:55 +02:00
void handleTelemetry();
void handleTelecommands();
2021-09-19 12:27:48 +02:00
};
#endif /* CCSDSHANDLER_H_ */