Class DdsCommandPublisher

Inheritance Relationships

Base Type

  • public QObject

Class Documentation

class DdsCommandPublisher : public QObject

Publisher for DDS type Command as a QML element.

This class is a QML element and enables QML applications to gain access to a DDS signal type as a read-only QML properties.


Unlike most other adapters in sinspekto, the DDS QoS of this are implemented with writers with dds::core::policy::Durability::TransientLocal() and for readers also dds::core::policy::Reliability::Reliable();, see DDS QoS for details.

Public Functions

explicit DdsCommandPublisher(QObject *parent = nullptr)


The initialization is deferred to an init() function.


parent[in] QObject pointer.

virtual ~DdsCommandPublisher()


fkin::CommandType command() const

Property accessor for command.


command as a CommandType enum.

QString commandName() const

Property accessor for command name.


Command as a human readable string.

QString responseMessage() const

Property accessor for response message.


Response message string.

bool responseStatus() const

Property accessor for response status.


Response status. True is OK.

void init(QtToDds *dds, const QString &topic, const QString &recipient, const QString &responseTopic = QString(), int responseTimeout_ms = 1000)

Initializes DDS writer and connects Qt signals and slots.

  • dds[in] Pointer to QtToDds instance.

  • topic[in] Name of DDS topic for which to publish.

  • recipient[in] Key identifier for the command.

  • responseTopic[in] Name of DDS topic to subscribe to command responses, acknowledgments. (optional)

  • responseTimeout_ms[in] Time in milliseconds to wait for an acknowledgment. (default: 1000)

Public Slots

void setCommand(fkin::CommandType command)

Sets command and sends over DDS.

Sends requested command over DDS. Emits commandChanged() and commandNameChanged(). If a responseTopic is defined in init(), starts the response timer.


command[in] Command to send.

void updateResponse()

Reads the command response from DDS.

If there is a response, emits confirmedResponseSeqNr()

void setResponseMessage(const QString &responseMessage)

Sets the new response message and emits responseMessageChanged().


responseMessage[in] The response message to set.

void setResponseStatus(bool status)

Sets the new response status and emits responseStatusChanged().


status[in] The response status to set.

void handleNoResponse()

Sets timout message and sets response status false. Emits noResponse().


void commandChanged(fkin::CommandType command)

DDS command has changed.

This signal is connected to the QML DdsCommandPublisher::command property.


command[out] New command.

void commandNameChanged(const QString &commandName)

DDS command name has changed.

This signal is connected to the QML DdsCommandPublisher::commandName property.


commandName[out] Human readable command name.

void responseMessageChanged(const QString &responseMessage)

DDS response message name has changed.

This signal is connected to the QML DdsCommandPublisher::responseMessage property.


responseMessage[out] Human readable response message.

void responseStatusChanged(bool responseStatus)

DDS response status has changed.

This signal is connected to the QML DdsCommandPublisher::responseStatus property.


responseStatus[out] Is the response OK?

void gotResponse()

Triggered when a response is received.

void noResponse()

Triggered when no response is received.

void confirmedResponseSeqNr(int sequenceNr)

Triggered when a response is received.


sequenceNr[out] Sequence number of confirmed command.


fkin::CommandType command

Command enum.

QString commandName

Human readable command name.

QString responseMessage

Response message on a command.

bool responseStatus

Response status of a sent command.

Private Members

std::unique_ptr<sinspekto::Writer<fkin::Command>> m_writer

The DDS writer wrapper class.

std::unique_ptr<sinspekto::Reader<fkin::CommandResponse>> m_reader

The DDS writer wrapper class.

QString m_recipient

Recipient identifier string.

QString m_responseMessage

Response message variable.

bool m_responseStatus

Response status.

std::int32_t m_awaitingSeqNr

Sequence number of message.

QTimer m_timer

Response timer.