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 "MAVLinkEnums.h"
4#include "QGCStateMachine.h"
6
7class Vehicle;
10class CompInfo;
11class CompInfoParam;
12class CompInfoGeneral;
16class FunctionState;
17class QGCFinalState;
18
20{
21 Q_OBJECT
22
23public:
24 explicit ComponentInformationManager(Vehicle *vehicle, QObject *parent = nullptr);
26
27 typedef void (*RequestAllCompleteFn)(void *requestAllCompleteFnData);
28
29 void requestAllComponentInformation(RequestAllCompleteFn requestAllCompletFn, void * requestAllCompleteFnData);
30 CompInfoParam *compInfoParam(uint8_t compId);
31 CompInfoGeneral *compInfoGeneral(uint8_t compId);
32
33 ComponentInformationCache &fileCache() { return _fileCache; }
34 ComponentInformationTranslation *translation() { return _translation; }
35
36 float progress() const;
37
38 static constexpr int cachedFileMaxAgeSec = 3 * 24 * 3600;
39
40signals:
42
43private:
44 void _createStates();
45 void _wireTransitions();
46 void _wireProgressTracking();
47
48 // State action functions
49 void _requestCompInfoGeneral(AsyncFunctionState* state);
50 void _updateAllUri();
51 void _requestCompInfoParam(SkippableAsyncState* state);
52 void _requestCompInfoEvents(SkippableAsyncState* state);
53 void _requestCompInfoActuators(SkippableAsyncState* state);
54 void _signalComplete();
55
56 // Skip predicates
57 bool _isCompTypeSupported(COMP_METADATA_TYPE type) const;
58
59 // Progress tracking
60 void _updateProgress();
61
62 static QString _getFileCacheTag(int compInfoType, uint32_t crc, bool isTranslation);
63
64 RequestMetaDataTypeStateMachine _requestTypeStateMachine;
65 RequestAllCompleteFn _requestAllCompleteFn = nullptr;
66 void* _requestAllCompleteFnData = nullptr;
67 QGCCachedFileDownload* _cachedFileDownload = nullptr;
68 ComponentInformationCache& _fileCache;
69 ComponentInformationTranslation* _translation = nullptr;
70
71 QMap<uint8_t /* compId */, QMap<COMP_METADATA_TYPE, CompInfo*>> _compInfoMap;
72
73 // State pointers
74 AsyncFunctionState* _stateRequestGeneral = nullptr;
75 FunctionState* _stateUpdateUri = nullptr;
76 SkippableAsyncState* _stateRequestParam = nullptr;
77 SkippableAsyncState* _stateRequestEvents = nullptr;
78 SkippableAsyncState* _stateRequestActuators = nullptr;
79 FunctionState* _stateComplete = nullptr;
80 QGCFinalState* _stateFinal = nullptr;
81
82 // Progress tracking
83 int _currentStateIndex = 0;
84 static constexpr int _stateCount = 6;
85
87};
Calls a function when entered and waits for an external trigger to advance.
Base class for all CompInfo types.
Definition CompInfo.h:15
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)
Cached file download with time-based expiration.
Final state for a QGCStateMachine with logging support.
QGroundControl specific state machine with enhanced error handling.
Vehicle * vehicle() const
Combines skip condition checking with async operation setup in a single state.