ccsds handler wip

This commit is contained in:
Jakob Meier
2021-09-22 16:54:55 +02:00
parent e2c26efe4a
commit d54e2276d6
12 changed files with 327 additions and 236 deletions

View File

@ -16,7 +16,6 @@
*/
class CCSDSHandler: public SystemObject,
public ExecutableObjectIF,
public HasModesIF,
public AcceptsTelemetryIF,
public HasReturnvaluesIF,
public ReceivesParameterMessagesIF {
@ -80,27 +79,26 @@ public:
*/
ReturnValue_t initialize();
MessageQueueId_t getCommandQueue() const;
/**
* Method to configure the TC Virtual Channels in the TC Data Link Layer.
* The call is forwarded to the #dataLinkLayer class.
* @param virtualChannelId VCID to add.
* @param object Pointer to the Virtual Channel object that is added.
* @return See the #dataLinkLayer class.
* @brief Function to add a virtual channel
*
* @param virtualChannelId ID of the virtual channel to add
* @param virtualChannel Pointer to virtual channel object
*
* @return RETURN_OK if successful, otherwise RETURN_FAILED
*/
ReturnValue_t addVirtualChannel(uint8_t virtualChannelId,
VirtualChannelReceptionIF* object);
void addVirtualChannel(VcId_t virtualChannelId, VirtualChannel* virtualChannel);
Mode_t getMode() const;
Submode_t getSubmode() const;
void setParentQueue(MessageQueueId_t parentQueueId);
MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0);
ReturnValue_t setHealth(HealthState health);
HasHealthIF::HealthState getHealth();
ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId,
ParameterWrapper *parameterWrapper,
const ParameterWrapper *newValues, uint16_t startAtIndex);
void triggerEvent(Event event, uint32_t parameter1 = 0,
uint32_t parameter2 = 0);
ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueIdentifier,
ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues,
uint16_t startAtIndex);
protected:
MessageQueue commandQueue; //!< Queue to receive control commands.
VCGeneration* virtualChannels[BoardHandler::USED_VIRTUAL_CHANNELS_PER_BOARD];//!< An array of VCGeneration classes which each manage on TM Virtual Channel.
@ -148,68 +146,15 @@ protected:
void setToExternalControl();
void announceMode(bool recursive);
private:
enum CcsdsState_t {
STATE_IDLE,
STATE_TURN_ON,
STATE_TURN_OFF,
STATE_DO_PASSIVATE_OFF,
STATE_TURN_SWITCH_OFF,
STATE_WAIT_ON,
STATE_WAIT_LINK,
STATE_WAIT_OFF,
STATE_INITIALIZE_BOARD,
STATE_SELECT_SUBMODE,
STATE_WAIT_SUBMODE_ACTIVE,
STATE_DO_PASSIVATE,
STATE_WAIT_SUBMODE_PASSIVE,
STATE_HANDLE_STARTUP,
};
CcsdsState_t state;
enum CommState {
SEND_WRITE, GET_WRITE, SEND_READ, GET_READ
};
CommState commState;
Mode_t mode;
Submode_t submode;
BoardHandler boardHandler;//!< The class that handles the low-level communication with the board.
DataLinkLayer dataLinkLayer;//!< The class that manages the TC Data Link Layer protocols.
uint8_t frameBuffer[MAX_FRAME_SIZE]; //!< The main buffer to store single frames in.
uint16_t frameLength; //!< Indicates the current length of the found frame.
object_id_t channelId; //!< Defines the id of the RMAP Channel to use.
MemoryHelper memoryHelper; //!< Helps handling memory messages.
bool pendingWrite; //!< Attribute to manage remote Memory write.
using VcId_t = uint8_t;
using VirtualChannelMap = std::unordered_map<VcId_t, VcInterfaceIF*>;
using VirtualChannelMapIter = VirtualChannelMap::iterator;
bool pendingRead; //!< Attribute to manage remote Memory read.
VirtualChannelMap virtualChannelMap;
ModeHelper modeHelper; //!< Helps handling mode messages.
HealthHelper healthHelper; //!< Helps setting the health information correctly.
ParameterHelper parameterHelper;
PowerSwitcher powerSwitcher; //!< Helps switching switches on and off.
bool switchOffWasReported; //!< To avoid reporting SWITCH_WENT_OFF multiple times.
CCSDSBoardFailureIsolation fdir;
class DataRateSet: public ControllerSet {
public:
DataRateSet();
virtual ~DataRateSet();
void setToDefault();
PoolVector<float, BoardHandler::USED_VIRTUAL_CHANNELS_PER_BOARD> dataRate;
PoolVector<float, BoardHandler::USED_VIRTUAL_CHANNELS_PER_BOARD> dataRates;
};
DataRateSet rateSet;
void setMode(Mode_t newMode, Submode_t newSubmode); //!< Method to safely setMode and inform everyone interested about it.
/**
* State machine of the Handler.
* Is responsible for handling mode transitions and for informing the modeHelper.
* In addition, it watches the SpW link and changes the Mode in case a link down or a link up is detected.
*/
void doStateMachine();
void executeAllWriteCommands();
void handleAllWriteReplies();
void executeAllReadCommands();
void handleAllReadReplies();
void handleTelemetry();
void handleTelecommands();
};
#endif /* CCSDSHANDLER_H_ */