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