Program Listing for File RatatoskDouble2.hpp

Return to documentation for file (sinspekto/ratatosk/RatatoskDouble2.hpp)

#pragma once

#include "sinspekto/QtToDds.hpp"
#include "QDateTime"
#include "QVector2D"

class RatatoskDouble2Subscriber : public QObject
{
  Q_OBJECT
  Q_PROPERTY(QVector2D value READ value NOTIFY valueChanged)
  Q_PROPERTY(QDateTime timestamp READ timestamp NOTIFY timestampChanged)

public:
  explicit RatatoskDouble2Subscriber(QObject *parent = nullptr);
  virtual ~RatatoskDouble2Subscriber();
  QVector2D value() const;
  QDateTime timestamp() const;
  Q_INVOKABLE void init(
      QtToDds* dds,
      const QString& topic,
      bool with_listener=true);

signals:
  void valueChanged(QVector2D value);
  void timestampChanged(QDateTime timestamp);
  void eventHeard();

public slots:
  void updateValue();

private:
  std::unique_ptr<sinspekto::Reader<ratatosk::types::Double2>> m_reader;

};

class RatatoskDouble2Publisher : public QObject
{
  Q_OBJECT
  Q_PROPERTY(QVector2D value READ value WRITE setValue NOTIFY valueChanged)

public:
  explicit RatatoskDouble2Publisher(QObject *parent = nullptr);
  virtual ~RatatoskDouble2Publisher();

  QVector2D value() const;
  Q_INVOKABLE void init(
      QtToDds* dds,
      const QString& topic,
      QVector2D start_value,
      bool send_first);

signals:
  void valueChanged(QVector2D value);

public slots:
  void setValue(QVector2D value);

  void publish();

private:
  std::unique_ptr<sinspekto::Writer<ratatosk::types::Double2>> m_writer;
};