4#include <QtCore/QObject>
5#include <QtCore/QString>
6#include <QtCore/QTimer>
7#include <QtQmlIntegration/QtQmlIntegration>
10#include "MAVLinkEnums.h"
70 void bulkRefresh(
int componentId,
const QStringList &names,
bool notifyFailure =
true);
93#ifdef QGC_UNITTEST_BUILD
98 void setPendingWritesForTest(
bool pending);
137 void _factRawValueUpdated(
const QVariant &rawValue);
141 void _handleParamValue(
int componentId,
const QString ¶meterName,
int parameterCount,
int parameterIndex, MAV_PARAM_TYPE mavParamType,
const QVariant ¶meterValue);
143 void _mavlinkParamSet(
int componentId,
const QString &name,
FactMetaData::ValueType_t valueType,
const QVariant &rawValue);
144 void _waitingParamTimeout();
145 void _tryCacheLookup();
146 void _resetHashCheck();
147 void _startParameterDownload(uint8_t componentId);
148 void _hashCheckTimeout();
149 void _paramRequestListTimeout();
151 int _actualComponentId(
int componentId)
const;
152 void _mavlinkParamRequestRead(
int componentId,
const QString ¶mName,
int paramIndex,
bool notifyFailure);
153 void _requestHashCheck(uint8_t componentId);
154 void _writeLocalParamCache(
int vehicleId,
int componentId);
155 void _tryCacheHashLoad(
int vehicleId,
int componentId,
const QVariant &hashValue);
156 void _loadMetaData();
157 void _clearMetaData();
166 QString _remapParamNameToVersion(
const QString ¶mName)
const;
170 void _loadOfflineEditingParams();
171 QString _logVehiclePrefix(
int componentId)
const;
176 bool _fillIndexBatchQueue(
bool waitingParamTimeout);
177 void _updateProgressBar();
178 void _checkInitialLoadComplete();
179 void _ftpDownloadComplete(
const QString &fileName,
const QString &errorMsg);
180 void _ftpDownloadProgress(
float progress);
183 bool _parseParamFile(
const QString &filename);
184 void _incrementPendingWriteCount();
185 void _decrementPendingWriteCount();
186 QString _vehicleAndComponentString(
int componentId)
const;
192 QMap<
int , QMap<QString ,
Fact*>> _mapCompId2FactMap;
194 double _loadProgress = 0;
195 bool _parametersReady =
false;
196 bool _parameterDownloadSkipped =
false;
197 bool _missingParameters =
false;
198 bool _initialLoadComplete =
false;
199 bool _waitingForDefaultComponent =
false;
200 bool _metaDataAddedToFacts =
false;
201 bool _logReplay =
false;
202 bool _hashCheckDone =
false;
203 bool _cacheOnlyHashCheck =
false;
205 typedef QPair<
int , QVariant > ParamTypeVal;
206 typedef QMap<QString , ParamTypeVal> CacheMapName2ParamTypeVal;
208 QMap<
int ,
bool> _debugCacheCRC;
209 QMap<
int , CacheMapName2ParamTypeVal> _debugCacheMap;
210 QMap<
int , QMap<QString ,
bool >> _debugCacheParamSeen;
213 int _prevWaitingReadParamIndexCount = 0;
215 bool _readParamIndexProgressActive =
false;
218 int _initialRequestRetryCount = 0;
219 static constexpr int _maxInitialLoadRetrySingleParam = 5;
220 bool _disableAllRetries =
false;
221 const int _waitForParamValueAckMs;
223 bool _indexBatchQueueActive =
false;
224 QList<int> _indexBatchQueue;
226 QMap<int, int> _paramCountMap;
227 QMap<int, QMap<int, int>> _waitingReadParamIndexMap;
228 QMap<int, QList<int>> _failedReadParamIndexMap;
230 int _totalParamCount = 0;
231 int _pendingWritesCount = 0;
233 QTimer _hashCheckTimer;
234 QTimer _paramRequestListTimer;
235 QTimer _waitingParamTimeoutTimer;
239 bool _tryftp =
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
void refreshParametersPrefix(int componentId, const QString &namePrefix)
Request a refresh on all parameters that begin with the specified prefix.
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 kParamSetRetryCount
Number of retries for PARAM_SET.
void _paramSetSuccess(int componentId, const QString ¶mName)
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 kTestMaxInitialRequestTimeMs
Maximum time to wait for initial request retries to exhaust in tests.
void _paramSetFailure(int componentId, const QString ¶mName)