Class DdsCommandSubscriber

Inheritance Relationships

Base Type

  • public QObject

Class Documentation

class DdsCommandSubscriber : public QObject

Subscriber 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 DdsCommandSubscriber(QObject *parent = nullptr)


The initialization is deferred to an init() function.


parent[in] QObject pointer.

virtual ~DdsCommandSubscriber()


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.

void init(QtToDds *dds, const QString &topic, const QString &recipient, const QString &replyTopic = QString())

Initializes DDS reader and connects Qt signals and slots.

  • dds[in] Pointer to QtToDds instance.

  • topic[in] Name of DDS topic to subscribe to.

  • recipient[in] Key identifier for the command.

  • replyTopic[in] Name of DDS topic to publish command replies.

Public Slots

void updateCommand()

Takes all new samples from the subscribed topic and uses the last sample.

This slot calls take() from the DDS reader and stores the last new sample as the current command value. If there were a new sample it emits commandChanged(), commandNameChanged() and sendReply().

void sendReply()

Sends a command acknowledgment on DDS.

This slot is called from updateCommand().


void commandChanged(fkin::CommandType command)

DDS command has changed.

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


command[out] New command.

void commandNameChanged(QString commandName)

DDS command name has changed.

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


commandName[out] Human readable command name.

void eventHeard()

DdsReaderListener calls this signal when there is data available on the subscribed topic.

If DdsCommandSubscriber is initialized with a non-empty replyTopic, eventHeard() will be connected to the slot updateCommand().


fkin::CommandType command

Subscribed command.

QString commandName

Human readable command name.

Private Members

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

The DDS reader wrapper class.

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

The DDS writer wrapper class.

QString m_recipient

Recipient identifier string.