swift
Loading...
Searching...
No Matches
fgswiftbustrafficproxy.h
Go to the documentation of this file.
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#ifndef SWIFT_SIMPLUGIN_FLIGHTGEAR_TRAFFIC_PROXY_H
7#define SWIFT_SIMPLUGIN_FLIGHTGEAR_TRAFFIC_PROXY_H
8
9#include <QObject>
10#include <QString>
11#include <QStringList>
12
18
19// clazy:excludeall=const-signal-or-slot
20
21class QDBusConnection;
22
24#define FGSWIFTBUS_TRAFFIC_INTERFACENAME "org.swift_project.fgswiftbus.traffic"
25#define FGSWIFTBUS_TRAFFIC_OBJECTPATH "/fgswiftbus/traffic"
27
28namespace swift::simplugin::flightgear
29{
32
35 {
37 bool isEmpty() const { return callsigns.isEmpty(); }
38
40 bool hasSameSizes() const
41 {
42 const int s = callsigns.size();
43 if (s != latitudesDeg.size())
44 {
45 return false;
46 }
47 if (s != longitudesDeg.size())
48 {
49 return false;
50 }
51 if (s != altitudesFt.size())
52 {
53 return false;
54 }
55 if (s != pitchesDeg.size())
56 {
57 return false;
58 }
59 if (s != rollsDeg.size())
60 {
61 return false;
62 }
63 if (s != headingsDeg.size())
64 {
65 return false;
66 }
67 return true;
68 }
69
88
98 };
99
102 {
104 bool isEmpty() const { return callsigns.isEmpty(); }
105
109 {
110 this->callsigns.push_back(callsign.asString());
111 this->gears.push_back(parts.isFixedGearDown() ? 1 : 0);
112 this->flaps.push_back(parts.getFlapsPercent() / 100.0);
113 this->spoilers.push_back(parts.isSpoilersOut() ? 1 : 0);
114 this->speedBrakes.push_back(parts.isSpoilersOut() ? 1 : 0);
115 this->slats.push_back(parts.getFlapsPercent() / 100.0);
116 this->wingSweeps.push_back(0.0);
117 this->thrusts.push_back(parts.isAnyEngineOn() ? 0 : 0.75);
118 this->elevators.push_back(0.0);
119 this->rudders.push_back(0.0);
120 this->ailerons.push_back(0.0);
121 this->landLights.push_back(parts.getLights().isLandingOn());
122 this->beaconLights.push_back(parts.getLights().isBeaconOn());
123 this->strobeLights.push_back(parts.getLights().isStrobeOn());
124 this->navLights.push_back(parts.getLights().isNavOn());
125 this->lightPatterns.push_back(0);
126 this->taxiLights.push_back(parts.getLights().isTaxiOn());
127 }
128
146 };
147
159
166
171 {
173
174 public:
177 std::function<void(const swift::misc::geo::CElevationPlane &, const swift::misc::aviation::CCallsign &)>;
178
180 using RemoteAircraftDataCallback = std::function<void(
181 const QStringList &, const QDoubleList &, const QDoubleList &, const QDoubleList &, const QDoubleList &)>;
182
184 static const QString &InterfaceName()
185 {
186 static QString s(FGSWIFTBUS_TRAFFIC_INTERFACENAME);
187 return s;
188 }
189
191 static const QString &ObjectPath()
192 {
193 static QString s(FGSWIFTBUS_TRAFFIC_OBJECTPATH);
194 return s;
195 }
196
198 CFGSwiftBusTrafficProxy(QDBusConnection &connection, QObject *parent = nullptr, bool dummy = false);
199
201 bool isValid() const { return m_dbusInterface->isValid(); }
202
203 signals:
206 void simFrame();
207
209 void remoteAircraftAdded(const QString &callsign);
210
212 void remoteAircraftAddingFailed(const QString &callsign);
213
214 public slots:
218
220 bool initialize();
221
223 void cleanup();
224
226 void addPlane(const QString &callsign, const QString &modelName, const QString &aircraftIcao,
227 const QString &airlineIcao, const QString &livery);
228
230 void removePlane(const QString &callsign);
231
233 void removeAllPlanes();
234
237
240
243
245 void getRemoteAircraftData(const QStringList &callsigns, const RemoteAircraftDataCallback &setter) const;
246
248 void getElevationAtPosition(const swift::misc::aviation::CCallsign &callsign, double latitudeDeg,
249 double longitudeDeg, double altitudeMeters, const ElevationCallback &setter) const;
250
251 private:
252 swift::misc::CGenericDBusInterface *m_dbusInterface = nullptr;
253 };
254} // namespace swift::simplugin::flightgear
255
256#endif // SWIFT_SIMPLUGIN_FLIGHTGEAR_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 physical_quantities::CSpeed & getGroundSpeed() const
Get ground speed.
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.
static CSpeedUnit kts()
Knots.
Definition units.h:817
void remoteAircraftAdded(const QString &callsign)
Remote aircraft successfully added.
std::function< void( const QStringList &, const QDoubleList &, const QDoubleList &, const QDoubleList &, const QDoubleList &)> RemoteAircraftDataCallback
Remote aircrafts data callback.
void setPlanesTransponders(const swift::simplugin::flightgear::PlanesTransponders &planesTransponders)
Set the transponders of multiple traffic aircrafts.
void setPlanesSurfaces(const swift::simplugin::flightgear::PlanesSurfaces &planesSurfaces)
Set the surfaces of multiple traffic aircrafts.
void cleanup()
Reverse the actions of initialize().
std::function< void(const swift::misc::geo::CElevationPlane &, const swift::misc::aviation::CCallsign &)> ElevationCallback
Elevation callback.
void remoteAircraftAddingFailed(const QString &callsign)
Remote aircraft adding failed.
void addPlane(const QString &callsign, const QString &modelName, const QString &aircraftIcao, const QString &airlineIcao, const QString &livery)
Introduce a new traffic aircraft.
bool initialize()
Initialize the multiplayer planes rendering and return true if successful.
bool isValid() const
Does the remote object exist?
MultiplayerAcquireInfo acquireMultiplayerPlanes()
Returns whether multiplayer planes have been acquired. If not, owner will be set to the plugin that a...
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 getRemoteAircraftData(const QStringList &callsigns, const RemoteAircraftDataCallback &setter) const
Get remote aircrafts data (lat, lon, elevation and CG).
void removePlane(const QString &callsign)
Remove a traffic aircraft.
CFGSwiftBusTrafficProxy(QDBusConnection &connection, QObject *parent=nullptr, bool dummy=false)
Constructor.
void setPlanesPositions(const swift::simplugin::flightgear::PlanesPositions &planesPositions)
Set the position of multiple traffic aircrafts.
QList< double > QDoubleList
List of doubles.
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
QObject * parent() const const
QString owner
Name of the plugin having multiplayer planes acquired.
bool hasAcquired
Has FGSwiftBus acquired multiplayer planes?
void push_back(const swift::misc::aviation::CAircraftSituation &situation)
Push back the latest situation.
QList< double > longitudesDeg
List of longitudes.
QList< double > groundSpeedKts
List of groundspeeds.
QList< bool > strobeLights
List of strobeLights.
QList< double > wingSweeps
List of wingSweeps.
QList< int > lightPatterns
List of lightPatterns.
QList< double > speedBrakes
List of speedBrakes.
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 beaconLights.