mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 07:35:48 +08:00
refs #276 using async dbus calls to improve responsiveness of the xplane sim driver
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "simulator_xplane.h"
|
||||
#include "xbus_service_proxy.h"
|
||||
#include <QDBusServiceWatcher>
|
||||
#include <QTimer>
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
@@ -19,6 +20,45 @@ namespace BlackSimPlugin
|
||||
m_watcher->addWatchedService(CXBusServiceProxy::InterfaceName());
|
||||
connect(m_watcher, &QDBusServiceWatcher::serviceRegistered, this, &CSimulatorXPlane::serviceRegistered);
|
||||
connect(m_watcher, &QDBusServiceWatcher::serviceUnregistered, this, &CSimulatorXPlane::serviceUnregistered);
|
||||
|
||||
m_fastTimer = new QTimer(this);
|
||||
m_slowTimer = new QTimer(this);
|
||||
connect(m_fastTimer, &QTimer::timeout, this, &CSimulatorXPlane::fastTimerTimeout);
|
||||
connect(m_slowTimer, &QTimer::timeout, this, &CSimulatorXPlane::slowTimerTimeout);
|
||||
m_fastTimer->start(100);
|
||||
m_slowTimer->start(1000);
|
||||
|
||||
resetData();
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::fastTimerTimeout()
|
||||
{
|
||||
if (isConnected())
|
||||
{
|
||||
m_service->getLatitudeAsync(&m_xplaneData.latitude);
|
||||
m_service->getLongitudeAsync(&m_xplaneData.longitude);
|
||||
m_service->getAltitudeMSLAsync(&m_xplaneData.altitude);
|
||||
m_service->getGroundSpeedAsync(&m_xplaneData.groundspeed);
|
||||
m_service->getPitchAsync(&m_xplaneData.pitch);
|
||||
m_service->getRollAsync(&m_xplaneData.roll);
|
||||
m_service->getTrueHeadingAsync(&m_xplaneData.trueHeading);
|
||||
m_service->getCom1ActiveAsync(&m_xplaneData.com1Active);
|
||||
m_service->getCom1StandbyAsync(&m_xplaneData.com1Standby);
|
||||
m_service->getCom2ActiveAsync(&m_xplaneData.com2Active);
|
||||
m_service->getCom2StandbyAsync(&m_xplaneData.com2Standby);
|
||||
m_service->getTransponderCodeAsync(&m_xplaneData.xpdrCode);
|
||||
m_service->getTransponderModeAsync(&m_xplaneData.xpdrMode);
|
||||
m_service->getTransponderIdentAsync(&m_xplaneData.xpdrIdent);
|
||||
}
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::slowTimerTimeout()
|
||||
{
|
||||
if (isConnected())
|
||||
{
|
||||
m_service->getAircraftModelPathAsync(&m_xplaneData.aircraftModelPath);
|
||||
m_service->getAircraftIcaoCodeAsync(&m_xplaneData.aircraftIcaoCode);
|
||||
}
|
||||
}
|
||||
|
||||
bool CSimulatorXPlane::isConnected() const
|
||||
@@ -101,53 +141,61 @@ namespace BlackSimPlugin
|
||||
|
||||
BlackMisc::Aviation::CAircraft CSimulatorXPlane::getOwnAircraft() const
|
||||
{
|
||||
if (! m_service) { return {}; }
|
||||
if (! isConnected()) { return {}; }
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
Aviation::CAircraftSituation situation;
|
||||
situation.setPosition({ m_service->getLatitude(), m_service->getLongitude(), 0 });
|
||||
situation.setAltitude({ m_service->getAltitudeMSL(), Aviation::CAltitude::MeanSeaLevel, CLengthUnit::m() });
|
||||
situation.setHeading({ m_service->getTrueHeading(), Aviation::CHeading::True, CAngleUnit::deg() });
|
||||
situation.setPitch({ m_service->getPitch(), CAngleUnit::deg() });
|
||||
situation.setBank({ m_service->getRoll(), CAngleUnit::deg() });
|
||||
situation.setGroundspeed({ m_service->getGroundSpeed(), CSpeedUnit::m_s() });
|
||||
situation.setPosition({ m_xplaneData.latitude, m_xplaneData.longitude, 0 });
|
||||
situation.setAltitude({ m_xplaneData.altitude, Aviation::CAltitude::MeanSeaLevel, CLengthUnit::m() });
|
||||
situation.setHeading({ m_xplaneData.trueHeading, Aviation::CHeading::True, CAngleUnit::deg() });
|
||||
situation.setPitch({ m_xplaneData.pitch, CAngleUnit::deg() });
|
||||
situation.setBank({ m_xplaneData.roll, CAngleUnit::deg() });
|
||||
situation.setGroundspeed({ m_xplaneData.groundspeed, CSpeedUnit::m_s() });
|
||||
Aviation::CAircraft ac { {}, {}, situation };
|
||||
ac.setIcaoInfo(Aviation::CAircraftIcao { m_service->getAircraftIcaoCode() });
|
||||
ac.setCom1System(Aviation::CComSystem::getCom1System({ m_service->getCom1Active(), CFrequencyUnit::kHz() }, { m_service->getCom1Standby(), CFrequencyUnit::kHz() }));
|
||||
ac.setCom2System(Aviation::CComSystem::getCom2System({ m_service->getCom2Active(), CFrequencyUnit::kHz() }, { m_service->getCom2Standby(), CFrequencyUnit::kHz() }));
|
||||
ac.setTransponder(Aviation::CTransponder::getStandardTransponder(m_service->getTransponderCode(), xpdrMode(m_service->getTransponderMode(), m_service->getTransponderIdent())));
|
||||
ac.setIcaoInfo(Aviation::CAircraftIcao { m_xplaneData.aircraftIcaoCode });
|
||||
ac.setCom1System(Aviation::CComSystem::getCom1System({ m_xplaneData.com1Active, CFrequencyUnit::kHz() }, { m_xplaneData.com1Standby, CFrequencyUnit::kHz() }));
|
||||
ac.setCom2System(Aviation::CComSystem::getCom2System({ m_xplaneData.com2Active, CFrequencyUnit::kHz() }, { m_xplaneData.com2Standby, CFrequencyUnit::kHz() }));
|
||||
ac.setTransponder(Aviation::CTransponder::getStandardTransponder(m_xplaneData.xpdrCode, xpdrMode(m_xplaneData.xpdrMode, m_xplaneData.xpdrIdent)));
|
||||
return ac;
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::displayStatusMessage(const BlackMisc::CStatusMessage &message) const
|
||||
{
|
||||
if (! m_service) { return; }
|
||||
if (! isConnected()) { return; }
|
||||
// TODO
|
||||
Q_UNUSED(message);
|
||||
}
|
||||
|
||||
BlackMisc::Network::CAircraftModel CSimulatorXPlane::getAircraftModel() const
|
||||
{
|
||||
if (! m_service) { return {}; }
|
||||
return m_service->getAircraftModelPath();
|
||||
if (! isConnected()) { return {}; }
|
||||
return m_xplaneData.aircraftModelPath;
|
||||
}
|
||||
|
||||
bool CSimulatorXPlane::updateOwnSimulatorCockpit(const BlackMisc::Aviation::CAircraft &aircraft)
|
||||
{
|
||||
if (! m_service) { return false; }
|
||||
if (! isConnected()) { return false; }
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
auto com1 = Aviation::CComSystem::getCom1System({ m_service->getCom1Active(), CFrequencyUnit::kHz() }, { m_service->getCom1Standby(), CFrequencyUnit::kHz() });
|
||||
auto com2 = Aviation::CComSystem::getCom2System({ m_service->getCom2Active(), CFrequencyUnit::kHz() }, { m_service->getCom2Standby(), CFrequencyUnit::kHz() });
|
||||
auto xpdr = Aviation::CTransponder::getStandardTransponder(m_service->getTransponderCode(), xpdrMode(m_service->getTransponderMode(), m_service->getTransponderIdent()));
|
||||
auto com1 = Aviation::CComSystem::getCom1System({ m_xplaneData.com1Active, CFrequencyUnit::kHz() }, { m_xplaneData.com1Standby, CFrequencyUnit::kHz() });
|
||||
auto com2 = Aviation::CComSystem::getCom2System({ m_xplaneData.com2Active, CFrequencyUnit::kHz() }, { m_xplaneData.com2Standby, CFrequencyUnit::kHz() });
|
||||
auto xpdr = Aviation::CTransponder::getStandardTransponder(m_xplaneData.xpdrCode, xpdrMode(m_xplaneData.xpdrMode, m_xplaneData.xpdrIdent));
|
||||
if (aircraft.hasChangedCockpitData(com1, com2, xpdr))
|
||||
{
|
||||
m_service->setCom1Active(aircraft.getCom1System().getFrequencyActive().valueRounded(CFrequencyUnit::kHz(), 0));
|
||||
m_service->setCom1Standby(aircraft.getCom1System().getFrequencyStandby().valueRounded(CFrequencyUnit::kHz(), 0));
|
||||
m_service->setCom2Active(aircraft.getCom2System().getFrequencyActive().valueRounded(CFrequencyUnit::kHz(), 0));
|
||||
m_service->setCom2Standby(aircraft.getCom2System().getFrequencyStandby().valueRounded(CFrequencyUnit::kHz(), 0));
|
||||
m_service->setTransponderCode(aircraft.getTransponderCode());
|
||||
m_service->setTransponderMode(xpdrMode(aircraft.getTransponderMode()));
|
||||
m_xplaneData.com1Active = aircraft.getCom1System().getFrequencyActive().valueRounded(CFrequencyUnit::kHz(), 0);
|
||||
m_xplaneData.com1Standby = aircraft.getCom1System().getFrequencyStandby().valueRounded(CFrequencyUnit::kHz(), 0);
|
||||
m_xplaneData.com2Active = aircraft.getCom2System().getFrequencyActive().valueRounded(CFrequencyUnit::kHz(), 0);
|
||||
m_xplaneData.com2Standby = aircraft.getCom2System().getFrequencyStandby().valueRounded(CFrequencyUnit::kHz(), 0);
|
||||
m_xplaneData.xpdrCode = aircraft.getTransponderCode();
|
||||
m_xplaneData.xpdrMode = xpdrMode(aircraft.getTransponderMode());
|
||||
m_service->setCom1Active(m_xplaneData.com1Active);
|
||||
m_service->setCom1Standby(m_xplaneData.com1Standby);
|
||||
m_service->setCom2Active(m_xplaneData.com2Active);
|
||||
m_service->setCom2Standby(m_xplaneData.com2Standby);
|
||||
m_service->setTransponderCode(m_xplaneData.xpdrCode);
|
||||
m_service->setTransponderMode(m_xplaneData.xpdrMode);
|
||||
|
||||
m_service->cancelAllPendingAsyncCalls(); // in case there is already a reply with some old data incoming
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -37,15 +37,6 @@ namespace BlackSimPlugin
|
||||
//! \copydoc BlackCore::ISimulator::canConnect
|
||||
virtual bool canConnect() override;
|
||||
|
||||
private:
|
||||
QDBusConnection m_conn { "default" };
|
||||
QDBusServiceWatcher *m_watcher { nullptr };
|
||||
CXBusServiceProxy *m_service { nullptr };
|
||||
|
||||
private slots:
|
||||
void serviceRegistered();
|
||||
void serviceUnregistered();
|
||||
|
||||
public slots:
|
||||
//! \copydoc BlackCore::ISimulator::connectTo
|
||||
virtual bool connectTo() override;
|
||||
@@ -81,6 +72,44 @@ namespace BlackSimPlugin
|
||||
|
||||
//! \copydoc BlackCore::ISimulator::getAircraftModel
|
||||
virtual BlackMisc::Network::CAircraftModel getAircraftModel() const override;
|
||||
|
||||
private slots:
|
||||
void serviceRegistered();
|
||||
void serviceUnregistered();
|
||||
void fastTimerTimeout();
|
||||
void slowTimerTimeout();
|
||||
|
||||
private:
|
||||
QDBusConnection m_conn { "default" };
|
||||
QDBusServiceWatcher *m_watcher { nullptr };
|
||||
CXBusServiceProxy *m_service { nullptr };
|
||||
QTimer *m_fastTimer { nullptr };
|
||||
QTimer *m_slowTimer { nullptr };
|
||||
|
||||
struct // data is written by DBus async method callbacks
|
||||
{
|
||||
QString aircraftModelPath;
|
||||
QString aircraftIcaoCode;
|
||||
double latitude;
|
||||
double longitude;
|
||||
double altitude;
|
||||
double groundspeed;
|
||||
double pitch;
|
||||
double roll;
|
||||
double trueHeading;
|
||||
int com1Active;
|
||||
int com1Standby;
|
||||
int com2Active;
|
||||
int com2Standby;
|
||||
int xpdrCode;
|
||||
int xpdrMode;
|
||||
bool xpdrIdent;
|
||||
} m_xplaneData;
|
||||
|
||||
void resetData()
|
||||
{
|
||||
m_xplaneData = { "", "", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false };
|
||||
}
|
||||
};
|
||||
|
||||
//! Factory for creating CSimulatorXPlane instance
|
||||
|
||||
@@ -38,136 +38,244 @@ namespace BlackSimPlugin
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<QString>(QLatin1String("getAircraftModelPath"));
|
||||
}
|
||||
void CXBusServiceProxy::getAircraftModelPathAsync(QString *o_modelPath)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getAircraftModelPath"), setterCallback(o_modelPath));
|
||||
}
|
||||
|
||||
QString CXBusServiceProxy::getAircraftModelFilename() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<QString>(QLatin1String("getAircraftModelFilename"));
|
||||
}
|
||||
void CXBusServiceProxy::getAircraftModelFilenameAsync(QString *o_modelFilename)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getAircraftModelFilename"), setterCallback(o_modelFilename));
|
||||
}
|
||||
|
||||
QString CXBusServiceProxy::getAircraftModelLivery() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<QString>(QLatin1String("getAircraftModelLivery"));
|
||||
}
|
||||
void CXBusServiceProxy::getAircraftModelLiveryAsync(QString *o_modelLivery)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getAircraftModelLivery"), setterCallback(o_modelLivery));
|
||||
}
|
||||
|
||||
QString CXBusServiceProxy::getAircraftIcaoCode() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<QString>(QLatin1String("getAircraftIcaoCode"));
|
||||
}
|
||||
void CXBusServiceProxy::getAircraftIcaoCodeAsync(QString *o_icaoCode)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getAircraftIcaoCode"), setterCallback(o_icaoCode));
|
||||
}
|
||||
|
||||
int CXBusServiceProxy::getXPlaneVersionMajor() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<int>(QLatin1String("getXPlaneVersionMajor"));
|
||||
}
|
||||
void CXBusServiceProxy::getXPlaneVersionMajorAsync(int *o_versionMajor)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getXPlaneVersionMajor"), setterCallback(o_versionMajor));
|
||||
}
|
||||
|
||||
int CXBusServiceProxy::getXPlaneVersionMinor() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<int>(QLatin1String("getXPlaneVersionMinor"));
|
||||
}
|
||||
void CXBusServiceProxy::getXPlaneVersionMinorAsync(int *o_versionMinor)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getXPlaneVersionMinor"), setterCallback(o_versionMinor));
|
||||
}
|
||||
|
||||
QString CXBusServiceProxy::getXPlaneInstallationPath() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<QString>(QLatin1String("getXPlaneInstallationPath"));
|
||||
}
|
||||
void CXBusServiceProxy::getXPlaneInstallationPathAsync(QString *o_installPath)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getXPlaneInstallationPath"), setterCallback(o_installPath));
|
||||
}
|
||||
|
||||
QString CXBusServiceProxy::getXPlanePreferencesPath() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<QString>(QLatin1String("getXPlanePreferencesPath"));
|
||||
}
|
||||
void CXBusServiceProxy::getXPlanePreferencesPathAsync(QString *o_prefsPath)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getXPlanePreferencesPath"), setterCallback(o_prefsPath));
|
||||
}
|
||||
|
||||
double CXBusServiceProxy::getLatitude() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<double>(QLatin1String("getLatitude"));
|
||||
}
|
||||
void CXBusServiceProxy::getLatitudeAsync(double *o_latitude)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getLatitude"), setterCallback(o_latitude));
|
||||
}
|
||||
|
||||
double CXBusServiceProxy::getLongitude() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<double>(QLatin1String("getLongitude"));
|
||||
}
|
||||
void CXBusServiceProxy::getLongitudeAsync(double *o_longitude)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getLongitude"), setterCallback(o_longitude));
|
||||
}
|
||||
|
||||
double CXBusServiceProxy::getAltitudeMSL() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<double>(QLatin1String("getAltitudeMSL"));
|
||||
}
|
||||
void CXBusServiceProxy::getAltitudeMSLAsync(double *o_altitude)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getAltitudeMSL"), setterCallback(o_altitude));
|
||||
}
|
||||
|
||||
double CXBusServiceProxy::getHeightAGL() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<double>(QLatin1String("getHeightAGL"));
|
||||
}
|
||||
void CXBusServiceProxy::getHeightAGLAsync(double *o_height)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getHeightAGL"), setterCallback(o_height));
|
||||
}
|
||||
|
||||
double CXBusServiceProxy::getGroundSpeed() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<double>(QLatin1String("getGroundSpeed"));
|
||||
}
|
||||
void CXBusServiceProxy::getGroundSpeedAsync(double *o_groundspeed)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getGroundSpeed"), setterCallback(o_groundspeed));
|
||||
}
|
||||
|
||||
double CXBusServiceProxy::getIndicatedAirspeed() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<double>(QLatin1String("getIndicatedAirspeed"));
|
||||
}
|
||||
void CXBusServiceProxy::getIndicatedAirspeedAsync(double *o_ias)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getIndicatedAirspeed"), setterCallback(o_ias));
|
||||
}
|
||||
|
||||
double CXBusServiceProxy::getTrueAirspeed() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<double>(QLatin1String("getTrueAirspeed"));
|
||||
}
|
||||
void CXBusServiceProxy::getTrueAirspeedAsync(double *o_tas)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getTrueAirspeed"), setterCallback(o_tas));
|
||||
}
|
||||
|
||||
double CXBusServiceProxy::getPitch() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<double>(QLatin1String("getPitch"));
|
||||
}
|
||||
void CXBusServiceProxy::getPitchAsync(double *o_pitch)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getPitch"), setterCallback(o_pitch));
|
||||
}
|
||||
|
||||
double CXBusServiceProxy::getRoll() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<double>(QLatin1String("getRoll"));
|
||||
}
|
||||
void CXBusServiceProxy::getRollAsync(double *o_roll)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getRoll"), setterCallback(o_roll));
|
||||
}
|
||||
|
||||
double CXBusServiceProxy::getTrueHeading() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<double>(QLatin1String("getTrueHeading"));
|
||||
}
|
||||
void CXBusServiceProxy::getTrueHeadingAsync(double *o_heading)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getTrueHeading"), setterCallback(o_heading));
|
||||
}
|
||||
|
||||
bool CXBusServiceProxy::getAnyWheelOnGround() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<bool>(QLatin1String("getAnyWheelOnGround"));
|
||||
}
|
||||
void CXBusServiceProxy::getAnyWheelOnGroundAsync(bool *o_anyWheel)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getAnyWheelOnGround"), setterCallback(o_anyWheel));
|
||||
}
|
||||
|
||||
bool CXBusServiceProxy::getAllWheelsOnGround() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<bool>(QLatin1String("getAllWheelsOnGround"));
|
||||
}
|
||||
void CXBusServiceProxy::getAllWheelsOnGroundAsync(bool *o_allWheels)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getAllWheelsOnGround"), setterCallback(o_allWheels));
|
||||
}
|
||||
|
||||
int CXBusServiceProxy::getCom1Active() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<int>(QLatin1String("getCom1Active"));
|
||||
}
|
||||
void CXBusServiceProxy::getCom1ActiveAsync(int *o_com1Active)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getCom1Active"), setterCallback(o_com1Active));
|
||||
}
|
||||
|
||||
int CXBusServiceProxy::getCom1Standby() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<int>(QLatin1String("getCom1Standby"));
|
||||
}
|
||||
void CXBusServiceProxy::getCom1StandbyAsync(int *o_com1Standby)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getCom1Standby"), setterCallback(o_com1Standby));
|
||||
}
|
||||
|
||||
int CXBusServiceProxy::getCom2Active() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<int>(QLatin1String("getCom2Active"));
|
||||
}
|
||||
void CXBusServiceProxy::getCom2ActiveAsync(int *o_com2Active)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getCom2Active"), setterCallback(o_com2Active));
|
||||
}
|
||||
|
||||
int CXBusServiceProxy::getCom2Standby() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<int>(QLatin1String("getCom2Standby"));
|
||||
}
|
||||
void CXBusServiceProxy::getCom2StandbyAsync(int *o_com2Standby)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getCom2Standby"), setterCallback(o_com2Standby));
|
||||
}
|
||||
|
||||
int CXBusServiceProxy::getTransponderCode() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<int>(QLatin1String("getTransponderCode"));
|
||||
}
|
||||
void CXBusServiceProxy::getTransponderCodeAsync(int *o_xpdrCode)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getTransponderCode"), setterCallback(o_xpdrCode));
|
||||
}
|
||||
|
||||
int CXBusServiceProxy::getTransponderMode() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<int>(QLatin1String("getTransponderMode"));
|
||||
}
|
||||
void CXBusServiceProxy::getTransponderModeAsync(int *o_xpdrMode)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getTransponderMode"), setterCallback(o_xpdrMode));
|
||||
}
|
||||
|
||||
bool CXBusServiceProxy::getTransponderIdent() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<bool>(QLatin1String("getTransponderIdent"));
|
||||
}
|
||||
void CXBusServiceProxy::getTransponderIdentAsync(bool *o_ident)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getTransponderIdent"), setterCallback(o_ident));
|
||||
}
|
||||
|
||||
void CXBusServiceProxy::setCom1Active(int freq)
|
||||
{
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
//! \file
|
||||
|
||||
#include "blackmisc/genericdbusinterface.h"
|
||||
#include <functional>
|
||||
|
||||
//! \cond PRIVATE
|
||||
#define XBUS_SERVICE_INTERFACENAME "net.vatsim.xbus.service"
|
||||
@@ -48,96 +49,195 @@ namespace BlackSimPlugin
|
||||
//! Does the remote object exist?
|
||||
bool isValid() const { return m_dbusInterface->isValid(); }
|
||||
|
||||
//! Cancel all current async slot calls
|
||||
void cancelAllPendingAsyncCalls() { m_dbusInterface->cancelAllPendingAsyncCalls(); }
|
||||
|
||||
private:
|
||||
BlackMisc::CGenericDBusInterface *m_dbusInterface = nullptr;
|
||||
|
||||
void relaySignals();
|
||||
|
||||
// Returns a function object which can be passed to CGenericDBusInterface::callDBusAsync.
|
||||
template <typename T>
|
||||
std::function<void(QDBusPendingCallWatcher *)> setterCallback(T *obj)
|
||||
{
|
||||
return [this, obj] (QDBusPendingCallWatcher *watcher)
|
||||
{
|
||||
QDBusPendingReply<T> reply = *watcher;
|
||||
if (reply.isError()) { emit asyncMethodError(reply.error()); }
|
||||
else { *obj = reply; }
|
||||
};
|
||||
}
|
||||
|
||||
signals:
|
||||
//! Emitted if an asynchronous method call caused a DBus error
|
||||
void asyncMethodError(QDBusError error);
|
||||
|
||||
//! \copydoc XBus::CService::aircraftModelChanged
|
||||
void aircraftModelChanged(const QString &path, const QString &filename, const QString &livery, const QString &icao);
|
||||
|
||||
public slots:
|
||||
//! \copydoc XBus::CService::getAircraftModelPath
|
||||
//! @{
|
||||
QString getAircraftModelPath() const;
|
||||
void getAircraftModelPathAsync(QString *o_modelPath);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XBus::CService::getAircraftModelFilename
|
||||
//! @{
|
||||
QString getAircraftModelFilename() const;
|
||||
void getAircraftModelFilenameAsync(QString *o_modelFilename);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XBus::CService::getAircraftModelLivery
|
||||
//! @{
|
||||
QString getAircraftModelLivery() const;
|
||||
void getAircraftModelLiveryAsync(QString *o_modelLivery);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XBus::CService::getAircraftIcaoCode
|
||||
//! @{
|
||||
QString getAircraftIcaoCode() const;
|
||||
void getAircraftIcaoCodeAsync(QString *o_icaoCode);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XBus::CService::getXPlaneVersionMajor
|
||||
//! @{
|
||||
int getXPlaneVersionMajor() const;
|
||||
void getXPlaneVersionMajorAsync(int *o_versionMajor);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XBus::CService::getXPlaneVersionMinor
|
||||
//! @{
|
||||
int getXPlaneVersionMinor() const;
|
||||
void getXPlaneVersionMinorAsync(int *o_versionMinor);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XBus::CService::getXPlaneInstallationPath
|
||||
//! @{
|
||||
QString getXPlaneInstallationPath() const;
|
||||
void getXPlaneInstallationPathAsync(QString *o_installPath);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XBus::CService::getXPlanePreferencesPath
|
||||
//! @{
|
||||
QString getXPlanePreferencesPath() const;
|
||||
void getXPlanePreferencesPathAsync(QString *o_prefsPath);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XBus::CService::getLatitude
|
||||
//! @{
|
||||
double getLatitude() const;
|
||||
void getLatitudeAsync(double *o_latitude);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XBus::CService::getLongitude
|
||||
//! @{
|
||||
double getLongitude() const;
|
||||
void getLongitudeAsync(double *o_longitude);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XBus::CService::getAltitudeMSL
|
||||
//! @{
|
||||
double getAltitudeMSL() const;
|
||||
void getAltitudeMSLAsync(double *o_altitude);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XBus::CService::getHeightAGL
|
||||
//! @{
|
||||
double getHeightAGL() const;
|
||||
void getHeightAGLAsync(double *o_height);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XBus::CService::getGroundSpeed
|
||||
//! @{
|
||||
double getGroundSpeed() const;
|
||||
void getGroundSpeedAsync(double *o_groundspeed);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XBus::CService::getIndicatedAirspeed
|
||||
//! @{
|
||||
double getIndicatedAirspeed() const;
|
||||
void getIndicatedAirspeedAsync(double *o_ias);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XBus::CService::getTrueAirspeed
|
||||
//! @{
|
||||
double getTrueAirspeed() const;
|
||||
void getTrueAirspeedAsync(double *o_tas);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XBus::CService::getPitch
|
||||
//! @{
|
||||
double getPitch() const;
|
||||
void getPitchAsync(double *o_pitch);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XBus::CService::getRoll
|
||||
//! @{
|
||||
double getRoll() const;
|
||||
void getRollAsync(double *o_roll);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XBus::CService::getTrueHeading
|
||||
//! @{
|
||||
double getTrueHeading() const;
|
||||
void getTrueHeadingAsync(double *o_heading);
|
||||
//! @}
|
||||
|
||||
//! Get whether any wheel is on the ground
|
||||
//! @{
|
||||
bool getAnyWheelOnGround() const;
|
||||
void getAnyWheelOnGroundAsync(bool *o_anyWheel);
|
||||
//! @}
|
||||
|
||||
//! Get whether all wheels are on the ground
|
||||
//! @{
|
||||
bool getAllWheelsOnGround() const;
|
||||
void getAllWheelsOnGroundAsync(bool *o_allWheels);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XBus::CService::getCom1Active
|
||||
//! @{
|
||||
int getCom1Active() const;
|
||||
void getCom1ActiveAsync(int *o_com1Active);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XBus::CService::getCom1Standby
|
||||
//! @{
|
||||
int getCom1Standby() const;
|
||||
void getCom1StandbyAsync(int *o_com1Standby);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XBus::CService::getCom2Active
|
||||
//! @{
|
||||
int getCom2Active() const;
|
||||
void getCom2ActiveAsync(int *o_com2Active);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XBus::CService::getCom2Standby
|
||||
//! @{
|
||||
int getCom2Standby() const;
|
||||
void getCom2StandbyAsync(int *o_com2Standby);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XBus::CService::getTransponderCode
|
||||
//! @{
|
||||
int getTransponderCode() const;
|
||||
void getTransponderCodeAsync(int *o_xpdrCode);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XBus::CService::getTransponderMode
|
||||
//! @{
|
||||
int getTransponderMode() const;
|
||||
void getTransponderModeAsync(int *o_xpdrMode);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XBus::CService::getTransponderIdent
|
||||
//! @{
|
||||
bool getTransponderIdent() const;
|
||||
void getTransponderIdentAsync(bool *o_ident);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XBus::CService::setCom1Active
|
||||
void setCom1Active(int freq);
|
||||
|
||||
Reference in New Issue
Block a user