8#include <QDBusConnection>
9#include <QLatin1String>
13#define XSWIFTBUS_SERVICENAME "org.swift-project.xswiftbus"
16using namespace swift::misc::aviation;
17using namespace swift::misc::geo;
18using namespace swift::misc::physical_quantities;
20namespace swift::simplugin::xplane
36 s = connection.
connect(
QString(),
"/xswiftbus/traffic",
"org.swift_project.xswiftbus.traffic",
"simFrame",
40 s = connection.
connect(
QString(),
"/xswiftbus/traffic",
"org.swift_project.xswiftbus.traffic",
44 s = connection.
connect(
QString(),
"/xswiftbus/traffic",
"org.swift_project.xswiftbus.traffic",
56 CLogMessage(
this).
debug(u
"CXSwiftBusTrafficProxy::acquireMultiplayerPlanes returned: %1")
67 return m_dbusInterface->callDBusRet<
bool>(
QLatin1String(
"initialize"));
79 m_dbusInterface->callDBus(
QLatin1String(
"setDefaultIcao"), defaultIcao);
84 m_dbusInterface->callDBus(
QLatin1String(
"setMaxPlanes"), planes);
89 m_dbusInterface->callDBus(
QLatin1String(
"setMaxDrawDistance"), nauticalMiles);
96 m_dbusInterface->callDBus(
QLatin1String(
"addPlane"), callsign, modelName, aircraftIcao, airlineIcao, livery);
101 m_dbusInterface->callDBus(
QLatin1String(
"removePlane"), callsign);
132 m_dbusInterface->callDBus(
QLatin1String(
"setInterpolatorMode"), callsign, spline);
150 setter(callsigns, latitudesDeg, longitudesDeg, elevationsM, waterFlags, verticalOffsets);
155 CLogMessage(
this).
warning(u
"xswiftbus DBus error getRemoteAircraftData: %1") << errorMsg;
157 watcher->deleteLater();
159 m_dbusInterface->callDBusAsync(
QLatin1String(
"getRemoteAircraftData"), callback, callsigns);
163 double longitudeDeg,
double altitudeMeters,
171 const double elevationMeters = reply.
argumentAt<1>();
172 const double latitudeDegrees = reply.
argumentAt<2>();
173 const double longitudeDegrees = reply.
argumentAt<3>();
174 const CAltitude elevationAlt = std::isnan(elevationMeters) ?
181 setter(elevation, cs, isWater);
185 watcher->deleteLater();
188 m_dbusInterface->callDBusAsync(
QLatin1String(
"getElevationAtPosition"), callback, callsign.
asString(),
189 latitudeDeg, longitudeDeg, altitudeMeters);
196 m_dbusInterface->callDBus(
QLatin1String(
"setFollowedAircraft"), callsign);
static CAngleUnit deg()
Degrees.
Used for hand written interface based on virtual methods.
static const QString & driver()
Driver.
static const QString & dbus()
DBus related.
Class for emitting a log message.
Derived & debug()
Set the severity to debug.
Derived & warning(const char16_t(&format)[N])
Set the severity to warning, providing a format string.
Altitude as used in aviation, can be AGL or MSL altitude.
static const CAltitude & null()
Null altitude (MSL).
Value object encapsulating information of a callsign.
const QString & asString() const
Get callsign (normalized).
Plane of same elevation, can be a single point or larger area (e.g. airport).
static const physical_quantities::CLength & singlePointRadius()
Radius for single point.
static CLengthUnit m()
Meter m.
static CLengthUnit ft()
Foot ft.
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.
void removeAllPlanes()
Remove all traffic aircraft.
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.
void simFrame()
Simulator frame.
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.
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).
Free functions in swift::misc.
bool connect(const QString &service, const QString &path, const QString &interface, const QString &name, QObject *receiver, const char *slot)
QString message() const const
QVariant argumentAt(int index) const const
QDBusError error() const const
bool isError() const const
QObject * parent() const const
Multiplayer Acquire Info.
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.
QStringList callsigns
List of callsigns.
QList< double > headingsDeg
List of headings.
QList< double > rollsDeg
List of rolls.
QList< bool > onGrounds
List of onGrounds.
QList< double > latitudesDeg
List of latitudes.
QList< double > longitudesDeg
List of longitudes.
QList< double > slats
List of slats.
QList< bool > beaconLights
List of beacon lights.
QList< bool > landLights
List of landing lights.
QList< double > gears
List of gears.
QStringList callsigns
List of callsigns.
QList< double > speedBrakes
List of speed brakes.
QList< bool > strobeLights
List of strobe lights.
QList< double > rudders
List of rudders.
QList< double > ailerons
List of ailerons.
QList< bool > navLights
List of nav lights.
QList< double > thrusts
List of thrusts.
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 > flaps
List of flaps.
QList< double > wingSweeps
List of wing sweeps.
QList< bool > idents
List of active idents.
QStringList callsigns
List of callsigns.
QList< bool > modeCs
List of active mode C's.
QList< int > codes
List of transponder codes.