Class DdsBitSubscriber

Inheritance Relationships

Base Type

  • public QObject

Class Documentation

class DdsBitSubscriber : public QObject

Subscriber for DDS type Bit 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 property.

Public Functions

explicit DdsBitSubscriber(QObject *parent = nullptr)

Constructor.

The initialization is deferred to an init() function.

Parameters

parent[in] QObject pointer.

virtual ~DdsBitSubscriber()

Destructor.

bool signal() const

Property accessor for bit value in QML.

Returns

bit value as bool.

void init(QtToDds *dds, const QString &topic, bool with_listener = true)

Initializes DDS reader and connects Qt signals and slots.

Parameters
  • dds[in] Pointer to QtToDds instance.

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

  • with_listener[in] Use DdsReaderListener callback to trigger eventHeard() signal.

Public Slots

void updateSignal()

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 bit value. If there were a new sample it emits signalChanged().

Signals

void signalChanged(bool value)

DDS value has changed.

This signal is connected to the QML DdsBitSubscriber::signal property.

Parameters

value[out] New bit value.

void eventHeard()

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

If DdsBitSubscriber is initialized with_listener=true, eventHeard() will be connected to the slot updateSignal().

Properties

bool signal

DDS Bit as bool QML property.

Private Members

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

The DDS reader wrapper class.