Program Listing for File DdsBit.hpp

Return to documentation for file (sinspekto/DdsBit.hpp)

#pragma once

#include "sinspekto/QtToDds.hpp"

class DdsBitSubscriber : public QObject
{
  Q_OBJECT
  Q_PROPERTY(bool signal READ signal NOTIFY signalChanged)

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

  bool signal() const;

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

signals:
  void signalChanged(bool value);
  void eventHeard();

public slots:
  void updateSignal();

private:
  std::unique_ptr<sinspekto::Reader<fkin::Bit>> m_reader;
};

class DdsBitPublisher : public QObject
{
  Q_OBJECT
  Q_PROPERTY(bool signal READ signal WRITE setSignal NOTIFY signalChanged)

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

  bool signal() const;

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

signals:
  void signalChanged(bool value);

public slots:
  void setSignal(bool value);

  void publish();

private:
  std::unique_ptr<sinspekto::Writer<fkin::Bit>> m_writer;
};