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

Don Gagne's avatar
Don Gagne committed
10

11 12
#ifndef PX4ParameterMetaData_H
#define PX4ParameterMetaData_H
Don Gagne's avatar
Don Gagne committed
13 14 15 16 17 18

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

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

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

26
Q_DECLARE_LOGGING_CATEGORY(PX4ParameterMetaDataLog)
Don Gagne's avatar
Don Gagne committed
27

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 37
    void loadParameterFactMetaDataFile  (const QString& metaDataFile);
    void addMetaDataToFact              (Fact* fact, MAV_TYPE vehicleType);
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);
Don Gagne's avatar
Don Gagne committed
52

53 54
    bool _parameterMetaDataLoaded;   ///< true: parameter meta data already loaded
    QMap<QString, FactMetaData*> _mapParameterName2FactMetaData; ///< Maps from a parameter name to FactMetaData
Don Gagne's avatar
Don Gagne committed
55 56
};

57
#endif