QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
ComponentInformationManager.h
Go to the documentation of this file.
1#pragma once
2
3#include "MAVLinkLib.h"
4#include "QGCStateMachine.h"
6
7#include <QtCore/QLoggingCategory>
8
9Q_DECLARE_LOGGING_CATEGORY(ComponentInformationManagerLog)
10
11class Vehicle;
14class CompInfo;
15class CompInfoParam;
16class CompInfoGeneral;
20class FunctionState;
21class QGCFinalState;
22
24{
25 Q_OBJECT
26
27public:
28 explicit ComponentInformationManager(Vehicle *vehicle, QObject *parent = nullptr);
30
31 typedef void (*RequestAllCompleteFn)(void *requestAllCompleteFnData);
32
33 void requestAllComponentInformation(RequestAllCompleteFn requestAllCompletFn, void * requestAllCompleteFnData);
34 CompInfoParam *compInfoParam(uint8_t compId);
35 CompInfoGeneral *compInfoGeneral(uint8_t compId);
36
37 ComponentInformationCache &fileCache() { return _fileCache; }
38 ComponentInformationTranslation *translation() { return _translation; }
39
40 float progress() const;
41
42 static constexpr int cachedFileMaxAgeSec = 3 * 24 * 3600;
43
44signals:
46
47private:
48 void _createStates();
49 void _wireTransitions();
50 void _wireProgressTracking();
51
52 // State action functions
53 void _requestCompInfoGeneral(AsyncFunctionState* state);
54 void _updateAllUri();
55 void _requestCompInfoParam(SkippableAsyncState* state);
56 void _requestCompInfoEvents(SkippableAsyncState* state);
57 void _requestCompInfoActuators(SkippableAsyncState* state);
58 void _signalComplete();
59
60 // Skip predicates
61 bool _isCompTypeSupported(COMP_METADATA_TYPE type) const;
62
63 // Progress tracking
64 void _updateProgress();
65
66 static QString _getFileCacheTag(int compInfoType, uint32_t crc, bool isTranslation);
67
68 RequestMetaDataTypeStateMachine _requestTypeStateMachine;
69 RequestAllCompleteFn _requestAllCompleteFn = nullptr;
70 void* _requestAllCompleteFnData = nullptr;
71 QGCCachedFileDownload* _cachedFileDownload = nullptr;
72 ComponentInformationCache& _fileCache;
73 ComponentInformationTranslation* _translation = nullptr;
74
75 QMap<uint8_t /* compId */, QMap<COMP_METADATA_TYPE, CompInfo*>> _compInfoMap;
76
77 // State pointers
78 AsyncFunctionState* _stateRequestGeneral = nullptr;
79 FunctionState* _stateUpdateUri = nullptr;
80 SkippableAsyncState* _stateRequestParam = nullptr;
81 SkippableAsyncState* _stateRequestEvents = nullptr;
82 SkippableAsyncState* _stateRequestActuators = nullptr;
83 FunctionState* _stateComplete = nullptr;
84 QGCFinalState* _stateFinal = nullptr;
85
86 // Progress tracking
87 int _currentStateIndex = 0;
88 static constexpr int _stateCount = 6;
89
91};
Q_DECLARE_LOGGING_CATEGORY(AndroidSerialLog)
Base class for all CompInfo types.
Definition CompInfo.h:14
ComponentInformationTranslation * translation()
static constexpr int cachedFileMaxAgeSec
3 days
CompInfoParam * compInfoParam(uint8_t compId)
void progressUpdate(float progress)
CompInfoGeneral * compInfoGeneral(uint8_t compId)
ComponentInformationCache & fileCache()
void requestAllComponentInformation(RequestAllCompleteFn requestAllCompletFn, void *requestAllCompleteFnData)
void(* RequestAllCompleteFn)(void *requestAllCompleteFnData)
Final state for a QGCStateMachine with logging support.
QGroundControl specific state machine with enhanced error handling.