Class CommandResponder

Class Documentation

class mimir::control::CommandResponder

Request and reply class for user commands.

This class ensures that commands received over DDS from other applications are posted as event in the specified state machine.

Public Functions

inline CommandResponder(const std::string &requestTopicName, const std::string &replyTopicName, const std::string &recipient, dds::pub::Publisher publisher, dds::sub::Subscriber subscriber, boost::statechart::fifo_scheduler<> &scheduler, boost::statechart::fifo_scheduler<>::processor_handle machine)

Constructor that sets up DDS readers, writers, listeners.

This function constructs the following:

  • A topic requestTopicName, which is filtered on the recipient key.

  • A reader for command requests of this filtered topic.

  • A writer for command responses to replyTopicName.

  • A command listener callback to post event into state machine.

Parameters
  • requestTopicName[in] Topic for requests

  • replyTopicName[in] Topic for responses

  • recipient[in] Recipient key

  • publisher[in] Reference to the publisher

  • subscriber[in] Reference to the subscriber

  • scheduler[in] Reference to the state machine scheduler

  • machine[in] Reference to the state machine handle

CommandResponder(const CommandResponder&) = delete
CommandResponder &operator=(const CommandResponder&) = delete
CommandResponder(CommandResponder&&) = default
CommandResponder &operator=(CommandResponder&&) = default
inline ~CommandResponder()

Destructor. Resets listener.

Private Functions

inline void handleResponse()

Callback function for command responses.

This function is used as the callback function in the CommandListener member variable. It parses the incoming command and posts appropriate events in the state machine.

CommandResponder() = delete

Private Members

boost::statechart::fifo_scheduler &m_scheduler

Scheduler for state machine.

boost::statechart::fifo_scheduler::processor_handle m_stateMachine

StateMachine reference.

dds::sub::DataReader<fkin::Command> m_requestReader

DDS reader for requests.

dds::pub::DataWriter<fkin::CommandResponse> m_replyWriter

DDS writer for command responses.

std::unique_ptr<CommandListener<fkin::Command>> m_listener

Command listener callback.