AirspaceFlightPlanProvider.h 9.97 KB
Newer Older
Gus Grubba's avatar
Gus Grubba committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/****************************************************************************
 *
 *   (c) 2017 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.
 *
 ****************************************************************************/

#pragma once

/**
 * @file AirspaceFlightPlanProvider.h
 * Create and maintain a flight plan
 */

17 18 19
#include "AirspaceAdvisoryProvider.h"
#include "QmlObjectListModel.h"

Gus Grubba's avatar
Gus Grubba committed
20
#include <QObject>
21
#include <QDateTime>
Gus Grubba's avatar
Gus Grubba committed
22
#include <QAbstractListModel>
Gus Grubba's avatar
Gus Grubba committed
23

24
class PlanMasterController;
Gus Grubba's avatar
Gus Grubba committed
25
class AirspaceFlightInfo;
Gus Grubba's avatar
Gus Grubba committed
26

Gus Grubba's avatar
Gus Grubba committed
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
//-----------------------------------------------------------------------------
class AirspaceFlightAuthorization : public QObject
{
    Q_OBJECT
public:
    AirspaceFlightAuthorization                     (QObject *parent = nullptr);

    enum AuthorizationStatus {
        Accepted,
        Rejected,
        Pending,
        AcceptedOnSubmission,
        RejectedOnSubmission,
        Unknown
    };

    Q_ENUM(AuthorizationStatus)

    Q_PROPERTY(QString              name            READ name           CONSTANT)
    Q_PROPERTY(QString              id              READ id             CONSTANT)
    Q_PROPERTY(AuthorizationStatus  status          READ status         CONSTANT)
    Q_PROPERTY(QString              message         READ message        CONSTANT)

    virtual QString                 name            () = 0;
    virtual QString                 id              () = 0;
    virtual AuthorizationStatus     status          () = 0;
    virtual QString                 message         () = 0;

};


Gus Grubba's avatar
Gus Grubba committed
58 59 60 61 62
//-----------------------------------------------------------------------------
class AirspaceFlightInfo : public QObject
{
    Q_OBJECT
public:
Gus Grubba's avatar
Gus Grubba committed
63
    AirspaceFlightInfo                              (QObject *parent = nullptr);
Gus Grubba's avatar
Gus Grubba committed
64

Gus Grubba's avatar
Gus Grubba committed
65 66 67 68 69 70
    Q_PROPERTY(QString              flightID        READ flightID       CONSTANT)
    Q_PROPERTY(QString              flightPlanID    READ flightPlanID   CONSTANT)
    Q_PROPERTY(QString              createdTime     READ createdTime    CONSTANT)
    Q_PROPERTY(QString              startTime       READ startTime      CONSTANT)
    Q_PROPERTY(QString              endTime         READ endTime        CONSTANT)
    Q_PROPERTY(QGeoCoordinate       takeOff         READ takeOff        CONSTANT)
71 72
    Q_PROPERTY(QVariantList         boundingBox     READ boundingBox    CONSTANT)
    Q_PROPERTY(bool                 active          READ active         NOTIFY activeChanged)
Gus Grubba's avatar
Gus Grubba committed
73 74 75 76 77

    virtual QString                 flightID        () = 0;
    virtual QString                 flightPlanID    () = 0;
    virtual QString                 createdTime     () = 0;
    virtual QString                 startTime       () = 0;
78
    virtual QDateTime               qStartTime      () = 0;
Gus Grubba's avatar
Gus Grubba committed
79 80
    virtual QString                 endTime         () = 0;
    virtual QGeoCoordinate          takeOff         () = 0;
81 82
    virtual QVariantList            boundingBox     () = 0;
    virtual bool                    active          () = 0;
Gus Grubba's avatar
Gus Grubba committed
83 84

signals:
85
    void    activeChanged                           ();
Gus Grubba's avatar
Gus Grubba committed
86 87
};

Gus Grubba's avatar
Gus Grubba committed
88 89 90 91 92 93 94 95 96 97
//-----------------------------------------------------------------------------
class AirspaceFlightModel : public QAbstractListModel
{
    Q_OBJECT
public:

    enum QGCLogModelRoles {
        ObjectRole = Qt::UserRole + 1
    };

Gus Grubba's avatar
Gus Grubba committed
98
    AirspaceFlightModel         (QObject *parent = 0);
Gus Grubba's avatar
Gus Grubba committed
99 100

    Q_PROPERTY(int count READ count NOTIFY countChanged)
Gus Grubba's avatar
Gus Grubba committed
101 102

    Q_INVOKABLE AirspaceFlightInfo* get                 (int index);
103
    Q_INVOKABLE int                 findFlightID        (QString flightID);
Gus Grubba's avatar
Gus Grubba committed
104

105
    int         count           () const;
Gus Grubba's avatar
Gus Grubba committed
106
    void        append          (AirspaceFlightInfo *entry);
107
    void        remove          (const QString& flightID);
Gus Grubba's avatar
Gus Grubba committed
108
    void        remove          (int index);
109 110
    void        clear           ();
    void        sortStartFlight ();
Gus Grubba's avatar
Gus Grubba committed
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126

    AirspaceFlightInfo*
                operator[]      (int i);

    int         rowCount        (const QModelIndex & parent = QModelIndex()) const;
    QVariant    data            (const QModelIndex & index, int role = Qt::DisplayRole) const;

signals:
    void        countChanged    ();

protected:
    QHash<int, QByteArray> roleNames() const;
private:
    QList<AirspaceFlightInfo*> _flightEntries;
};

Gus Grubba's avatar
Gus Grubba committed
127 128 129 130 131 132 133
//-----------------------------------------------------------------------------
class AirspaceFlightPlanProvider : public QObject
{
    Q_OBJECT
public:

    enum PermitStatus {
134
        PermitNone = 0,     //-- No flght plan
Gus Grubba's avatar
Gus Grubba committed
135 136 137
        PermitPending,
        PermitAccepted,
        PermitRejected,
138
        PermitNotRequired,
Gus Grubba's avatar
Gus Grubba committed
139 140 141 142
    };

    Q_ENUM(PermitStatus)

143
    AirspaceFlightPlanProvider                      (QObject *parent = nullptr);
Gus Grubba's avatar
Gus Grubba committed
144

Gus Grubba's avatar
Gus Grubba committed
145
    ///< Flight Planning and Filing
146
    Q_PROPERTY(QDateTime            flightStartTime         READ flightStartTime    WRITE  setFlightStartTime   NOTIFY flightStartTimeChanged)      ///< Start of flight
147 148
    Q_PROPERTY(int                  flightDuration          READ flightDuration     WRITE  setFlightDuration    NOTIFY flightDurationChanged)       ///< Flight Duration
    Q_PROPERTY(bool                 flightStartsNow         READ flightStartsNow    WRITE  setFlightStartsNow   NOTIFY flightStartsNowChanged)
Gus Grubba's avatar
Gus Grubba committed
149 150 151

    ///< Flight Briefing
    Q_PROPERTY(PermitStatus         flightPermitStatus      READ flightPermitStatus                             NOTIFY flightPermitStatusChanged)   ///< State of flight permission
152 153
    Q_PROPERTY(bool                 valid                   READ valid                                          NOTIFY advisoryChanged)
    Q_PROPERTY(QmlObjectListModel*  advisories              READ advisories                                     NOTIFY advisoryChanged)
Gus Grubba's avatar
Gus Grubba committed
154
    Q_PROPERTY(QmlObjectListModel*  ruleSets                READ ruleSets                                       NOTIFY advisoryChanged)
155
    Q_PROPERTY(QGCGeoBoundingCube*  missionArea             READ missionArea                                    NOTIFY missionAreaChanged)
156
    Q_PROPERTY(AirspaceAdvisoryProvider::AdvisoryColor airspaceColor READ airspaceColor                         NOTIFY advisoryChanged)
157 158 159 160
    Q_PROPERTY(QmlObjectListModel*  rulesViolation          READ rulesViolation                                 NOTIFY rulesChanged)
    Q_PROPERTY(QmlObjectListModel*  rulesInfo               READ rulesInfo                                      NOTIFY rulesChanged)
    Q_PROPERTY(QmlObjectListModel*  rulesReview             READ rulesReview                                    NOTIFY rulesChanged)
    Q_PROPERTY(QmlObjectListModel*  rulesFollowing          READ rulesFollowing                                 NOTIFY rulesChanged)
161
    Q_PROPERTY(QmlObjectListModel*  briefFeatures           READ briefFeatures                                  NOTIFY rulesChanged)
Gus Grubba's avatar
Gus Grubba committed
162 163 164
    Q_PROPERTY(QmlObjectListModel*  authorizations          READ authorizations                                 NOTIFY rulesChanged)

    ///< Flight Management
Gus Grubba's avatar
Gus Grubba committed
165
    Q_PROPERTY(AirspaceFlightModel* flightList              READ flightList                                     NOTIFY flightListChanged)
Gus Grubba's avatar
Gus Grubba committed
166
    Q_PROPERTY(bool                 loadingFlightList       READ loadingFlightList                              NOTIFY loadingFlightListChanged)
167

Gus Grubba's avatar
Gus Grubba committed
168
    //-- TODO: This will submit the current flight plan in memory.
Gus Grubba's avatar
Gus Grubba committed
169 170 171
    Q_INVOKABLE virtual void    submitFlightPlan            () = 0;
    Q_INVOKABLE virtual void    updateFlightPlan            () = 0;
    Q_INVOKABLE virtual void    loadFlightList              (QDateTime startTime, QDateTime endTime) = 0;
172
    Q_INVOKABLE virtual void    endFlight                   (QString flighID) = 0;
173

174
    virtual PermitStatus        flightPermitStatus  () const { return PermitNone; }
175
    virtual QDateTime           flightStartTime     () const = 0;
176 177
    virtual int                 flightDuration      () const = 0;
    virtual bool                flightStartsNow     () const = 0;
178
    virtual QGCGeoBoundingCube* missionArea         () = 0;
Gus Grubba's avatar
Gus Grubba committed
179 180 181 182
    virtual bool                valid               () = 0;                     ///< Current advisory list is valid
    virtual QmlObjectListModel* advisories          () = 0;                     ///< List of AirspaceAdvisory
    virtual QmlObjectListModel* ruleSets            () = 0;                     ///< List of AirspaceRuleSet
    virtual AirspaceAdvisoryProvider::AdvisoryColor  airspaceColor () = 0;      ///< Aispace overall color
Gus Grubba's avatar
Gus Grubba committed
183

184 185 186 187
    virtual QmlObjectListModel* rulesViolation      () = 0;                     ///< List of AirspaceRule in violation
    virtual QmlObjectListModel* rulesInfo           () = 0;                     ///< List of AirspaceRule need more information
    virtual QmlObjectListModel* rulesReview         () = 0;                     ///< List of AirspaceRule should review
    virtual QmlObjectListModel* rulesFollowing      () = 0;                     ///< List of AirspaceRule following
188
    virtual QmlObjectListModel* briefFeatures       () = 0;                     ///< List of AirspaceRule in violation
Gus Grubba's avatar
Gus Grubba committed
189
    virtual QmlObjectListModel* authorizations      () = 0;                     ///< List of AirspaceFlightAuthorization
Gus Grubba's avatar
Gus Grubba committed
190
    virtual AirspaceFlightModel*flightList          () = 0;                     ///< List of AirspaceFlightInfo
Gus Grubba's avatar
Gus Grubba committed
191
    virtual bool                loadingFlightList   () = 0;
192

193
    virtual void                setFlightStartTime  (QDateTime start) = 0;
194 195
    virtual void                setFlightDuration   (int seconds) = 0;
    virtual void                setFlightStartsNow  (bool now) = 0;
196
    virtual void                startFlightPlanning (PlanMasterController* planController) = 0;
Gus Grubba's avatar
Gus Grubba committed
197 198

signals:
199 200
    void flightPermitStatusChanged                  ();
    void flightStartTimeChanged                     ();
201 202
    void flightStartsNowChanged                     ();
    void flightDurationChanged                      ();
203
    void advisoryChanged                            ();
204
    void missionAreaChanged                         ();
205
    void rulesChanged                               ();
Gus Grubba's avatar
Gus Grubba committed
206
    void flightListChanged                          ();
Gus Grubba's avatar
Gus Grubba committed
207
    void loadingFlightListChanged                   ();
Gus Grubba's avatar
Gus Grubba committed
208
};