-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathDevDriver.h
376 lines (294 loc) · 10.3 KB
/
DevDriver.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
#pragma once
#include <QObject>
#include <ProtoBinnary.h>
#include <IDBinnary.h>
#include <QHash>
#include <QVector>
#include "QTimer"
using namespace Parsers;
class DevDriver : public QObject
{
Q_OBJECT
public:
explicit DevDriver(QObject *parent = nullptr);
~DevDriver();
typedef enum {
DatasetOff = 0,
DatasetCh1 = 1,
DatasetCh2 = 2,
DatasetRequest = 255
} DatasetChannel;
enum UpgradeStatus {
failUpgrade = -1,
successUpgrade = 101
};
#ifdef SEPARATE_READING
QTimer* getProcessTimer();
QList<QTimer*> getChildTimers();
#endif
int distMax();
void setDistMax(int dist);
int distDeadZone();
void setDistDeadZone(int dead_zone);
int distConfidence();
void setConfidence(int confidence);
int chartSamples();
void setChartSamples(int samples);
int chartResolution();
void setChartResolution(int resol);
int chartOffset();
void setChartOffset(int offset);
int dspSmoothFactor();
void setDspSmoothFactor(int dsp_smooth);
int datasetTimestamp();
void setDatasetTimestamp(int ch_param);
int datasetDist();
void setDatasetDist(int ch_param);
int datasetChart();
void setDatasetChart(int ch_param);
int datasetTemp();
void setDatasetTemp(int ch_param);
int datasetEuler();
void setDatasetEuler(int ch_param);
int datasetSDDBT();
void setDatasetSDDBT(int ch_param);
int datasetSDDBT_P2();
void setDatasetSDDBT_P2(int ch_param);
int ch1Period();
void setCh1Period(int period);
int ch2Period();
void setCh2Period(int period);
void sendUpdateFW(QByteArray update_data);
bool isUpdatingFw() { return m_bootloader; }
int upgradeFWStatus() {return m_upgrade_status; }
void sendFactoryFW(QByteArray update_data);
int transFreq();
void setTransFreq(int freq);
int transPulse();
void setTransPulse(int pulse);
int transBoost();
void setTransBoost(int boost);
int soundSpeed();
void setSoundSpeed(int speed);
float yaw();
float pitch();
float roll();
void setBusAddress(int addr);
int getBusAddress();
void setDevAddress(int addr);
int getDevAddress();
void setBaudrate(int baudrate);
int getBaudrate();
void setDevDefAddress(int addr);
int getDevDefAddress();
QString devName() { return m_devName; }
int devType() const { return static_cast<int>(idVersion->boardVersion()); }
uint32_t devSerialNumber();
QString devPN();
QString fwVersion() { return m_fwVer; }
BoardVersion boardVersion() {
return idVersion->boardVersion();
}
bool isBoardInited() { return boardVersion() != BoardNone; }
bool isSonar() {
BoardVersion ver = boardVersion();
return ver == BoardBase || ver == BoardNBase || ver == BoardEnhanced || ver == BoardChirp || ver == BoardNEnhanced || ver == BoardSideEnhanced || ver == BoardEcho20 || ver == BoardNanoSSS;
}
bool isRecorder() {
BoardVersion ver = boardVersion();
return ver == BoardRecorderMini;
}
bool isDoppler() {
BoardVersion ver = boardVersion();
return ver == BoardDVL;
}
bool isUSBLBeacon() {
BoardVersion ver = boardVersion();
return ver == BoardUSBLBeacon;
}
bool isUSBL() {
BoardVersion ver = boardVersion();
return ver == BoardUSBL;
}
bool isChartSupport() { return m_state.duplex && isSonar(); }
bool isDistSupport() { return m_state.duplex && isSonar(); }
bool isDSPSupport() { return m_state.duplex && isSonar(); }
bool isTransducerSupport() { return m_state.duplex && isSonar(); }
bool isDatasetSupport() { return m_state.duplex && isSonar(); }
bool isSoundSpeedSupport() { return m_state.duplex && isSonar(); }
bool isAddressSupport() { return m_state.duplex; }
bool isUpgradeSupport() { return m_state.duplex; }
bool getDatasetState() { return datasetState_; };
bool getDistSetupState() { return distSetupState_; };
bool getChartSetupState() { return chartSetupState_; };
bool getDspSetupState() { return dspSetupState_; };
bool getTranscState() { return transcState_; };
bool getSoundSpeedState() { return soundSpeedState_; };
bool getUartState() { return uartState_; };
signals:
void binFrameOut(ProtoBinOut proto_out);
void chartComplete(int16_t channel, QVector<uint8_t> data, float resolution, float offset);
void rawDataRecieved(RawData raw_data);
void iqComplete(QByteArray data, uint8_t type);
void attitudeComplete(float yaw, float pitch, float roll);
void distComplete(int dist);
void usblSolutionComplete(IDBinUsblSolution::UsblSolution data);
void beaconActivationComplete(uint8_t id);
void positionComplete(uint32_t date, uint32_t time, double lat, double lon);
void chartSetupChanged();
void dspSetupChanged();
void distSetupChanged();
void datasetChanged();
void transChanged();
void soundChanged();
void UARTChanged();
void upgradeProgressChanged(int progress_status);
void upgradeChanged();
void deviceVersionChanged();
void deviceIDChanged(QByteArray uid);
void onReboot();
void dopplerVeloComplete();
void dopplerBeamComplete(IDBinDVL::BeamSolution *beams, uint16_t cnt);
void dvlSolutionComplete(IDBinDVL::DVLSolution dvlSolution);
public slots:
void protoComplete(FrameParser& proto);
void startConnection(bool duplex);
void stopConnection();
void restartState();
void requestDist();
void requestChart();
void requestStreamList();
void requestStream(int stream_id);
void setConsoleOut(bool is_console);
void flashSettings();
void resetSettings();
void reboot();
void process();
void dvlChangeMode(bool ismode1, bool ismode2, bool ismode3, bool ismode4, float range_mode4);
void importSettingsFromXML(const QString& file_path);
void exportSettingsToXML(const QString& file_path);
void setDatasetState(bool state);
void setDistSetupState(bool state);
void setChartSetupState(bool state);
void setDspSetupState(bool state);
void setTranscState(bool state);
void setSoundSpeedState(bool state);
void setUartState(bool state);
void askBeaconPosition() {
IDBinUsblSolution::USBLRequestBeacon ask;
askBeaconPosition(ask);
}
void askBeaconPosition(IDBinUsblSolution::USBLRequestBeacon ask);
void enableBeaconOnce(float timeout);
#ifdef SEPARATE_READING
void initProcessTimerConnects();
void initChildsTimersConnects();
#endif
protected:
typedef void (DevDriver::* ParseCallback)(Type type, Version ver, Resp resp);
//FrameParser* m_proto;
IDBinTimestamp* idTimestamp = NULL;
IDBinDist* idDist = NULL;
IDBinChart* idChart = NULL;
IDBinAttitude* idAtt = NULL;
IDBinTemp* idTemp = NULL;
IDBinDataset* idDataset = NULL;
IDBinDistSetup* idDistSetup = NULL;
IDBinChartSetup* idChartSetup = NULL;
IDBinDSPSetup* idDSPSetup = NULL;
IDBinTransc* idTransc = NULL;
IDBinSoundSpeed* idSoundSpeed = NULL;
IDBinUART* idUART = NULL;
IDBinVersion* idVersion = NULL;
IDBinMark* idMark = NULL;
IDBinFlash* idFlash = NULL;
IDBinBoot* idBoot = NULL;
IDBinUpdate* idUpdate = NULL;
IDBinNav* idNav = NULL;
IDBinDVL* idDVL = NULL;
IDBinDVLMode* idDVLMode = NULL;
IDBinUsblSolution* idUSBL = NULL;
// QHash<ID, IDBin*> hashIDParsing;
// QHash<ID, ParseCallback> hashIDCallback;
// QHash<ID, IDBin*> hashIDSetup;
typedef struct ID_Instance {
ID_Instance() {
instance = NULL;
callback = NULL;
isSetup = false;
}
ID_Instance(IDBin* inst, ParseCallback call, bool is_setup = false) {
instance = inst;
callback = call;
isSetup = is_setup;
}
IDBin* instance = NULL;
ParseCallback callback = NULL;
bool isSetup = false;
} ID_Instance;
QHash<ID, ID_Instance> _hashID;
typedef enum {
ConfNone = 0,
ConfRequest,
ConfRx
} ConfStatus;
typedef enum {
UptimeNone,
UptimeRequest,
UptimeFix
} UptimeStatus;
struct {
bool connect = false;
bool duplex = false;
bool heartbeat = false;
bool mark = false;
ConfStatus conf = ConfNone;
UptimeStatus uptime = UptimeNone;
} m_state;
uint8_t _lastAddres = 0;
QTimer m_processTimer;
bool m_bootloader = false;
bool m_bootloaderLagacyMode = true;
int m_upgrade_status = 0;
int64_t _lastUpgradeAnswerTime = 0;
int64_t _timeoutUpgradeAnswerTime = 0;
bool m_isConsole = false;
int m_busAddress = 0;
int m_devAddress = 0;
int m_devDefAddress = 0;
QString m_devName = "...";
QString m_fwVer = "";
void regID(IDBin* id_bin, ParseCallback method, bool is_setup = false);
void requestSetup();
void fwUpgradeProcess();
protected slots:
void receivedTimestamp(Type type, Version ver, Resp resp);
void receivedDist(Type type, Version ver, Resp resp);
void receivedChart(Type type, Version ver, Resp resp);
void receivedAtt(Type type, Version ver, Resp resp);
void receivedTemp(Type type, Version ver, Resp resp);
void receivedDataset(Type type, Version ver, Resp resp);
void receivedDistSetup(Type type, Version ver, Resp resp);
void receivedChartSetup(Type type, Version ver, Resp resp);
void receivedDSPSetup(Type type, Version ver, Resp resp);
void receivedTransc(Type type, Version ver, Resp resp);
void receivedSoundSpeed(Type type, Version ver, Resp resp);
void receivedUART(Type type, Version ver, Resp resp);
void receivedVersion(Type type, Version ver, Resp resp);
void receivedMark(Type type, Version ver, Resp resp);
void receivedFlash(Type type, Version ver, Resp resp);
void receivedBoot(Type type, Version ver, Resp resp);
void receivedUpdate(Type type, Version ver, Resp resp);
void receivedNav(Type type, Version ver, Resp resp);
void receivedDVL(Type type, Version ver, Resp resp);
void receivedDVLMode(Type type, Version ver, Resp resp);
void receivedUSBL(Type type, Version ver, Resp resp);
private:
bool datasetState_;
bool distSetupState_;
bool chartSetupState_;
bool dspSetupState_;
bool transcState_;
bool soundSpeedState_;
bool uartState_;
};