-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.h
103 lines (82 loc) · 2.25 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
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <prologixgpib.h>
#include <QDebug>
#include <QStateMachine>
#include <QState>
#include <QFinalState>
#include <QTimer>
#include <QtCharts>
#include <math.h>
#include <QFile>
#include <QFileDialog>
#include <QMenu>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
private slots:
void on_btnStart_clicked();
void on_btnSave_clicked();
void on_chart_customContextMenuRequested(const QPoint &pos);
private:
enum last_action_t{
ACTION_NO_ACTION,
ACTION_INSTRUMENT_REQUEST,
ACTION_INSTRUMENT_INIT,
ACTION_SETTINGS_UPDATE,
ACTION_SWEEP_STARTED,
ACTION_POLL_SWEEP_FINISH,
ACTION_FIT_TRACE,
ACTION_TRANSFER_STIMULUS,
ACTION_TRANSFER_MAGNITUDE,
ACTION_TRANSFER_PHASE,
ACTION_CANCEL_SWEEP
}; //Keep track of the last GPIB action since it is asynchronous
struct trace_data_t {
double frequency;
double magnitude;
double phase;
};
last_action_t lastAction;
Ui::MainWindow *ui;
PrologixGPIB *gpib = nullptr;
void request_instrument();
void init_instrument();
void instrument_init_commands(QVector<QString> &commands);
quint8 instrument_gpib_id;
void gpib_response(QString resp);
void update_settings();
void start_sweep();
QTimer *pollHold = nullptr; //When sweeping, poll instrument to check if sweep has finished
void pollHold_timeout();
void fit_trace();
void get_stimulus();
void get_magnitude_data();
void get_phase_data();
void unpack_raw_data();
void disable_ui();
void enable_ui();
QString stimulus_raw;
QString magnitude_raw;
QString phase_raw;
QVector<trace_data_t> trace_data;
void init_plot();
QChart *chart = nullptr;
QChartView *chartView = nullptr;
QVBoxLayout *layout = nullptr;
QLineSeries *magnitude = nullptr;
QLineSeries *phase = nullptr;
QLogValueAxis *axisX = nullptr;
QValueAxis *axisY = nullptr;
QValueAxis *axisYPhase = nullptr;
void plot_data();
signals:
};
#endif // MAINWINDOW_H