swift
Loading...
Searching...
No Matches
xswiftbustrafficproxy.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_TRAFFIC_PROXY_H
7#define SWIFT_SIMPLUGIN_XSWIFTBUS_TRAFFIC_PROXY_H
8
9#include <QObject>
10#include <QString>
11#include <QStringList>
12
18#include "misc/logcategories.h"
19
20// clazy:excludeall=const-signal-or-slot
21
22class QDBusConnection;
23
25#define XSWIFTBUS_TRAFFIC_INTERFACENAME "org.swift_project.xswiftbus.traffic"
26#define XSWIFTBUS_TRAFFIC_OBJECTPATH "/xswiftbus/traffic"
28
29namespace swift::simplugin::xplane
30{
33
36
39 {
41 bool isEmpty() const { return callsigns.isEmpty(); }
42
44 bool hasSameSizes() const
45 {
46 const int s = callsigns.size();
47 if (s != latitudesDeg.size())
48 {
49 return false;
50 }
51 if (s != longitudesDeg.size())
52 {
53 return false;
54 }
55 if (s != altitudesFt.size())
56 {
57 return false;
58 }
59 if (s != pitchesDeg.size())
60 {
61 return false;
62 }
63 if (s != rollsDeg.size())
64 {
65 return false;
66 }
67 if (s != headingsDeg.size())
68 {
69 return false;
70 }
71 return true;
72 }
73
76 {
77 this->callsigns.push_back(situation.getCallsign().asString());
78 this->latitudesDeg.push_back(
80 this->longitudesDeg.push_back(
82 this->altitudesFt.push_back(
86 this->headingsDeg.push_back(
88 this->onGrounds.push_back(situation.isOnGround());
89 }
90
99 };
100
103 {
105 bool isEmpty() const { return callsigns.isEmpty(); }
106
110 {
111 this->callsigns.push_back(callsign.asString());
112 this->gears.push_back(parts.isFixedGearDown() ? 1 : 0);
113 this->flaps.push_back(parts.getFlapsPercent() / 100.0);
114 this->spoilers.push_back(parts.isSpoilersOut() ? 1 : 0);
115 this->speedBrakes.push_back(parts.isSpoilersOut() ? 1 : 0);
116 this->slats.push_back(parts.getFlapsPercent() / 100.0);
117 this->wingSweeps.push_back(0.0);
118 this->thrusts.push_back(parts.isAnyEngineOn() ? 0.75 : 0);
119 this->elevators.push_back(0.0);
120 this->rudders.push_back(0.0);
121 this->ailerons.push_back(0.0);
122 this->landLights.push_back(parts.getLights().isLandingOn());
123 this->taxiLights.push_back(parts.getLights().isTaxiOn());
124 this->beaconLights.push_back(parts.getLights().isBeaconOn());
125 this->strobeLights.push_back(parts.getLights().isStrobeOn());
126 this->navLights.push_back(parts.getLights().isNavOn());
127 this->lightPatterns.push_back(0);
128 }
129
147 };
148
160
167
172 {
174
175 public:
177 using ElevationCallback = std::function<void(const swift::misc::geo::CElevationPlane &,
178 const swift::misc::aviation::CCallsign &, bool)>;
179
182 std::function<void(const QStringList &, const QDoubleList &, const QDoubleList &, const QDoubleList &,
183 const QBoolList &, const QDoubleList &)>;
184
186 static const QString &InterfaceName()
187 {
188 static QString s(XSWIFTBUS_TRAFFIC_INTERFACENAME);
189 return s;
190 }
191
193 static const QString &ObjectPath()
194 {
195 static QString s(XSWIFTBUS_TRAFFIC_OBJECTPATH);
196 return s;
197 }
198
200 static const QStringList &getLogCategories();
201
203 CXSwiftBusTrafficProxy(QDBusConnection &connection, QObject *parent = nullptr, bool dummy = false);
204
206 bool isValid() const { return m_dbusInterface->isValid(); }
207
208 signals:
211 void simFrame();
212
214 void remoteAircraftAdded(const QString &callsign);
215
217 void remoteAircraftAddingFailed(const QString &callsign);
218
219 public slots:
222
224 bool initialize();
225
227 void cleanup();
228
230 QString loadPlanesPackage(const QString &path);
231
233 void setDefaultIcao(const QString &defaultIcao);
234
236 void setMaxPlanes(int planes);
237
239 void setMaxDrawDistance(double nauticalMiles);
240
242 void addPlane(const QString &callsign, const QString &modelName, const QString &aircraftIcao,
243 const QString &airlineIcao, const QString &livery);
244
246 void removePlane(const QString &callsign);
247
249 void removeAllPlanes();
250
253
256
259
261 void setInterpolatorMode(const QString &callsign, bool spline);
262
264 void getRemoteAircraftData(const QStringList &callsigns, const RemoteAircraftDataCallback &setter) const;
265
267 void getElevationAtPosition(const swift::misc::aviation::CCallsign &callsign, double latitudeDeg,
268 double longitudeDeg, double altitudeMeters, const ElevationCallback &setter) const;
269
271 void setFollowedAircraft(const QString &callsign);
272
273 private:
274 swift::misc::CGenericDBusInterface *m_dbusInterface = nullptr;
275 };
276} // namespace swift::simplugin::xplane
277
278#endif // SWIFT_SIMPLUGIN_XSWIFTBUS_TRAFFIC_PROXY_H
Used for hand written interface based on virtual methods.
bool isLandingOn() const
Landing lights on?
bool isBeaconOn() const
Beacon lights on?
bool isNavOn() const
Nac lights on?
bool isTaxiOn() const
Taxi lights on?
bool isStrobeOn() const
Strobes lights on?
Value object encapsulating information of aircraft's parts.
CAircraftLights getLights() const
Get aircraft lights.
bool isSpoilersOut() const
Are spoilers out?
bool isFixedGearDown() const
Is fixed gear down?
bool isAnyEngineOn() const
Any engine on?
int getFlapsPercent() const
Get flaps position in percent.
Value object encapsulating information of an aircraft's situation.
const CHeading & getHeading() const
Get heading.
geo::CLongitude longitude() const
Longitude.
const physical_quantities::CAngle & getBank() const
Get bank (angle).
geo::CLatitude latitude() const
Latitude.
const physical_quantities::CAngle & getPitch() const
Get pitch.
const CAltitude & getAltitude() const
Get altitude.
const CCallsign & getCallsign() const
Corresponding callsign.
Value object encapsulating information of a callsign.
Definition callsign.h:30
const QString & asString() const
Get callsign (normalized).
Definition callsign.h:96
Plane of same elevation, can be a single point or larger area (e.g. airport).
static CAngleUnit deg()
Degrees.
Definition units.h:276
static CLengthUnit ft()
Foot ft.
Definition units.h:157
double value(MU unit) const
Value in given unit.
void cleanup()
Reverse the actions of initialize().
void setMaxPlanes(int planes)
Set the maximum number of aircraft.
void addPlane(const QString &callsign, const QString &modelName, const QString &aircraftIcao, const QString &airlineIcao, const QString &livery)
Introduce a new traffic aircraft.
MultiplayerAcquireInfo acquireMultiplayerPlanes()
Returns whether multiplayer planes have been acquired. If not, owner will be set to the plugin that a...
void remoteAircraftAddingFailed(const QString &callsign)
Remote aircraft adding failed.
bool initialize()
Initialize the multiplayer planes rendering and return true if successful.
void setPlanesPositions(const swift::simplugin::xplane::PlanesPositions &planesPositions)
Set the position of multiple traffic aircrafts.
std::function< void(const QStringList &, const QDoubleList &, const QDoubleList &, const QDoubleList &, const QBoolList &, const QDoubleList &)> RemoteAircraftDataCallback
Remote aircrafts data callback.
void setFollowedAircraft(const QString &callsign)
Sets the aircraft with callsign to be followed in plane view.
static const QString & InterfaceName()
Service name.
void setMaxDrawDistance(double nauticalMiles)
Set the maximum distance at which to draw aircraft (nautical miles).
void setPlanesSurfaces(const swift::simplugin::xplane::PlanesSurfaces &planesSurfaces)
Set the flight control surfaces and lights of multiple traffic aircrafts.
std::function< void(const swift::misc::geo::CElevationPlane &, const swift::misc::aviation::CCallsign &, bool)> ElevationCallback
Elevation callback.
void getElevationAtPosition(const swift::misc::aviation::CCallsign &callsign, double latitudeDeg, double longitudeDeg, double altitudeMeters, const ElevationCallback &setter) const
Get the ground elevation at an arbitrary position.
void setInterpolatorMode(const QString &callsign, bool spline)
QString loadPlanesPackage(const QString &path)
Load a collection of planes from the given directory and return error message if unsuccessful.
CXSwiftBusTrafficProxy(QDBusConnection &connection, QObject *parent=nullptr, bool dummy=false)
Constructor.
void setDefaultIcao(const QString &defaultIcao)
Set the ICAO code to use for aircraft without a model match.
void setPlanesTransponders(const swift::simplugin::xplane::PlanesTransponders &planesTransponders)
Set the transponder of multiple traffic aircraft.
static const QString & ObjectPath()
Service path.
void removePlane(const QString &callsign)
Remove a traffic aircraft.
bool isValid() const
Does the remote object exist?
void remoteAircraftAdded(const QString &callsign)
Remote aircraft successfully added.
static const QStringList & getLogCategories()
Log. categories.
void getRemoteAircraftData(const QStringList &callsigns, const RemoteAircraftDataCallback &setter) const
Get remote aircrafts data (lat, lon, elevation and CG).
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
QObject * parent() const const
bool hasAcquired
Has xswiftbus acquired multiplayer planes?
QString owner
Name of the plugin having multiplayer planes acquired.
QList< double > pitchesDeg
List of pitches.
QList< double > altitudesFt
List of altitudes.
QList< double > headingsDeg
List of headings.
QList< bool > onGrounds
List of onGrounds.
void push_back(const swift::misc::aviation::CAircraftSituation &situation)
Push back the latest situation.
QList< double > latitudesDeg
List of latitudes.
QList< double > longitudesDeg
List of longitudes.
void push_back(const swift::misc::aviation::CCallsign &callsign, const swift::misc::aviation::CAircraftParts &parts)
Push back the latest parts.
QList< bool > beaconLights
List of beacon lights.
QList< bool > landLights
List of landing lights.
QList< double > speedBrakes
List of speed brakes.
QList< bool > strobeLights
List of strobe lights.
QList< double > ailerons
List of ailerons.
QList< bool > navLights
List of nav lights.
QList< double > elevators
List of elevators.
QList< bool > taxiLights
List of taxi lights.
QList< int > lightPatterns
List of light patterns.
QList< double > spoilers
List of spoilers.
QList< double > wingSweeps
List of wing sweeps.
QList< bool > idents
List of active idents.
QList< bool > modeCs
List of active mode C's.
QList< int > codes
List of transponder codes.
QList< bool > QBoolList
List of bools.
QList< double > QDoubleList
List of doubles.