mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-14 00:25:35 +08:00
Ref T27, store flight plan remarks in VATSIM reader
This can be used in airspace monitor
This commit is contained in:
committed by
Mathew Sutcliffe
parent
39bd8aa2bb
commit
042f725e54
@@ -103,7 +103,7 @@ namespace BlackCore
|
|||||||
this->connect(sApp->getWebDataServices()->getBookingReader(), &CVatsimBookingReader::atcBookingsReadUnchanged, this, &CAirspaceMonitor::onReadUnchangedAtcBookings);
|
this->connect(sApp->getWebDataServices()->getBookingReader(), &CVatsimBookingReader::atcBookingsReadUnchanged, this, &CAirspaceMonitor::onReadUnchangedAtcBookings);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sApp->getWebDataServices()->getVatsimDataFileReader())
|
if (this->supportsVatsimDataFile())
|
||||||
{
|
{
|
||||||
this->connect(sApp->getWebDataServices()->getVatsimDataFileReader(), &CVatsimDataFileReader::dataFileRead, this, &CAirspaceMonitor::onReceivedDataFile);
|
this->connect(sApp->getWebDataServices()->getVatsimDataFileReader(), &CVatsimDataFileReader::dataFileRead, this, &CAirspaceMonitor::onReceivedDataFile);
|
||||||
}
|
}
|
||||||
@@ -305,6 +305,14 @@ namespace BlackCore
|
|||||||
return plan;
|
return plan;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CAirspaceMonitor::tryToGetFlightPlanRemarks(const CCallsign &callsign) const
|
||||||
|
{
|
||||||
|
if (callsign.isEmpty()) { return ""; }
|
||||||
|
if (m_flightPlanCache.contains(callsign)) { return m_flightPlanCache[callsign].getRemarks(); }
|
||||||
|
if (this->supportsVatsimDataFile()) { return sApp->getWebDataServices()->getVatsimDataFileReader()->getFlightPlanRemarksForCallsign(callsign); }
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
CUserList CAirspaceMonitor::getUsers() const
|
CUserList CAirspaceMonitor::getUsers() const
|
||||||
{
|
{
|
||||||
CUserList users;
|
CUserList users;
|
||||||
@@ -1293,6 +1301,11 @@ namespace BlackCore
|
|||||||
return this->m_network && this->m_network->isConnected();
|
return this->m_network && this->m_network->isConnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CAirspaceMonitor::supportsVatsimDataFile() const
|
||||||
|
{
|
||||||
|
return sApp && sApp->getWebDataServices() && sApp->getWebDataServices()->getVatsimDataFileReader();
|
||||||
|
}
|
||||||
|
|
||||||
CLength CAirspaceMonitor::calculateDistanceToOwnAircraft(const CAircraftSituation &situation) const
|
CLength CAirspaceMonitor::calculateDistanceToOwnAircraft(const CAircraftSituation &situation) const
|
||||||
{
|
{
|
||||||
CLength distance = getOwnAircraft().calculateGreatCircleDistance(situation);
|
CLength distance = getOwnAircraft().calculateGreatCircleDistance(situation);
|
||||||
|
|||||||
@@ -121,6 +121,11 @@ namespace BlackCore
|
|||||||
//! \remarks pseudo synchronous, call the async functions and waits for result
|
//! \remarks pseudo synchronous, call the async functions and waits for result
|
||||||
BlackMisc::Aviation::CFlightPlan loadFlightPlanFromNetwork(const BlackMisc::Aviation::CCallsign &callsign);
|
BlackMisc::Aviation::CFlightPlan loadFlightPlanFromNetwork(const BlackMisc::Aviation::CCallsign &callsign);
|
||||||
|
|
||||||
|
//! Try to get flight plan remarks
|
||||||
|
//! \remarks returns a value only if the flight plan is already cached
|
||||||
|
//! \threadsafe
|
||||||
|
QString tryToGetFlightPlanRemarks(const BlackMisc::Aviation::CCallsign &callsign) const;
|
||||||
|
|
||||||
//! Returns this list of other clients we know about
|
//! Returns this list of other clients we know about
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
BlackMisc::Network::CClientList getOtherClients() const;
|
BlackMisc::Network::CClientList getOtherClients() const;
|
||||||
@@ -286,6 +291,9 @@ namespace BlackCore
|
|||||||
//! Connected with network?
|
//! Connected with network?
|
||||||
bool isConnected() const;
|
bool isConnected() const;
|
||||||
|
|
||||||
|
//! Supports VATSIM data file
|
||||||
|
bool supportsVatsimDataFile() const;
|
||||||
|
|
||||||
//! Distance calculation
|
//! Distance calculation
|
||||||
BlackMisc::PhysicalQuantities::CLength calculateDistanceToOwnAircraft(const BlackMisc::Aviation::CAircraftSituation &situation) const;
|
BlackMisc::PhysicalQuantities::CLength calculateDistanceToOwnAircraft(const BlackMisc::Aviation::CAircraftSituation &situation) const;
|
||||||
|
|
||||||
|
|||||||
@@ -121,14 +121,16 @@ namespace BlackCore
|
|||||||
CVoiceCapabilities CVatsimDataFileReader::getVoiceCapabilityForCallsign(const CCallsign &callsign)
|
CVoiceCapabilities CVatsimDataFileReader::getVoiceCapabilityForCallsign(const CCallsign &callsign)
|
||||||
{
|
{
|
||||||
QReadLocker rl(&this->m_lock);
|
QReadLocker rl(&this->m_lock);
|
||||||
if (this->m_voiceCapabilities.contains(callsign))
|
return (this->m_voiceCapabilities.contains(callsign)) ?
|
||||||
{
|
m_voiceCapabilities[callsign] :
|
||||||
return m_voiceCapabilities[callsign];
|
CVoiceCapabilities::fromVoiceCapabilities(CVoiceCapabilities::Unknown);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
QString CVatsimDataFileReader::getFlightPlanRemarksForCallsign(const CCallsign &callsign)
|
||||||
return CVoiceCapabilities::fromVoiceCapabilities(CVoiceCapabilities::Unknown);
|
{
|
||||||
}
|
QReadLocker rl(&this->m_lock);
|
||||||
|
return (this->m_flightPlanRemarks.contains(callsign)) ?
|
||||||
|
m_flightPlanRemarks[callsign] : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void CVatsimDataFileReader::updateWithVatsimDataFileData(CSimulatedAircraft &aircraftToBeUdpated) const
|
void CVatsimDataFileReader::updateWithVatsimDataFileData(CSimulatedAircraft &aircraftToBeUdpated) const
|
||||||
@@ -237,7 +239,8 @@ namespace BlackCore
|
|||||||
CServerList fsdServers;
|
CServerList fsdServers;
|
||||||
CAtcStationList atcStations;
|
CAtcStationList atcStations;
|
||||||
CSimulatedAircraftList aircraft;
|
CSimulatedAircraftList aircraft;
|
||||||
QMap<CCallsign, CVoiceCapabilities> voiceCapabilities;
|
QMap<CCallsign, CVoiceCapabilities> voiceCapabilitiesMap;
|
||||||
|
QMap<CCallsign, QString> flightPlanRemarksMap;
|
||||||
QDateTime updateTimestampFromFile;
|
QDateTime updateTimestampFromFile;
|
||||||
|
|
||||||
QStringList clientSectionAttributes;
|
QStringList clientSectionAttributes;
|
||||||
@@ -289,16 +292,17 @@ namespace BlackCore
|
|||||||
const double alt = clientPartsMap["altitude"].toDouble();
|
const double alt = clientPartsMap["altitude"].toDouble();
|
||||||
const CFrequency frequency = CFrequency(clientPartsMap["frequency"].toDouble(), CFrequencyUnit::MHz());
|
const CFrequency frequency = CFrequency(clientPartsMap["frequency"].toDouble(), CFrequencyUnit::MHz());
|
||||||
CCoordinateGeodetic position(lat, lng, alt);
|
CCoordinateGeodetic position(lat, lng, alt);
|
||||||
CAltitude altitude(alt, CAltitude::MeanSeaLevel, CLengthUnit::ft());
|
const CAltitude altitude(alt, CAltitude::MeanSeaLevel, CLengthUnit::ft());
|
||||||
QString flightPlanRemarks = clientPartsMap["planned_remarks"];
|
const QString flightPlanRemarks = clientPartsMap["planned_remarks"].trimmed();
|
||||||
|
|
||||||
// Voice capabilities
|
// Voice capabilities
|
||||||
if (!flightPlanRemarks.isEmpty())
|
if (!flightPlanRemarks.isEmpty())
|
||||||
{
|
{
|
||||||
CVoiceCapabilities vc(flightPlanRemarks);
|
flightPlanRemarksMap[callsign] = flightPlanRemarks;
|
||||||
|
const CVoiceCapabilities vc(flightPlanRemarks);
|
||||||
if (!vc.isUnknown())
|
if (!vc.isUnknown())
|
||||||
{
|
{
|
||||||
voiceCapabilities.insert(callsign, vc);
|
voiceCapabilitiesMap.insert(callsign, vc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -403,9 +407,8 @@ namespace BlackCore
|
|||||||
this->setUpdateTimestamp(updateTimestampFromFile);
|
this->setUpdateTimestamp(updateTimestampFromFile);
|
||||||
this->m_aircraft = aircraft;
|
this->m_aircraft = aircraft;
|
||||||
this->m_atcStations = atcStations;
|
this->m_atcStations = atcStations;
|
||||||
this->m_voiceCapabilities = voiceCapabilities;
|
this->m_voiceCapabilities = voiceCapabilitiesMap;
|
||||||
|
this->m_flightPlanRemarks = flightPlanRemarksMap;
|
||||||
// check if we need to save in cache
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update cache itself is thread safe
|
// update cache itself is thread safe
|
||||||
@@ -417,7 +420,6 @@ namespace BlackCore
|
|||||||
this->m_lastGoodSetup.set(vs);
|
this->m_lastGoodSetup.set(vs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// warnings, if required
|
// warnings, if required
|
||||||
if (!illegalIcaoCodes.isEmpty())
|
if (!illegalIcaoCodes.isEmpty())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -109,6 +109,10 @@ namespace BlackCore
|
|||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
BlackMisc::Network::CVoiceCapabilities getVoiceCapabilityForCallsign(const BlackMisc::Aviation::CCallsign &callsign);
|
BlackMisc::Network::CVoiceCapabilities getVoiceCapabilityForCallsign(const BlackMisc::Aviation::CCallsign &callsign);
|
||||||
|
|
||||||
|
//! Flight plan remarks for callsign
|
||||||
|
//! \threadsafe
|
||||||
|
QString getFlightPlanRemarksForCallsign(const BlackMisc::Aviation::CCallsign &callsign);
|
||||||
|
|
||||||
//! Update aircraft with VATSIM aircraft data from data file
|
//! Update aircraft with VATSIM aircraft data from data file
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
void updateWithVatsimDataFileData(BlackMisc::Simulation::CSimulatedAircraft &aircraftToBeUdpated) const;
|
void updateWithVatsimDataFileData(BlackMisc::Simulation::CSimulatedAircraft &aircraftToBeUdpated) const;
|
||||||
@@ -140,11 +144,12 @@ namespace BlackCore
|
|||||||
private:
|
private:
|
||||||
void reloadSettings();
|
void reloadSettings();
|
||||||
|
|
||||||
BlackMisc::Aviation::CAtcStationList m_atcStations;
|
BlackMisc::Aviation::CAtcStationList m_atcStations;
|
||||||
BlackMisc::Simulation::CSimulatedAircraftList m_aircraft;
|
BlackMisc::Simulation::CSimulatedAircraftList m_aircraft;
|
||||||
BlackMisc::CData<BlackCore::Data::TVatsimSetup> m_lastGoodSetup { this };
|
BlackMisc::CData<BlackCore::Data::TVatsimSetup> m_lastGoodSetup { this };
|
||||||
BlackMisc::CSettingReadOnly<BlackCore::Vatsim::TVatsimDataFile> m_settings { this, &CVatsimDataFileReader::reloadSettings };
|
BlackMisc::CSettingReadOnly<BlackCore::Vatsim::TVatsimDataFile> m_settings { this, &CVatsimDataFileReader::reloadSettings };
|
||||||
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::Network::CVoiceCapabilities> m_voiceCapabilities;
|
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::Network::CVoiceCapabilities> m_voiceCapabilities; //!< voice capabilities
|
||||||
|
QMap<BlackMisc::Aviation::CCallsign, QString> m_flightPlanRemarks; //!< cache for flight plan remarks
|
||||||
|
|
||||||
//! Split line and assign values to their corresponding attribute names
|
//! Split line and assign values to their corresponding attribute names
|
||||||
//! \remark attributes expected as lower case
|
//! \remark attributes expected as lower case
|
||||||
|
|||||||
Reference in New Issue
Block a user