24 Q_MOC_INCLUDE(
"Vehicle.h")
25 Q_MOC_INCLUDE(
"QmlObjectListModel.h")
46 Q_INVOKABLE
void download(const QString &path = QString());
63 QString
transport()
const {
return (_transport == Transport::Ftp) ? QStringLiteral(
"ftp") : QStringLiteral(
"messages"); }
83 void _setActiveVehicle(
Vehicle *vehicle);
84 void _vehicleArmedChanged(
bool armed);
86 void _logEntry(uint32_t time_utc, uint32_t size, uint16_t
id, uint16_t num_logs, uint16_t last_log_num);
87 void _logData(uint32_t ofs, uint16_t
id, uint8_t count,
const uint8_t *data);
88 void _processDownload();
89 void _handleCompressionProgress(qreal progress);
90 void _handleCompressionFinished(
bool success);
92 void _ftpListDirComplete(
const QStringList &dirList,
const QString &errorMsg);
93 void _ftpDownloadComplete(
const QString &file,
const QString &errorMsg);
94 void _ftpDownloadProgress(
float value);
95 void _ftpDeleteComplete(
const QString &file,
const QString &errorMsg);
98 enum class Transport { Messages, Ftp };
99 enum class FtpListState {
Idle, ListingRoot, ListingSubdir };
101 QmlObjectListModel *_getModel()
const {
return _logEntriesModel; }
102 bool _getRequestingList()
const {
return _requestingLogEntries; }
103 bool _getDownloadingLogs()
const {
return _downloadingLogs; }
106 bool _vehicleArmed()
const;
107 bool _chunkComplete()
const;
108 bool _entriesComplete()
const;
109 bool _logComplete()
const;
110 bool _prepareLogDownload();
111 void _downloadToDirectory(
const QString &dir);
112 void _findMissingData();
113 void _findMissingEntries();
114 void _receivedAllData();
115 void _receivedAllEntries();
116 void _requestLogData(uint16_t
id, uint32_t offset, uint32_t count,
int retryCount = 0);
117 void _requestLogList(uint32_t start, uint32_t end);
118 void _requestLogEnd();
119 void _resetSelection(
bool canceled =
false);
120 void _setDownloading(
bool active);
121 void _setListing(
bool active);
122 void _updateDataRate();
124 void _sortEntriesByTimestamp();
127 void _ftpStartListing();
129 void _ftpListNextSubdir();
130 uint _ftpProcessFileEntries(
const QStringList &dirList,
const QString &subdir);
131 void _ftpFinishListing();
132 void _ftpFallbackToMessages();
133 void _ftpDownloadToDirectory(
const QString &dir);
134 void _ftpDownloadEntry(QGCOnboardLogEntry *entry);
135 void _ftpDownloadQueueNext();
136 void _ftpDeleteNext();
138 QGCOnboardLogEntry *_getNextSelected()
const;
140 QTimer *_timer =
nullptr;
141 QmlObjectListModel *_logEntriesModel =
nullptr;
143 bool _downloadingLogs =
false;
144 bool _requestingLogEntries =
false;
147 std::unique_ptr<OnboardLogDownloadData> _downloadData;
148 QString _downloadPath;
149 Vehicle *_vehicle =
nullptr;
150 bool _compressLogs =
false;
151 bool _compressing =
false;
152 float _compressionProgress = 0.0F;
153 bool _sortAscending =
false;
155 Transport _transport = Transport::Messages;
156 bool _ftpDisabled =
false;
157 FtpListState _ftpListState = FtpListState::Idle;
159 bool _ftpTriedFallbackRoot =
false;
160 QStringList _ftpDirsToList;
161 uint _ftpLogIdCounter = 0;
162 QQueue<QGCOnboardLogEntry*> _ftpDownloadQueue;
163 QQueue<QGCOnboardLogEntry*> _ftpDeleteQueue;
164 bool _ftpDeleting =
false;
165 QGCOnboardLogEntry *_ftpCurrentDownloadEntry =
nullptr;
166 bool _ftpDownloadHadError =
false;
167 QElapsedTimer _ftpDownloadElapsed;
168 size_t _ftpDownloadBytesAtLastUpdate = 0;
169 qreal _ftpDownloadRateAvg = 0.;
171 static constexpr uint32_t kTimeOutMs = 500;
172 static constexpr uint32_t kGUIRateMs = 500;
173 static constexpr uint32_t kRequestLogListTimeoutMs = 5000;