mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
refs #296 implemented CSimulatorXPlane::getAirportsInRange
This commit is contained in:
@@ -88,7 +88,10 @@ namespace BlackSimPlugin
|
||||
m_traffic = new CXBusTrafficProxy(m_conn, this);
|
||||
if (m_service->isValid() && m_traffic->isValid() && m_traffic->initialize())
|
||||
{
|
||||
// FIXME duplication
|
||||
connect(m_service, &CXBusServiceProxy::aircraftModelChanged, this, &CSimulatorXPlane::emitAircraftModelChanged);
|
||||
connect(m_service, &CXBusServiceProxy::airportsInRangeUpdated, this, &CSimulatorXPlane::setAirportsInRange);
|
||||
m_service->updateAirportsInRange();
|
||||
m_watcher->setConnection(m_conn);
|
||||
emit statusChanged(ISimulator::Connected);
|
||||
return true;
|
||||
@@ -128,7 +131,10 @@ namespace BlackSimPlugin
|
||||
{
|
||||
delete m_service;
|
||||
m_service = new CXBusServiceProxy(m_conn, this);
|
||||
// FIXME duplication
|
||||
connect(m_service, &CXBusServiceProxy::aircraftModelChanged, this, &CSimulatorXPlane::emitAircraftModelChanged);
|
||||
connect(m_service, &CXBusServiceProxy::airportsInRangeUpdated, this, &CSimulatorXPlane::setAirportsInRange);
|
||||
m_service->updateAirportsInRange();
|
||||
}
|
||||
else if (serviceName == CXBusTrafficProxy::InterfaceName())
|
||||
{
|
||||
@@ -204,20 +210,39 @@ namespace BlackSimPlugin
|
||||
return { m_xplaneData.aircraftModelPath, true };
|
||||
}
|
||||
|
||||
BlackMisc::Aviation::CAirportList CSimulatorXPlane::getAirportsInRange() const
|
||||
void CSimulatorXPlane::setAirportsInRange(const QStringList &icaos, const QStringList &names, const BlackMisc::CSequence<double> &lats, const BlackMisc::CSequence<double> &lons, const BlackMisc::CSequence<double> &alts)
|
||||
{
|
||||
// TODO: Fill with airports nearby from sim
|
||||
BlackMisc::Aviation::CAirportList airports;
|
||||
return airports;
|
||||
qDebug() << alts;
|
||||
m_airports.clear();
|
||||
auto icaoIt = icaos.begin();
|
||||
auto nameIt = names.begin();
|
||||
auto latIt = lats.begin();
|
||||
auto lonIt = lons.begin();
|
||||
auto altIt = alts.begin();
|
||||
for (; icaoIt != icaos.end() && nameIt != names.end() && latIt != lats.end() && lonIt != lons.end() && altIt != alts.end(); ++icaoIt, ++nameIt, ++latIt, ++lonIt, ++altIt)
|
||||
{
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Geo;
|
||||
|
||||
m_airports.push_back({ *icaoIt, { CLatitude(*latIt, CAngleUnit::deg()), CLongitude(*lonIt, CAngleUnit::deg()), CLength(*altIt, CLengthUnit::ft()) }, *nameIt });
|
||||
}
|
||||
using namespace BlackMisc::Math;
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::setTimeSynchronization(bool enable, BlackMisc::PhysicalQuantities::CTime offset)
|
||||
BlackMisc::Aviation::CAirportList CSimulatorXPlane::getAirportsInRange() const
|
||||
{
|
||||
auto copy = m_airports;
|
||||
copy.sortByRange({ m_xplaneData.latitude, m_xplaneData.longitude, 0 }, true);
|
||||
copy.truncate(20);
|
||||
return copy;
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::setTimeSynchronization(bool enable, BlackMisc::PhysicalQuantities::CTime)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
emit this->displayStatusMessage(CStatusMessage::getWarningMessage("Use time synchronization of XP itself", CStatusMessage::TypeSimulator));
|
||||
emit displayStatusMessage(CStatusMessage::getWarningMessage("X-Plane already provides real time synchronization", CStatusMessage::TypeSimulator));
|
||||
}
|
||||
Q_UNUSED(offset);
|
||||
}
|
||||
|
||||
bool CSimulatorXPlane::updateOwnSimulatorCockpit(const BlackMisc::Aviation::CAircraft &aircraft)
|
||||
|
||||
@@ -92,6 +92,7 @@ namespace BlackSimPlugin
|
||||
private slots:
|
||||
void serviceRegistered(const QString &serviceName);
|
||||
void serviceUnregistered();
|
||||
void setAirportsInRange(const QStringList &icaoCodes, const QStringList &names, const BlackMisc::CSequence<double> &lats, const BlackMisc::CSequence<double> &lons, const BlackMisc::CSequence<double> &alts);
|
||||
void emitAircraftModelChanged(const QString &path, const QString &filename, const QString &livery, const QString &icao);
|
||||
void fastTimerTimeout();
|
||||
void slowTimerTimeout();
|
||||
@@ -103,6 +104,8 @@ namespace BlackSimPlugin
|
||||
CXBusTrafficProxy *m_traffic { nullptr };
|
||||
QTimer *m_fastTimer { nullptr };
|
||||
QTimer *m_slowTimer { nullptr };
|
||||
|
||||
BlackMisc::Aviation::CAirportList m_airports;
|
||||
QSet<QString> m_planes; // FIXME should not be needed here IMHO
|
||||
|
||||
struct // data is written by DBus async method callbacks
|
||||
|
||||
@@ -34,6 +34,11 @@ namespace BlackSimPlugin
|
||||
}
|
||||
}
|
||||
|
||||
void CXBusServiceProxy::updateAirportsInRange()
|
||||
{
|
||||
m_dbusInterface->callDBus(QLatin1String("updateAirportsInRange"));
|
||||
}
|
||||
|
||||
QString CXBusServiceProxy::getAircraftModelPath() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<QString>(QLatin1String("getAircraftModelPath"));
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
//! \file
|
||||
|
||||
#include "blackmisc/genericdbusinterface.h"
|
||||
#include "blackmisc/sequence.h"
|
||||
#include <functional>
|
||||
|
||||
//! \cond PRIVATE
|
||||
@@ -21,6 +22,9 @@ namespace BlackSimPlugin
|
||||
namespace XPlane
|
||||
{
|
||||
|
||||
//! Typedef needed to use CSequence<double> as a DBus argument
|
||||
typedef BlackMisc::CSequence<double> CDoubleSequence;
|
||||
|
||||
/*!
|
||||
* Proxy object connected to a real XBus::CService object via DBus
|
||||
*/
|
||||
@@ -76,7 +80,13 @@ namespace BlackSimPlugin
|
||||
//! \copydoc XBus::CService::aircraftModelChanged
|
||||
void aircraftModelChanged(const QString &path, const QString &filename, const QString &livery, const QString &icao);
|
||||
|
||||
//! \copydoc XBus::CService::airportsInRangeUpdated
|
||||
void airportsInRangeUpdated(const QStringList &icaoCodes, const QStringList &names, const CDoubleSequence &lats, const CDoubleSequence &lons, const CDoubleSequence &alts);
|
||||
|
||||
public slots:
|
||||
//! \copydoc XBus::CService::updateAirportsInRange
|
||||
void updateAirportsInRange();
|
||||
|
||||
//! \copydoc XBus::CService::getAircraftModelPath
|
||||
//! @{
|
||||
QString getAircraftModelPath() const;
|
||||
|
||||
Reference in New Issue
Block a user