mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 12:55:31 +08:00
Ref T259, check if plane object is in m_planesByCallsign
This commit is contained in:
@@ -281,6 +281,7 @@ namespace XSwiftBus
|
|||||||
void CTraffic::setPlanePosition(const QString &callsign, double latitude, double longitude, double altitude, double pitch, double roll, double heading)
|
void CTraffic::setPlanePosition(const QString &callsign, double latitude, double longitude, double altitude, double pitch, double roll, double heading)
|
||||||
{
|
{
|
||||||
const auto plane = m_planesByCallsign.value(callsign, nullptr);
|
const auto plane = m_planesByCallsign.value(callsign, nullptr);
|
||||||
|
if (!plane) { return; }
|
||||||
plane->position.lat = latitude;
|
plane->position.lat = latitude;
|
||||||
plane->position.lon = longitude;
|
plane->position.lon = longitude;
|
||||||
plane->position.elevation = altitude;
|
plane->position.elevation = altitude;
|
||||||
@@ -292,6 +293,8 @@ namespace XSwiftBus
|
|||||||
void CTraffic::addPlaneSurfaces(const QString &callsign, double gear, double flap, double spoiler, double speedBrake, double slat, double wingSweep, double thrust,
|
void CTraffic::addPlaneSurfaces(const QString &callsign, double gear, double flap, double spoiler, double speedBrake, double slat, double wingSweep, double thrust,
|
||||||
double elevator, double rudder, double aileron, bool landLight, bool beaconLight, bool strobeLight, bool navLight, int lightPattern, bool onGround, qint64 relativeTime, qint64 timeOffset)
|
double elevator, double rudder, double aileron, bool landLight, bool beaconLight, bool strobeLight, bool navLight, int lightPattern, bool onGround, qint64 relativeTime, qint64 timeOffset)
|
||||||
{
|
{
|
||||||
|
const auto plane = m_planesByCallsign.value(callsign, nullptr);
|
||||||
|
if (!plane) { return; }
|
||||||
const auto surfaces = std::make_pair(relativeTime + timeOffset + QDateTime::currentMSecsSinceEpoch(), [ = ](Plane * plane)
|
const auto surfaces = std::make_pair(relativeTime + timeOffset + QDateTime::currentMSecsSinceEpoch(), [ = ](Plane * plane)
|
||||||
{
|
{
|
||||||
plane->hasSurfaces = true;
|
plane->hasSurfaces = true;
|
||||||
@@ -312,18 +315,14 @@ namespace XSwiftBus
|
|||||||
plane->surfaces.lights.flashPattern = lightPattern;
|
plane->surfaces.lights.flashPattern = lightPattern;
|
||||||
});
|
});
|
||||||
|
|
||||||
const auto plane = m_planesByCallsign.value(callsign, nullptr);
|
if (plane->hasSurfaces) { plane->pendingSurfaces.push_back(surfaces); }
|
||||||
if (plane)
|
else { surfaces.second(plane); }
|
||||||
{
|
|
||||||
if (plane->hasSurfaces) { plane->pendingSurfaces.push_back(surfaces); }
|
|
||||||
else { surfaces.second(plane); }
|
|
||||||
|
|
||||||
BlackMisc::Aviation::CAircraftParts parts;
|
BlackMisc::Aviation::CAircraftParts parts;
|
||||||
parts.setOnGround(onGround);
|
parts.setOnGround(onGround);
|
||||||
parts.setMSecsSinceEpoch(relativeTime + QDateTime::currentMSecsSinceEpoch());
|
parts.setMSecsSinceEpoch(relativeTime + QDateTime::currentMSecsSinceEpoch());
|
||||||
parts.setTimeOffsetMs(timeOffset);
|
parts.setTimeOffsetMs(timeOffset);
|
||||||
plane->interpolator.addAircraftParts(parts);
|
plane->interpolator.addAircraftParts(parts);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTraffic::setPlaneSurfaces(const QString &callsign, double gear, double flap, double spoiler, double speedBrake, double slat, double wingSweep, double thrust,
|
void CTraffic::setPlaneSurfaces(const QString &callsign, double gear, double flap, double spoiler, double speedBrake, double slat, double wingSweep, double thrust,
|
||||||
@@ -331,38 +330,35 @@ namespace XSwiftBus
|
|||||||
{
|
{
|
||||||
Q_UNUSED(onGround);
|
Q_UNUSED(onGround);
|
||||||
const auto plane = m_planesByCallsign.value(callsign, nullptr);
|
const auto plane = m_planesByCallsign.value(callsign, nullptr);
|
||||||
if (plane)
|
if (!plane) { return; }
|
||||||
{
|
|
||||||
plane->hasSurfaces = true;
|
plane->hasSurfaces = true;
|
||||||
plane->targetGearPosition = gear;
|
plane->targetGearPosition = static_cast<float>(gear);
|
||||||
plane->surfaces.flapRatio = flap;
|
plane->surfaces.flapRatio = static_cast<float>(flap);
|
||||||
plane->surfaces.spoilerRatio = spoiler;
|
plane->surfaces.spoilerRatio = static_cast<float>(spoiler);
|
||||||
plane->surfaces.speedBrakeRatio = speedBrake;
|
plane->surfaces.speedBrakeRatio = static_cast<float>(speedBrake);
|
||||||
plane->surfaces.slatRatio = slat;
|
plane->surfaces.slatRatio = static_cast<float>(slat);
|
||||||
plane->surfaces.wingSweep = wingSweep;
|
plane->surfaces.wingSweep = static_cast<float>(wingSweep);
|
||||||
plane->surfaces.thrust = thrust;
|
plane->surfaces.thrust = static_cast<float>(thrust);
|
||||||
plane->surfaces.yokePitch = elevator;
|
plane->surfaces.yokePitch = static_cast<float>(elevator);
|
||||||
plane->surfaces.yokeHeading = rudder;
|
plane->surfaces.yokeHeading = static_cast<float>(rudder);
|
||||||
plane->surfaces.yokeRoll = aileron;
|
plane->surfaces.yokeRoll = static_cast<float>(aileron);
|
||||||
plane->surfaces.lights.landLights = landLight;
|
plane->surfaces.lights.landLights = landLight;
|
||||||
plane->surfaces.lights.bcnLights = beaconLight;
|
plane->surfaces.lights.bcnLights = beaconLight;
|
||||||
plane->surfaces.lights.strbLights = strobeLight;
|
plane->surfaces.lights.strbLights = strobeLight;
|
||||||
plane->surfaces.lights.navLights = navLight;
|
plane->surfaces.lights.navLights = navLight;
|
||||||
plane->surfaces.lights.flashPattern = lightPattern;
|
plane->surfaces.lights.flashPattern = lightPattern;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTraffic::setPlaneTransponder(const QString &callsign, int code, bool modeC, bool ident)
|
void CTraffic::setPlaneTransponder(const QString &callsign, int code, bool modeC, bool ident)
|
||||||
{
|
{
|
||||||
const auto plane = m_planesByCallsign.value(callsign, nullptr);
|
const auto plane = m_planesByCallsign.value(callsign, nullptr);
|
||||||
if (plane)
|
if (!plane) { return; }
|
||||||
{
|
plane->hasXpdr = true;
|
||||||
plane->hasXpdr = true;
|
plane->xpdr.code = code;
|
||||||
plane->xpdr.code = code;
|
if (ident) { plane->xpdr.mode = xpmpTransponderMode_ModeC_Ident; }
|
||||||
if (ident) { plane->xpdr.mode = xpmpTransponderMode_ModeC_Ident; }
|
else if (modeC) { plane->xpdr.mode = xpmpTransponderMode_ModeC; }
|
||||||
else if (modeC) { plane->xpdr.mode = xpmpTransponderMode_ModeC; }
|
else { plane->xpdr.mode = xpmpTransponderMode_Standby; }
|
||||||
else { plane->xpdr.mode = xpmpTransponderMode_Standby; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTraffic::setInterpolatorMode(const QString &callsign, bool spline)
|
void CTraffic::setInterpolatorMode(const QString &callsign, bool spline)
|
||||||
|
|||||||
Reference in New Issue
Block a user