QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
OnboardLogController.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QObject>
4#include <QtQmlIntegration/QtQmlIntegration>
5
9class QTimer;
10class QThread;
11class Vehicle;
12class OnboardLogDownloadTest;
13
14class OnboardLogController : public QObject
15{
16 Q_OBJECT
17 QML_ELEMENT
18 QML_SINGLETON
19 Q_MOC_INCLUDE("Vehicle.h")
20 Q_MOC_INCLUDE("QmlObjectListModel.h")
21 Q_PROPERTY(QmlObjectListModel *model READ _getModel CONSTANT)
22 Q_PROPERTY(bool requestingList READ _getRequestingList NOTIFY requestingListChanged)
23 Q_PROPERTY(bool downloadingLogs READ _getDownloadingLogs NOTIFY downloadingLogsChanged)
24 Q_PROPERTY(bool compressLogs READ compressLogs WRITE setCompressLogs NOTIFY compressLogsChanged)
25 Q_PROPERTY(bool compressing READ compressing NOTIFY compressingChanged)
27
28 friend class OnboardLogDownloadTest;
29
30public:
31 explicit OnboardLogController(QObject *parent = nullptr);
33
34 Q_INVOKABLE void refresh();
35 Q_INVOKABLE void download(const QString &path = QString());
36 Q_INVOKABLE void eraseAll();
37 Q_INVOKABLE void cancel();
38
39 bool compressLogs() const { return _compressLogs; }
40 void setCompressLogs(bool compress);
41 bool compressing() const { return _compressing; }
42 float compressionProgress() const { return _compressionProgress; }
43
45 Q_INVOKABLE bool compressLogFile(const QString &logPath);
46
48 Q_INVOKABLE void cancelCompression();
49
50signals:
57 void compressionComplete(const QString &outputPath, const QString &error);
58
59private slots:
60 void _setActiveVehicle(Vehicle *vehicle);
61 void _logEntry(uint32_t time_utc, uint32_t size, uint16_t id, uint16_t num_logs, uint16_t last_log_num);
62 void _logData(uint32_t ofs, uint16_t id, uint8_t count, const uint8_t *data);
63 void _processDownload();
64 void _handleCompressionProgress(qreal progress);
65 void _handleCompressionFinished(bool success);
66
67private:
68 QmlObjectListModel *_getModel() const { return _logEntriesModel; }
69 bool _getRequestingList() const { return _requestingLogEntries; }
70 bool _getDownloadingLogs() const { return _downloadingLogs; }
71
72 bool _chunkComplete() const;
73 bool _entriesComplete() const;
74 bool _logComplete() const;
75 bool _prepareLogDownload();
76 void _downloadToDirectory(const QString &dir);
77 void _findMissingData();
78 void _findMissingEntries();
79 void _receivedAllData();
80 void _receivedAllEntries();
81 void _requestLogData(uint16_t id, uint32_t offset, uint32_t count, int retryCount = 0);
82 void _requestLogList(uint32_t start, uint32_t end);
83 void _requestLogEnd();
84 void _resetSelection(bool canceled = false);
85 void _setDownloading(bool active);
86 void _setListing(bool active);
87 void _updateDataRate();
88
89 QGCOnboardLogEntry *_getNextSelected() const;
90
91 QTimer *_timer = nullptr;
92 QmlObjectListModel *_logEntriesModel = nullptr;
93
94 bool _downloadingLogs = false;
95 bool _requestingLogEntries = false;
96 int _apmOffset = 0;
97 int _retries = 0;
98 std::unique_ptr<OnboardLogDownloadData> _downloadData;
99 QString _downloadPath;
100 Vehicle *_vehicle = nullptr;
101 bool _compressLogs = false;
102 bool _compressing = false;
103 float _compressionProgress = 0.0F;
104
105 static constexpr uint32_t kTimeOutMs = 500;
106 static constexpr uint32_t kGUIRateMs = 500;
107 static constexpr uint32_t kRequestLogListTimeoutMs = 5000;
108};
Error error
void download(const QString &path=QString())
void compressionComplete(const QString &outputPath, const QString &error)
void compressionProgressChanged()
float compressionProgress() const
void setCompressLogs(bool compress)
bool compressLogFile(const QString &logPath)
Compress a single log file.
void cancelCompression()
Cancel compression.