APMFlightModesComponentController.h 3.62 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 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

#ifndef APMFlightModesComponentController_H
#define APMFlightModesComponentController_H

#include <QObject>
#include <QQuickItem>
#include <QList>
#include <QStringList>

#include "UASInterface.h"
#include "AutoPilotPlugin.h"
#include "FactPanelController.h"
#include "Vehicle.h"

/// MVC Controller for FlightModesComponent.qml.
class APMFlightModesComponentController : public FactPanelController
{
    Q_OBJECT
    
public:
30 31 32 33 34 35 36 37
    enum SimpleModeValues {
        SimpleModeStandard = 0,
        SimpleModeSimple,
        SimpleModeSuperSimple,
        SimpleModeCustom
    };
    Q_ENUM(SimpleModeValues)

Don Gagne's avatar
Don Gagne committed
38 39
    APMFlightModesComponentController(void);
    
40 41 42 43 44 45 46 47 48 49 50 51 52
    Q_PROPERTY(QString      modeParamPrefix         MEMBER _modeParamPrefix         CONSTANT)
    Q_PROPERTY(QString      modeChannelParam        MEMBER _modeChannelParam        CONSTANT)
    Q_PROPERTY(int          activeFlightMode        READ activeFlightMode           NOTIFY activeFlightModeChanged)
    Q_PROPERTY(int          channelCount            MEMBER _channelCount            CONSTANT)
    Q_PROPERTY(QVariantList channelOptionEnabled    READ channelOptionEnabled       NOTIFY channelOptionEnabledChanged)
    Q_PROPERTY(bool         simpleModesSupported    MEMBER _simpleModesSupported    CONSTANT)
    Q_PROPERTY(QStringList  simpleModeNames         MEMBER _simpleModeNames         CONSTANT)
    Q_PROPERTY(int          simpleMode              MEMBER _simpleMode              NOTIFY simpleModeChanged)
    Q_PROPERTY(QVariantList simpleModeEnabled       MEMBER _simpleModeEnabled       NOTIFY simpleModeEnabledChanged)
    Q_PROPERTY(QVariantList superSimpleModeEnabled  MEMBER _superSimpleModeEnabled  NOTIFY superSimpleModeEnabledChanged)

    Q_INVOKABLE void setSimpleMode(int fltModeIndex, bool enabled);
    Q_INVOKABLE void setSuperSimpleMode(int fltModeIndex, bool enabled);
Don Gagne's avatar
Don Gagne committed
53

Tomaz Canabrava's avatar
Tomaz Canabrava committed
54 55
    int activeFlightMode(void) const { return _activeFlightMode; }
    QVariantList channelOptionEnabled(void) const { return _rgChannelOptionEnabled; }
Don Gagne's avatar
Don Gagne committed
56 57

signals:
58 59 60 61 62 63
    void activeFlightModeChanged        (int activeFlightMode);
    void channelOptionEnabledChanged    (void);
    void simpleModeChanged              (int simpleMode);
    void simpleModeEnabledChanged       (void);
    void superSimpleModeEnabledChanged  (void);

Don Gagne's avatar
Don Gagne committed
64
private slots:
65 66
    void _rcChannelsChanged                     (int channelCount, int pwmValues[Vehicle::cMaxRcChannels]);
    void _updateSimpleParamsFromSimpleMode      (void);
67
    void _setupSimpleModeEnabled     (void);
68

Don Gagne's avatar
Don Gagne committed
69
private:
Don Gagne's avatar
Don Gagne committed
70 71
    QString         _modeParamPrefix;
    QString         _modeChannelParam;
Don Gagne's avatar
Don Gagne committed
72 73 74
    int             _activeFlightMode;
    int             _channelCount;
    QVariantList    _rgChannelOptionEnabled;
75 76 77 78 79 80 81 82 83 84 85 86 87
    QStringList     _simpleModeNames;
    int             _simpleMode;
    Fact*           _simpleModeFact;
    Fact*           _superSimpleModeFact;
    bool            _simpleModesSupported;
    QVariantList    _simpleModeEnabled;
    QVariantList    _superSimpleModeEnabled;

    static const uint8_t    _allSimpleBits =    0x3F;
    static const int        _cChannelOptions =  10;
    static const int        _cSimpleModeBits =  8;
    static const int        _cFltModes =        6;

88 89 90
    static const char*      _simpleParamName;
    static const char*      _superSimpleParamName;

91
    static bool _typeRegistered;
Don Gagne's avatar
Don Gagne committed
92 93 94
};

#endif