-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathParameterLoader.h
More file actions
76 lines (59 loc) · 2.35 KB
/
Copy pathParameterLoader.h
File metadata and controls
76 lines (59 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef PARAMETERLOADER_H
#define PARAMETERLOADER_H
/**
* Load parameters from flight controller and store parameters in Fact
**/
#include <QObject>
#include <QVariant>
#include <common/mavlink.h>
#include <QMutex>
#include <QMap>
#include <QTimer>
#include "PX4FirmwarePlugin.h"
#include "Fact.h"
#include "PX4ParameterMetaData.h"
class Vehicle;
class ParameterLoader : public QObject
{
Q_OBJECT
public:
explicit ParameterLoader(Vehicle *vehicle, QObject *parent = 0);
~ParameterLoader();
/// @return true: param of specified name exists
bool paramExists(int componentId,const QString& name);
/// @return Fact* of specified name
Fact* getFact(int componentId, const QString& name);
/// reload all parameters from flight controller when calibration finished
void refreshParameters(void);
signals:
/// signal to PX4AutopilotPlugin to start calibration status check
void paramsReady(bool noMissingParams);
/// signal to MessagePanel to show parameters loading progress
void paramLoadProgress(int currentCount,int totalCount);
private slots:
void _valueUpdated(const QVariant& value);
void _parameterUpdate(int componentId, QString paramName, int paramCount, int paramId, int type,QVariant value);
void _initialParamRequestTimeout();
private:
/// get actual component Id
int _actualCompId(int componentId);
void _refreshAllParameters();
void _addMetaDataToDefaultComponent(void);
/// check if initial parameters are loaded completely
void _checkInitialLoadComplete(void);
Vehicle* _vehicle;
PX4FirmwarePlugin *_px4FirmwarePlugin;
PX4ParameterMetaData* _parameterMetaData;
static Fact _defaultFact; ///< Used to return default fact, when parameter not found
/// singleShot timer for requesting initial parameters from flight controller, stopped when parameters received
QTimer _initialParamRequestTimer;
QMutex _dataMutex;
/// store parameters received from flight controller
/// key: name of parameter, value: QVariant:containing a copy of Fact pointer
QMap<QString,QVariant> _mapParamName2Variant;
int _defaultCompId; /// default component Id
bool _compParamsComplete; /// true if all parameters loaded
int _currentParamCount; /// number parameters received
int _totalParamCount; /// number of all parameters
};
#endif // PARAMETERLOADER_H