mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 10:55:32 +08:00
refs #296 implemented CSimulatorXPlane::getAirportsInRange
This commit is contained in:
@@ -157,6 +157,11 @@ void BlackMisc::registerMetadata()
|
|||||||
Settings::registerMetadata();
|
Settings::registerMetadata();
|
||||||
Audio::registerMetadata();
|
Audio::registerMetadata();
|
||||||
Hardware::registerMetadata();
|
Hardware::registerMetadata();
|
||||||
|
|
||||||
|
// needed by XBus proxy class
|
||||||
|
qRegisterMetaType<CSequence<double>>();
|
||||||
|
qRegisterMetaType<CSequence<double>>("CDoubleSequence");
|
||||||
|
qDBusRegisterMetaType<CSequence<double>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -88,7 +88,10 @@ namespace BlackSimPlugin
|
|||||||
m_traffic = new CXBusTrafficProxy(m_conn, this);
|
m_traffic = new CXBusTrafficProxy(m_conn, this);
|
||||||
if (m_service->isValid() && m_traffic->isValid() && m_traffic->initialize())
|
if (m_service->isValid() && m_traffic->isValid() && m_traffic->initialize())
|
||||||
{
|
{
|
||||||
|
// FIXME duplication
|
||||||
connect(m_service, &CXBusServiceProxy::aircraftModelChanged, this, &CSimulatorXPlane::emitAircraftModelChanged);
|
connect(m_service, &CXBusServiceProxy::aircraftModelChanged, this, &CSimulatorXPlane::emitAircraftModelChanged);
|
||||||
|
connect(m_service, &CXBusServiceProxy::airportsInRangeUpdated, this, &CSimulatorXPlane::setAirportsInRange);
|
||||||
|
m_service->updateAirportsInRange();
|
||||||
m_watcher->setConnection(m_conn);
|
m_watcher->setConnection(m_conn);
|
||||||
emit statusChanged(ISimulator::Connected);
|
emit statusChanged(ISimulator::Connected);
|
||||||
return true;
|
return true;
|
||||||
@@ -128,7 +131,10 @@ namespace BlackSimPlugin
|
|||||||
{
|
{
|
||||||
delete m_service;
|
delete m_service;
|
||||||
m_service = new CXBusServiceProxy(m_conn, this);
|
m_service = new CXBusServiceProxy(m_conn, this);
|
||||||
|
// FIXME duplication
|
||||||
connect(m_service, &CXBusServiceProxy::aircraftModelChanged, this, &CSimulatorXPlane::emitAircraftModelChanged);
|
connect(m_service, &CXBusServiceProxy::aircraftModelChanged, this, &CSimulatorXPlane::emitAircraftModelChanged);
|
||||||
|
connect(m_service, &CXBusServiceProxy::airportsInRangeUpdated, this, &CSimulatorXPlane::setAirportsInRange);
|
||||||
|
m_service->updateAirportsInRange();
|
||||||
}
|
}
|
||||||
else if (serviceName == CXBusTrafficProxy::InterfaceName())
|
else if (serviceName == CXBusTrafficProxy::InterfaceName())
|
||||||
{
|
{
|
||||||
@@ -204,20 +210,39 @@ namespace BlackSimPlugin
|
|||||||
return { m_xplaneData.aircraftModelPath, true };
|
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
|
qDebug() << alts;
|
||||||
BlackMisc::Aviation::CAirportList airports;
|
m_airports.clear();
|
||||||
return airports;
|
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)
|
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)
|
bool CSimulatorXPlane::updateOwnSimulatorCockpit(const BlackMisc::Aviation::CAircraft &aircraft)
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ namespace BlackSimPlugin
|
|||||||
private slots:
|
private slots:
|
||||||
void serviceRegistered(const QString &serviceName);
|
void serviceRegistered(const QString &serviceName);
|
||||||
void serviceUnregistered();
|
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 emitAircraftModelChanged(const QString &path, const QString &filename, const QString &livery, const QString &icao);
|
||||||
void fastTimerTimeout();
|
void fastTimerTimeout();
|
||||||
void slowTimerTimeout();
|
void slowTimerTimeout();
|
||||||
@@ -103,6 +104,8 @@ namespace BlackSimPlugin
|
|||||||
CXBusTrafficProxy *m_traffic { nullptr };
|
CXBusTrafficProxy *m_traffic { nullptr };
|
||||||
QTimer *m_fastTimer { nullptr };
|
QTimer *m_fastTimer { nullptr };
|
||||||
QTimer *m_slowTimer { nullptr };
|
QTimer *m_slowTimer { nullptr };
|
||||||
|
|
||||||
|
BlackMisc::Aviation::CAirportList m_airports;
|
||||||
QSet<QString> m_planes; // FIXME should not be needed here IMHO
|
QSet<QString> m_planes; // FIXME should not be needed here IMHO
|
||||||
|
|
||||||
struct // data is written by DBus async method callbacks
|
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
|
QString CXBusServiceProxy::getAircraftModelPath() const
|
||||||
{
|
{
|
||||||
return m_dbusInterface->callDBusRet<QString>(QLatin1String("getAircraftModelPath"));
|
return m_dbusInterface->callDBusRet<QString>(QLatin1String("getAircraftModelPath"));
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
//! \file
|
//! \file
|
||||||
|
|
||||||
#include "blackmisc/genericdbusinterface.h"
|
#include "blackmisc/genericdbusinterface.h"
|
||||||
|
#include "blackmisc/sequence.h"
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
//! \cond PRIVATE
|
//! \cond PRIVATE
|
||||||
@@ -21,6 +22,9 @@ namespace BlackSimPlugin
|
|||||||
namespace XPlane
|
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
|
* Proxy object connected to a real XBus::CService object via DBus
|
||||||
*/
|
*/
|
||||||
@@ -76,7 +80,13 @@ namespace BlackSimPlugin
|
|||||||
//! \copydoc XBus::CService::aircraftModelChanged
|
//! \copydoc XBus::CService::aircraftModelChanged
|
||||||
void aircraftModelChanged(const QString &path, const QString &filename, const QString &livery, const QString &icao);
|
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:
|
public slots:
|
||||||
|
//! \copydoc XBus::CService::updateAirportsInRange
|
||||||
|
void updateAirportsInRange();
|
||||||
|
|
||||||
//! \copydoc XBus::CService::getAircraftModelPath
|
//! \copydoc XBus::CService::getAircraftModelPath
|
||||||
//! @{
|
//! @{
|
||||||
QString getAircraftModelPath() const;
|
QString getAircraftModelPath() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user