PX4ParameterMetaData.h 1.89 KB
Newer Older
1 2
/****************************************************************************
 *
Gus Grubba's avatar
Gus Grubba committed
3
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 5 6 7 8 9
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/

10
#pragma once
Don Gagne's avatar
Don Gagne committed
11 12 13 14 15 16

#include <QObject>
#include <QMap>
#include <QXmlStreamReader>
#include <QLoggingCategory>

17
#include "FactSystem.h"
18
#include "AutoPilotPlugin.h"
19
#include "Vehicle.h"
Don Gagne's avatar
Don Gagne committed
20 21 22 23

/// @file
///     @author Don Gagne <don@thegagnes.com>

24
Q_DECLARE_LOGGING_CATEGORY(PX4ParameterMetaDataLog)
Don Gagne's avatar
Don Gagne committed
25

26 27
//#define GENERATE_PARAMETER_JSON

28
/// Loads and holds parameter fact meta data for PX4 stack
29
class PX4ParameterMetaData : public QObject
Don Gagne's avatar
Don Gagne committed
30 31 32 33
{
    Q_OBJECT
    
public:
34
    PX4ParameterMetaData(void);
35

36
    void            loadParameterFactMetaDataFile   (const QString& metaDataFile);
37
    FactMetaData*   getMetaDataForFact              (const QString& name, MAV_TYPE vehicleType, FactMetaData::ValueType_t type);
38

39
    static void getParameterMetaDataVersionInfo(const QString& metaDataFile, int& majorVersion, int& minorVersion);
40

Don Gagne's avatar
Don Gagne committed
41
private:
42 43 44 45 46 47 48
    enum {
        XmlStateNone,
        XmlStateFoundParameters,
        XmlStateFoundVersion,
        XmlStateFoundGroup,
        XmlStateFoundParameter,
        XmlStateDone
49
    };    
Don Gagne's avatar
Don Gagne committed
50

51
    QVariant _stringToTypedVariant(const QString& string, FactMetaData::ValueType_t type, bool* convertOk);
52
    static void _outputFileWarning(const QString& metaDataFile, const QString& error1, const QString& error2);
Don Gagne's avatar
Don Gagne committed
53

54 55 56 57
#ifdef GENERATE_PARAMETER_JSON
    void _generateParameterJson();
#endif

58 59
    bool                                _parameterMetaDataLoaded        = false;    ///< true: parameter meta data already loaded
    FactMetaData::NameToMetaDataMap_t   _mapParameterName2FactMetaData;             ///< Maps from a parameter name to FactMetaData
Don Gagne's avatar
Don Gagne committed
60
};