-
Notifications
You must be signed in to change notification settings - Fork 222
/
mainwindow.h
201 lines (182 loc) · 6.77 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
/*
Copyright 2012-2014 Benjamin Vedder benjamin@vedder.se
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/>.
*/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QLabel>
#include <QTimer>
#include <QByteArray>
#include <QSerialPort>
#include "qcustomplot.h"
#include "packetinterface.h"
#include "serialization.h"
#include "datatypes.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
bool eventFilter(QObject *object, QEvent *e);
typedef struct {
bool updated;
double cycle_int_limit;
double bemf_coupling_k;
QVector<int> hall_table;
int hall_res;
} detect_res_t;
private slots:
void serialDataAvailable();
void serialPortError(QSerialPort::SerialPortError error);
void timerSlot();
void packetDataToSend(QByteArray &data);
void fwVersionReceived(int major, int minor);
void ackReceived(QString ackType);
void mcValuesReceived(MC_VALUES values);
void printReceived(QString str);
void samplesReceived(QByteArray data);
void rotorPosReceived(double pos);
void experimentSamplesReceived(QVector<double> samples);
void mcconfReceived(mc_configuration mcconf);
void motorParamReceived(double cycle_int_limit, double bemf_coupling_k, QVector<int> hall_table, int hall_res);
void motorRLReceived(double r, double l);
void motorLinkageReceived(double flux_linkage);
void encoderParamReceived(double offset, double ratio, bool inverted);
void focHallTableReceived(QVector<int> hall_table, int res);
void appconfReceived(app_configuration appconf);
void decodedPpmReceived(double ppm_value, double ppm_last_len);
void decodedAdcReceived(double adc_value, double adc_voltage, double adc_value2, double adc_voltage2);
void decodedChukReceived(double chuk_value);
void on_serialConnectButton_clicked();
void on_udpConnectButton_clicked();
void on_disconnectButton_clicked();
void on_getDataButton_clicked();
void on_getDataStartButton_clicked();
void on_dutyButton_clicked();
void on_rpmButton_clicked();
void on_currentButton_clicked();
void on_offButton_clicked();
void on_offBrakeButton_clicked();
void on_replotButton_clicked();
void on_rescaleButton_clicked();
void on_horizontalZoomBox_clicked();
void on_verticalZoomBox_clicked();
void on_filterLogScaleBox_clicked(bool checked);
void on_filterLogScaleBox2_clicked(bool checked);
void on_detectButton_clicked();
void on_clearTerminalButton_clicked();
void on_sendTerminalButton_clicked();
void on_stopDetectButton_clicked();
void on_experimentClearSamplesButton_clicked();
void on_experimentSaveSamplesButton_clicked();
void on_mcconfReadButton_clicked();
void on_mcconfReadDefaultButton_clicked();
void on_mcconfWriteButton_clicked();
void on_currentBrakeButton_clicked();
void on_mcconfLoadXmlButton_clicked();
void on_mcconfSaveXmlButton_clicked();
void on_mcconfDetectMotorParamButton_clicked();
void on_appconfReadButton_clicked();
void on_appconfWriteButton_clicked();
void on_appconfRebootButton_clicked();
void on_appconfReadDefaultButton_clicked();
void on_posCtrlButton_clicked();
void on_firmwareChooseButton_clicked();
void on_firmwareUploadButton_clicked();
void on_firmwareVersionReadButton_clicked();
void on_firmwareCancelButton_clicked();
void on_servoOutputSlider_valueChanged(int value);
void on_mcconfFocObserverGainCalcButton_clicked();
void on_mcconfFocMeasureRLButton_clicked();
void on_mcconfFocMeasureLinkageButton_clicked();
void on_mcconfFocCalcCCButton_clicked();
void on_mcconfFocApplyRLLambdaButton_clicked();
void on_mcconfFocCalcCCApplyButton_clicked();
void on_mcconfDetectApplyButton_clicked();
void on_mcconfFocMeasureEncoderButton_clicked();
void on_mcconfFocMeasureEncoderApplyButton_clicked();
void on_detectEncoderButton_clicked();
void on_detectPidPosButton_clicked();
void on_detectPidPosErrorButton_clicked();
void on_detectEncoderObserverErrorButton_clicked();
void on_detectObserverButton_clicked();
void on_mcconfFocMeasureHallButton_clicked();
void on_mcconfFocMeasureHallApplyButton_clicked();
void on_refreshButton_clicked();
private:
Ui::MainWindow *ui;
QSerialPort *mSerialPort;
QTimer *mTimer;
QLabel *mStatusLabel;
int mStatusInfoTime;
bool mFwVersionReceived;
int mFwRetries;
QList<QPair<int, int> > mCompatibleFws;
Serialization *mSerialization;
int mSampleInt;
QByteArray curr1Array;
QByteArray curr2Array;
QByteArray ph1Array;
QByteArray ph2Array;
QByteArray ph3Array;
QByteArray vZeroArray;
QByteArray statusArray;
QByteArray currTotArray;
QByteArray fSwArray;
QByteArray tmpCurr1Array;
QByteArray tmpCurr2Array;
QByteArray tmpPh1Array;
QByteArray tmpPh2Array;
QByteArray tmpPh3Array;
QByteArray tmpVZeroArray;
QByteArray tmpStatusArray;
QByteArray tmpCurrTotArray;
QByteArray tmpFSwArray;
QVector<double> tempMos1Vec;
QVector<double> tempMos2Vec;
QVector<double> tempMos3Vec;
QVector<double> tempMos4Vec;
QVector<double> tempMos5Vec;
QVector<double> tempMos6Vec;
QVector<double> tempPcbVec;
QVector<double> currInVec;
QVector<double> currMotorVec;
QVector<double> dutyVec;
QVector<double> rpmVec;
QVector<double> voltInVec;
QVector<double> positionVec;
bool mRealtimeGraphsAdded;
bool mDoReplot;
bool mDoReplotPos;
bool mDoRescale;
bool mDoFilterReplot;
PacketInterface *mPacketInterface;
bool keyLeft;
bool keyRight;
bool mMcconfLoaded;
bool mAppconfLoaded;
detect_res_t mDetectRes;
QVector<QVector<double> > mExperimentSamples;
mc_configuration getMcconfGui();
void setMcconfGui(const mc_configuration &mcconf);
void showStatusInfo(QString info, bool isGood);
void appendDoubleAndTrunc(QVector<double> *vec, double num, int maxSize);
void clearBuffers();
void saveExperimentSamplesToFile(QString path);
void refreshSerialDevices();
};
#endif // MAINWINDOW_H