mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 21:56:43 +08:00
refs #811, airports default implementation
* if no sim data are available use reader data * merge airport data for FSX * Added "network" in .pro (needed for network classes such as readers)
This commit is contained in:
@@ -114,7 +114,7 @@ namespace BlackCore
|
||||
//! Display a text message
|
||||
virtual void displayTextMessage(const BlackMisc::Network::CTextMessage &message) const = 0;
|
||||
|
||||
//! Airports in range from simulator
|
||||
//! Airports in range from simulator, or if not available from web service
|
||||
virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const = 0;
|
||||
|
||||
//! Set time synchronization between simulator and user's computer time
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <functional>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Geo;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
@@ -62,8 +63,8 @@ namespace BlackCore
|
||||
);
|
||||
|
||||
// timer
|
||||
this->m_oneSecondTimer.setObjectName(this->objectName().append(":m_oneSecondTimer"));
|
||||
connect(&m_oneSecondTimer, &QTimer::timeout, this, &CSimulatorCommon::ps_oneSecondTimer);
|
||||
this->m_oneSecondTimer.setObjectName(this->objectName().append(":m_oneSecondTimer"));
|
||||
this->m_oneSecondTimer.start(1000);
|
||||
|
||||
// swift data
|
||||
@@ -76,14 +77,14 @@ namespace BlackCore
|
||||
CLogMessage(this).info("Initialized simulator driver %1") << m_simulatorPluginInfo.toQString();
|
||||
}
|
||||
|
||||
CSimulatorCommon::~CSimulatorCommon() { }
|
||||
|
||||
const CLogCategoryList &CSimulatorCommon::getLogCategories()
|
||||
{
|
||||
static const CLogCategoryList cats( { CLogCategory::driver(), CLogCategory::plugin() });
|
||||
static const CLogCategoryList cats({ CLogCategory::driver(), CLogCategory::plugin() });
|
||||
return cats;
|
||||
}
|
||||
|
||||
CSimulatorCommon::~CSimulatorCommon() { }
|
||||
|
||||
bool CSimulatorCommon::logicallyAddRemoteAircraft(const CSimulatedAircraft &remoteAircraft)
|
||||
{
|
||||
Q_ASSERT_X(remoteAircraft.hasModelString(), Q_FUNC_INFO, "Missing model string");
|
||||
@@ -106,6 +107,12 @@ namespace BlackCore
|
||||
return false;
|
||||
}
|
||||
|
||||
int CSimulatorCommon::maxAirportsInRange() const
|
||||
{
|
||||
// might change in future or become a setting or such
|
||||
return 20;
|
||||
}
|
||||
|
||||
void CSimulatorCommon::blinkHighlightedAircraft()
|
||||
{
|
||||
if (m_highlightedAircraft.isEmpty() || m_highlightEndTimeMsEpoch < 1) { return; }
|
||||
@@ -216,6 +223,17 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
CAirportList CSimulatorCommon::getAirportsInRange() const
|
||||
{
|
||||
// default implementation
|
||||
if (!sApp->hasWebDataServices()) { return CAirportList(); }
|
||||
|
||||
const CAirportList airports = sApp->getWebDataServices()->getAirports();
|
||||
if (airports.isEmpty()) { return airports; }
|
||||
const CCoordinateGeodetic ownPosition = this->getOwnAircraftPosition();
|
||||
return airports.findClosest(maxAirportsInRange(), ownPosition);
|
||||
}
|
||||
|
||||
CAircraftModel CSimulatorCommon::reverseLookupModel(const CAircraftModel &model)
|
||||
{
|
||||
bool modified = false;
|
||||
@@ -373,4 +391,15 @@ namespace BlackCore
|
||||
m_aircraftToAddAgainWhenRemoved.clear();
|
||||
}
|
||||
|
||||
CAirportList CSimulatorCommon::getWebServiceAirports() const
|
||||
{
|
||||
if (!sApp->hasWebDataServices()) { return CAirportList(); }
|
||||
return sApp->getWebDataServices()->getAirports();
|
||||
}
|
||||
|
||||
CAirport CSimulatorCommon::getWebServiceAirport(const CAirportIcaoCode &icao) const
|
||||
{
|
||||
if (!sApp->hasWebDataServices()) { return CAirport(); }
|
||||
return sApp->getWebDataServices()->getAirports().findFirstByIcao(icao);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -77,6 +77,7 @@ namespace BlackCore
|
||||
virtual void highlightAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const BlackMisc::PhysicalQuantities::CTime &displayTime) override;
|
||||
virtual const BlackMisc::Simulation::CSimulatorPluginInfo &getSimulatorPluginInfo() const override;
|
||||
virtual const BlackMisc::Simulation::CSimulatorInternals &getSimulatorInternals() const override;
|
||||
virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const override;
|
||||
virtual void unload() override;
|
||||
virtual int physicallyRemoveMultipleRemoteAircraft(const BlackMisc::Aviation::CCallsignSet &callsigns) override;
|
||||
//! @}
|
||||
@@ -100,6 +101,9 @@ namespace BlackCore
|
||||
virtual void ps_remoteProviderRemovedAircraft(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
//! @}
|
||||
|
||||
//! All swift data read from DB
|
||||
virtual void ps_allSwiftDataRead();
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CSimulatorCommon(const BlackMisc::Simulation::CSimulatorPluginInfo &info,
|
||||
@@ -108,11 +112,14 @@ namespace BlackCore
|
||||
BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider,
|
||||
QObject *parent);
|
||||
|
||||
//! \copydoc ISimulator::logicallyAddRemoteAircraft
|
||||
//! \name Interface implementations
|
||||
//! @{
|
||||
virtual bool logicallyAddRemoteAircraft(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft) override;
|
||||
|
||||
//! \copydoc ISimulator::logicallyRemoveRemoteAircraft
|
||||
virtual bool logicallyRemoveRemoteAircraft(const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
//! @}
|
||||
|
||||
//! Max.airports in range
|
||||
int maxAirportsInRange() const;
|
||||
|
||||
//! Reset state
|
||||
virtual void reset();
|
||||
@@ -120,6 +127,12 @@ namespace BlackCore
|
||||
//! Clear all aircraft related data
|
||||
virtual void clearAllAircraft();
|
||||
|
||||
//! Airports from web services
|
||||
BlackMisc::Aviation::CAirportList getWebServiceAirports() const;
|
||||
|
||||
//! Airport from web services by ICAO code
|
||||
BlackMisc::Aviation::CAirport getWebServiceAirport(const BlackMisc::Aviation::CAirportIcaoCode &icao) const;
|
||||
|
||||
//! Blink the highlighted aircraft
|
||||
void blinkHighlightedAircraft();
|
||||
|
||||
@@ -150,10 +163,6 @@ namespace BlackCore
|
||||
//! Lookup against DB data
|
||||
static BlackMisc::Simulation::CAircraftModel reverseLookupModel(const BlackMisc::Simulation::CAircraftModel &model);
|
||||
|
||||
private slots:
|
||||
//! All swift data read from DB
|
||||
void ps_allSwiftDataRead();
|
||||
|
||||
private:
|
||||
bool m_blinkCycle = false; //!< use for highlighting
|
||||
qint64 m_highlightEndTimeMsEpoch = 0; //!< end highlighting
|
||||
|
||||
Reference in New Issue
Block a user