swift
Loading...
Searching...
No Matches
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
22class QDBusConnection;
24
26#define XSWIFTBUS_SERVICE_INTERFACENAME "org.swift_project.xswiftbus.service"
27#define XSWIFTBUS_SERVICE_OBJECTPATH "/xswiftbus/service"
29
30namespace swift::simplugin::xplane
31{
32 struct XPlaneData;
33
38 {
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
63 void cancelAllPendingAsyncCalls() { m_dbusInterface->cancelAllPendingAsyncCalls(); }
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())
75 {
76 emit this->asyncMethodError(reply.error());
77 }
78 else
79 {
80 *obj = reply;
81 }
82 watcher->deleteLater();
83 };
84 }
85
86 signals:
89
91 void aircraftModelChanged(const QString &path, const QString &filename, const QString &livery,
92 const QString &icao, const QString &modelString, const QString &name,
93 const QString &description);
94
97
98 public slots:
101
104
107
110
113
116
119
122
125
128
130 void addTextMessage(const QString &text, double red, double green, double blue);
131
135 void getAircraftModelPathAsync(QString *o_modelPath);
137
141 void getAircraftModelFilenameAsync(QString *o_modelFilename);
143
147 void getAircraftLiveryAsync(QString *o_modelLivery);
149
153 void getAircraftIcaoCodeAsync(QString *o_icaoCode);
155
159 void getAircraftDescriptionAsync(QString *o_description);
161
165 void getAircraftModelStringAsync(QString *o_modelString);
167
170 QString getAircraftName() const;
171 void getAircraftNameAsync(QString *o_name);
173
176 int getXPlaneVersionMajor() const;
177 void getXPlaneVersionMajorAsync(int *o_versionMajor);
179
182 int getXPlaneVersionMinor() const;
183 void getXPlaneVersionMinorAsync(int *o_versionMinor);
185
189 void getXPlaneInstallationPathAsync(QString *o_installPath);
191
195 void getXPlanePreferencesPathAsync(QString *o_prefsPath);
197
200 bool isPaused() const;
201 void isPausedAsync(bool *o_paused);
203
206 bool isUsingRealTime() const;
207 void isUsingRealTimeAsync(bool *o_isRealTime);
209
212 void getFrameStats(double *o_averageFps, double *o_simTimeRatio, double *o_trackMilesShort,
213 double *o_minutesLate) const;
214 void getFrameStatsAsync(double *o_averageFps, double *o_simTimeRatio, double *o_trackMilesShort,
215 double *o_minutesLate);
217
219 void resetFrameTotals();
220
222 void setFlightNetworkConnected(bool connected);
223
225 void setOwnCallsign(const QString &callsign);
226
229 double getLatitudeDeg() const;
230 void getLatitudeDegAsync(double *o_latitude);
232
235 double getLongitudeDeg() const;
236 void getLongitudeDegAsync(double *o_longitude);
238
241 double getAltitudeMslM() const;
242 void getAltitudeMslMAsync(double *o_altitude);
244
247 double getPressureAltitudeFt() const;
248 void getPressureAltitudeFtAsync(double *o_altitude);
250
253 double getHeightAglM() const;
254 void getHeightAglMAsync(double *o_height);
256
259 double getGroundSpeedMps() const;
260 void getGroundSpeedMpsAsync(double *o_groundspeed);
262
265 double getIndicatedAirspeedKias() const;
266 void getIndicatedAirspeedKiasAsync(double *o_ias);
268
271 double getTrueAirspeedKias() const;
272 void getTrueAirspeedKiasAsync(double *o_tas);
274
277 double getPitchDeg() const;
278 void getPitchDegAsync(double *o_pitch);
280
283 double getRollDeg() const;
284 void getRollDegAsync(double *o_roll);
286
289 double getTrueHeadingDeg() const;
290 void getTrueHeadingDegAsync(double *o_heading);
292
295 double getLocalXVelocityMps() const;
296 void getLocalXVelocityMpsAsync(double *o_velocity);
298
301 double getLocalYVelocityMps() const;
302 void getLocalYVelocityMpsAsync(double *o_velocity);
304
307 double getLocalZVelocityMps() const;
308 void getLocalZVelocityMpsAsync(double *o_velocity);
310
313 double getPitchRadPerSec() const;
314 void getPitchRadPerSecAsync(double *o_radPerSec);
316
319 double getRollRadPerSec() const;
320 void getRollRadPerSecAsync(double *o_radPerSec);
322
325 double getHeadingRadPerSec() const;
326 void getHeadingRadPerSecAsync(double *o_radPerSec);
328
331 bool getAnyWheelOnGround() const;
332 void getAnyWheelOnGroundAsync(bool *o_anyWheel);
334
337 bool getAllWheelsOnGround() const;
338 void getAllWheelsOnGroundAsync(bool *o_allWheels);
340
343 double getGroundElevation() const;
344 void getGroundElevationAsync(double *o_elevationM);
346
349 int getCom1ActiveKhz() const;
350 void getCom1ActiveKhzAsync(int *o_com1Active);
352
355 int getCom1StandbyKhz() const;
356 void getCom1StandbyKhzAsync(int *o_com1Standby);
358
361 bool isCom1Receiving() const;
362 void isCom1ReceivingAsync(bool *o_com1Rec);
364
367 bool isCom1Transmitting() const;
368 void isCom1TransmittingAsync(bool *o_com1Tx);
370
373 double getCom1Volume() const;
374 void getCom1VolumeAsync(double *o_com1Volume);
376
379 int getCom2ActiveKhz() const;
380 void getCom2ActiveKhzAsync(int *o_com2Active);
382
385 int getCom2StandbyKhz() const;
386 void getCom2StandbyKhzAsync(int *o_com2Standby);
388
391 bool isCom2Receiving() const;
392 void isCom2ReceivingAsync(bool *o_com2Rec);
394
397 bool isCom2Transmitting() const;
398 void isCom2TransmittingAsync(bool *o_com2Tx);
400
403 double getCom2Volume() const;
404 void getCom2VolumeAsync(double *o_com2Volume);
406
409 int getTransponderCode() const;
410 void getTransponderCodeAsync(int *o_xpdrCode);
412
415 int getTransponderMode() const;
416 void getTransponderModeAsync(int *o_xpdrMode);
418
421 bool getTransponderIdent() const;
422 void getTransponderIdentAsync(bool *o_ident);
424
427 bool getBeaconLightsOn() const;
428 void getBeaconLightsOnAsync(bool *o_beaconLightsOn);
430
433 bool getLandingLightsOn() const;
434 void getLandingLightsOnAsync(bool *o_landingLightsOn);
436
439 bool getNavLightsOn() const;
440 void getNavLightsOnAsync(bool *o_navLightsOn);
442
445 bool getStrobeLightsOn() const;
446 void getStrobeLightsOnAsync(bool *o_strobeLightsOn);
448
451 bool getTaxiLightsOn() const;
452 void getTaxiLightsOnAsync(bool *o_taxiLightsOn);
454
457 double getQNHInHg() const;
458 void getQNHInHgAsync(double *o_qnh);
460
462 void setCom1ActiveKhz(int freq);
463
465 void setCom1StandbyKhz(int freq);
466
468 void setCom2ActiveKhz(int freq);
469
471 void setCom2StandbyKhz(int freq);
472
474 void setTransponderCode(int code);
475
477 void setTransponderMode(int mode);
478
481 double getFlapsDeployRatio() const;
482 void getFlapsDeployRatioAsync(double *o_flapsDeployRatio);
484
487 double getGearDeployRatio() const;
488 void getGearDeployRatioAsync(double *o_gearDeployRatio);
490
493 int getNumberOfEngines() const;
494 void getNumberOfEnginesAsync(double *o_numberOfEngines);
496
500 void getEngineN1PercentageAsync(QList<double> *o_engineN1Percentage);
502
505 double getSpeedBrakeRatio() const;
506 void getSpeedBrakeRatioAsync(double *o_speedBrakeRatio);
508
511 QString getSettingsJson() const;
512 void getSettingsJsonAsync(QString *o_jsonSettings);
514
516 void setSettingsJson(const QString &json);
517 };
518} // namespace swift::simplugin::xplane
519
520#endif // SWIFT_SIMPLUGIN_XSWIFTBUS_SERVICE_PROXY_H
Used for hand written interface based on virtual methods.
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.
bool getBeaconLightsOn() const
Get whether landing lights are on.
static const QString & InterfaceName()
Service name.
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 setOwnCallsign(const QString &callsign)
Set the current own callsign.
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.
static const QString & ObjectPath()
Service path.
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.
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.
void setFlightNetworkConnected(bool connected)
Set the current connection state.
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...
QDBusError error() const const
bool isError() const const
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
QObject * parent() const const