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

10

11
#pragma once
12 13 14 15 16 17 18 19 20

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

#include <QObject>
#include <QQuickItem>

#include "UASInterface.h"
#include "AutoPilotPlugin.h"
Don Gagne's avatar
Don Gagne committed
21 22 23
#include "QGCLoggingCategory.h"

Q_DECLARE_LOGGING_CATEGORY(FactPanelControllerLog)
24

25
/// FactPanelController is used for handling missing Facts from C++ code.
26 27
class FactPanelController : public QObject
{
dogmaphobic's avatar
dogmaphobic committed
28
    Q_OBJECT
29
public:
30
    FactPanelController();
dogmaphobic's avatar
dogmaphobic committed
31

32
    Q_PROPERTY(Vehicle* vehicle MEMBER _vehicle CONSTANT)
dogmaphobic's avatar
dogmaphobic committed
33 34 35 36

    Q_INVOKABLE Fact*   getParameterFact    (int componentId, const QString& name, bool reportMissing = true);
    Q_INVOKABLE bool    parameterExists     (int componentId, const QString& name);

37 38 39 40 41 42
    /// Queries the vehicle for parameters which were not available on initial download but should be available now.
    /// Signals missingParametersAvailable when done. Only works for MAV_COMP_ID_AUTOPILOT1 parameters.
    Q_INVOKABLE void    getMissingParameters(QStringList rgNames);

signals:
    void missingParametersAvailable(void);
dogmaphobic's avatar
dogmaphobic committed
43

44
protected:
Don Gagne's avatar
Don Gagne committed
45 46 47
    /// Checks for existence of the specified parameters
    /// @return true: all parameters exists, false: parameters missing and reported
    bool _allParametersExists(int componentId, QStringList names);
dogmaphobic's avatar
dogmaphobic committed
48

49
    /// Report a missing parameter
Don Gagne's avatar
Don Gagne committed
50
    void _reportMissingParameter(int componentId, const QString& name);
dogmaphobic's avatar
dogmaphobic committed
51

52 53 54
    Vehicle*            _vehicle    = nullptr;
    UASInterface*       _uas        = nullptr;
    AutoPilotPlugin*    _autopilot  = nullptr;
dogmaphobic's avatar
dogmaphobic committed
55

56
private slots:
57
    void _checkForMissingParameters(void);
dogmaphobic's avatar
dogmaphobic committed
58

59
private:
60 61
    QStringList _missingParameterWaitList;
    QTimer      _missingParametersTimer;
62
};