Program Listing for File DdsOptiStats.hpp

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

#pragma once

#include "sinspekto/QtToDds.hpp"
#include "QDateTime"
#include <vector>

class DdsOptiStatsSubscriber : public QObject
{
  Q_OBJECT
  Q_PROPERTY(unsigned int iterations READ iterations NOTIFY iterationsChanged)
  Q_PROPERTY(bool status READ status NOTIFY statusChanged)
  Q_PROPERTY(QString status_text READ status_text NOTIFY status_textChanged)
  Q_PROPERTY(double obj READ obj NOTIFY objChanged)
  Q_PROPERTY(double solve_time READ solve_time NOTIFY solve_timeChanged)
  Q_PROPERTY(std::vector<double> p READ p NOTIFY pChanged)
  Q_PROPERTY(std::vector<double> x0 READ x0 NOTIFY x0Changed)
  Q_PROPERTY(QDateTime timestamp READ timestamp NOTIFY timestampChanged)

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

  unsigned int iterations() const;
  bool status() const;
  QString status_text() const;
  double obj() const;
  double solve_time() const;
  std::vector<double> p() const;
  std::vector<double> x0() const;
  QDateTime timestamp() const;
  Q_INVOKABLE void init(
      QtToDds* dds,
      const QString& topic,
      const QString& id,
      bool with_listener=true);

signals:
  void iterationsChanged(unsigned long iterations);
  void statusChanged(bool status);
  void status_textChanged(QString status_text);
  void objChanged(double objective);
  void solve_timeChanged(double solve_time);
  void pChanged(std::vector<double> parameters);
  void x0Changed(std::vector<double> x0);
  void timestampChanged(QDateTime timestamp);
  void eventHeard();

public slots:
  void updateValues();

private:
  std::unique_ptr<sinspekto::Reader<fkin::OptiStats>> m_reader;
  QString m_id;

};