mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 21:56:43 +08:00
Simplify the X-Plane traffic plane positions and surfaces API
This commit is contained in:
committed by
Klaus Basan
parent
33963041cc
commit
c437c2eabd
@@ -707,31 +707,8 @@ namespace BlackSimPlugin
|
||||
// interpolation for all remote aircraft
|
||||
const QList<CXPlaneMPAircraft> xplaneAircraftList(m_xplaneAircraftObjects.values());
|
||||
|
||||
QStringList posCallsigns;
|
||||
QList<double> latitudes;
|
||||
QList<double> longitudes;
|
||||
QList<double> altitudes;
|
||||
QList<double> pitches;
|
||||
QList<double> rolles;
|
||||
QList<double> headings;
|
||||
|
||||
QStringList surfaceCallsign;
|
||||
QList<double> gear;
|
||||
QList<double> flap;
|
||||
QList<double> spoiler;
|
||||
QList<double> speedBrake;
|
||||
QList<double> slat;
|
||||
QList<double> wingSweep;
|
||||
QList<double> thrust;
|
||||
QList<double> elevator;
|
||||
QList<double> rudder;
|
||||
QList<double> aileron;
|
||||
QList<bool> landLight;
|
||||
QList<bool> beaconLight;
|
||||
QList<bool> strobeLight;
|
||||
QList<bool> navLight;
|
||||
QList<int> lightPattern;
|
||||
QList<bool> onGround;
|
||||
PlanesPositions planesPositions;
|
||||
PlanesSurfaces planesSurfaces;
|
||||
|
||||
for (const CXPlaneMPAircraft &xplaneAircraft : xplaneAircraftList)
|
||||
{
|
||||
@@ -751,13 +728,13 @@ namespace BlackSimPlugin
|
||||
if (!xplaneAircraft.isSameAsSent(interpolatedSituation))
|
||||
{
|
||||
m_xplaneAircraftObjects[xplaneAircraft.getCallsign()].setSituationAsSent(interpolatedSituation);
|
||||
posCallsigns.push_back(interpolatedSituation.getCallsign().asString());
|
||||
latitudes.push_back(interpolatedSituation.latitude().value(CAngleUnit::deg()));
|
||||
longitudes.push_back(interpolatedSituation.longitude().value(CAngleUnit::deg()));
|
||||
altitudes.push_back(interpolatedSituation.getAltitude().value(CLengthUnit::ft()));
|
||||
pitches.push_back(interpolatedSituation.getPitch().value(CAngleUnit::deg()));
|
||||
rolles.push_back(interpolatedSituation.getBank().value(CAngleUnit::deg()));
|
||||
headings.push_back(interpolatedSituation.getHeading().value(CAngleUnit::deg()));
|
||||
planesPositions.callsigns.push_back(interpolatedSituation.getCallsign().asString());
|
||||
planesPositions.latitudes.push_back(interpolatedSituation.latitude().value(CAngleUnit::deg()));
|
||||
planesPositions.longitudes.push_back(interpolatedSituation.longitude().value(CAngleUnit::deg()));
|
||||
planesPositions.altitudes.push_back(interpolatedSituation.getAltitude().value(CLengthUnit::ft()));
|
||||
planesPositions.pitches.push_back(interpolatedSituation.getPitch().value(CAngleUnit::deg()));
|
||||
planesPositions.rolls.push_back(interpolatedSituation.getBank().value(CAngleUnit::deg()));
|
||||
planesPositions.headings.push_back(interpolatedSituation.getHeading().value(CAngleUnit::deg()));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -768,35 +745,35 @@ namespace BlackSimPlugin
|
||||
const CAircraftParts parts(result);
|
||||
if (result.getPartsStatus().isSupportingParts() || parts.getPartsDetails() == CAircraftParts::GuessedParts)
|
||||
{
|
||||
surfaceCallsign.push_back(xplaneAircraft.getCallsign().asString());
|
||||
gear.push_back(parts.isGearDown() ? 1 : 0);
|
||||
flap.push_back(parts.getFlapsPercent() / 100.0);
|
||||
spoiler.push_back(parts.isSpoilersOut() ? 1 : 0);
|
||||
speedBrake.push_back(parts.isSpoilersOut() ? 1 : 0);
|
||||
slat.push_back(parts.getFlapsPercent() / 100.0);
|
||||
wingSweep.push_back(0.0);
|
||||
thrust.push_back(parts.isAnyEngineOn() ? 0 : 0.75);
|
||||
elevator.push_back(0.0);
|
||||
rudder.push_back(0.0);
|
||||
aileron.push_back(0.0);
|
||||
landLight.push_back(parts.getLights().isLandingOn());
|
||||
beaconLight.push_back(parts.getLights().isBeaconOn());
|
||||
strobeLight.push_back(parts.getLights().isStrobeOn());
|
||||
navLight.push_back(parts.getLights().isNavOn());
|
||||
lightPattern.push_back(0);
|
||||
onGround.push_back(parts.isOnGround());
|
||||
planesSurfaces.callsigns.push_back(xplaneAircraft.getCallsign().asString());
|
||||
planesSurfaces.gears.push_back(parts.isGearDown() ? 1 : 0);
|
||||
planesSurfaces.flaps.push_back(parts.getFlapsPercent() / 100.0);
|
||||
planesSurfaces.spoilers.push_back(parts.isSpoilersOut() ? 1 : 0);
|
||||
planesSurfaces.speedBrakes.push_back(parts.isSpoilersOut() ? 1 : 0);
|
||||
planesSurfaces.slats.push_back(parts.getFlapsPercent() / 100.0);
|
||||
planesSurfaces.wingSweeps.push_back(0.0);
|
||||
planesSurfaces.thrusts.push_back(parts.isAnyEngineOn() ? 0 : 0.75);
|
||||
planesSurfaces.elevators.push_back(0.0);
|
||||
planesSurfaces.rudders.push_back(0.0);
|
||||
planesSurfaces.ailerons.push_back(0.0);
|
||||
planesSurfaces.landLights.push_back(parts.getLights().isLandingOn());
|
||||
planesSurfaces.beaconLights.push_back(parts.getLights().isBeaconOn());
|
||||
planesSurfaces.strobeLights.push_back(parts.getLights().isStrobeOn());
|
||||
planesSurfaces.navLights.push_back(parts.getLights().isNavOn());
|
||||
planesSurfaces.lightPatterns.push_back(0);
|
||||
planesSurfaces.onGrounds.push_back(parts.isOnGround());
|
||||
}
|
||||
|
||||
} // all callsigns
|
||||
|
||||
if (! posCallsigns.isEmpty())
|
||||
if (! planesPositions.isEmpty())
|
||||
{
|
||||
m_trafficProxy->setPlanePositions(posCallsigns, latitudes, longitudes, altitudes, pitches, rolles, headings);
|
||||
m_trafficProxy->setPlanesPositions(planesPositions);
|
||||
}
|
||||
|
||||
if (! surfaceCallsign.isEmpty())
|
||||
if (! planesSurfaces.isEmpty())
|
||||
{
|
||||
m_trafficProxy->setPlaneSurfaces(surfaceCallsign, gear, flap, spoiler, speedBrake, slat, wingSweep, thrust, elevator, rudder, aileron, landLight, beaconLight, strobeLight, navLight, lightPattern, onGround);
|
||||
m_trafficProxy->setPlanesSurfaces(planesSurfaces);
|
||||
}
|
||||
|
||||
const qint64 dt = QDateTime::currentMSecsSinceEpoch() - currentTimestamp;
|
||||
|
||||
@@ -82,19 +82,24 @@ namespace BlackSimPlugin
|
||||
m_dbusInterface->callDBus(QLatin1String("removeAllPlanes"));
|
||||
}
|
||||
|
||||
void CXSwiftBusTrafficProxy::setPlanePositions(const QStringList &callsigns, const QList<double> &latitudes, const QList<double> &longitudes, const QList<double> &altitudes,
|
||||
const QList<double> &pitches, const QList<double> &rolles, const QList<double> &headings)
|
||||
void CXSwiftBusTrafficProxy::setPlanesPositions(const PlanesPositions &planesPositions)
|
||||
{
|
||||
m_dbusInterface->callDBus(QLatin1String("setPlanePositions"), callsigns, latitudes, longitudes, altitudes, pitches, rolles, headings);
|
||||
m_dbusInterface->callDBus(QLatin1String("setPlanesPositions"),
|
||||
planesPositions.callsigns, planesPositions.latitudes, planesPositions.longitudes,
|
||||
planesPositions.altitudes, planesPositions.pitches, planesPositions.rolls,
|
||||
planesPositions.headings);
|
||||
}
|
||||
|
||||
void CXSwiftBusTrafficProxy::setPlaneSurfaces(const QStringList &callsign, const QList<double> &gear, const QList<double> &flap, const QList<double> &spoiler,
|
||||
const QList<double> &speedBrake, const QList<double> &slat, const QList<double> &wingSweep, const QList<double> &thrust,
|
||||
const QList<double> &elevator, const QList<double> &rudder, const QList<double> &aileron, const QList<bool> &landLight,
|
||||
const QList<bool> &beaconLight, const QList<bool> &strobeLight, const QList<bool> &navLight, const QList<int> &lightPattern, const QList<bool> &onGround)
|
||||
void CXSwiftBusTrafficProxy::setPlanesSurfaces(const PlanesSurfaces &planesSurfaces)
|
||||
{
|
||||
m_dbusInterface->callDBus(QLatin1String("setPlaneSurfaces"), callsign, gear, flap, spoiler, speedBrake, slat, wingSweep, thrust, elevator, rudder, aileron,
|
||||
landLight, beaconLight, strobeLight, navLight, lightPattern, onGround);
|
||||
m_dbusInterface->callDBus(QLatin1String("setPlanesSurfaces"),
|
||||
planesSurfaces.callsigns, planesSurfaces.gears, planesSurfaces.flaps,
|
||||
planesSurfaces.spoilers, planesSurfaces.speedBrakes, planesSurfaces.slats,
|
||||
planesSurfaces.wingSweeps, planesSurfaces.thrusts, planesSurfaces.elevators,
|
||||
planesSurfaces.rudders, planesSurfaces.ailerons,
|
||||
planesSurfaces.landLights, planesSurfaces.beaconLights, planesSurfaces.strobeLights,
|
||||
planesSurfaces.navLights, planesSurfaces.lightPatterns,
|
||||
planesSurfaces.onGrounds);
|
||||
}
|
||||
|
||||
void CXSwiftBusTrafficProxy::setPlaneTransponder(const QString &callsign, int code, bool modeC, bool ident)
|
||||
|
||||
@@ -31,6 +31,49 @@ namespace BlackSimPlugin
|
||||
{
|
||||
namespace XPlane
|
||||
{
|
||||
//! List of doubles
|
||||
using QDoubleList = QList<double>;
|
||||
|
||||
//! Planes positions
|
||||
struct PlanesPositions
|
||||
{
|
||||
//! Is empty?
|
||||
bool isEmpty() const { return callsigns.isEmpty(); }
|
||||
|
||||
QStringList callsigns; //!< List of callsigns
|
||||
QList<double> latitudes; //!< List of latitudes
|
||||
QList<double> longitudes; //!< List of longitudes
|
||||
QList<double> altitudes; //!< List of altitudes
|
||||
QList<double> pitches; //!< List of pitches
|
||||
QList<double> rolls; //!< List of rolls
|
||||
QList<double> headings; //!< List of headings
|
||||
};
|
||||
|
||||
//! Planes surfaces
|
||||
struct PlanesSurfaces
|
||||
{
|
||||
//! Is empty?
|
||||
bool isEmpty() const { return callsigns.isEmpty(); }
|
||||
|
||||
QStringList callsigns; //!< List of callsigns
|
||||
QList<double> gears; //!< List of gears
|
||||
QList<double> flaps; //!< List of flaps
|
||||
QList<double> spoilers; //!< List of spoilers
|
||||
QList<double> speedBrakes; //!< List of speedBrakes
|
||||
QList<double> slats; //!< List of slats
|
||||
QList<double> wingSweeps; //!< List of wingSweeps
|
||||
QList<double> thrusts; //!< List of thrusts
|
||||
QList<double> elevators; //!< List of elevators
|
||||
QList<double> rudders; //!< List of rudders
|
||||
QList<double> ailerons; //!< List of ailerons
|
||||
QList<bool> landLights; //!< List of landLights
|
||||
QList<bool> beaconLights; //!< List of beaconLights
|
||||
QList<bool> strobeLights; //!< List of strobeLights
|
||||
QList<bool> navLights; //!< List of navLights
|
||||
QList<int> lightPatterns; //!< List of lightPatterns
|
||||
QList<bool> onGrounds; //!< List of onGrounds
|
||||
};
|
||||
|
||||
/*!
|
||||
* Proxy object connected to a real XSwiftBus::CTraffic object via DBus
|
||||
*/
|
||||
@@ -39,9 +82,6 @@ namespace BlackSimPlugin
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! List of doubles
|
||||
using QDoubleList = QList<double>;
|
||||
|
||||
//! Elevation callback
|
||||
using ElevationCallback = std::function<void (const BlackMisc::Geo::CElevationPlane &, const BlackMisc::Aviation::CCallsign &)>;
|
||||
|
||||
@@ -113,15 +153,11 @@ namespace BlackSimPlugin
|
||||
//! \copydoc XSwiftBus::CTraffic::removeAllPlanes
|
||||
void removeAllPlanes();
|
||||
|
||||
//! \copydoc XSwiftBus::CTraffic::setPlanePositions
|
||||
void setPlanePositions(const QStringList &callsigns, const QList<double> &latitudes, const QList<double> &longitudes, const QList<double> &altitudes,
|
||||
const QList<double> &pitches, const QList<double> &rolles, const QList<double> &headings);
|
||||
//! \copydoc XSwiftBus::CTraffic::setPlanesPositions
|
||||
void setPlanesPositions(const PlanesPositions &planesPositions);
|
||||
|
||||
//! \copydoc XSwiftBus::CTraffic::setPlaneSurfaces
|
||||
void setPlaneSurfaces(const QStringList &callsign, const QList<double> &gear, const QList<double> &flap, const QList<double> &spoiler,
|
||||
const QList<double> &speedBrake, const QList<double> &slat, const QList<double> &wingSweep, const QList<double> &thrust,
|
||||
const QList<double> &elevator, const QList<double> &rudder, const QList<double> &aileron, const QList<bool> &landLight,
|
||||
const QList<bool> &beaconLight, const QList<bool> &strobeLight, const QList<bool> &navLight, const QList<int> &lightPattern, const QList<bool> &onGround);
|
||||
void setPlanesSurfaces(const PlanesSurfaces &planesSurfaces);
|
||||
|
||||
//! \copydoc XSwiftBus::CTraffic::setPlaneTransponder
|
||||
void setPlaneTransponder(const QString &callsign, int code, bool modeC, bool ident);
|
||||
|
||||
Reference in New Issue
Block a user