Class DdsWeatherDataSubscriber

Inheritance Relationships

Base Type

  • public QObject

Class Documentation

class DdsWeatherDataSubscriber : public QObject

Subscriber for DDS type weather::ModuleData 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 DdsWeatherDataSubscriber(QObject *parent = nullptr)

Constructor.

The initialization is deferred to an init() function.

Parameters

parent[in] QObject pointer.

virtual ~DdsWeatherDataSubscriber()

Destructor.

QString module_name() const

Property accessor for module_name in QML.

Returns

User-defined name of module.

QString type() const

Property accessor for type in QML.

Returns

Type of module.

QString temp_trend() const

Property accessor for temp_trend in QML.

Returns

Temperature trend last 12 h.

QString pressure_trend() const

Property accessor for pressure_trend in QML.

Returns

Pressure trend last 12 h.

double CO2() const

Property accessor for CO2 [ppm] in QML.

Returns

CO2.

double noise() const

Property accessor for noise [dB] in QML.

Returns

Noise.

double humidity() const

Property accessor form humidity [%] in QML.

Returns

Humidity.

double temperature() const

Property accessor for temperature [deg C] in QML.

Returns

Temperature.

double pressure() const

Property accessor for pressure [mbar] in QML.

Returns

Pressure.

unsigned int signal_strength() const

Property accessor for signal_strength [56 is good, 86 is bad] in QML.

Returns

Signal strength.

unsigned int battery() const

Property accessor for battery [%] in QML.

Returns

Battery percentage.

bool reachable() const

Property accessor for reachable in QML.

Returns

Is module connected to cloud within 5 h.

QDateTime sampleTime() const

Property accessor for sampleTime in QML.

Returns

Timestamp as QML compatible type.

QDateTime timestamp() const

Property accessor for timestamp in QML.

Returns

Timestamp as QML compatible type.

void init(QtToDds *dds, const QString &topic, const QString &id, 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 for which to subscribe.

  • id[in] Key identifier for the topic instance.

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

Public Slots

void updateValues()

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

Signals

void module_nameChanged(QString module_name)

User-defined name of module.

This signal is connected to module_name QML property.

Parameters

module_name[out] New value.

void typeChanged(QString type)

Type name of module.

This signal is connected to type QML property.

Parameters

type[out] New value.

void temp_trendChanged(QString temp_trend)

Temperature trend (up, down, stable)

This signal is connected to temp_trend QML property.

Parameters

temp_trend[out] New value.

void pressure_trendChanged(QString pressure_trend)

Pressure trend (up, down, stable).

This signal is connected to pressure_trend QML property.

Parameters

pressure_trend[out] New value.

void reachableChanged(bool reachable)

Is module connected to cloud within 5 h.

This signal is connected to reachable QML property.

Parameters

reachable[out] New value.

void CO2Changed(double CO2)

A new sample has arrived.

This signal is connected to CO2 QML property.

Parameters

CO2[out] New value.

void noiseChanged(double noise)

A new sample has arrived.

This signal is connected to noise QML property.

Parameters

noise[out] New value.

void humidityChanged(double humidity)

A new sample has arrived.

This signal is connected to humidity QML property.

Parameters

humidity[out] New value.

void temperatureChanged(double temperature)

A new sample has arrived.

This signal is connected to temperature QML property.

Parameters

temperature[out] New value.

void pressureChanged(double pressure)

A new sample has arrived.

This signal is connected to pressure QML property.

Parameters

pressure[out] New value.

void signal_strengthChanged(unsigned int signal_strength)

A new sample has arrived.

This signal is connected to signal_strength QML property.

Parameters

signal_strength[out] New value.

void batteryChanged(unsigned int battery)

A new sample has arrived.

This signal is connected to battery QML property.

Parameters

battery[out] New value.

void sampleTimeChanged(QDateTime sampleTime)

Timestamp of Weather data has changed.

This signal is connected to the QML sampleTime property.

Parameters

sampleTime[out] New timestamp value.

void timestampChanged(QDateTime timestamp)

Timestamp of DDS value has changed.

This signal is connected to the QML DdsWeatherDataSubscriber::timestamp property.

Parameters

timestamp[out] New timestamp value.

void eventHeard()

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

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

Properties

QString module_name
QString type
QString temp_trend
QString pressure_trend
double CO2
double noise
double humidity
double temperature
double pressure
unsigned int signal_strength
unsigned int battery
bool reachable
QDateTime sampleTime
QDateTime timestamp

Timestamp of sample.

Private Members

std::unique_ptr<sinspekto::Reader<weather::ModuleData>> m_reader

The DDS reader wrapper class.

QString m_id

Key identifier for topic instance.