PX4ParameterMetaData.h 1.83 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 38
    void            loadParameterFactMetaDataFile   (const QString& metaDataFile);
    FactMetaData*   getMetaDataForFact              (const QString& name, MAV_TYPE vehicleType);
    void            addMetaDataToFact               (Fact* fact, MAV_TYPE vehicleType);
39

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

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

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

55 56
    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
57 58
};

59
#endif