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;
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 
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:
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:
95 
98 
101 
104 
107 
110 
113 
116 
119 
122 
124  void addTextMessage(const QString &text, double red, double green, double blue);
125 
129  void getAircraftModelPathAsync(QString *o_modelPath);
131 
135  void getAircraftModelFilenameAsync(QString *o_modelFilename);
137 
140  QString getAircraftLivery() const;
141  void getAircraftLiveryAsync(QString *o_modelLivery);
143 
147  void getAircraftIcaoCodeAsync(QString *o_icaoCode);
149 
153  void getAircraftDescriptionAsync(QString *o_description);
155 
159  void getAircraftModelStringAsync(QString *o_modelString);
161 
164  QString getAircraftName() const;
165  void getAircraftNameAsync(QString *o_name);
167 
170  int getXPlaneVersionMajor() const;
171  void getXPlaneVersionMajorAsync(int *o_versionMajor);
173 
176  int getXPlaneVersionMinor() const;
177  void getXPlaneVersionMinorAsync(int *o_versionMinor);
179 
183  void getXPlaneInstallationPathAsync(QString *o_installPath);
185 
189  void getXPlanePreferencesPathAsync(QString *o_prefsPath);
191 
194  bool isPaused() const;
195  void isPausedAsync(bool *o_paused);
197 
200  bool isUsingRealTime() const;
201  void isUsingRealTimeAsync(bool *o_isRealTime);
203 
206  void getFrameStats(double *o_averageFps, double *o_simTimeRatio, double *o_trackMilesShort,
207  double *o_minutesLate) const;
208  void getFrameStatsAsync(double *o_averageFps, double *o_simTimeRatio, double *o_trackMilesShort,
209  double *o_minutesLate);
211 
213  void resetFrameTotals();
214 
217  double getLatitudeDeg() const;
218  void getLatitudeDegAsync(double *o_latitude);
220 
223  double getLongitudeDeg() const;
224  void getLongitudeDegAsync(double *o_longitude);
226 
229  double getAltitudeMslM() const;
230  void getAltitudeMslMAsync(double *o_altitude);
232 
235  double getPressureAltitudeFt() const;
236  void getPressureAltitudeFtAsync(double *o_altitude);
238 
241  double getHeightAglM() const;
242  void getHeightAglMAsync(double *o_height);
244 
247  double getGroundSpeedMps() const;
248  void getGroundSpeedMpsAsync(double *o_groundspeed);
250 
253  double getIndicatedAirspeedKias() const;
254  void getIndicatedAirspeedKiasAsync(double *o_ias);
256 
259  double getTrueAirspeedKias() const;
260  void getTrueAirspeedKiasAsync(double *o_tas);
262 
265  double getPitchDeg() const;
266  void getPitchDegAsync(double *o_pitch);
268 
271  double getRollDeg() const;
272  void getRollDegAsync(double *o_roll);
274 
277  double getTrueHeadingDeg() const;
278  void getTrueHeadingDegAsync(double *o_heading);
280 
283  double getLocalXVelocityMps() const;
284  void getLocalXVelocityMpsAsync(double *o_velocity);
286 
289  double getLocalYVelocityMps() const;
290  void getLocalYVelocityMpsAsync(double *o_velocity);
292 
295  double getLocalZVelocityMps() const;
296  void getLocalZVelocityMpsAsync(double *o_velocity);
298 
301  double getPitchRadPerSec() const;
302  void getPitchRadPerSecAsync(double *o_radPerSec);
304 
307  double getRollRadPerSec() const;
308  void getRollRadPerSecAsync(double *o_radPerSec);
310 
313  double getHeadingRadPerSec() const;
314  void getHeadingRadPerSecAsync(double *o_radPerSec);
316 
319  bool getAnyWheelOnGround() const;
320  void getAnyWheelOnGroundAsync(bool *o_anyWheel);
322 
325  bool getAllWheelsOnGround() const;
326  void getAllWheelsOnGroundAsync(bool *o_allWheels);
328 
331  double getGroundElevation() const;
332  void getGroundElevationAsync(double *o_elevationM);
334 
337  int getCom1ActiveKhz() const;
338  void getCom1ActiveKhzAsync(int *o_com1Active);
340 
343  int getCom1StandbyKhz() const;
344  void getCom1StandbyKhzAsync(int *o_com1Standby);
346 
349  bool isCom1Receiving() const;
350  void isCom1ReceivingAsync(bool *o_com1Rec);
352 
355  bool isCom1Transmitting() const;
356  void isCom1TransmittingAsync(bool *o_com1Tx);
358 
361  double getCom1Volume() const;
362  void getCom1VolumeAsync(double *o_com1Volume);
364 
367  int getCom2ActiveKhz() const;
368  void getCom2ActiveKhzAsync(int *o_com2Active);
370 
373  int getCom2StandbyKhz() const;
374  void getCom2StandbyKhzAsync(int *o_com2Standby);
376 
379  bool isCom2Receiving() const;
380  void isCom2ReceivingAsync(bool *o_com2Rec);
382 
385  bool isCom2Transmitting() const;
386  void isCom2TransmittingAsync(bool *o_com2Tx);
388 
391  double getCom2Volume() const;
392  void getCom2VolumeAsync(double *o_com2Volume);
394 
397  int getTransponderCode() const;
398  void getTransponderCodeAsync(int *o_xpdrCode);
400 
403  int getTransponderMode() const;
404  void getTransponderModeAsync(int *o_xpdrMode);
406 
409  bool getTransponderIdent() const;
410  void getTransponderIdentAsync(bool *o_ident);
412 
415  bool getBeaconLightsOn() const;
416  void getBeaconLightsOnAsync(bool *o_beaconLightsOn);
418 
421  bool getLandingLightsOn() const;
422  void getLandingLightsOnAsync(bool *o_landingLightsOn);
424 
427  bool getNavLightsOn() const;
428  void getNavLightsOnAsync(bool *o_navLightsOn);
430 
433  bool getStrobeLightsOn() const;
434  void getStrobeLightsOnAsync(bool *o_strobeLightsOn);
436 
439  bool getTaxiLightsOn() const;
440  void getTaxiLightsOnAsync(bool *o_taxiLightsOn);
442 
445  double getQNHInHg() const;
446  void getQNHInHgAsync(double *o_qnh);
448 
450  void setCom1ActiveKhz(int freq);
451 
453  void setCom1StandbyKhz(int freq);
454 
456  void setCom2ActiveKhz(int freq);
457 
459  void setCom2StandbyKhz(int freq);
460 
462  void setTransponderCode(int code);
463 
465  void setTransponderMode(int mode);
466 
469  double getFlapsDeployRatio() const;
470  void getFlapsDeployRatioAsync(double *o_flapsDeployRatio);
472 
475  double getGearDeployRatio() const;
476  void getGearDeployRatioAsync(double *o_gearDeployRatio);
478 
481  int getNumberOfEngines() const;
482  void getNumberOfEnginesAsync(double *o_numberOfEngines);
484 
488  void getEngineN1PercentageAsync(QList<double> *o_engineN1Percentage);
490 
493  double getSpeedBrakeRatio() const;
494  void getSpeedBrakeRatioAsync(double *o_speedBrakeRatio);
496 
499  QString getSettingsJson() const;
500  void getSettingsJsonAsync(QString *o_jsonSettings);
502 
504  void setSettingsJson(const QString &json);
505  };
506 } // namespace swift::simplugin::xplane
507 
508 #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...
bool isValid() const const
QDBusError error() const const
bool isError() const const
Q_OBJECTQ_OBJECT
QObject * parent() const const