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);
138 void _factRawValueUpdated(
const QVariant &rawValue);
142 void _handleParamValue(
int componentId,
const QString ¶meterName,
int parameterCount,
int parameterIndex, MAV_PARAM_TYPE mavParamType,
const QVariant ¶meterValue);
144 void _mavlinkParamSet(
int componentId,
const QString &name,
FactMetaData::ValueType_t valueType,
const QVariant &rawValue);
145 void _waitingParamTimeout();
146 void _tryCacheLookup();
147 void _resetHashCheck();
148 void _startParameterDownload(uint8_t componentId);
149 void _hashCheckTimeout();
150 void _paramRequestListTimeout();
152 int _actualComponentId(
int componentId)
const;
153 void _mavlinkParamRequestRead(
int componentId,
const QString ¶mName,
int paramIndex,
bool notifyFailure);
154 void _requestHashCheck(uint8_t componentId);
155 void _writeLocalParamCache(
int vehicleId,
int componentId);
156 void _tryCacheHashLoad(
int vehicleId,
int componentId,
const QVariant &hashValue);
157 void _loadMetaData();
158 void _clearMetaData();
167 QString _remapParamNameToVersion(
const QString ¶mName)
const;
171 void _loadOfflineEditingParams();
172 QString _logVehiclePrefix(
int componentId)
const;
177 bool _fillIndexBatchQueue(
bool waitingParamTimeout);
178 void _updateProgressBar();
179 void _checkInitialLoadComplete();
180 void _ftpDownloadComplete(
const QString &fileName,
const QString &errorMsg);
181 void _ftpDownloadProgress(
float progress);
184 bool _parseParamFile(
const QString &filename);
185 void _incrementPendingWriteCount();
186 void _decrementPendingWriteCount();
187 QString _vehicleAndComponentString(
int componentId)
const;
193 QMap<
int , QMap<QString ,
Fact*>> _mapCompId2FactMap;
195 double _loadProgress = 0;
196 bool _parametersReady =
false;
197 bool _parameterDownloadSkipped =
false;
198 bool _missingParameters =
false;
199 bool _initialLoadComplete =
false;
200 bool _waitingForDefaultComponent =
false;
201 bool _metaDataAddedToFacts =
false;
202 bool _logReplay =
false;
203 bool _hashCheckDone =
false;
204 bool _cacheOnlyHashCheck =
false;
206 typedef QPair<
int , QVariant > ParamTypeVal;
207 typedef QMap<QString , ParamTypeVal> CacheMapName2ParamTypeVal;
209 QMap<
int ,
bool> _debugCacheCRC;
210 QMap<
int , CacheMapName2ParamTypeVal> _debugCacheMap;
211 QMap<
int , QMap<QString ,
bool >> _debugCacheParamSeen;
214 int _prevWaitingReadParamIndexCount = 0;
216 bool _readParamIndexProgressActive =
false;
219 int _initialRequestRetryCount = 0;
220 static constexpr int _maxInitialLoadRetrySingleParam = 5;
221 bool _disableAllRetries =
false;
222 const int _waitForParamValueAckMs;
224 bool _indexBatchQueueActive =
false;
225 QList<int> _indexBatchQueue;
227 QMap<int, int> _paramCountMap;
228 QMap<int, QMap<int, int>> _waitingReadParamIndexMap;
229 QMap<int, QList<int>> _failedReadParamIndexMap;
231 int _totalParamCount = 0;
232 int _pendingWritesCount = 0;
234 QTimer _hashCheckTimer;
235 QTimer _paramRequestListTimer;
236 QTimer _waitingParamTimeoutTimer;
240 bool _tryftp =
false;
241 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
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 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)