Class DdsCommandPublisher¶
Defined in File DdsCommand.hpp
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.
Note
Unlike most other adapters in sinspekto, the DDS QoS of this are implemented with writers with
dds::core::policy::Durability::TransientLocal()
and for readers alsodds::core::policy::Reliability::Reliable();
, see DDS QoS for details.Public Functions
-
explicit DdsCommandPublisher(QObject *parent = nullptr)¶
Constructor.
The initialization is deferred to an init() function.
- Parameters
parent – [in] QObject pointer.
-
virtual ~DdsCommandPublisher()¶
Destructor.
-
fkin::CommandType command() const
Property accessor for command.
- Returns
command as a CommandType enum.
-
QString commandName() const
Property accessor for command name.
- Returns
Command as a human readable string.
-
QString responseMessage() const
Property accessor for response message.
- Returns
Response message string.
-
bool responseStatus() const
Property accessor for response status.
- Returns
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.
- Parameters
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.
- Parameters
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().
- Parameters
responseMessage – [in] The response message to set.
-
void setResponseStatus(bool status)¶
Sets the new response status and emits responseStatusChanged().
- Parameters
status – [in] The response status to set.
-
void handleNoResponse()¶
Sets timout message and sets response status false. Emits noResponse().
Signals
-
void commandChanged(fkin::CommandType command)¶
DDS command has changed.
This signal is connected to the QML DdsCommandPublisher::command property.
- Parameters
command – [out] New command.
-
void commandNameChanged(const QString &commandName)¶
DDS command name has changed.
This signal is connected to the QML DdsCommandPublisher::commandName property.
- Parameters
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.
- Parameters
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.
- Parameters
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.
- Parameters
sequenceNr – [out] Sequence number of confirmed command.
Properties
-
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.
-
explicit DdsCommandPublisher(QObject *parent = nullptr)¶