swift
xswiftbusserviceproxy.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef SWIFT_SIMPLUGIN_XSWIFTBUS_SERVICE_PROXY_H
7 #define SWIFT_SIMPLUGIN_XSWIFTBUS_SERVICE_PROXY_H
8 
9 #include <functional>
10 
11 #include <QDBusError>
12 #include <QDBusPendingReply>
13 #include <QList>
14 #include <QObject>
15 #include <QString>
16 #include <QStringList>
17 
19 
20 // clazy:excludeall=const-signal-or-slot
21 
22 class QDBusConnection;
23 class QDBusPendingCallWatcher;
24 
26 #define XSWIFTBUS_SERVICE_INTERFACENAME "org.swift_project.xswiftbus.service"
27 #define XSWIFTBUS_SERVICE_OBJECTPATH "/xswiftbus/service"
29 
30 namespace swift::simplugin::xplane
31 {
32  struct XPlaneData;
33 
37  class CXSwiftBusServiceProxy : public QObject
38  {
39  Q_OBJECT
40 
41  public:
43  static const QString &InterfaceName()
44  {
45  static const QString s(XSWIFTBUS_SERVICE_INTERFACENAME);
46  return s;
47  }
48 
50  static const QString &ObjectPath()
51  {
52  static const QString s(XSWIFTBUS_SERVICE_OBJECTPATH);
53  return s;
54  }
55 
57  CXSwiftBusServiceProxy(QDBusConnection &connection, QObject *parent = nullptr, bool dummy = false);
58 
60  bool isValid() const { return m_dbusInterface->isValid(); }
61 
64 
65  private:
66  swift::misc::CGenericDBusInterface *m_dbusInterface = nullptr;
67 
68  // Returns a function object which can be passed to CGenericDBusInterface::callDBusAsync.
69  template <typename T>
70  std::function<void(QDBusPendingCallWatcher *)> setterCallback(T *obj)
71  {
72  return [this, obj](QDBusPendingCallWatcher *watcher) {
73  QDBusPendingReply<T> reply = *watcher;
74  if (reply.isError()) { emit this->asyncMethodError(reply.error()); }
75  else { *obj = reply; }
76  watcher->deleteLater();
77  };
78  }
79 
80  signals:
82  SWIFT_NO_RELAY void asyncMethodError(QDBusError error);
83 
85  void aircraftModelChanged(const QString &path, const QString &filename, const QString &livery,
86  const QString &icao, const QString &modelString, const QString &name,
87  const QString &description);
88 
90  void sceneryLoaded();
91 
92  public slots:
94  QString getVersionNumber();
95 
97  QString getCommitHash();
98 
101 
104 
107 
110 
113 
116 
119 
122 
124  void addTextMessage(const QString &text, double red, double green, double blue);
125 
127  void updateAirportsInRange();
128 
131  QString getAircraftModelPath() const;
132  void getAircraftModelPathAsync(QString *o_modelPath);
134 
137  QString getAircraftModelFilename() const;
138  void getAircraftModelFilenameAsync(QString *o_modelFilename);
140 
143  QString getAircraftLivery() const;
144  void getAircraftLiveryAsync(QString *o_modelLivery);
146 
149  QString getAircraftIcaoCode() const;
150  void getAircraftIcaoCodeAsync(QString *o_icaoCode);
152 
155  QString getAircraftDescription() const;
156  void getAircraftDescriptionAsync(QString *o_description);
158 
161  QString getAircraftModelString() const;
162  void getAircraftModelStringAsync(QString *o_modelString);
164 
167  QString getAircraftName() const;
168  void getAircraftNameAsync(QString *o_name);
170 
173  int getXPlaneVersionMajor() const;
174  void getXPlaneVersionMajorAsync(int *o_versionMajor);
176 
179  int getXPlaneVersionMinor() const;
180  void getXPlaneVersionMinorAsync(int *o_versionMinor);
182 
185  QString getXPlaneInstallationPath() const;
186  void getXPlaneInstallationPathAsync(QString *o_installPath);
188 
191  QString getXPlanePreferencesPath() const;
192  void getXPlanePreferencesPathAsync(QString *o_prefsPath);
194 
197  bool isPaused() const;
198  void isPausedAsync(bool *o_paused);
200 
203  bool isUsingRealTime() const;
204  void isUsingRealTimeAsync(bool *o_isRealTime);
206 
209  void getFrameStats(double *o_averageFps, double *o_simTimeRatio, double *o_trackMilesShort,
210  double *o_minutesLate) const;
211  void getFrameStatsAsync(double *o_averageFps, double *o_simTimeRatio, double *o_trackMilesShort,
212  double *o_minutesLate);
214 
216  void resetFrameTotals();
217 
220  double getLatitudeDeg() const;
221  void getLatitudeDegAsync(double *o_latitude);
223 
226  double getLongitudeDeg() const;
227  void getLongitudeDegAsync(double *o_longitude);
229 
232  double getAltitudeMslM() const;
233  void getAltitudeMslMAsync(double *o_altitude);
235 
238  double getPressureAltitudeFt() const;
239  void getPressureAltitudeFtAsync(double *o_altitude);
241 
244  double getHeightAglM() const;
245  void getHeightAglMAsync(double *o_height);
247 
250  double getGroundSpeedMps() const;
251  void getGroundSpeedMpsAsync(double *o_groundspeed);
253 
256  double getIndicatedAirspeedKias() const;
257  void getIndicatedAirspeedKiasAsync(double *o_ias);
259 
262  double getTrueAirspeedKias() const;
263  void getTrueAirspeedKiasAsync(double *o_tas);
265 
268  double getPitchDeg() const;
269  void getPitchDegAsync(double *o_pitch);
271 
274  double getRollDeg() const;
275  void getRollDegAsync(double *o_roll);
277 
280  double getTrueHeadingDeg() const;
281  void getTrueHeadingDegAsync(double *o_heading);
283 
286  double getLocalXVelocityMps() const;
287  void getLocalXVelocityMpsAsync(double *o_velocity);
289 
292  double getLocalYVelocityMps() const;
293  void getLocalYVelocityMpsAsync(double *o_velocity);
295 
298  double getLocalZVelocityMps() const;
299  void getLocalZVelocityMpsAsync(double *o_velocity);
301 
304  double getPitchRadPerSec() const;
305  void getPitchRadPerSecAsync(double *o_radPerSec);
307 
310  double getRollRadPerSec() const;
311  void getRollRadPerSecAsync(double *o_radPerSec);
313 
316  double getHeadingRadPerSec() const;
317  void getHeadingRadPerSecAsync(double *o_radPerSec);
319 
322  bool getAnyWheelOnGround() const;
323  void getAnyWheelOnGroundAsync(bool *o_anyWheel);
325 
328  bool getAllWheelsOnGround() const;
329  void getAllWheelsOnGroundAsync(bool *o_allWheels);
331 
334  double getGroundElevation() const;
335  void getGroundElevationAsync(double *o_elevationM);
337 
340  int getCom1ActiveKhz() const;
341  void getCom1ActiveKhzAsync(int *o_com1Active);
343 
346  int getCom1StandbyKhz() const;
347  void getCom1StandbyKhzAsync(int *o_com1Standby);
349 
352  bool isCom1Receiving() const;
353  void isCom1ReceivingAsync(bool *o_com1Rec);
355 
358  bool isCom1Transmitting() const;
359  void isCom1TransmittingAsync(bool *o_com1Tx);
361 
364  double getCom1Volume() const;
365  void getCom1VolumeAsync(double *o_com1Volume);
367 
370  int getCom2ActiveKhz() const;
371  void getCom2ActiveKhzAsync(int *o_com2Active);
373 
376  int getCom2StandbyKhz() const;
377  void getCom2StandbyKhzAsync(int *o_com2Standby);
379 
382  bool isCom2Receiving() const;
383  void isCom2ReceivingAsync(bool *o_com2Rec);
385 
388  bool isCom2Transmitting() const;
389  void isCom2TransmittingAsync(bool *o_com2Tx);
391 
394  double getCom2Volume() const;
395  void getCom2VolumeAsync(double *o_com2Volume);
397 
400  int getTransponderCode() const;
401  void getTransponderCodeAsync(int *o_xpdrCode);
403 
406  int getTransponderMode() const;
407  void getTransponderModeAsync(int *o_xpdrMode);
409 
412  bool getTransponderIdent() const;
413  void getTransponderIdentAsync(bool *o_ident);
415 
418  bool getBeaconLightsOn() const;
419  void getBeaconLightsOnAsync(bool *o_beaconLightsOn);
421 
424  bool getLandingLightsOn() const;
425  void getLandingLightsOnAsync(bool *o_landingLightsOn);
427 
430  bool getNavLightsOn() const;
431  void getNavLightsOnAsync(bool *o_navLightsOn);
433 
436  bool getStrobeLightsOn() const;
437  void getStrobeLightsOnAsync(bool *o_strobeLightsOn);
439 
442  bool getTaxiLightsOn() const;
443  void getTaxiLightsOnAsync(bool *o_taxiLightsOn);
445 
448  double getQNHInHg() const;
449  void getQNHInHgAsync(double *o_qnh);
451 
453  void setCom1ActiveKhz(int freq);
454 
456  void setCom1StandbyKhz(int freq);
457 
459  void setCom2ActiveKhz(int freq);
460 
462  void setCom2StandbyKhz(int freq);
463 
465  void setTransponderCode(int code);
466 
468  void setTransponderMode(int mode);
469 
472  double getFlapsDeployRatio() const;
473  void getFlapsDeployRatioAsync(double *o_flapsDeployRatio);
475 
478  double getGearDeployRatio() const;
479  void getGearDeployRatioAsync(double *o_gearDeployRatio);
481 
484  int getNumberOfEngines() const;
485  void getNumberOfEnginesAsync(double *o_numberOfEngines);
487 
490  QList<double> getEngineN1Percentage() const;
491  void getEngineN1PercentageAsync(QList<double> *o_engineN1Percentage);
493 
496  double getSpeedBrakeRatio() const;
497  void getSpeedBrakeRatioAsync(double *o_speedBrakeRatio);
499 
502  QString getSettingsJson() const;
503  void getSettingsJsonAsync(QString *o_jsonSettings);
505 
507  void setSettingsJson(const QString &json);
508  };
509 } // namespace swift::simplugin::xplane
510 
511 #endif // SWIFT_SIMPLUGIN_XSWIFTBUS_SERVICE_PROXY_H
Used for hand written interface based on virtual methods.
void cancelAllPendingAsyncCalls()
Cancel all asynchronous DBus calls which are currently pending.
Proxy object connected to a real XSwiftBus::CService object via DBus.
double getLocalXVelocityMps() const
Get aircraft local velocity in world coordinates meters per second.
QString getCommitHash()
Get SHA1 of the last commit that could influence xswiftbus.
static const QString & InterfaceName()
Service name.
bool getBeaconLightsOn() const
Get whether landing lights are on.
void isUsingRealTimeAsync(bool *o_isRealTime)
True if sim time is tracking operating system time.
void getOwnAircraftModelDataAsync(swift::simplugin::xplane::XPlaneData *o_xplaneData)
Get own model data.
void getOwnAircraftCom2DataAsync(swift::simplugin::xplane::XPlaneData *o_xplaneData)
Get own aircraft COM2 data.
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.
double getLocalYVelocityMps() const
Get aircraft local velocity in world coordinates meters per second.
void getTransponderModeAsync(int *o_xpdrMode)
Get the current transponder mode (depends on the aircraft, 0 and 1 usually mean standby,...
void getAltitudeMslMAsync(double *o_altitude)
Get aircraft altitude in meters.
void getEngineN1PercentageAsync(QList< double > *o_engineN1Percentage)
Get the N1 speed as percent of max (per engine)
int getNumberOfEngines() const
Get the number of engines of current aircraft.
double getLatitudeDeg() const
Get aircraft latitude in degrees.
QString getAircraftModelFilename() const
Get base filename of current aircraft model.
QString getXPlaneInstallationPath() const
Get root of X-Plane install path.
void getAircraftIcaoCodeAsync(QString *o_icaoCode)
Get the ICAO code of the current aircraft model.
bool getTaxiLightsOn() const
Get whether taxi lights are on.
void getAircraftModelPathAsync(QString *o_modelPath)
Get full path to current aircraft model.
void getAircraftModelFilenameAsync(QString *o_modelFilename)
Get base filename of current aircraft model.
void getPitchDegAsync(double *o_pitch)
Get aircraft pitch in degrees above horizon.
int getXPlaneVersionMajor() const
Get major version number.
void setCom2ActiveKhz(int freq)
Set the current COM2 active frequency in kHz.
QString getXPlanePreferencesPath() const
Get full path to X-Plane preferences file.
double getRollDeg() const
Get aircraft roll in degrees.
void getPitchRadPerSecAsync(double *o_radPerSec)
Get aircraft angular velocity in radians per second.
void getAllWheelsOnGroundAsync(bool *o_allWheels)
Get whether all wheels are on the ground.
double getCom2Volume() const
Get the COM2 volume 0..1.
static const QString & ObjectPath()
Service path.
double getGearDeployRatio() const
Get gear deploy ratio, where 0 is up and 1 is down.
QString getAircraftLivery() const
Get current aircraft livery.
void getBeaconLightsOnAsync(bool *o_beaconLightsOn)
Get whether landing lights are on.
void getLocalZVelocityMpsAsync(double *o_velocity)
Get aircraft local velocity in world coordinates meters per second.
double getLongitudeDeg() const
Get aircraft longitude in degrees.
void setTransponderCode(int code)
Set the current transponder code in decimal.
void getSpeedBrakeRatioAsync(double *o_speedBrakeRatio)
Get the ratio how much the speedbrakes surfaces are extended (0.0 is fully retracted,...
bool getLandingLightsOn() const
Get whether landing lights are on.
void getIndicatedAirspeedKiasAsync(double *o_ias)
Get aircraft IAS in knots.
void getTaxiLightsOnAsync(bool *o_taxiLightsOn)
Get whether taxi lights are on.
void addTextMessage(const QString &text, double red, double green, double blue)
Add a text message to the on-screen display, with RGB components in the range [0,1].
void getGroundElevationAsync(double *o_elevationM)
Get elevation of ground under the plane (in meters)
void getRollRadPerSecAsync(double *o_radPerSec)
Get aircraft angular velocity in radians per second.
void setCom1StandbyKhz(int freq)
Set the current COM1 standby frequency in kHz.
void isCom1ReceivingAsync(bool *o_com1Rec)
Is COM1 receiving?
double getTrueAirspeedKias() const
Get aircraft TAS in meters per second.
void getOwnAircraftLightsAsync(swift::simplugin::xplane::XPlaneData *o_xplaneData)
Get own lights data.
void getCom1StandbyKhzAsync(int *o_com1Standby)
Get the current COM1 standby frequency in kHz.
void getOwnAircraftVelocityDataAsync(swift::simplugin::xplane::XPlaneData *o_xplaneData)
Get own aircraft velocity data.
void getAnyWheelOnGroundAsync(bool *o_anyWheel)
Get whether any wheel is on the ground.
void setCom1ActiveKhz(int freq)
Set the current COM1 active frequency in kHz.
void getOwnAircraftXpdrAsync(swift::simplugin::xplane::XPlaneData *o_xplaneData)
Get own XPDR data.
void getLandingLightsOnAsync(bool *o_landingLightsOn)
Get whether landing lights are on.
int getCom1StandbyKhz() const
Get the current COM1 standby frequency in kHz.
QString getAircraftDescription() const
Get the description of the current aircraft model.
void getXPlaneVersionMinorAsync(int *o_versionMinor)
Get minor version number.
void getStrobeLightsOnAsync(bool *o_strobeLightsOn)
Get whether strobe lights are on.
QString getAircraftName() const
Get name of current aircraft model.
bool getTransponderIdent() const
Get whether we are currently squawking ident.
void isPausedAsync(bool *o_paused)
True if sim is paused.
double getPitchDeg() const
Get aircraft pitch in degrees above horizon.
void isCom2TransmittingAsync(bool *o_com2Tx)
Is COM2 transmitting?
void getGroundSpeedMpsAsync(double *o_groundspeed)
Get aircraft groundspeed in meters per second.
double getCom1Volume() const
Get the COM1 volume 0..1.
int getTransponderMode() const
Get the current transponder mode (depends on the aircraft, 0 and 1 usually mean standby,...
void getTrueAirspeedKiasAsync(double *o_tas)
Get aircraft TAS in meters per second.
void getCom2VolumeAsync(double *o_com2Volume)
Get the COM2 volume 0..1.
bool isUsingRealTime() const
True if sim time is tracking operating system time.
int getCom2ActiveKhz() const
Get the current COM2 active frequency in kHz.
int getCom2StandbyKhz() const
Get the current COM2 standby frequency in kHz.
bool isValid() const
Does the remote object exist?
void isCom2ReceivingAsync(bool *o_com2Rec)
Is COM2 receiving?
void setSettingsJson(const QString &json)
Set settings.
void getCom2StandbyKhzAsync(int *o_com2Standby)
Get the current COM2 standby frequency in kHz.
QString getAircraftModelString() const
Get canonical swift model string of current aircraft model.
bool getStrobeLightsOn() const
Get whether strobe lights are on.
QString getAircraftIcaoCode() const
Get the ICAO code of the current aircraft model.
void getFlapsDeployRatioAsync(double *o_flapsDeployRatio)
Get flaps deploy ratio, where 0.0 is flaps fully retracted, and 1.0 is flaps fully extended.
void getGearDeployRatioAsync(double *o_gearDeployRatio)
Get gear deploy ratio, where 0 is up and 1 is down.
QString getAircraftModelPath() const
Get full path to current aircraft model.
QList< double > getEngineN1Percentage() const
Get the N1 speed as percent of max (per engine)
double getIndicatedAirspeedKias() const
Get aircraft IAS in knots.
void getXPlaneVersionMajorAsync(int *o_versionMajor)
Get major version number.
bool getNavLightsOn() const
Get whether nav lights are on.
void getLocalXVelocityMpsAsync(double *o_velocity)
Get aircraft local velocity in world coordinates meters per second.
double getRollRadPerSec() const
Get aircraft angular velocity in radians per second.
double getGroundElevation() const
Get elevation of ground under the plane (in meters)
double getFlapsDeployRatio() const
Get flaps deploy ratio, where 0.0 is flaps fully retracted, and 1.0 is flaps fully extended.
void getPressureAltitudeFtAsync(double *o_altitude)
Get aircraft pressure altitude in feet in standard atmosphere in X-Plane 12. NaN in earlier versions ...
void getTransponderCodeAsync(int *o_xpdrCode)
Get the current transponder code in decimal.
int getCom1ActiveKhz() const
Get the current COM1 active frequency in kHz.
int getTransponderCode() const
Get the current transponder code in decimal.
CXSwiftBusServiceProxy(QDBusConnection &connection, QObject *parent=nullptr, bool dummy=false)
Constructor.
void getAircraftModelStringAsync(QString *o_modelString)
Get canonical swift model string of current aircraft model.
void getFrameStats(double *o_averageFps, double *o_simTimeRatio, double *o_trackMilesShort, double *o_minutesLate) const
Frames-per-second, averaged over the last 500 frames, or since this function was last called,...
void getRollDegAsync(double *o_roll)
Get aircraft roll in degrees.
bool getAnyWheelOnGround() const
Get whether any wheel is on the ground.
void getOwnAircraftPartsAsync(swift::simplugin::xplane::XPlaneData *o_xplaneData)
Get own parts such as gear, flaps.
void getSettingsJsonAsync(QString *o_jsonSettings)
Get settings.
double getPressureAltitudeFt() const
Get aircraft pressure altitude in feet in standard atmosphere in X-Plane 12. NaN in earlier versions ...
void getCom2ActiveKhzAsync(int *o_com2Active)
Get the current COM2 active frequency in kHz.
void isCom1TransmittingAsync(bool *o_com1Tx)
Is COM1 transmitting?
double getTrueHeadingDeg() const
Get aircraft true heading in degrees.
void getNavLightsOnAsync(bool *o_navLightsOn)
Get whether nav lights are on.
SWIFT_NO_RELAY void asyncMethodError(QDBusError error)
Emitted if an asynchronous method call caused a DBus error.
void getHeightAglMAsync(double *o_height)
Get aircraft height in meters.
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.
void getQNHInHgAsync(double *o_qnh)
Get barometric pressure at sea level in inches of mercury.
void getAircraftNameAsync(QString *o_name)
Get name of current aircraft model.
double getLocalZVelocityMps() const
Get aircraft local velocity in world coordinates meters per second.
void getLatitudeDegAsync(double *o_latitude)
Get aircraft latitude in degrees.
void getAircraftDescriptionAsync(QString *o_description)
Get the description of the current aircraft model.
void getCom1VolumeAsync(double *o_com1Volume)
Get the COM1 volume 0..1.
double getQNHInHg() const
Get barometric pressure at sea level in inches of mercury.
void getOwnAircraftSituationDataAsync(swift::simplugin::xplane::XPlaneData *o_xplaneData)
Get own aircraft situation data.
void getNumberOfEnginesAsync(double *o_numberOfEngines)
Get the number of engines of current aircraft.
double getGroundSpeedMps() const
Get aircraft groundspeed in meters per second.
void setCom2StandbyKhz(int freq)
Set the current COM2 standby frequency in kHz.
void getXPlaneInstallationPathAsync(QString *o_installPath)
Get root of X-Plane install path.
void resetFrameTotals()
Reset the monitoring of total miles and minutes lost due to low frame rate.
double getSpeedBrakeRatio() const
Get the ratio how much the speedbrakes surfaces are extended (0.0 is fully retracted,...
double getHeightAglM() const
Get aircraft height in meters.
void getLongitudeDegAsync(double *o_longitude)
Get aircraft longitude in degrees.
void getCom1ActiveKhzAsync(int *o_com1Active)
Get the current COM1 active frequency in kHz.
double getAltitudeMslM() const
Get aircraft altitude in meters.
void cancelAllPendingAsyncCalls()
Cancel all current async slot calls.
int getXPlaneVersionMinor() const
Get minor version number.
bool getAllWheelsOnGround() const
Get whether all wheels are on the ground.
double getPitchRadPerSec() const
Get aircraft angular velocity in radians per second.
QString getVersionNumber()
Get xswiftbus version number.
void getOwnAircraftCom1DataAsync(swift::simplugin::xplane::XPlaneData *o_xplaneData)
Get own aircraft COM1 data.
void getLocalYVelocityMpsAsync(double *o_velocity)
Get aircraft local velocity in world coordinates meters per second.
double getHeadingRadPerSec() const
Get aircraft angular velocity in radians per second.
void getXPlanePreferencesPathAsync(QString *o_prefsPath)
Get full path to X-Plane preferences file.
void getHeadingRadPerSecAsync(double *o_radPerSec)
Get aircraft angular velocity in radians per second.
void getTrueHeadingDegAsync(double *o_heading)
Get aircraft true heading in degrees.
void getFrameStatsAsync(double *o_averageFps, double *o_simTimeRatio, double *o_trackMilesShort, double *o_minutesLate)
Frames-per-second, averaged over the last 500 frames, or since this function was last called,...
void getTransponderIdentAsync(bool *o_ident)
Get whether we are currently squawking ident.
#define SWIFT_NO_RELAY
Any signals tagged with this macro will be ignored by swift::misc::CGenericDBusInterface::relayParent...