6 #include <QLatin1String>
11 class QDBusConnection;
13 #define FGSWIFTBUS_SERVICE_SERVICENAME "org.swift-project.fgswiftbus"
15 namespace swift::simplugin::flightgear
25 s = connection.connect(
26 QString(),
"/fgswiftbus/service",
"org.swift_project.fgswiftbus.service",
"aircraftModelChanged",
this,
30 s = connection.connect(
31 QString(),
"/fgswiftbus/service",
"org.swift_project.fgswiftbus.service",
"airportsInRangeUpdated",
33 SIGNAL(airportsInRangeUpdated(QStringList, QStringList, QList<double>, QList<double>, QList<double>)));
40 return m_dbusInterface->
callDBusRet<
int>(QLatin1String(
"getVersionNumber"));
45 if (!o_flightgearData) {
return; }
46 QPointer<CFGSwiftBusServiceProxy> myself(
this);
47 std::function<void(QDBusPendingCallWatcher *)> callback = [=](QDBusPendingCallWatcher *watcher) {
48 if (!myself) {
return; }
49 QDBusPendingReply<double, double, double, double, double, double, double, double> reply = *watcher;
52 o_flightgearData->
latitudeDeg = reply.argumentAt<0>();
54 o_flightgearData->
altitudeFt = reply.argumentAt<2>();
56 o_flightgearData->
pitchDeg = reply.argumentAt<4>();
57 o_flightgearData->
rollDeg = reply.argumentAt<5>();
61 watcher->deleteLater();
63 m_dbusInterface->
callDBusAsync(QLatin1String(
"getOwnAircraftSituationData"), callback);
68 if (!o_flightgearData) {
return; }
69 QPointer<CFGSwiftBusServiceProxy> myself(
this);
70 std::function<void(QDBusPendingCallWatcher *)> callback = [=](QDBusPendingCallWatcher *watcher) {
71 if (!myself) {
return; }
72 QDBusPendingReply<double, double, double, double, double, double> reply = *watcher;
75 o_flightgearData->
velocityXMs = reply.argumentAt<0>();
76 o_flightgearData->
velocityYMs = reply.argumentAt<1>();
77 o_flightgearData->
velocityZMs = reply.argumentAt<2>();
82 watcher->deleteLater();
84 m_dbusInterface->
callDBusAsync(QLatin1String(
"getOwnAircraftVelocityData"), callback);
89 m_dbusInterface->
callDBus(QLatin1String(
"addTextMessage"), text);
94 return m_dbusInterface->
callDBusRet<QString>(QLatin1String(
"getAircraftModelPath"));
98 m_dbusInterface->
callDBusAsync(QLatin1String(
"getAircraftModelPath"), setterCallback(o_modelPath));
103 return m_dbusInterface->
callDBusRet<QString>(QLatin1String(
"getAircraftModelFilename"));
107 m_dbusInterface->
callDBusAsync(QLatin1String(
"getAircraftModelFilename"), setterCallback(o_modelFilename));
112 return m_dbusInterface->
callDBusRet<QString>(QLatin1String(
"getAircraftLivery"));
116 m_dbusInterface->
callDBusAsync(QLatin1String(
"getAircraftLivery"), setterCallback(o_modelLivery));
121 return m_dbusInterface->
callDBusRet<QString>(QLatin1String(
"getAircraftIcaoCode"));
125 m_dbusInterface->
callDBusAsync(QLatin1String(
"getAircraftIcaoCode"), setterCallback(o_icaoCode));
130 return m_dbusInterface->
callDBusRet<QString>(QLatin1String(
"getAircraftDescription"));
134 m_dbusInterface->
callDBusAsync(QLatin1String(
"getAircraftDescription"), setterCallback(o_description));
139 return m_dbusInterface->
callDBusRet<QString>(QLatin1String(
"getAircraftModelString"));
143 m_dbusInterface->
callDBusAsync(QLatin1String(
"getAircraftModelString"), setterCallback(o_modelString));
148 return m_dbusInterface->
callDBusRet<QString>(QLatin1String(
"getAircraftName"));
152 m_dbusInterface->
callDBusAsync(QLatin1String(
"getAircraftName"), setterCallback(o_name));
157 return m_dbusInterface->
callDBusRet<
bool>(QLatin1String(
"isPaused"));
161 m_dbusInterface->
callDBusAsync(QLatin1String(
"isPaused"), setterCallback(o_paused));
166 return m_dbusInterface->
callDBusRet<
double>(QLatin1String(
"getLatitudeDeg"));
170 m_dbusInterface->
callDBusAsync(QLatin1String(
"getLatitudeDeg"), setterCallback(o_latitude));
175 return m_dbusInterface->
callDBusRet<
double>(QLatin1String(
"getLongitudeDeg"));
179 m_dbusInterface->
callDBusAsync(QLatin1String(
"getLongitudeDeg"), setterCallback(o_longitude));
184 return m_dbusInterface->
callDBusRet<
double>(QLatin1String(
"getAltitudeMslFt"));
188 m_dbusInterface->
callDBusAsync(QLatin1String(
"getAltitudeMslFt"), setterCallback(o_altitude));
193 return m_dbusInterface->
callDBusRet<
double>(QLatin1String(
"getHeightAglFt"));
197 m_dbusInterface->
callDBusAsync(QLatin1String(
"getHeightAglFt"), setterCallback(o_height));
202 return m_dbusInterface->
callDBusRet<
double>(QLatin1String(
"getGroundSpeedKts"));
206 m_dbusInterface->
callDBusAsync(QLatin1String(
"getGroundSpeedKts"), setterCallback(o_groundspeed));
211 return m_dbusInterface->
callDBusRet<
double>(QLatin1String(
"getPitchDeg"));
215 m_dbusInterface->
callDBusAsync(QLatin1String(
"getPitchDeg"), setterCallback(o_pitch));
220 return m_dbusInterface->
callDBusRet<
double>(QLatin1String(
"getRollDeg"));
224 m_dbusInterface->
callDBusAsync(QLatin1String(
"getRollDeg"), setterCallback(o_roll));
229 return m_dbusInterface->
callDBusRet<
bool>(QLatin1String(
"getAllWheelsOnGround"));
233 m_dbusInterface->
callDBusAsync(QLatin1String(
"getAllWheelsOnGround"), setterCallback(o_allWheels));
238 return m_dbusInterface->
callDBusRet<
int>(QLatin1String(
"getCom1ActiveKhz"));
242 m_dbusInterface->
callDBusAsync(QLatin1String(
"getCom1ActiveKhz"), setterCallback(o_com1Active));
247 return m_dbusInterface->
callDBusRet<
int>(QLatin1String(
"getCom1StandbyKhz"));
251 m_dbusInterface->
callDBusAsync(QLatin1String(
"getCom1StandbyKhz"), setterCallback(o_com1Standby));
256 return m_dbusInterface->
callDBusRet<
int>(QLatin1String(
"getCom2ActiveKhz"));
260 m_dbusInterface->
callDBusAsync(QLatin1String(
"getCom2ActiveKhz"), setterCallback(o_com2Active));
265 return m_dbusInterface->
callDBusRet<
double>(QLatin1String(
"getCom1Volume"));
269 m_dbusInterface->
callDBusAsync(QLatin1String(
"getCom1Volume"), setterCallbackWithDefault(o_com1Volume, 0.5));
274 return m_dbusInterface->
callDBusRet<
double>(QLatin1String(
"getCom2Volume"));
278 m_dbusInterface->
callDBusAsync(QLatin1String(
"getCom2Volume"), setterCallbackWithDefault(o_com2Volume, 0.5));
283 return m_dbusInterface->
callDBusRet<
int>(QLatin1String(
"getCom2StandbyKhz"));
287 m_dbusInterface->
callDBusAsync(QLatin1String(
"getCom2StandbyKhz"), setterCallback(o_com2Standby));
292 return m_dbusInterface->
callDBusRet<
int>(QLatin1String(
"getTransponderCode"));
296 m_dbusInterface->
callDBusAsync(QLatin1String(
"getTransponderCode"), setterCallback(o_xpdrCode));
301 return m_dbusInterface->
callDBusRet<
int>(QLatin1String(
"getTransponderMode"));
305 m_dbusInterface->
callDBusAsync(QLatin1String(
"getTransponderMode"), setterCallback(o_xpdrMode));
310 return m_dbusInterface->
callDBusRet<
bool>(QLatin1String(
"getTransponderIdent"));
314 m_dbusInterface->
callDBusAsync(QLatin1String(
"getTransponderIdent"), setterCallback(o_ident));
319 return m_dbusInterface->
callDBusRet<
bool>(QLatin1String(
"getBeaconLightsOn"));
324 m_dbusInterface->
callDBusAsync(QLatin1String(
"getBeaconLightsOn"), setterCallback(o_beaconLightsOn));
329 return m_dbusInterface->
callDBusRet<
bool>(QLatin1String(
"getLandingLightsOn"));
334 m_dbusInterface->
callDBusAsync(QLatin1String(
"getLandingLightsOn"), setterCallback(o_landingLightsOn));
339 return m_dbusInterface->
callDBusRet<
bool>(QLatin1String(
"getNavLightsOn"));
344 m_dbusInterface->
callDBusAsync(QLatin1String(
"getNavLightsOn"), setterCallback(o_navLightsOn));
349 return m_dbusInterface->
callDBusRet<
bool>(QLatin1String(
"getStrobeLightsOn"));
354 m_dbusInterface->
callDBusAsync(QLatin1String(
"getStrobeLightsOn"), setterCallback(o_strobeLightsOn));
359 return m_dbusInterface->
callDBusRet<
bool>(QLatin1String(
"getTaxiLightsOn"));
364 m_dbusInterface->
callDBusAsync(QLatin1String(
"getTaxiLightsOn"), setterCallback(o_taxiLightsOn));
369 return m_dbusInterface->
callDBusRet<
double>(QLatin1String(
"getPressureAltitudeFt"));
374 m_dbusInterface->
callDBusAsync(QLatin1String(
"getPressureAltitudeFt"), setterCallback(o_qnh));
379 m_dbusInterface->
callDBus(QLatin1String(
"setCom1ActiveKhz"), freq);
384 m_dbusInterface->
callDBus(QLatin1String(
"setCom1StandbyKhz"), freq);
389 m_dbusInterface->
callDBus(QLatin1String(
"setCom2ActiveKhz"), freq);
394 m_dbusInterface->
callDBus(QLatin1String(
"setCom2StandbyKhz"), freq);
399 m_dbusInterface->
callDBus(QLatin1String(
"setTransponderCode"), code);
404 m_dbusInterface->
callDBus(QLatin1String(
"setTransponderMode"), mode);
408 return m_dbusInterface->
callDBusRet<
double>(QLatin1String(
"getFlapsDeployRatio"));
413 m_dbusInterface->
callDBusAsync(QLatin1String(
"getFlapsDeployRatio"), setterCallback(o_flapsDeployRatio));
418 return m_dbusInterface->
callDBusRet<
double>(QLatin1String(
"getGearDeployRatio"));
423 m_dbusInterface->
callDBusAsync(QLatin1String(
"getGearDeployRatio"), setterCallback(o_gearDeployRatio));
428 return m_dbusInterface->
callDBusRet<QList<double>>(QLatin1String(
"getEngineN1Percentage"));
433 m_dbusInterface->
callDBusAsync(QLatin1String(
"getEngineN1Percentage"), setterCallback(o_engineN1Percentage));
438 return m_dbusInterface->
callDBusRet<
double>(QLatin1String(
"getSpeedBrakeRatio"));
443 m_dbusInterface->
callDBusAsync(QLatin1String(
"getSpeedBrakeRatio"), setterCallback(o_speedBrakeRatio));
448 return m_dbusInterface->
callDBusRet<
double>(QLatin1String(
"getGroundElevation"));
453 m_dbusInterface->
callDBusAsync(QLatin1String(
"getGroundElevation"), setterCallback(o_groundElevation));
Used for hand written interface based on virtual methods.
void callDBus(QLatin1String method, Args &&...args)
Call DBus, no return value.
Ret callDBusRet(QLatin1String method, Args &&...args)
Call DBus with synchronous return value.
QDBusPendingCallWatcher * callDBusAsync(QLatin1String method, Func callback, Args &&...args)
Call DBus with asynchronous return value Callback can be any callable object taking a single argument...
void getRollDegAsync(double *o_roll)
Get aircraft roll in degrees.
int getTransponderMode() const
Get the current transponder mode (depends on the aircraft, 0 and 1 usually mean standby,...
double getGroundElevation() const
Get ground elevation [m] for current airplane position.
void getOwnAircraftSituationData(FlightgearData *o_flightgearData)
Get own aircraft situation data.
double getCom2Volume() const
Get Com2 volume [0..1].
QString getAircraftModelFilename() const
Get base filename of current aircraft model.
void getGroundElevationAsync(double *o_groundElevation)
Get ground elevation [m] for current airplane position.
bool getLandingLightsOn() const
Get whether landing lights are on.
bool getTaxiLightsOn() const
Get whether taxi lights are on.
void getAircraftModelPathAsync(QString *o_modelPath)
Get full path to current aircraft model.
void setCom2StandbyKhz(int freq)
Set the current COM2 standby frequency in kHz.
double getFlapsDeployRatio() const
Get flaps deploy ratio, where 0.0 is flaps fully retracted, and 1.0 is flaps fully extended.
double getGroundSpeedKts() const
Get aircraft groundspeed in knots.
QString getAircraftModelString() const
Get canonical swift model string of current aircraft model.
void getAircraftModelStringAsync(QString *o_modelString)
Get canonical swift model string of current aircraft model.
QString getAircraftName() const
Get name of current aircraft model.
double getHeightAglFt() const
Get aircraft height in feet.
QString getAircraftIcaoCode() const
Get the ICAO code of the current aircraft model.
double getGearDeployRatio() const
Get gear deploy ratio, where 0 is up and 1 is down.
void getGroundSpeedKtsAsync(double *o_groundspeed)
Get aircraft groundspeed in knots.
double getLatitudeDeg() const
Get aircraft latitude in degrees.
void getCom2StandbyKhzAsync(int *o_com2Standby)
Get the current COM2 standby frequency in kHz.
void getCom2VolumeAsync(double *o_com2Volume)
Get Com2 volume [0..1].
bool getAllWheelsOnGround() const
Get whether all wheels are on the ground.
void setCom1StandbyKhz(int freq)
Set the current COM1 standby frequency in kHz.
void getStrobeLightsOnAsync(bool *o_strobeLightsOn)
Get whether strobe lights are on.
int getVersionNumber()
Get Flightgear version number.
void getCom1VolumeAsync(double *o_com1Volume)
Get Com1 volume [0..1].
QString getAircraftLivery() const
Get current aircraft livery.
void getLandingLightsOnAsync(bool *o_landingLightsOn)
Get whether landing lights are on.
double getCom1Volume() const
Get Com1 volume [0..1].
bool getNavLightsOn() const
Get whether nav lights are on.
void getLongitudeDegAsync(double *o_longitude)
Get aircraft longitude in degrees.
bool getBeaconLightsOn() const
Get whether beacon lights are on.
int getCom1ActiveKhz() const
Get the current COM1 active frequency in kHz.
void getAircraftDescriptionAsync(QString *o_description)
Get the description of the current aircraft model.
bool getStrobeLightsOn() const
Get whether strobe lights are on.
void getTaxiLightsOnAsync(bool *o_taxiLightsOn)
Get whether taxi lights are on.
void getPitchDegAsync(double *o_pitch)
Get aircraft pitch in degrees above horizon.
void getTransponderModeAsync(int *o_xpdrMode)
Get the current transponder mode (depends on the aircraft, 0 and 1 usually mean standby,...
void getAircraftNameAsync(QString *o_name)
Get name of current aircraft model.
void getNavLightsOnAsync(bool *o_navLightsOn)
Get whether nav lights are on.
void getAllWheelsOnGroundAsync(bool *o_allWheels)
Get whether all wheels are on the ground.
void getLatitudeDegAsync(double *o_latitude)
Get aircraft latitude in degrees.
int getCom2StandbyKhz() const
Get the current COM2 standby frequency in kHz.
QList< double > getEngineN1Percentage() const
Get the N1 speed as percent of max (per engine)
void getCom2ActiveKhzAsync(int *o_com2Active)
Get the current COM2 active frequency in kHz.
void getPressureAltitudeFtAsync(double *o_qnh)
Get pressure altitude in feet.
QString getAircraftDescription() const
Get the description of the current aircraft model.
void getCom1ActiveKhzAsync(int *o_com1Active)
Get the current COM1 active frequency in kHz.
void setCom2ActiveKhz(int freq)
Set the current COM2 active frequency in kHz.
static const QString & ObjectPath()
Service path.
double getSpeedBrakeRatio() const
Get the ratio how much the speedbrakes surfaces are extended (0.0 is fully retracted,...
void isPausedAsync(bool *o_paused)
True if sim is paused.
void getAircraftIcaoCodeAsync(QString *o_icaoCode)
Get the ICAO code of the current aircraft model.
void getTransponderIdentAsync(bool *o_ident)
Get whether we are currently squawking ident.
int getCom2ActiveKhz() const
Get the current COM2 active frequency in kHz.
bool getTransponderIdent() const
Get whether we are currently squawking ident.
void setTransponderCode(int code)
Set the current transponder code in decimal.
static const QString & InterfaceName()
Service name.
void getGearDeployRatioAsync(double *o_gearDeployRatio)
Get gear deploy ratio, where 0 is up and 1 is down.
void getSpeedBrakeRatioAsync(double *o_speedBrakeRatio)
Get the ratio how much the speedbrakes surfaces are extended (0.0 is fully retracted,...
void aircraftModelChanged(const QString &path, const QString &filename, const QString &livery, const QString &icao, const QString &modelString, const QString &name, const QString &description)
Own aircraft model changed.
double getAltitudeMslFt() const
Get aircraft altitude in feet.
void getBeaconLightsOnAsync(bool *o_beaconLightsOn)
Get whether beacon lights are on.
void getAltitudeMslFtAsync(double *o_altitude)
Get aircraft altitude in feet.
void getHeightAglFtAsync(double *o_height)
Get aircraft height in feet.
void getFlapsDeployRatioAsync(double *o_flapsDeployRatio)
Get flaps deploy ratio, where 0.0 is flaps fully retracted, and 1.0 is flaps fully extended.
void getAircraftModelFilenameAsync(QString *o_modelFilename)
Get base filename of current aircraft model.
double getPitchDeg() const
Get aircraft pitch in degrees above horizon.
void getTransponderCodeAsync(int *o_xpdrCode)
Get the current transponder code in decimal.
double getPressureAltitudeFt() const
Get pressure altitude in feet.
void getEngineN1PercentageAsync(QList< double > *o_engineN1Percentage)
Get the N1 speed as percent of max (per engine)
void getCom1StandbyKhzAsync(int *o_com1Standby)
Get the current COM1 standby frequency in kHz.
void setTransponderMode(int mode)
Set the current transponder mode (depends on the aircraft, 0 and 1 usually mean standby,...
void getAircraftLiveryAsync(QString *o_modelLivery)
Get current aircraft livery.
QString getAircraftModelPath() const
Get full path to current aircraft model.
int getCom1StandbyKhz() const
Get the current COM1 standby frequency in kHz.
CFGSwiftBusServiceProxy(QDBusConnection &connection, QObject *parent=nullptr, bool dummy=false)
Constructor.
void setCom1ActiveKhz(int freq)
Set the current COM1 active frequency in kHz.
double getRollDeg() const
Get aircraft roll in degrees.
int getTransponderCode() const
Get the current transponder code in decimal.
void getOwnAircraftVelocityData(FlightgearData *o_flightgearData)
Get own aircraft velocity data.
bool isPaused() const
True if sim is paused.
double getLongitudeDeg() const
Get aircraft longitude in degrees.
void addTextMessage(const QString &text)
Add a text message to the on-screen display.
double pressureAltitudeFt
Pressure altitude [inhg].
double pitchDeg
Pitch [deg].
double longitudeDeg
Latitude [deg].
double latitudeDeg
Longitude [deg].
double rollRateRadPerSec
Roll angular velocity [rad/s].
double velocityZMs
z velocity [m/s]
double pitchRateRadPerSec
Pitch angular velocity [rad/s].
double groundspeedKts
Ground speed [kts].
double trueHeadingDeg
True heading [deg].
double velocityYMs
y velocity [m/s]
double velocityXMs
x velocity [m/s]
double yawRateRadPerSec
Yaw angular velocity [rad/s].
double rollDeg
Roll [deg].
double altitudeFt
Altitude [ft].