Commit b20f9be0 authored by Gus Grubba's avatar Gus Grubba

Wiring brief "Flight Features"

parent d21752cb
......@@ -159,6 +159,7 @@ AirMapFlightPlanManager::_createFlightPlan()
if (result) {
_pilotID = QString::fromStdString(result.value().id);
qCDebug(AirMapManagerLog) << "Got Pilot ID:"<<_pilotID;
_state = State::Idle;
_uploadFlightPlan();
} else {
_flightPermitStatus = AirspaceFlightPlanProvider::PermitNone;
......@@ -257,9 +258,10 @@ AirMapFlightPlanManager::_uploadFlightPlan()
if (result) {
_flightPlan = QString::fromStdString(result.value().id);
qCDebug(AirMapManagerLog) << "Flight plan created:" << _flightPlan;
_state = State::FlightPolling;
_state = State::Idle;
_pollBriefing();
} else {
_state = State::Idle;
QString description = QString::fromStdString(result.error().description() ? result.error().description().get() : "");
emit error("Flight Plan creation failed", QString::fromStdString(result.error().message()), description);
}
......@@ -332,10 +334,11 @@ AirMapFlightPlanManager::_updateFlightPlan()
if (!isAlive.lock()) return;
if (_state != State::FlightUpdate) return;
if (result) {
_state = State::Idle;
qCDebug(AirMapManagerLog) << "Flight plan updated:" << _flightPlan;
_state = State::FlightPolling;
_pollBriefing();
} else {
_state = State::Idle;
QString description = QString::fromStdString(result.error().description() ? result.error().description().get() : "");
emit error("Flight Plan creation failed", QString::fromStdString(result.error().message()), description);
}
......@@ -367,10 +370,12 @@ rules_sort(QObject* a, QObject* b)
void
AirMapFlightPlanManager::_pollBriefing()
{
if (_state != State::FlightPolling) {
qCWarning(AirMapManagerLog) << "AirMapFlightPlanManager::_pollBriefing: not in polling state";
if (_state != State::Idle) {
qCWarning(AirMapManagerLog) << "AirMapFlightPlanManager::_pollBriefing: not idle" << (int)_state;
_pollTimer.start(500);
return;
}
_state = State::FlightPolling;
FlightPlans::RenderBriefing::Parameters params;
params.authorization = _shared.loginToken().toStdString();
params.id = _flightPlan.toStdString();
......@@ -405,6 +410,7 @@ AirMapFlightPlanManager::_pollBriefing()
_rulesInfo.clearAndDeleteContents();
_rulesReview.clearAndDeleteContents();
_rulesFollowing.clearAndDeleteContents();
_briefFeatures.clear();
for(const auto& ruleset : briefing.evaluation.rulesets) {
AirMapRuleSet* pRuleSet = new AirMapRuleSet(this);
pRuleSet->_id = QString::fromStdString(ruleset.id);
......@@ -415,6 +421,10 @@ AirMapFlightPlanManager::_pollBriefing()
for (const auto& feature : rule.features) {
AirMapRuleFeature* pFeature = new AirMapRuleFeature(feature, this);
pRule->_features.append(pFeature);
if(rule.status == RuleSet::Rule::Status::missing_info) {
_briefFeatures.append(pFeature);
qCDebug(AirMapManagerLog) << "Adding briefing feature" << pFeature->name() << pFeature->description() << pFeature->type();
}
}
pRuleSet->_rules.append(pRule);
//-- Rules separated by status for presentation
......@@ -478,14 +488,15 @@ AirMapFlightPlanManager::_pollBriefing()
_state = State::Idle;
} else if(pending) {
//-- Wait until we send the next polling request
_state = State::Idle;
_pollTimer.setSingleShot(true);
_pollTimer.start(2000);
}
} else {
_state = State::Idle;
QString description = QString::fromStdString(result.error().description() ? result.error().description().get() : "");
emit error("Brief Request failed",
QString::fromStdString(result.error().message()), description);
_state = State::Idle;
}
});
}
......@@ -513,6 +524,7 @@ AirMapFlightPlanManager::_deleteFlightPlan()
qCDebug(AirMapManagerLog) << "Flight plan deleted";
_state = State::Idle;
} else {
_state = State::Idle;
QString description = QString::fromStdString(result.error().description() ? result.error().description().get() : "");
emit error("Flight Plan deletion failed", QString::fromStdString(result.error().message()), description);
}
......
......@@ -43,6 +43,7 @@ public:
QmlObjectListModel* rulesInfo () override { return &_rulesInfo; }
QmlObjectListModel* rulesReview () override { return &_rulesReview; }
QmlObjectListModel* rulesFollowing () override { return &_rulesFollowing; }
QmlObjectListModel* briefFeatures () override { return &_briefFeatures; }
void startFlightPlanning (PlanMasterController* planController) override;
void setFlightStartTime (QDateTime start) override;
......@@ -100,6 +101,7 @@ private:
QmlObjectListModel _rulesInfo;
QmlObjectListModel _rulesReview;
QmlObjectListModel _rulesFollowing;
QmlObjectListModel _briefFeatures;
AirspaceAdvisoryProvider::AdvisoryColor _airspaceColor;
AirspaceFlightPlanProvider::PermitStatus _flightPermitStatus = AirspaceFlightPlanProvider::PermitNone;
......
......@@ -55,6 +55,18 @@ Item {
return _colorGray;
}
function hasBriefRules() {
if(QGroundControl.airspaceManager.flightPlan.rulesViolation.count > 0)
return true;
if(QGroundControl.airspaceManager.flightPlan.rulesInfo.count > 0)
return true;
if(QGroundControl.airspaceManager.flightPlan.rulesReview.count > 0)
return true;
if(QGroundControl.airspaceManager.flightPlan.rulesFollowing.count > 0)
return true;
return false;
}
on_AirspaceColorChanged: {
if(_validAdvisories) {
if(QGroundControl.airspaceManager.advisories.airspaceColor === AirspaceAdvisoryProvider.Yellow) {
......@@ -692,10 +704,14 @@ Item {
Item { width: 1; height: ScreenTools.defaultFontPixelHeight * 0.25; }
QGCLabel {
text: qsTr("Flight Context")
visible: QGroundControl.airspaceManager.flightPlan.briefFeatures.count > 0
}
Repeater {
model: [1, 2, 3, 4, 5, 6]
model: QGroundControl.airspaceManager.flightPlan.briefFeatures
visible: QGroundControl.airspaceManager.flightPlan.briefFeatures.count > 0
delegate: FlightFeature {
feature: object
visible: object && object.type !== AirspaceRuleFeature.Unknown && object.description !== "" && object.name !== ""
anchors.right: parent.right
anchors.left: parent.left
}
......@@ -798,6 +814,7 @@ Item {
Item { width: 1; height: ScreenTools.defaultFontPixelHeight * 0.25; }
QGCLabel {
text: qsTr("Rules & Compliance")
visible: hasBriefRules()
}
ExclusiveGroup { id: ruleGroup }
ComplianceRules {
......
......@@ -5,16 +5,18 @@ import QtQuick.Dialogs 1.2
import QtQml 2.2
import QGroundControl 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Airmap 1.0
import QGroundControl.Airspace 1.0
import QGroundControl.Controls 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Airmap 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.SettingsManager 1.0
Rectangle {
id: _root
height: questionCol.height + (ScreenTools.defaultFontPixelHeight * 1.25)
color: qgcPal.windowShade
property var feature: null
QGCPalette {
id: qgcPal
colorGroupEnabled: enabled
......@@ -22,15 +24,52 @@ Rectangle {
Column {
id: questionCol
spacing: ScreenTools.defaultFontPixelHeight * 0.5
anchors.centerIn: parent
anchors.margins: ScreenTools.defaultFontPixelWidth
anchors.right: parent.right
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
QGCLabel {
text: "Question?"
anchors.left: questionText.left
text: feature.description
anchors.right: parent.right
anchors.left: parent.left
wrapMode: Text.WordWrap
visible: feature.type !== AirspaceRuleFeature.Boolean
}
QGCTextField {
id: questionText
width: _root.width - (ScreenTools.defaultFontPixelWidth * 2)
anchors.horizontalCenter: parent.horizontalCenter
text: feature.value ? feature.value : ""
visible: feature.type !== AirspaceRuleFeature.Boolean
anchors.right: parent.right
anchors.left: parent.left
inputMethodHints: feature.type === AirspaceRuleFeature.Float ? Qt.ImhFormattedNumbersOnly :Qt.ImhNone
onAccepted: {
feature.value = parseFloat(text)
}
onEditingFinished: {
feature.value = parseFloat(text)
}
}
Item {
height: Math.max(checkBox.height, label.height)
anchors.right: parent.right
anchors.left: parent.left
visible: feature.type === AirspaceRuleFeature.Boolean
QGCCheckBox {
id: checkBox
text: ""
checked: feature.value ? feature.value : false
onClicked: feature.value = checked
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
}
QGCLabel {
id: label
text: feature.description
anchors.right: parent.right
anchors.left: checkBox.right
anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 0.5
wrapMode: Text.WordWrap
anchors.verticalCenter: parent.verticalCenter
}
}
}
}
......@@ -53,6 +53,7 @@ public:
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)
virtual PermitStatus flightPermitStatus () const { return PermitNone; }
virtual QDateTime flightStartTime () const = 0;
......@@ -67,6 +68,7 @@ public:
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
virtual QmlObjectListModel* briefFeatures () = 0; ///< List of AirspaceRule in violation
virtual void setFlightStartTime (QDateTime start) = 0;
virtual void setFlightEndTime (QDateTime end) = 0;
......
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