forked from vedderb/vesc_tool
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathcommands.h
147 lines (126 loc) · 4.69 KB
/
commands.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
/*
Copyright 2016 - 2017 Benjamin Vedder [email protected]
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 COMMANDS_H
#define COMMANDS_H
#include <QObject>
#include <QTimer>
#include "vbytearray.h"
#include "datatypes.h"
#include "packet.h"
#include "configparams.h"
class Commands : public QObject
{
Q_OBJECT
public:
explicit Commands(QObject *parent = 0);
void setLimitedMode(bool is_limited);
Q_INVOKABLE bool isLimitedMode();
Q_INVOKABLE void setSendCan(bool sendCan, int id = -1);
Q_INVOKABLE bool getSendCan();
Q_INVOKABLE void setCanSendId(unsigned int id);
Q_INVOKABLE int getCanSendId();
void setMcConfig(ConfigParams *mcConfig);
void setAppConfig(ConfigParams *appConfig);
Q_INVOKABLE void startFirmwareUpload(QByteArray &newFirmware, bool isBootloader = false);
double getFirmwareUploadProgress();
QString getFirmwareUploadStatus();
Q_INVOKABLE void cancelFirmwareUpload();
void checkMcConfig();
signals:
void dataToSend(QByteArray &data);
void fwVersionReceived(int major, int minor, QString hw, QByteArray uuid);
void ackReceived(QString ackType);
void valuesReceived(MC_VALUES values);
void printReceived(QString str);
void samplesReceived(QByteArray bytes);
void rotorPosReceived(double pos);
void experimentSamplesReceived(QVector<double> samples);
void bldcDetectReceived(bldc_detect param);
void decodedPpmReceived(double value, double last_len);
void decodedAdcReceived(double value, double voltage, double value2, double voltage2);
void decodedChukReceived(double value);
void motorRLReceived(double r, double l, double r2, double l2);
void motorLinkageReceived(double flux_linkage,double flux_linkage2, bool dir1, bool dir2);
void encoderParamReceived(double offset, double ratio, bool inverted);
void customAppDataReceived(QByteArray data);
void focHallTableReceived(QVector<int> hall_table, int res);
void nrfPairingRes(NRF_PAIR_RES res);
void mcConfigCheckResult(QStringList paramsNotSet);
public slots:
void processPacket(QByteArray data);
void getFwVersion();
void getValues();
void sendTerminalCmd(QString cmd);
void setDutyCycle(double dutyCycle1,double dutyCycle2);
void setCurrent(double current1,double current2);
void setCurrentBrake(double current1,double current2);
void setRpm(int rpm1,int rpm2);
void setPos(double pos1,double pos2);
void setHandbrake(double current1,double current2);
void setDetect(disp_pos_mode mode);
void samplePrint(debug_sampling_mode mode, int sample_len, int dec);
void getMcconf();
void getMcconfDefault();
void setMcconf(bool check = true);
void getAppConf();
void getAppConfDefault();
void setAppConf();
void detectMotorParam(double current, double min_rpm, double low_duty);
void reboot();
void sendAlive();
void getDecodedPpm();
void getDecodedAdc();
void getDecodedChuk();
void setServoPos(double pos);
void measureRL();
void measureLinkage();
void measureEncoder(double current);
void measureHallFoc(double current);
void sendCustomAppData(QByteArray data);
void sendCustomAppData(unsigned char *data, unsigned int len);
void setChukData(chuck_data &data);
void pairNrf(int ms);
private slots:
void timerSlot();
private:
void emitData(QByteArray data);
void firmwareUploadUpdate(bool isTimeout);
QString faultToStr(mc_fault_code fault);
QTimer *mTimer;
bool mSendCan;
int mCanId;
bool mIsLimitedMode;
// FW upload state
QByteArray mNewFirmware;
bool mFirmwareIsUploading;
int mFirmwareState;
int mFimwarePtr;
int mFirmwareTimer;
int mFirmwareRetries;
bool mFirmwareIsBootloader;
QString mFirmwareUploadStatus;
ConfigParams *mMcConfig;
ConfigParams *mAppConfig;
ConfigParams mMcConfigLast;
bool mCheckNextMcConfig;
int mTimeoutCount;
int mTimeoutFwVer;
int mTimeoutMcconf;
int mTimeoutAppconf;
int mTimeoutValues;
int mTimeoutDecPpm;
int mTimeoutDecAdc;
int mTimeoutDecChuk;
};
#endif // COMMANDS_H