Commit f6c18f78 authored by Gus Grubba's avatar Gus Grubba

Updating airmapd binaries

Implementing authorization management
parent 51a6792a
......@@ -25,11 +25,37 @@
using namespace airmap;
//-----------------------------------------------------------------------------
AirMapFlightAuthorization::AirMapFlightAuthorization(const Evaluation::Authorization auth, QObject *parent)
: AirspaceFlightAuthorization(parent)
, _auth(auth)
{
}
//-----------------------------------------------------------------------------
AirspaceFlightAuthorization::AuthorizationStatus
AirMapFlightAuthorization::status()
{
switch(_auth.status) {
case Evaluation::Authorization::Status::accepted:
return AirspaceFlightAuthorization::Accepted;
case Evaluation::Authorization::Status::rejected:
return AirspaceFlightAuthorization::Rejected;
case Evaluation::Authorization::Status::pending:
return AirspaceFlightAuthorization::Pending;
case Evaluation::Authorization::Status::accepted_upon_submission:
return AirspaceFlightAuthorization::AcceptedOnSubmission;
case Evaluation::Authorization::Status::rejected_upon_submission:
return AirspaceFlightAuthorization::RejectedOnSubmission;
}
return AirspaceFlightAuthorization::Unknown;
}
//-----------------------------------------------------------------------------
AirMapFlightInfo::AirMapFlightInfo(const airmap::Flight& flight, QObject *parent)
: AirspaceFlightInfo(parent)
, _flight(flight)
{
_flight = flight;
//-- TODO: Load bounding box geometry
......@@ -596,6 +622,7 @@ AirMapFlightPlanManager::_pollBriefing()
_advisories.endReset();
_valid = true;
//-- Collect Rulesets
_authorizations.clearAndDeleteContents();
_rulesViolation.clearAndDeleteContents();
_rulesInfo.clearAndDeleteContents();
_rulesReview.clearAndDeleteContents();
......@@ -642,13 +669,14 @@ AirMapFlightPlanManager::_pollBriefing()
_rulesets.append(pRuleSet);
qCDebug(AirMapManagerLog) << "Adding briefing ruleset" << pRuleSet->id();
}
emit advisoryChanged();
emit rulesChanged();
//-- Evaluate briefing status
bool rejected = false;
bool accepted = false;
bool pending = false;
for (const auto& authorization : briefing.evaluation.authorizations) {
AirMapFlightAuthorization* pAuth = new AirMapFlightAuthorization(authorization, this);
_authorizations.append(pAuth);
qCDebug(AirMapManagerLog) << "Autorization:" << pAuth->name() << " (" << pAuth->message() << ")" << (int)pAuth->status();
switch (authorization.status) {
case Evaluation::Authorization::Status::accepted:
case Evaluation::Authorization::Status::accepted_upon_submission:
......@@ -661,12 +689,18 @@ AirMapFlightPlanManager::_pollBriefing()
case Evaluation::Authorization::Status::pending:
pending = true;
break;
//-- If we don't know, accept it
default:
accepted = true;
break;
}
}
if (briefing.evaluation.authorizations.size() == 0) {
// If we don't get any authorizations, we assume it's accepted
accepted = true;
}
emit advisoryChanged();
emit rulesChanged();
qCDebug(AirMapManagerLog) << "Flight approval: accepted=" << accepted << "rejected" << rejected << "pending" << pending;
if ((rejected || accepted) && !pending) {
if (rejected) { // rejected has priority
......
......@@ -22,6 +22,22 @@
class PlanMasterController;
//-----------------------------------------------------------------------------
class AirMapFlightAuthorization : public AirspaceFlightAuthorization
{
Q_OBJECT
public:
AirMapFlightAuthorization (const airmap::Evaluation::Authorization auth, QObject *parent = nullptr);
AirspaceFlightAuthorization::AuthorizationStatus
status () override;
QString name () override { return QString::fromStdString(_auth.authority.name); }
QString id () override { return QString::fromStdString(_auth.authority.id); }
QString message () override { return QString::fromStdString(_auth.message); }
private:
airmap::Evaluation::Authorization _auth;
};
//-----------------------------------------------------------------------------
class AirMapFlightInfo : public AirspaceFlightInfo
{
......@@ -65,6 +81,7 @@ public:
QmlObjectListModel* rulesReview () override { return &_rulesReview; }
QmlObjectListModel* rulesFollowing () override { return &_rulesFollowing; }
QmlObjectListModel* briefFeatures () override { return &_briefFeatures; }
QmlObjectListModel* authorizations () override { return &_authorizations; }
AirspaceFlightModel*flightList () override { return &_flightList; }
bool loadingFlightList () override { return _loadingFlightList; }
......@@ -138,6 +155,7 @@ private:
QmlObjectListModel _rulesReview;
QmlObjectListModel _rulesFollowing;
QmlObjectListModel _briefFeatures;
QmlObjectListModel _authorizations;
AirspaceFlightModel _flightList;
QDateTime _rangeStart;
QDateTime _rangeEnd;
......
......@@ -31,7 +31,6 @@ Q_DECLARE_LOGGING_CATEGORY(AirMapManagerLog)
class AirMapManager : public AirspaceManager
{
Q_OBJECT
public:
AirMapManager(QGCApplication* app, QGCToolbox* toolbox);
virtual ~AirMapManager();
......
......@@ -61,22 +61,55 @@ Item {
anchors.right: parent.right
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
QGCLabel {
text: qsTr("No Authorization Required")
visible: _flightPermit !== AirspaceFlightPlanProvider.PermitNone
anchors.horizontalCenter: parent.horizontalCenter
}
/*
QGCLabel {
text: qsTr("Automatic authorization to fly in controlled airspace")
visible: _flightPermit !== AirspaceFlightPlanProvider.PermitNone
font.pointSize: ScreenTools.smallFontPointSize
//-- Actual Authorization from some jurisdiction
Repeater {
visible: QGroundControl.airspaceManager.flightPlan.authorizations.count > 0
model: QGroundControl.airspaceManager.flightPlan.authorizations
Column {
spacing: ScreenTools.defaultFontPixelHeight * 0.5
anchors.right: parent.right
anchors.left: parent.left
QGCLabel {
text: object.name
font.family: ScreenTools.demiboldFontFamily
anchors.horizontalCenter: parent.horizontalCenter
}
Rectangle {
anchors.right: parent.right
anchors.left: parent.left
height: label.height + (ScreenTools.defaultFontPixelHeight * 0.5)
color: {
if(object.status === AirspaceFlightAuthorization.Pending)
return _colorOrange
if(object.status === AirspaceFlightAuthorization.Accepted || object.status === AirspaceFlightAuthorization.AcceptedOnSubmission)
return _colorGreen
if(object.status === AirspaceFlightAuthorization.Rejected || object.status === AirspaceFlightAuthorization.RejectedOnSubmission)
return _colorRed
return _colorGray
}
QGCLabel {
id: label
color: _colorWhite
text: {
if(object.status === AirspaceFlightAuthorization.Pending)
return qsTr("Authorization Pending")
if(object.status === AirspaceFlightAuthorization.Accepted || object.status === AirspaceFlightAuthorization.AcceptedOnSubmission)
return qsTr("Authorization Accepted")
if(object.status === AirspaceFlightAuthorization.Rejected || object.status === AirspaceFlightAuthorization.RejectedOnSubmission)
return qsTr("Authorization Rejected")
return qsTr("Authorization Unknown")
}
anchors.centerIn: parent
}
}
}
}
*/
//-- Implied Authorization from no jurisdiction
Rectangle {
anchors.right: parent.right
anchors.left: parent.left
height: label.height + (ScreenTools.defaultFontPixelHeight * 0.5)
height: noAuthLabel.height + (ScreenTools.defaultFontPixelHeight * 0.5)
visible: QGroundControl.airspaceManager.flightPlan.authorizations.count < 1
color: {
if(_flightPermit === AirspaceFlightPlanProvider.PermitPending)
return _colorOrange
......@@ -87,7 +120,7 @@ Item {
return _colorGray
}
QGCLabel {
id: label
id: noAuthLabel
color: _colorWhite
text: {
if(_flightPermit === AirspaceFlightPlanProvider.PermitPending)
......
......@@ -11,6 +11,12 @@
#include "AirspaceFlightPlanProvider.h"
#include <QQmlEngine>
//-----------------------------------------------------------------------------
AirspaceFlightAuthorization::AirspaceFlightAuthorization(QObject *parent)
: QObject(parent)
{
}
//-----------------------------------------------------------------------------
AirspaceFlightInfo::AirspaceFlightInfo(QObject *parent)
: QObject(parent)
......
......@@ -24,12 +24,43 @@
class PlanMasterController;
class AirspaceFlightInfo;
//-----------------------------------------------------------------------------
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;
};
//-----------------------------------------------------------------------------
class AirspaceFlightInfo : public QObject
{
Q_OBJECT
public:
AirspaceFlightInfo (QObject *parent = nullptr);
AirspaceFlightInfo (QObject *parent = nullptr);
Q_PROPERTY(QString flightID READ flightID CONSTANT)
Q_PROPERTY(QString flightPlanID READ flightPlanID CONSTANT)
......@@ -73,7 +104,7 @@ public:
ObjectRole = Qt::UserRole + 1
};
AirspaceFlightModel(QObject *parent = 0);
AirspaceFlightModel (QObject *parent = 0);
Q_PROPERTY(int count READ count NOTIFY countChanged)
......@@ -118,20 +149,25 @@ public:
AirspaceFlightPlanProvider (QObject *parent = nullptr);
Q_PROPERTY(PermitStatus flightPermitStatus READ flightPermitStatus NOTIFY flightPermitStatusChanged) ///< State of flight permission
///< Flight Planning and Filing
Q_PROPERTY(QDateTime flightStartTime READ flightStartTime WRITE setFlightStartTime NOTIFY flightStartTimeChanged) ///< Start of flight
Q_PROPERTY(QDateTime flightEndTime READ flightEndTime WRITE setFlightEndTime NOTIFY flightEndTimeChanged) ///< End of flight
///< Flight Briefing
Q_PROPERTY(PermitStatus flightPermitStatus READ flightPermitStatus NOTIFY flightPermitStatusChanged) ///< State of flight permission
Q_PROPERTY(bool valid READ valid NOTIFY advisoryChanged)
Q_PROPERTY(QmlObjectListModel* advisories READ advisories NOTIFY advisoryChanged)
Q_PROPERTY(QmlObjectListModel* ruleSets READ ruleSets NOTIFY advisoryChanged)
Q_PROPERTY(QGCGeoBoundingCube* missionArea READ missionArea NOTIFY missionAreaChanged)
Q_PROPERTY(AirspaceAdvisoryProvider::AdvisoryColor airspaceColor READ airspaceColor NOTIFY advisoryChanged)
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)
Q_PROPERTY(QmlObjectListModel* briefFeatures READ briefFeatures NOTIFY rulesChanged)
Q_PROPERTY(QmlObjectListModel* authorizations READ authorizations NOTIFY rulesChanged)
///< Flight Management
Q_PROPERTY(AirspaceFlightModel* flightList READ flightList NOTIFY flightListChanged)
Q_PROPERTY(bool loadingFlightList READ loadingFlightList NOTIFY loadingFlightListChanged)
......@@ -156,6 +192,7 @@ public:
virtual QmlObjectListModel* rulesReview () = 0; ///< List of AirspaceRule should review
virtual QmlObjectListModel* rulesFollowing () = 0; ///< List of AirspaceRule following
virtual QmlObjectListModel* briefFeatures () = 0; ///< List of AirspaceRule in violation
virtual QmlObjectListModel* authorizations () = 0; ///< List of AirspaceFlightAuthorization
virtual AirspaceFlightModel*flightList () = 0; ///< List of AirspaceFlightInfo
virtual bool loadingFlightList () = 0;
......
......@@ -38,6 +38,8 @@ AirspaceManager::AirspaceManager(QGCApplication* app, QGCToolbox* toolbox)
qmlRegisterUncreatableType<AirspaceRuleSet> ("QGroundControl.Airspace", 1, 0, "AirspaceRuleSet", "Reference only");
qmlRegisterUncreatableType<AirspaceRulesetsProvider> ("QGroundControl.Airspace", 1, 0, "AirspaceRulesetsProvider", "Reference only");
qmlRegisterUncreatableType<AirspaceWeatherInfoProvider> ("QGroundControl.Airspace", 1, 0, "AirspaceWeatherInfoProvider", "Reference only");
qmlRegisterUncreatableType<AirspaceFlightAuthorization> ("QGroundControl.Airspace", 1, 0, "AirspaceFlightAuthorization", "Reference only");
qmlRegisterUncreatableType<AirspaceFlightInfo> ("QGroundControl.Airspace", 1, 0, "AirspaceFlightInfo", "Reference only");
}
AirspaceManager::~AirspaceManager()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment