File indexing completed on 2024-04-28 15:14:08

0001 /***************************************************************************
0002 File                 : MQTT_test.h
0003 Project              : LabPlot
0004 Description          : Tests for MQTT import.
0005 --------------------------------------------------------------------
0006 --------------------------------------------------------------------
0007 Copyright   : (C) 2018 Kovacs Ferencz (kferike98@gmail.com)
0008 
0009 ***************************************************************************/
0010 
0011 /***************************************************************************
0012  *                                                                         *
0013  *  This program is free software; you can redistribute it and/or modify   *
0014  *  it under the terms of the GNU General Public License as published by   *
0015  *  the Free Software Foundation; either version 2 of the License, or      *
0016  *  (at your option) any later version.                                    *
0017  *                                                                         *
0018  *  This program is distributed in the hope that it will be useful,        *
0019  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
0020  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
0021  *  GNU General Public License for more details.                           *
0022  *                                                                         *
0023  *   You should have received a copy of the GNU General Public License     *
0024  *   along with this program; if not, write to the Free Software           *
0025  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
0026  *   Boston, MA  02110-1301  USA                                           *
0027  *                                                                         *
0028  ***************************************************************************/
0029 
0030 #ifndef MQTT_TEST_H
0031 #define MQTT_TEST_H
0032 
0033 #include <QMainWindow>
0034 #include <QMqttClient>
0035 #include <QMqttTopicName>
0036 #include <QTimer>
0037 #include <QVector>
0038 #include <random>
0039 
0040 namespace Ui {
0041 class MainWindow;
0042 }
0043 
0044 class MainWindow : public QMainWindow
0045 {
0046     Q_OBJECT
0047 
0048 public:
0049     explicit MainWindow(QWidget *parent = 0);
0050     ~MainWindow();
0051 
0052 public slots:
0053     void setClientPort(int p);
0054 
0055 private slots:
0056     void on_buttonConnect_clicked();
0057     void on_buttonQuit_clicked();
0058     void brokerDisconnected();
0059     void on_buttonSubscribe_clicked();
0060     void onTimeout();
0061     void intervalChanged(const QString&);
0062     void onConnect();
0063 
0064 private:
0065     Ui::MainWindow *ui;
0066     QMqttClient *m_client;
0067     bool m_run;
0068     QMqttTopicName* m_brownianX;
0069     quint8 m_qos;
0070     QTimer* m_timer;
0071     unsigned m_seed;
0072     std::default_random_engine* m_generator;
0073     std::normal_distribution<double>* m_distribution;
0074     double m_delta;
0075     double m_dt;
0076     int m_pathes;
0077     int m_iters;
0078     int m_iterCount;
0079     int m_itersTotal;
0080     int m_interval;
0081 
0082     QVector<QMqttTopicName*> m_brownianTopics;
0083     QVector<double> m_x;
0084 };
0085 
0086 #endif // MQTT_TEST_H