5#include <QtCore/QObject>
8#include <QtCore/QString>
9#include <QtCore/QTimer>
10#include <QtQmlIntegration/QtQmlIntegration>
13#include "MAVLinkEnums.h"
66 void refreshParameter(
int componentId,
const QString& paramName,
bool notifyFailure =
true);
77 void bulkRefresh(
int componentId,
const QStringList &names,
bool notifyFailure =
true);
105#ifdef QGC_UNITTEST_BUILD
110 void setPendingWritesForTest(
bool pending);
154 void _factRawValueUpdated(
const QVariant &rawValue);
158 void _handleParamValue(
int componentId,
const QString ¶meterName,
int parameterCount,
int parameterIndex, MAV_PARAM_TYPE mavParamType,
const QVariant ¶meterValue);
160 void _mavlinkParamSet(
int componentId,
const QString &name,
FactMetaData::ValueType_t valueType,
const QVariant &rawValue);
161 void _waitingParamTimeout();
162 void _tryCacheLookup();
163 void _resetHashCheck();
164 void _startParameterDownload(uint8_t componentId);
165 void _hashCheckTimeout();
166 void _paramRequestListTimeout();
168 int _actualComponentId(
int componentId)
const;
169 void _mavlinkParamRequestRead(
int componentId,
const QString ¶mName,
int paramIndex,
bool notifyFailure);
171 void _sendParamRequestReadIndex(
int componentId,
int paramIndex);
172 void _requestHashCheck(uint8_t componentId);
173 void _writeLocalParamCache(quint32 vehicleId,
int componentId);
174 void _tryCacheHashLoad(quint32 vehicleId,
int componentId,
const QVariant& hashValue);
175 void _loadMetaData();
176 void _clearMetaData();
185 QString _remapParamNameToVersion(
const QString ¶mName)
const;
189 void _loadOfflineEditingParams();
190 QString _logVehiclePrefix(
int componentId)
const;
195 bool _fillIndexBatchQueue(
bool waitingParamTimeout);
198 void _giveUpOnUnresponsiveComponents();
199 void _updateProgressBar();
200 void _checkInitialLoadComplete();
202 void _checkOtherComponentsLoadComplete();
203 bool _anyComponentWaiting()
const;
204 void _ftpDownloadComplete(
const QString &fileName,
const QString &errorMsg);
206 void _handleHeartbeat(
int componentId);
207 void _sendParamRequestList(uint8_t componentId);
208 void _ftpDownloadProgress(
float progress);
211 bool _parseParamFile(
const QString &filename);
212 void _incrementPendingWriteCount();
213 void _decrementPendingWriteCount();
214 QString _vehicleAndComponentString(
int componentId)
const;
220 QMap<
int , QMap<QString ,
Fact*>> _mapCompId2FactMap;
222 double _loadProgress = 0;
223 bool _parametersReady =
false;
224 bool _parameterDownloadSkipped =
false;
225 bool _missingParameters =
false;
226 bool _initialLoadComplete =
false;
227 bool _otherComponentsReported =
false;
228 bool _waitingForDefaultComponent =
false;
229 bool _metaDataAddedToFacts =
false;
230 bool _logReplay =
false;
231 bool _hashCheckDone =
false;
232 bool _cacheOnlyHashCheck =
false;
233 int _rebootMessageSuppressCount = 0;
235 typedef QPair<
int , QVariant > ParamTypeVal;
236 typedef QMap<QString , ParamTypeVal> CacheMapName2ParamTypeVal;
238 QMap<
int ,
bool> _debugCacheCRC;
239 QMap<
int , CacheMapName2ParamTypeVal> _debugCacheMap;
240 QMap<
int , QMap<QString ,
bool >> _debugCacheParamSeen;
243 int _prevWaitingReadParamIndexCount = 0;
245 bool _readParamIndexProgressActive =
false;
246 bool _refreshAllProgressActive =
false;
249 int _initialRequestRetryCount = 0;
251 bool _disableAllRetries =
false;
252 const int _waitForParamValueAckMs;
254 bool _indexBatchQueueActive =
false;
255 QList<QPair<int, int>> _indexBatchQueue;
257 QMap<int, int> _paramCountMap;
258 QMap<int, QMap<int, int>> _waitingReadParamIndexMap;
259 QMap<int, QList<int>> _failedReadParamIndexMap;
260 QMap<int, int> _paramValuesReceivedThisCycle;
261 QMap<int, int> _silentCycleCount;
263 int _totalParamCount = 0;
264 int _pendingWritesCount = 0;
266 QTimer _hashCheckTimer;
267 QTimer _paramRequestListTimer;
268 QTimer _waitingParamTimeoutTimer;
272 bool _tryftp =
false;
273 bool _ftpDownloadInProgress =
false;
274 bool _ftpParamsLoaded =
false;
275 QSet<int> _heartbeatComponentIds;
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 QString parameterCacheFile(quint32 vehicleId, int componentId)
static constexpr int kTestInitialRequestIntervalMs
void factAdded(int componentId, Fact *fact)
static FactMetaData::ValueType_t mavTypeToFactType(MAV_PARAM_TYPE mavType)
void refreshParameter(int componentId, const QString ¶mName, bool notifyFailure=true)
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)
ParameterManager(Vehicle *vehicle)
double loadProgress() const
void bulkRefresh(int componentId, const QStringList &names, bool notifyFailure=true)
void tryHashCheckCacheLoad()
bool pendingWrites() const
static QDir parameterCacheDir()
void unsuppressRebootMessage()
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 suppressRebootMessage()
void pendingWritesChanged(bool pendingWrites)
static MAV_PARAM_TYPE factTypeToMavType(FactMetaData::ValueType_t factType)
static constexpr int kParamRequestReadRetryCount
Number of retries for PARAM_REQUEST_READ.
friend class ParameterEditorController
< true: There are still pending write updates against the vehicle
bool missingParameters() const
void resetAllToVehicleConfiguration()
bool parameterDownloadSkipped() const
Q_INVOKABLE void refreshAllParameters()
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)