diff --git a/src/blackgui/flightplancomponent.cpp b/src/blackgui/flightplancomponent.cpp index f4215d729..1988ce2b8 100644 --- a/src/blackgui/flightplancomponent.cpp +++ b/src/blackgui/flightplancomponent.cpp @@ -13,6 +13,7 @@ namespace BlackGui connect(this->ui->pb_Send, &QPushButton::pressed, this, &CFlightPlanComponent::sendFlightPlan); connect(this->ui->pb_Load, &QPushButton::pressed, this, &CFlightPlanComponent::loadFlightPlan); connect(this->ui->pb_Reset, &QPushButton::pressed, this, &CFlightPlanComponent::resetFlightPlan); + connect(this->ui->pb_ValidateFlightPlan, &QPushButton::pressed, this, &CFlightPlanComponent::validateFlightPlan); bool c; c = connect(this->ui->cb_VoiceCapabilities, SIGNAL(currentIndexChanged(int)), this, SLOT(buildRemarkString())); @@ -68,6 +69,11 @@ namespace BlackGui this->ui->le_CruiseTrueAirspeed->setText(flightPlan.getCruiseTrueAirspeed().valueRoundedWithUnit(BlackMisc::PhysicalQuantities::CSpeedUnit::kts(), 0)); } + CFlightPlan CFlightPlanComponent::getFlightPlan() const + { + return this->m_flightPlan; + } + BlackMisc::CStatusMessageList CFlightPlanComponent::validateAndInitializeFlightPlan(BlackMisc::Aviation::CFlightPlan &flightPlan) { BlackMisc::CStatusMessageList messages; @@ -191,17 +197,40 @@ namespace BlackGui if (messages.isEmpty()) { // no error, send if possible + CStatusMessage m; if (this->getIContextNetwork()->isConnected()) + { + flightPlan.setWhenLastSent(QDateTime::currentDateTimeUtc()); this->getIContextNetwork()->sendFlightPlan(flightPlan); + this->ui->le_LastSent->setText(flightPlan.whenLastSent().toString()); + m = CStatusMessage::getInfoMessage("Sent flight plan", CStatusMessage::TypeTrafficNetwork); + } else { - CStatusMessage m = CStatusMessage::getErrorMessage("No errors, but not connected, cannot send flight plan", CStatusMessage::TypeTrafficNetwork); - this->getIContextApplication()->sendStatusMessage(m); + flightPlan.setWhenLastSent(QDateTime()); + this->ui->le_LastSent->clear(); + m = CStatusMessage::getErrorMessage("No errors, but not connected, cannot send flight plan", CStatusMessage::TypeTrafficNetwork); } + this->sendStatusMessage(m); + this->m_flightPlan = flightPlan; // last valid FP } else { - this->getIContextApplication()->sendStatusMessages(messages); + this->sendStatusMessages(messages); + } + } + + void CFlightPlanComponent::validateFlightPlan() + { + CFlightPlan flightPlan; + CStatusMessageList messages = this->validateAndInitializeFlightPlan(flightPlan); + if (messages.isEmpty()) + { + this->sendStatusMessage(CStatusMessage::getInfoMessage("No errors", CStatusMessage::TypeTrafficNetwork)); + } + else + { + this->sendStatusMessages(messages); } } @@ -284,6 +313,8 @@ namespace BlackGui rem.append("PER/C "); else if (v.startsWith("D")) rem.append("PER/D "); + else if (v.startsWith("E")) + rem.append("PER/E "); if (this->ui->frp_SelcalCode->hasValidCode()) { @@ -304,7 +335,7 @@ namespace BlackGui void CFlightPlanComponent::copyRemarks() { this->ui->pte_Remarks->setPlainText(this->ui->pte_RemarksGenerated->toPlainText()); - this->getIContextApplication()->sendStatusMessage(CStatusMessage::getInfoMessage("Copied remarks", CStatusMessage::TypeTrafficNetwork)); + this->sendStatusMessage(CStatusMessage::getInfoMessage("Copied remarks", CStatusMessage::TypeTrafficNetwork)); } void CFlightPlanComponent::currentTabGenerator() diff --git a/src/blackgui/flightplancomponent.h b/src/blackgui/flightplancomponent.h index f162954ae..f1170b70e 100644 --- a/src/blackgui/flightplancomponent.h +++ b/src/blackgui/flightplancomponent.h @@ -29,9 +29,15 @@ namespace BlackGui //! Prefill with aircraft dara void prefillWithFlightPlanData(const BlackMisc::Aviation::CFlightPlan &flightPlan); + //! Get this flight plan + BlackMisc::Aviation::CFlightPlan getFlightPlan() const; + private: Ui::CFlightPlanComponent *ui; + //! My flight plan + BlackMisc::Aviation::CFlightPlan m_flightPlan; + //! Validate, generates status messages BlackMisc::CStatusMessageList validateAndInitializeFlightPlan(BlackMisc::Aviation::CFlightPlan &fligtPlan); @@ -51,6 +57,9 @@ namespace BlackGui //! Load Flightplan void loadFlightPlan(); + //! Validate Flightplan + void validateFlightPlan(); + //! Remark void buildRemarkString(); diff --git a/src/blackgui/flightplancomponent.ui b/src/blackgui/flightplancomponent.ui index 2853b0fcf..7114ecdb0 100644 --- a/src/blackgui/flightplancomponent.ui +++ b/src/blackgui/flightplancomponent.ui @@ -38,287 +38,10 @@ - - - - 99:99 - + + - 00:00 - - - - - - - 3. Aircraft type - - - false - - - true - - - - - - - 0 kts - - - 40 - - - - - - - 1. Type - - - - - - VFR - - - - - - - SVFR - - - - - - - IFR - - - true - - - - - - - - - - 10. Estimated time enroute - - - true - - - - - - - 5. Departure airport - - - true - - - - - - - Send plan - - - - - - - 7. Cruising altitude - - - true - - - - - - - - - - - - - - - - 40 - - - true - - - - - - - - - - 99:99 - - - 00:00 - - - 5 - - - - - - - >AAAA - - - ICAO - - - - - - - 6. Departure time - - - true - - - - - - - - - - true - - - - - - - 14. Pilots name / homebase - - - true - - - - - - - 40 - - - - - - - 9.Destination airport - - - true - - - - - - - 2. Callsign - - - false - - - true - - - - - - - 4. True airspeed - - - true - - - - - - - 8. Route - - - - - - - 13. Alternate airport - - - true - - - - - - - 12. Fuel on board - - - true - - - - - - - >AAAA - - - ICAO - - - - - - - >AAAA - - - ICAO - - - 4 - - - - - - - - - - 99:99 - - - 00:00 - - - 5 + Load plan @@ -364,17 +87,315 @@ - + Reset plan - - + + + + 99:99 + - Load plan + 00:00 + + + + + + + 0 kts + + + 40 + + + + + + + 3. Aircraft type + + + false + + + true + + + + + + + 8. Route + + + + + + + 12. Fuel on board + + + true + + + + + + + >AAAA + + + ICAO + + + 4 + + + + + + + + + + 99:99 + + + 00:00 + + + 5 + + + + + + + >AAAA + + + ICAO + + + + + + + 13. Alternate airport + + + true + + + + + + + + + + 99:99 + + + 00:00 + + + 5 + + + + + + + 7. Cruising altitude + + + true + + + + + + + 6. Departure time + + + true + + + + + + + + + + 1. Type + + + + + + VFR + + + + + + + SVFR + + + + + + + IFR + + + true + + + + + + + + + + >AAAA + + + ICAO + + + + + + + 4. True airspeed + + + true + + + + + + + Send plan + + + + + + + 40 + + + + + + + 2. Callsign + + + false + + + true + + + + + + + true + + + + + + + 10. Estimated time enroute + + + true + + + + + + + 14. Pilots name / homebase + + + true + + + + + + + 9.Destination airport + + + true + + + + + + + 5. Departure airport + + + true + + + + + + + + + + + + + 40 + + + true + + + + + + + + + + Sent + + + + + + + true + + + + + + + Validate @@ -616,17 +637,22 @@ - B: 92-121kts + B: 91-120kts - C: 122-142kts + C: 121-140kts - D: 143kts or above + D: 141-165kts + + + + + E: 166-210kts @@ -710,6 +736,41 @@ 1 + + rb_TypeVfr + rb_TypeSvfr + rb_TypeIfr + le_Callsign + le_AircraftType + le_CruiseTrueAirspeed + le_OriginAirport + le_TakeOffTimePlanned + le_CrusingAltitude + pte_Route + le_DestinationAirport + le_EstimatedTimeEnroute + le_FuelOnBoard + le_AlternateAirport + pb_RemarksGenerator + pte_Remarks + le_PilotsName + le_PilotsHomebase + pb_Reset + pb_Load + pb_Send + pb_Parse + pb_CopyOver + pte_RemarksGenerated + le_AirlineOperator + cb_PilotRating + cb_RequiredNavigationPerformance + pte_AdditionalRemarks + cb_VoiceCapabilities + le_AircraftRegistration + cb_PerformanceCategory + cb_NavigationEquipment + cb_NoSidsStarts + diff --git a/src/blackmisc/avflightplan.h b/src/blackmisc/avflightplan.h index ea6121f98..13e38c0e9 100644 --- a/src/blackmisc/avflightplan.h +++ b/src/blackmisc/avflightplan.h @@ -110,6 +110,9 @@ namespace BlackMisc //! Set remarks string (max 100 characters) void setRemarks(const QString &remarks) { m_remarks = remarks.left(100); } + //! When last sent + void setWhenLastSent(const QDateTime &dateTime) { m_lastSent = dateTime; } + //! Get ICAO aircraft equipment code string const QString &getEquipmentIcao() const { return m_equipmentIcao; } @@ -158,6 +161,12 @@ namespace BlackMisc //! Get route string const QString &getRoute() const { return m_route; } + //! When last sent + const QDateTime &whenLastSent() const { return m_lastSent; } + + //! Flight plan already sent + bool wasSent() const { return m_lastSent.isValid() && !m_lastSent.isNull(); } + //! Get remarks string const QString &getRemarks() const { return m_remarks; } @@ -210,12 +219,13 @@ namespace BlackMisc FlightRules m_flightRules; QString m_route; QString m_remarks; + QDateTime m_lastSent; }; } // namespace } // namespace Q_DECLARE_METATYPE(BlackMisc::Aviation::CFlightPlan) BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Aviation::CFlightPlan, (o.m_equipmentIcao, o.m_originAirportIcao, o.m_destinationAirportIcao, o.m_alternateAirportIcao, - o.m_takeoffTimePlanned, o.m_takeoffTimeActual, o.m_enrouteTime, o.m_fuelTime, o.m_cruiseAltitude/*, tie(o.m_cruiseTrueAirspeed, o.m_flightRules, o.m_route, o.m_remarks)*/)) + o.m_takeoffTimePlanned, o.m_takeoffTimeActual, o.m_enrouteTime, o.m_fuelTime, o.m_cruiseAltitude, tie(o.m_cruiseTrueAirspeed, o.m_flightRules, o.m_route, o.m_remarks, o.m_lastSent))) #endif // guard