Ref T129, SVFR/VFR discussion

* utility functions in flight plan class
* adjusted flight plan component and client
This commit is contained in:
Klaus Basan
2017-10-04 21:52:37 +02:00
committed by Mathew Sutcliffe
parent 510666622c
commit 3d541a8dd1
4 changed files with 67 additions and 27 deletions

View File

@@ -272,11 +272,7 @@ namespace BlackSample
args >> equipmentIcao >> originAirportIcao >> destinationAirportIcao >> alternateAirportIcao >> takeoffTimePlanned >> takeoffTimeActual
>> enrouteTime >> fuelTime >> cruiseAltitude >> cruiseTrueAirspeed >> flightRulesString >> route;
CFlightPlan::FlightRules flightRules;
if (flightRulesString == "IFR") { flightRules = CFlightPlan::IFR; }
else if (flightRulesString == "SVFR") { flightRules = CFlightPlan::SVFR; }
else { flightRules = BlackMisc::Aviation::CFlightPlan::VFR; }
const CFlightPlan::FlightRules flightRules = CFlightPlan::stringToFlightRules(flightRulesString);
const CCallsign callsign("DAMBZ");
CFlightPlan fp(callsign, equipmentIcao, originAirportIcao, destinationAirportIcao, alternateAirportIcao,
QDateTime::fromString(takeoffTimePlanned, "hhmm"), QDateTime::fromString(takeoffTimeActual, "hhmm"),
@@ -510,23 +506,15 @@ namespace BlackSample
std::cout << "METAR " << data.toStdString() << std::endl;
}
void Client::flightPlanReplyReceived(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CFlightPlan &flightPlan)
void Client::flightPlanReplyReceived(const CCallsign &callsign, const CFlightPlan &flightPlan)
{
std::string rules;
switch (flightPlan.getFlightRules())
{
default:
case BlackMisc::Aviation::CFlightPlan::IFR: rules = "IFR"; break;
case BlackMisc::Aviation::CFlightPlan::VFR: rules = "VFR"; break;
case BlackMisc::Aviation::CFlightPlan::SVFR: rules = "SVFR"; break;
}
const QString rules = flightPlan.getFlightRulesAsString();
std::cout << "FLIGHTPLAN " << callsign
<< flightPlan.getEquipmentIcao().toStdString() << " " << flightPlan.getOriginAirportIcao() << " "
<< flightPlan.getDestinationAirportIcao() << " " << flightPlan.getAlternateAirportIcao() << " "
<< flightPlan.getTakeoffTimePlannedHourMin().toStdString() << " " << flightPlan.getTakeoffTimeActualHourMin().toStdString() << " "
<< flightPlan.getEnrouteTime() << " " << flightPlan.getFuelTime() << " "
<< flightPlan.getCruiseAltitude() << " " << flightPlan.getCruiseTrueAirspeed() << " " << rules << " "
<< flightPlan.getCruiseAltitude() << " " << flightPlan.getCruiseTrueAirspeed() << " " << rules.toStdString() << " "
<< flightPlan.getRoute().toStdString() << " " << flightPlan.getRemarks().toStdString() << "\n";
}

View File

@@ -183,6 +183,14 @@ namespace BlackGui
else
{
ui->le_CrusingAltitude->setText(cruiseAlt.valueRoundedWithUnit(BlackMisc::PhysicalQuantities::CLengthUnit::ft(), 0));
switch (flightPlan.getFlightRulesAsVFRorIFR())
{
case CFlightPlan::VFR:
ui->rb_TypeVfr->setChecked(true);
break;
default:
ui->rb_TypeIfr->setChecked(true);
break;
}
}

View File

@@ -120,7 +120,8 @@ namespace BlackMisc
m_equipmentIcao(equipmentIcao), m_originAirportIcao(originAirportIcao), m_destinationAirportIcao(destinationAirportIcao), m_alternateAirportIcao(alternateAirportIcao),
m_takeoffTimePlanned(takeoffTimePlanned), m_takeoffTimeActual(takeoffTimeActual), m_enrouteTime(enrouteTime), m_fuelTime(fuelTime),
m_cruiseAltitude(cruiseAltitude), m_cruiseTrueAirspeed(cruiseTrueAirspeed), m_flightRules(flightRules),
m_route(route.trimmed().left(MaxRouteLength).toUpper()), m_remarks(remarks.trimmed().left(MaxRemarksLength).toUpper())
m_route(route.trimmed().left(MaxRouteLength).toUpper()),
m_remarks(remarks.trimmed().left(MaxRemarksLength).toUpper())
{
m_callsign.setTypeHint(CCallsign::Aircraft);
m_enrouteTime.switchUnit(BlackMisc::PhysicalQuantities::CTimeUnit::hrmin());
@@ -145,6 +146,24 @@ namespace BlackMisc
m_remarks = CFlightPlanRemarks(remarks, true);
}
CFlightPlan::FlightRules CFlightPlan::getFlightRulesAsVFRorIFR() const
{
switch (getFlightRules())
{
case IFR:
return IFR;
case VFR:
case SVFR:
case DVFR:
return VFR;
case UNKNOWN:
default:
break;
}
return UNKNOWN;
}
CVariant CFlightPlan::propertyByIndex(const CPropertyIndex &index) const
{
if (index.isMyself()) { return CVariant::from(*this); }
@@ -205,13 +224,26 @@ namespace BlackMisc
{
switch (rule)
{
case VFR: return QLatin1String("VFR");
case IFR: return QLatin1String("IFR");
case SVFR: return QLatin1String("SVFR");
default: return QLatin1String("???");
case VFR: return QLatin1String("VFR");
case IFR: return QLatin1String("IFR");
case SVFR: return QLatin1String("SVFR");
case DVFR: return QLatin1String("DVFR");
case UNKNOWN:
default: return QLatin1String("???");
}
}
CFlightPlan::FlightRules CFlightPlan::stringToFlightRules(const QString &flightRules)
{
if (flightRules.length() < 3) { return UNKNOWN; }
const QString fr(flightRules.toUpper().trimmed());
if (fr.startsWith("DVFR")) { return DVFR; }
if (fr.startsWith("SVFR")) { return SVFR; }
if (fr.startsWith("VFR")) { return VFR; }
if (fr.startsWith("IFR")) { return IFR; }
return UNKNOWN;
}
CIcon CFlightPlan::toIcon() const
{
return CIcon::iconByIndex(CIcons::StandardIconAppFlightPlan16);

View File

@@ -130,7 +130,8 @@ namespace BlackMisc
VFR = 0, //!< Visual flight rules
IFR, //!< Instrument flight rules
SVFR, //!< Special VFR (reserved for ATC use),
DVFR //!< Defense VFR
DVFR, //!< Defense VFR
UNKNOWN //!< Unknown
};
//! Properties by index
@@ -143,8 +144,10 @@ namespace BlackMisc
IndexRemarks
};
static constexpr int MaxRemarksLength = 150; //!< Max remarks length
static constexpr int MaxRouteLength = 150; //!< Max route length
//! \fixme max.length of complete flight plan is 768 characters, this here is an assumption and should be part of the underlying network layers
// https://forums.vatsim.net/viewtopic.php?f=6&t=63416
static constexpr int MaxRemarksLength = 256; //!< Max.remarks length
static constexpr int MaxRouteLength = 256; //!< Max.route length
//! Default constructor
CFlightPlan();
@@ -266,9 +269,15 @@ namespace BlackMisc
//! Get planned cruise TAS
const PhysicalQuantities::CSpeed &getCruiseTrueAirspeed() const { return m_cruiseTrueAirspeed; }
//! Get flight rules (VFR or IFR)
//! Get flight rules as in FlightRules
FlightRules getFlightRules() const { return m_flightRules; }
//! Rules only as IFR or VFR
FlightRules getFlightRulesAsVFRorIFR() const;
//! Get flight rules as in FlightRules as string
QString getFlightRulesAsString() const { return flightRuleToString(this->getFlightRules()); }
//! Get route string
const QString &getRoute() const { return m_route; }
@@ -308,9 +317,11 @@ namespace BlackMisc
//! Rules to string
static const QString flightRuleToString(FlightRules rule);
//! String to flight rules
static FlightRules stringToFlightRules(const QString &flightRules);
private:
CCallsign m_callsign;
CFlightPlanRemarks m_remarks;
CCallsign m_callsign; //!< aircraft callsign
QString m_equipmentIcao; //!< e.g. "T/A320/F"
CAircraftIcaoCode m_aircraftIcao; //!< Aircraft ICAO code derived from equipment ICAO
CAirportIcaoCode m_originAirportIcao;
@@ -324,6 +335,7 @@ namespace BlackMisc
PhysicalQuantities::CSpeed m_cruiseTrueAirspeed;
FlightRules m_flightRules;
QString m_route;
CFlightPlanRemarks m_remarks;
BLACK_METACLASS(
CFlightPlan,