Program Listing for File RatatoskPosInfo.hpp

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

#pragma once

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

class RatatoskPosInfoSubscriber : public QObject
{
  Q_OBJECT
  Q_PROPERTY(double lat READ lat NOTIFY latChanged)
  Q_PROPERTY(double lon READ lon NOTIFY lonChanged)
  Q_PROPERTY(double sog READ sog NOTIFY sogChanged)
  Q_PROPERTY(double cog READ cog NOTIFY cogChanged)
  Q_PROPERTY(QDateTime timestamp READ timestamp NOTIFY timestampChanged)

public:
  explicit RatatoskPosInfoSubscriber(QObject *parent = nullptr);
  virtual ~RatatoskPosInfoSubscriber();
  double lat() const;
  double lon() const;
  double sog() const;
  double cog() const;
  QDateTime timestamp() const;
  Q_INVOKABLE void init(
      QtToDds* dds,
      const QString& topic,
      bool with_listener=true);

signals:
  void latChanged(double lat);
  void lonChanged(double lon);
  void sogChanged(double sog);
  void cogChanged(double cog);
  void timestampChanged(QDateTime timestamp);
  void eventHeard();

public slots:
  void updateValue();

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

};