-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.h
379 lines (328 loc) · 10.6 KB
/
mainwindow.h
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QApplication>
#include <QTextEdit>
#include <iostream>
#include <windows.h>
#include <iostream>
#include <math.h>
#include <QtMath>
#include <time.h>
#include <locale.h>
#include <string.h>
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <cstring>
#include <string>
#include <Shlwapi.h>
#include <iomanip>
#include <QPushButton>
#include <QLineEdit>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QWidget>
#include <QDialog>
#include <QTabWidget>
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <QTimer.h>
#include <qwt_plot.h>
#include <qwt_plot_grid.h>
#include <qwt_legend.h>
#include <qwt_plot_curve.h>
#include <qwt_symbol.h>
#include <qwt_plot_magnifier.h>
#include <qwt_plot_panner.h>
#include <qwt_plot_picker.h>
#include <qwt_picker_machine.h>
#include <QFile>
#include <QTime>
#include <QTimer>
#include <QElapsedTimer>
#include <QMouseEvent>
#include <QLabel>
#include <QDataStream>
#include <QGroupBox>
#include <QCheckBox>
#include <QComboBox>
#include <QLineEdit>
#include <QtCharts/QChart>
#include <QtCharts/QChartView>
#include <QtCharts/QLineSeries>
#include <QtCharts/QAreaSeries>
//#include <fftw3.h>
#define SYNCHRO 0x79
#define UART_ADDR 0x0A
#define SERVICE_BITS_LEN 0x06
#define ECHO 0x00
#define ADC_CONT_1SEC 0x01
#define GENERATION_CTRL 0x02
#define OUTPUT_SWITCH 0x03
#define SET_ATT 0x04
#define AMP_MANAGE 0x05
#define ADC_ECHO 0x06
#define CRYSTAL_EN 0x07
#define AD5932_CTR 0x08
#define ADF4360_CTR 0x09
#define SEND_FREQ_PARAM 0x0A
#define SEND_FREQ_PARAM_TOTAL 0x0B
#define MODE_SELECT 0x0C
#define ON 0x01
#define OFF 0x00
#define MAXSIZE 0x09
#define STOPPER 400 /* Smaller than any datum */
#define MEDIAN_FILTER_SIZE (3)
#define LOW_PASS_FILTER_SIZE (4)
#define AVERAGE_FILTER_SIZE (3)
/******************************************* SWEEP DEFINES *******************************************/
#define SWEEP_LEN 5000
#define RAW_AMMOUNT 5
/******************************************* ADF4360 DEFINES ******************************************/
#define PRESC_8_9 0
#define PRESC_16_17 1
#define PRESC_32_33 2
#define OUT_13 0
#define OUT_11 1
#define OUT_8 2
#define OUT_6 3
#define SINGLE_MODE 0
#define AUTO_MODE 1
extern uint8_t mass[3][406];
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
void mouseReleaseEvent(QMouseEvent *e);
~MainWindow();
QSerialPort *COM;
QPalette *pal;
QwtPlot *plot;
QwtPlotCurve *curve; // Кривая
QwtPlotCurve *curve_DFT; // Кривая
QPolygonF points;
QPolygonF points_DFT;
QwtPlot *spectre_graph;
QwtPlotCurve *spectre_spurs; // Кривая
QPolygonF spectre_points;
QFile *File;
QTime *Timer_Data;
QTabWidget *TabS;
QLabel *out_message;
QLineEdit *in_message;
QWidget *first_tab;
QWidget *second_tab;
QWidget *third_tab;
QWidget *fourth_tab;
QWidget *fifth_tab;
QDataStream fileStream;
QGroupBox *crystal_group;
QCheckBox *crystal_status;
QPushButton *crystal_send;
QGroupBox *ad5932_group;
QCheckBox *msb_status;
QCheckBox *signal_type_status;
QCheckBox *ctrl_type_status;
QLabel *freq_start_label;
QLabel *freq_delta_label;
QLabel *n_increment_label;
QLabel *time_interval_label;
QLineEdit *freq_start;
QLineEdit *freq_delta;
QLineEdit *n_increment;
QLineEdit *time_interval;
QPushButton *ad5932_send;
QGroupBox *adf4360_group;
QLabel *a_counter_label;
QLabel *b_counter_label;
QLabel *r_counter_label;
QLabel *power_level_label;
QLabel *p_prescaler_label;
QLineEdit *a_counter;
QLineEdit *b_counter;
QLineEdit *r_counter;
QComboBox *power_level;
QComboBox *p_prescaler;
QPushButton *adf4360_send;
QCheckBox *test_radio_button;
QCheckBox *signal_type;
uint8_t signal_type_mode;
QString file_string;
QByteArray file_byte_array;
quint32 file_log_number;
QGroupBox *centerFreq;
QGroupBox *deltaFreq;
QGroupBox *stepFreq;
QLineEdit *centerFreq_edit;
QLineEdit *deltaFreq_edit;
QLineEdit *stepFreq_edit;
QPushButton *sendparamFreq;
QGroupBox *antenna_1;
QGroupBox *centerFreq_1;
QGroupBox *deltaFreq_1;
QGroupBox *stepFreq_1;
QLineEdit *centerFreq_edit_1;
QLineEdit *deltaFreq_edit_1;
QLineEdit *stepFreq_edit_1;
QComboBox *tag_select_1;
QGroupBox *antenna_2;
QGroupBox *centerFreq_2;
QGroupBox *deltaFreq_2;
QGroupBox *stepFreq_2;
QLineEdit *centerFreq_edit_2;
QLineEdit *deltaFreq_edit_2;
QLineEdit *stepFreq_edit_2;
QComboBox *tag_select_2;
QGroupBox *antenna_3;
QGroupBox *centerFreq_3;
QGroupBox *deltaFreq_3;
QGroupBox *stepFreq_3;
QLineEdit *centerFreq_edit_3;
QLineEdit *deltaFreq_edit_3;
QLineEdit *stepFreq_edit_3;
QComboBox *tag_select_3;
uint64_t tag_frequency[18];
uint64_t band_frequency[18];
uint64_t sweep_step_frequency[18];
uint16_t tag_number;
QPushButton *addParamFreq_tag;
QPushButton *sendparamFreq_total;
QPushButton *Parcel_test;
QTabWidget *Peak_Tabs;
QWidget *derivative_graph;
QWidget *peak_graph;
QwtPlot *derivative_plot;
QwtPlot *peak_plot;
QwtPlotCurve *derivative_curve;
QwtPlotCurve *peak_curve;
QPolygonF derivative_points;
QPolygonF peak_points;
uint64_t temperature_points;
QGroupBox *a_coef_groupbox;
QGroupBox *b_coef_groupbox;
QGroupBox *c_coef_groupbox;
QLineEdit *a_coefficient;
QLineEdit *b_coefficient;
QLineEdit *c_coefficient;
double a;
double b;
double c;
double temperature_interf_threshold;
uint8_t temperature_interf_counter;
double temperature_interf_mass[3];
double temperature_interf_derivative;
uint8_t temperature_interf_event;
uint8_t test_mass_coounter;
QLabel *service_message;
QCheckBox *auto_mode;
QPushButton *get_data;
uint8_t auto_mode_test;
uint16_t message_counter;
private:
Ui::MainWindow *ui;
typedef union{
uint16_t istd;
uint8_t cstd[2];
}std_union;
typedef union{
uint32_t listd;
uint16_t istd[2];
uint8_t cstd[4];
}long_std_union;
typedef union{
uint64_t llistd;
uint32_t listd[2];
uint16_t istd[4];
uint8_t cstd[8];
}long_long_std_union;
typedef struct
{
double *module;
double *real;
double *image;
}DFT_result;
typedef struct
{
uint16_t RAW_SIZE;
double RAW_MASSIVE[RAW_AMMOUNT][1000];
}RAW_DATA;
char CRC = 0;
uint8_t com_mode;
uint8_t uart_command;
uint8_t antenna_selected;
uint8_t path_selected;
uint8_t data_check_box;
uint8_t timer_2_mode;
uint8_t UART_RECEIVE_BUFFER[10000];
uint16_t adc_call_command_counter;
uint16_t adc_global_counter;
uint16_t attenuation_selected;
uint16_t X_DATA_BUFFER[1000];
uint64_t time;
QTimer *timer_1;
QElapsedTimer *timer_2;
QTimer *timer_3;
QPixmap *echo_pix;
QByteArray ba;
std_union len;
double ADC_DATA_BUFFER[1000];
double zero[1000];
DFT_result Fourier;
DFT_result Fourier_1;
DFT_result Fourier_2;
RAW_DATA READER_DATA;
QLabel *current_temperature;
QString *cur_temp;
private slots:
void readData(void);
void getEcho(void);
void getADC(void);
void setSwtich(void);
void setAttenuation(void);
void connectCOM(void);
void selectPath(void);
void selectAnt(void);
void selectAtt(void);
void writeAtt(void);
void setup_the_plot(void);
void clear_graph(void);
void paint_curve(uint16_t counter);
uint16_t median_filter(uint16_t datum);
uint16_t lowpass_filter(uint16_t datum);
double lowpass_filter_double_1(double datum);
double lowpass_filter_double_2(double datum);
uint16_t average_filter(uint16_t datum);
void through_filters_test(void);
void generation_maintain(void);
void send_accept(void);
void not_received(void);
void sigma_filter(void);
DFT_result discrete_FourierTransform(double *massive_re, double *massive_im, char dir, uint16_t N);
void FFT(short int dir,long m,double *x,double *y);
void ad5932_send_data(void);
void adf4360_send_data(void);
void crystal_send_data(void);
void send_freq_param(void);
void send_freq_param_total(void);
void add_freq_tag(void);
void test_mode_toggle(void);
void signal_type_toggle(void);
uint16_t peak_search(DFT_result *data, uint16_t len);
uint16_t peak_search_1(DFT_result *data, uint16_t len);
void get_ready_test_parcel(void);
double calc_temperature(uint16_t index);
void get_a_coef(void);
void get_b_coef(void);
void get_c_coef(void);
void change_adc_mode(void);
signals:
void data_received(void);
};
#endif // MAINWINDOW_H