swift
Loading...
Searching...
No Matches
fgswiftbusserviceproxy.cpp
1// SPDX-FileCopyrightText: Copyright (C) 2019 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#include <QLatin1String>
7#include <QPointer>
8
10
11class QDBusConnection;
12
13#define FGSWIFTBUS_SERVICE_SERVICENAME "org.swift-project.fgswiftbus"
14
15namespace swift::simplugin::flightgear
16{
19 {
20 m_dbusInterface = new swift::misc::CGenericDBusInterface(FGSWIFTBUS_SERVICE_SERVICENAME, ObjectPath(),
21 InterfaceName(), connection, this);
22 if (!dummy)
23 {
24 bool s {};
25 s = connection.connect(
26 QString(), "/fgswiftbus/service", "org.swift_project.fgswiftbus.service", "aircraftModelChanged", this,
28 Q_ASSERT(s);
29 }
30 }
31
33 {
34 return m_dbusInterface->callDBusRet<int>(QLatin1String("getVersionNumber"));
35 }
36
38 {
39 if (!o_flightgearData)
40 {
41 return;
42 }
44 std::function<void(QDBusPendingCallWatcher *)> callback = [=](QDBusPendingCallWatcher *watcher) {
45 if (!myself)
46 {
47 return;
48 }
50 if (!reply.isError())
51 {
52 o_flightgearData->latitudeDeg = reply.argumentAt<0>();
53 o_flightgearData->longitudeDeg = reply.argumentAt<1>();
54 o_flightgearData->altitudeFt = reply.argumentAt<2>();
55 o_flightgearData->groundspeedKts = reply.argumentAt<3>();
56 o_flightgearData->pitchDeg = reply.argumentAt<4>();
57 o_flightgearData->rollDeg = reply.argumentAt<5>();
58 o_flightgearData->trueHeadingDeg = reply.argumentAt<6>();
59 o_flightgearData->pressureAltitudeFt = reply.argumentAt<7>();
60 }
61 watcher->deleteLater();
62 };
63 m_dbusInterface->callDBusAsync(QLatin1String("getOwnAircraftSituationData"), callback);
64 }
65
67 {
68 if (!o_flightgearData)
69 {
70 return;
71 }
73 std::function<void(QDBusPendingCallWatcher *)> callback = [=](QDBusPendingCallWatcher *watcher) {
74 if (!myself)
75 {
76 return;
77 }
79 if (!reply.isError())
80 {
81 o_flightgearData->velocityXMs = reply.argumentAt<0>();
82 o_flightgearData->velocityYMs = reply.argumentAt<1>();
83 o_flightgearData->velocityZMs = reply.argumentAt<2>();
84 o_flightgearData->pitchRateRadPerSec = reply.argumentAt<3>();
85 o_flightgearData->rollRateRadPerSec = reply.argumentAt<4>();
86 o_flightgearData->yawRateRadPerSec = reply.argumentAt<5>();
87 }
88 watcher->deleteLater();
89 };
90 m_dbusInterface->callDBusAsync(QLatin1String("getOwnAircraftVelocityData"), callback);
91 }
92
94 {
95 m_dbusInterface->callDBus(QLatin1String("addTextMessage"), text);
96 }
97
99 {
100 return m_dbusInterface->callDBusRet<QString>(QLatin1String("getAircraftModelPath"));
101 }
103 {
104 m_dbusInterface->callDBusAsync(QLatin1String("getAircraftModelPath"), setterCallback(o_modelPath));
105 }
106
108 {
109 return m_dbusInterface->callDBusRet<QString>(QLatin1String("getAircraftModelFilename"));
110 }
112 {
113 m_dbusInterface->callDBusAsync(QLatin1String("getAircraftModelFilename"), setterCallback(o_modelFilename));
114 }
115
117 {
118 return m_dbusInterface->callDBusRet<QString>(QLatin1String("getAircraftLivery"));
119 }
121 {
122 m_dbusInterface->callDBusAsync(QLatin1String("getAircraftLivery"), setterCallback(o_modelLivery));
123 }
124
126 {
127 return m_dbusInterface->callDBusRet<QString>(QLatin1String("getAircraftIcaoCode"));
128 }
130 {
131 m_dbusInterface->callDBusAsync(QLatin1String("getAircraftIcaoCode"), setterCallback(o_icaoCode));
132 }
133
135 {
136 return m_dbusInterface->callDBusRet<QString>(QLatin1String("getAircraftDescription"));
137 }
139 {
140 m_dbusInterface->callDBusAsync(QLatin1String("getAircraftDescription"), setterCallback(o_description));
141 }
142
144 {
145 return m_dbusInterface->callDBusRet<QString>(QLatin1String("getAircraftModelString"));
146 }
148 {
149 m_dbusInterface->callDBusAsync(QLatin1String("getAircraftModelString"), setterCallback(o_modelString));
150 }
151
153 {
154 return m_dbusInterface->callDBusRet<QString>(QLatin1String("getAircraftName"));
155 }
157 {
158 m_dbusInterface->callDBusAsync(QLatin1String("getAircraftName"), setterCallback(o_name));
159 }
160
162 {
163 return m_dbusInterface->callDBusRet<bool>(QLatin1String("isPaused"));
164 }
166 {
167 m_dbusInterface->callDBusAsync(QLatin1String("isPaused"), setterCallback(o_paused));
168 }
169
171 {
172 return m_dbusInterface->callDBusRet<double>(QLatin1String("getLatitudeDeg"));
173 }
175 {
176 m_dbusInterface->callDBusAsync(QLatin1String("getLatitudeDeg"), setterCallback(o_latitude));
177 }
178
180 {
181 return m_dbusInterface->callDBusRet<double>(QLatin1String("getLongitudeDeg"));
182 }
184 {
185 m_dbusInterface->callDBusAsync(QLatin1String("getLongitudeDeg"), setterCallback(o_longitude));
186 }
187
189 {
190 return m_dbusInterface->callDBusRet<double>(QLatin1String("getAltitudeMslFt"));
191 }
193 {
194 m_dbusInterface->callDBusAsync(QLatin1String("getAltitudeMslFt"), setterCallback(o_altitude));
195 }
196
198 {
199 return m_dbusInterface->callDBusRet<double>(QLatin1String("getHeightAglFt"));
200 }
202 {
203 m_dbusInterface->callDBusAsync(QLatin1String("getHeightAglFt"), setterCallback(o_height));
204 }
205
207 {
208 return m_dbusInterface->callDBusRet<double>(QLatin1String("getGroundSpeedKts"));
209 }
211 {
212 m_dbusInterface->callDBusAsync(QLatin1String("getGroundSpeedKts"), setterCallback(o_groundspeed));
213 }
214
216 {
217 return m_dbusInterface->callDBusRet<double>(QLatin1String("getPitchDeg"));
218 }
220 {
221 m_dbusInterface->callDBusAsync(QLatin1String("getPitchDeg"), setterCallback(o_pitch));
222 }
223
225 {
226 return m_dbusInterface->callDBusRet<double>(QLatin1String("getRollDeg"));
227 }
229 {
230 m_dbusInterface->callDBusAsync(QLatin1String("getRollDeg"), setterCallback(o_roll));
231 }
232
234 {
235 return m_dbusInterface->callDBusRet<bool>(QLatin1String("getAllWheelsOnGround"));
236 }
238 {
239 m_dbusInterface->callDBusAsync(QLatin1String("getAllWheelsOnGround"), setterCallback(o_allWheels));
240 }
241
243 {
244 return m_dbusInterface->callDBusRet<int>(QLatin1String("getCom1ActiveKhz"));
245 }
247 {
248 m_dbusInterface->callDBusAsync(QLatin1String("getCom1ActiveKhz"), setterCallback(o_com1Active));
249 }
250
252 {
253 return m_dbusInterface->callDBusRet<int>(QLatin1String("getCom1StandbyKhz"));
254 }
256 {
257 m_dbusInterface->callDBusAsync(QLatin1String("getCom1StandbyKhz"), setterCallback(o_com1Standby));
258 }
259
261 {
262 return m_dbusInterface->callDBusRet<int>(QLatin1String("getCom2ActiveKhz"));
263 }
265 {
266 m_dbusInterface->callDBusAsync(QLatin1String("getCom2ActiveKhz"), setterCallback(o_com2Active));
267 }
268
270 {
271 return m_dbusInterface->callDBusRet<double>(QLatin1String("getCom1Volume"));
272 }
274 {
275 m_dbusInterface->callDBusAsync(QLatin1String("getCom1Volume"), setterCallbackWithDefault(o_com1Volume, 0.5));
276 }
277
279 {
280 return m_dbusInterface->callDBusRet<double>(QLatin1String("getCom2Volume"));
281 }
283 {
284 m_dbusInterface->callDBusAsync(QLatin1String("getCom2Volume"), setterCallbackWithDefault(o_com2Volume, 0.5));
285 }
286
288 {
289 return m_dbusInterface->callDBusRet<int>(QLatin1String("getCom2StandbyKhz"));
290 }
292 {
293 m_dbusInterface->callDBusAsync(QLatin1String("getCom2StandbyKhz"), setterCallback(o_com2Standby));
294 }
295
297 {
298 return m_dbusInterface->callDBusRet<int>(QLatin1String("getTransponderCode"));
299 }
301 {
302 m_dbusInterface->callDBusAsync(QLatin1String("getTransponderCode"), setterCallback(o_xpdrCode));
303 }
304
306 {
307 return m_dbusInterface->callDBusRet<int>(QLatin1String("getTransponderMode"));
308 }
310 {
311 m_dbusInterface->callDBusAsync(QLatin1String("getTransponderMode"), setterCallback(o_xpdrMode));
312 }
313
315 {
316 return m_dbusInterface->callDBusRet<bool>(QLatin1String("getTransponderIdent"));
317 }
319 {
320 m_dbusInterface->callDBusAsync(QLatin1String("getTransponderIdent"), setterCallback(o_ident));
321 }
322
324 {
325 return m_dbusInterface->callDBusRet<bool>(QLatin1String("getBeaconLightsOn"));
326 }
327
329 {
330 m_dbusInterface->callDBusAsync(QLatin1String("getBeaconLightsOn"), setterCallback(o_beaconLightsOn));
331 }
332
334 {
335 return m_dbusInterface->callDBusRet<bool>(QLatin1String("getLandingLightsOn"));
336 }
337
339 {
340 m_dbusInterface->callDBusAsync(QLatin1String("getLandingLightsOn"), setterCallback(o_landingLightsOn));
341 }
342
344 {
345 return m_dbusInterface->callDBusRet<bool>(QLatin1String("getNavLightsOn"));
346 }
347
349 {
350 m_dbusInterface->callDBusAsync(QLatin1String("getNavLightsOn"), setterCallback(o_navLightsOn));
351 }
352
354 {
355 return m_dbusInterface->callDBusRet<bool>(QLatin1String("getStrobeLightsOn"));
356 }
357
359 {
360 m_dbusInterface->callDBusAsync(QLatin1String("getStrobeLightsOn"), setterCallback(o_strobeLightsOn));
361 }
362
364 {
365 return m_dbusInterface->callDBusRet<bool>(QLatin1String("getTaxiLightsOn"));
366 }
367
369 {
370 m_dbusInterface->callDBusAsync(QLatin1String("getTaxiLightsOn"), setterCallback(o_taxiLightsOn));
371 }
372
374 {
375 return m_dbusInterface->callDBusRet<double>(QLatin1String("getPressureAltitudeFt"));
376 }
377
379 {
380 m_dbusInterface->callDBusAsync(QLatin1String("getPressureAltitudeFt"), setterCallback(o_qnh));
381 }
382
384 {
385 m_dbusInterface->callDBus(QLatin1String("setCom1ActiveKhz"), freq);
386 }
387
389 {
390 m_dbusInterface->callDBus(QLatin1String("setCom1StandbyKhz"), freq);
391 }
392
394 {
395 m_dbusInterface->callDBus(QLatin1String("setCom2ActiveKhz"), freq);
396 }
397
399 {
400 m_dbusInterface->callDBus(QLatin1String("setCom2StandbyKhz"), freq);
401 }
402
404 {
405 m_dbusInterface->callDBus(QLatin1String("setTransponderCode"), code);
406 }
407
409 {
410 m_dbusInterface->callDBus(QLatin1String("setTransponderMode"), mode);
411 }
413 {
414 return m_dbusInterface->callDBusRet<double>(QLatin1String("getFlapsDeployRatio"));
415 }
416
418 {
419 m_dbusInterface->callDBusAsync(QLatin1String("getFlapsDeployRatio"), setterCallback(o_flapsDeployRatio));
420 }
421
423 {
424 return m_dbusInterface->callDBusRet<double>(QLatin1String("getGearDeployRatio"));
425 }
426
428 {
429 m_dbusInterface->callDBusAsync(QLatin1String("getGearDeployRatio"), setterCallback(o_gearDeployRatio));
430 }
431
433 {
434 return m_dbusInterface->callDBusRet<QList<double>>(QLatin1String("getEngineN1Percentage"));
435 }
436
438 {
439 m_dbusInterface->callDBusAsync(QLatin1String("getEngineN1Percentage"), setterCallback(o_engineN1Percentage));
440 }
441
443 {
444 return m_dbusInterface->callDBusRet<double>(QLatin1String("getSpeedBrakeRatio"));
445 }
446
448 {
449 m_dbusInterface->callDBusAsync(QLatin1String("getSpeedBrakeRatio"), setterCallback(o_speedBrakeRatio));
450 }
451
453 {
454 return m_dbusInterface->callDBusRet<double>(QLatin1String("getGroundElevation"));
455 }
456
458 {
459 m_dbusInterface->callDBusAsync(QLatin1String("getGroundElevation"), setterCallback(o_groundElevation));
460 }
461} // namespace swift::simplugin::flightgear
Used for hand written interface based on virtual methods.
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.
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.
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.
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.
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.
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.
double getLongitudeDeg() const
Get aircraft longitude in degrees.
void addTextMessage(const QString &text)
Add a text message to the on-screen display.
bool connect(const QString &service, const QString &path, const QString &interface, const QString &name, QObject *receiver, const char *slot)
QVariant argumentAt(int index) const const
bool isError() const const
QObject(QObject *parent)
QObject * parent() const const
double pressureAltitudeFt
Pressure altitude [inhg].
double rollRateRadPerSec
Roll angular velocity [rad/s].
double pitchRateRadPerSec
Pitch angular velocity [rad/s].
double yawRateRadPerSec
Yaw angular velocity [rad/s].