-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.hpp
199 lines (157 loc) · 8.54 KB
/
mainwindow.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
/***************************************************************************
** This file is part of Serial Port Plotter **
** **
** **
** Serial Port Plotter is a program for plotting integer data from **
** serial port using Qt and QCustomPlot **
** **
** This program is free software: you can redistribute it and/or modify **
** it under the terms of the GNU General Public License as published by **
** the Free Software Foundation, either version 3 of the License, or **
** (at your option) any later version. **
** **
** This program is distributed in the hope that it will be useful, **
** but WITHOUT ANY WARRANTY; without even the implied warranty of **
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
** GNU General Public License for more details. **
** **
** You should have received a copy of the GNU General Public License **
** along with this program. If not, see http://www.gnu.org/licenses/. **
** **
****************************************************************************
** Author: Borislav **
** Contact: b.kereziev@gmail.com **
** Date: 29.12.14 **
****************************************************************************/
#ifndef MAINWINDOW_HPP
#define MAINWINDOW_HPP
#include <QMainWindow>
#include <QSlider>
#include <QtSerialPort/QtSerialPort>
#include <QSerialPortInfo>
#include "helpwindow.hpp"
#include "qcustomplot.h"
#include <QFileDialog>
#include "nrftask.h"
// Analog Widgets
#include "thermometer.h"
#include "led.h"
// Base de datos
#include "database.h"
#include <QTime>
#define CANALES 10
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
void CrearGrafico();
private slots:
void replot(); // Slot for repainting the plot
void onNewDataArrived(sensores newData); // Slot for new data from serial port
void on_spinAxesMin_valueChanged(int arg1); // Changing lower limit for the plot
void on_spinAxesMax_valueChanged(int arg1); // Changing upper limit for the plot
void on_comboAxes_currentIndexChanged(int index); // Display number of axes and colors in status bar
void on_spinYStep_valueChanged(int arg1); // Spin box for changing Y axis tick step
void on_saveJPGButton_clicked(); // Button for saving JPG
void on_resetPlotButton_clicked(); // Resets plot to initial zoom and coordinates
void onMouseMoveInPlot(QMouseEvent *event); // Displays coordinates of mouse pointer when clicked in plot in status bar
void on_spinPoints_valueChanged(int arg1); // Spin box controls how many data points are collected and displayed
void on_actionHow_to_use_triggered();
/***********************************************************/
void on_signal1Check_clicked(bool checked);
void on_signal2Check_clicked(bool checked);
void on_signal3Check_clicked(bool checked);
void on_signal4Check_clicked(bool checked);
void on_signal5Check_clicked(bool checked);
void on_signal6Check_clicked(bool checked);
void TempReceived(sensores );
void TargetReceived(target t);
void ConfigReceived(conf t);
// Temperaturas Objetivos Slider
void on_verticalSlider_valueChanged(int value);
void on_verticalSlider_2_valueChanged(int value);
void on_verticalSlider_3_valueChanged(int value);
void on_verticalSlider_4_valueChanged(int value);
void on_verticalSlider_5_valueChanged(int value);
void on_verticalSlider_6_valueChanged(int value);
void on_verticalSlider_7_valueChanged(int value);
void on_verticalSlider_8_valueChanged(int value);
// Temperaturas Objetivos SpinBox
void on_doubleSpinBox_valueChanged(double arg1);
void on_doubleSpinBox_2_valueChanged(double arg1);
void on_doubleSpinBox_3_valueChanged(double arg1);
void on_doubleSpinBox_4_valueChanged(double arg1);
void on_doubleSpinBox_5_valueChanged(double arg1);
void on_doubleSpinBox_6_valueChanged(double arg1);
void on_doubleSpinBox_7_valueChanged(double arg1);
void on_doubleSpinBox_8_valueChanged(double arg1);
void on_showHistButton_clicked();
void on_updateConfigButton_clicked();
void on_getTargetUpdateButton_clicked();
void on_sendActualSetpButton_clicked();
void on_sendActualConfigButton_clicked();
signals:
void newData(sensores data); // Emitted when new data has arrived
private:
Ui::MainWindow *ui;
ThermoMeter *termometros[CANT];
Led *led_frio[CANT];
Led *led_calor[CANT];
QLabel *temps_actuales[CANT];
QCheckBox *salidaAct[CANT];
QCheckBox *frioHab[CANT];
QCheckBox *calorHab[CANT];
QLineEdit *frioSal[CANT];
QLineEdit *calorSal[CANT];
bool connected; // Status connection variable
bool plotting; // Status plotting variable
int dataPointNumber; // Keep track of data points
QTimer updateTimer; // Timer used for replotting the plot
int numberOfAxes, numberOfAxes2; // Number of axes for the plot
QTime timeOfFirstData; // Record the time of the first data point
double timeBetweenSamples; // Store time between samples
QSerialPort *serialPort; // Serial port; runs in this thread
QString receivedData; // Used for reading from the port
int STATE; // State of recieiving message from port
int NUMBER_OF_POINTS; // Number of points plotted
HelpWindow *helpWindow;
QCustomPlot *pl;
QPen colores[CANT];
bool habilitado[CANT];
void exportarExcel();
void colourSetup();
int h;
void createUI(); // Populate the controls
void crearGrafico(); // Setup the QCustomPlot
void crearGraficoHistorico(); // Setup the QCustomPlot
void SetActualTemp(int fermentador, double temp);
void UpdateTemps();
void UpdateTargets();
void UpdateConfig();
conf getConfigFromForm();
double CalcRange(int value) ;
int CalcRange(double value);
double high;
double lower;
double res;
int max_slider, min_slider;
QSlider *sliders[CANT];
QDoubleSpinBox *edit_target[CANT];
/******* fin ********/
QSettings setting;
QThread tarea;
nRFTask *task;
sensores temperaturas;
conf configuracion;
target temp_target;
// Base de datos
DataBase *db;
QTime *tiempo;
// Open the inside serial port with these parameters
};
#endif // MAINWINDOW_HPP