5#include <QtCore/QObject>
7#include <QtCore/QString>
8#include <QtCore/QTimer>
9#include <QtQmlIntegration/QtQmlIntegration>
12#include "MAVLinkEnums.h"
74 void bulkRefresh(
int componentId,
const QStringList &names,
bool notifyFailure =
true);
97#ifdef QGC_UNITTEST_BUILD
102 void setPendingWritesForTest(
bool pending);
146 void _factRawValueUpdated(
const QVariant &rawValue);
150 void _handleParamValue(
int componentId,
const QString ¶meterName,
int parameterCount,
int parameterIndex, MAV_PARAM_TYPE mavParamType,
const QVariant ¶meterValue);
152 void _mavlinkParamSet(
int componentId,
const QString &name,
FactMetaData::ValueType_t valueType,
const QVariant &rawValue);
153 void _waitingParamTimeout();
154 void _tryCacheLookup();
155 void _resetHashCheck();
156 void _startParameterDownload(uint8_t componentId);
157 void _hashCheckTimeout();
158 void _paramRequestListTimeout();
160 int _actualComponentId(
int componentId)
const;
161 void _mavlinkParamRequestRead(
int componentId,
const QString ¶mName,
int paramIndex,
bool notifyFailure);
163 void _sendParamRequestReadIndex(
int componentId,
int paramIndex);
164 void _requestHashCheck(uint8_t componentId);
165 void _writeLocalParamCache(
int vehicleId,
int componentId);
166 void _tryCacheHashLoad(
int vehicleId,
int componentId,
const QVariant &hashValue);
167 void _loadMetaData();
168 void _clearMetaData();
177 QString _remapParamNameToVersion(
const QString ¶mName)
const;
181 void _loadOfflineEditingParams();
182 QString _logVehiclePrefix(
int componentId)
const;
187 bool _fillIndexBatchQueue(
bool waitingParamTimeout);
190 void _giveUpOnUnresponsiveComponents();
191 void _updateProgressBar();
192 void _checkInitialLoadComplete();
194 void _checkOtherComponentsLoadComplete();
195 bool _anyComponentWaiting()
const;
196 void _ftpDownloadComplete(
const QString &fileName,
const QString &errorMsg);
197 void _ftpDownloadProgress(
float progress);
200 bool _parseParamFile(
const QString &filename);
201 void _incrementPendingWriteCount();
202 void _decrementPendingWriteCount();
203 QString _vehicleAndComponentString(
int componentId)
const;
209 QMap<
int , QMap<QString ,
Fact*>> _mapCompId2FactMap;
211 double _loadProgress = 0;
212 bool _parametersReady =
false;
213 bool _parameterDownloadSkipped =
false;
214 bool _missingParameters =
false;
215 bool _initialLoadComplete =
false;
216 bool _otherComponentsReported =
false;
217 bool _waitingForDefaultComponent =
false;
218 bool _metaDataAddedToFacts =
false;
219 bool _logReplay =
false;
220 bool _hashCheckDone =
false;
221 bool _cacheOnlyHashCheck =
false;
223 typedef QPair<
int , QVariant > ParamTypeVal;
224 typedef QMap<QString , ParamTypeVal> CacheMapName2ParamTypeVal;
226 QMap<
int ,
bool> _debugCacheCRC;
227 QMap<
int , CacheMapName2ParamTypeVal> _debugCacheMap;
228 QMap<
int , QMap<QString ,
bool >> _debugCacheParamSeen;
231 int _prevWaitingReadParamIndexCount = 0;
233 bool _readParamIndexProgressActive =
false;
234 bool _refreshAllProgressActive =
false;
237 int _initialRequestRetryCount = 0;
239 bool _disableAllRetries =
false;
240 const int _waitForParamValueAckMs;
242 bool _indexBatchQueueActive =
false;
243 QList<QPair<int, int>> _indexBatchQueue;
245 QMap<int, int> _paramCountMap;
246 QMap<int, QMap<int, int>> _waitingReadParamIndexMap;
247 QMap<int, QList<int>> _failedReadParamIndexMap;
248 QMap<int, int> _paramValuesReceivedThisCycle;
249 QMap<int, int> _silentCycleCount;
251 int _totalParamCount = 0;
252 int _pendingWritesCount = 0;
254 QTimer _hashCheckTimer;
255 QTimer _paramRequestListTimer;
256 QTimer _waitingParamTimeoutTimer;
260 bool _tryftp =
false;
261 bool _ftpDownloadInProgress =
false;
struct __mavlink_message mavlink_message_t
struct param_union mavlink_param_union_t
A Fact is used to hold a single value within the system.
bool parameterExists(int componentId, const QString ¶mName) const
void parameterDownloadSkippedChanged()
static constexpr int kWaitForParamValueAckMs
Time to wait for param value ack after set param.
void mavlinkMessageReceived(const mavlink_message_t &message)
static constexpr int kParamRequestListTimeoutMs
Timeout for PARAM_REQUEST_LIST response.
Fact * getParameter(int componentId, const QString ¶mName)
static constexpr int kTestInitialRequestIntervalMs
void factAdded(int componentId, Fact *fact)
static FactMetaData::ValueType_t mavTypeToFactType(MAV_PARAM_TYPE mavType)
void setParameterDownloadSkipped(bool skipped)
QList< int > componentIds() const
static constexpr int kMaxInitialLoadRetrySingleParam
Maximum index re-read attempts for a single param during initial load.
void refreshParametersPrefix(int componentId, const QString &namePrefix)
Request a refresh on all parameters that begin with the specified prefix.
void initialParametersRequestFailed()
Vehicle never responded to PARAM_REQUEST_LIST, all retries exhausted.
void parametersReadyChanged(bool parametersReady)
double loadProgress() const
void bulkRefresh(int componentId, const QStringList &names, bool notifyFailure=true)
void tryHashCheckCacheLoad()
bool pendingWrites() const
static QDir parameterCacheDir()
static constexpr int kHashCheckTimeoutMs
Timeout for standalone _HASH_CHECK request.
void missingParametersChanged(bool missingParameters)
bool parametersReady() const
static constexpr int defaultComponentId
void resetAllParametersToDefaults()
static constexpr int kTestHashCheckTimeoutMs
Shortened _HASH_CHECK timeout in unit tests (MockLink responds instantly)
QStringList parameterNames(int componentId) const
Returns all parameter names.
void _paramRequestReadFailure(int componentId, const QString ¶mName, int paramIndex)
void _paramRequestReadSuccess(int componentId, const QString ¶mName, int paramIndex)
static constexpr int kIndexBatchMaxOutstanding
Maximum index re-reads in flight at once.
static constexpr int kParamSetRetryCount
Number of retries for PARAM_SET.
void _paramSetSuccess(int componentId, const QString ¶mName)
static constexpr int kUnresponsiveMinOutstanding
Minimum in-flight re-reads to a component before a silent cycle counts against it.
static constexpr int kMaxInitialRequestListRetry
Maximum retries for initial parameter request list.
void loadProgressChanged(float value)
void cacheCheckOnlyFailed()
void refreshParameter(int componentId, const QString ¶mName)
Request a refresh on the specific parameter.
void pendingWritesChanged(bool pendingWrites)
static MAV_PARAM_TYPE factTypeToMavType(FactMetaData::ValueType_t factType)
static constexpr int kParamRequestReadRetryCount
Number of retries for PARAM_REQUEST_READ.
bool missingParameters() const
void resetAllToVehicleConfiguration()
bool parameterDownloadSkipped() const
Q_INVOKABLE void refreshAllParameters()
static QString parameterCacheFile(int vehicleId, int componentId)
void writeParametersToStream(QTextStream &stream) const
static constexpr int kUnresponsiveSilentCycles
Consecutive silent cycles before a non-default component is given up on.
static constexpr int kTestMaxInitialRequestTimeMs
Maximum time to wait for initial request retries to exhaust in tests.
void _paramSetFailure(int componentId, const QString ¶mName)