mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-23 05:45:35 +08:00
[FG] Add surface/transponder support + sync changes from xswiftbus
Fixes #57
This commit is contained in:
@@ -87,6 +87,26 @@ namespace BlackSimPlugin
|
|||||||
planesPositions.headingsDeg, planesPositions.groundSpeedKts, planesPositions.onGrounds);
|
planesPositions.headingsDeg, planesPositions.groundSpeedKts, planesPositions.onGrounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CFGSwiftBusTrafficProxy::setPlanesSurfaces(const PlanesSurfaces &planesSurfaces)
|
||||||
|
{
|
||||||
|
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.taxiLights,
|
||||||
|
planesSurfaces.beaconLights, planesSurfaces.strobeLights,
|
||||||
|
planesSurfaces.navLights, planesSurfaces.lightPatterns);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CFGSwiftBusTrafficProxy::setPlanesTransponders(const PlanesTransponders &planesTransponders)
|
||||||
|
{
|
||||||
|
m_dbusInterface->callDBus(QLatin1String("setPlanesTransponders"),
|
||||||
|
planesTransponders.callsigns, planesTransponders.codes,
|
||||||
|
planesTransponders.modeCs, planesTransponders.idents);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void CFGSwiftBusTrafficProxy::getRemoteAircraftData(const QStringList &callsigns, const RemoteAircraftDataCallback &setter) const
|
void CFGSwiftBusTrafficProxy::getRemoteAircraftData(const QStringList &callsigns, const RemoteAircraftDataCallback &setter) const
|
||||||
{
|
{
|
||||||
std::function<void(QDBusPendingCallWatcher *)> callback = [ = ](QDBusPendingCallWatcher * watcher)
|
std::function<void(QDBusPendingCallWatcher *)> callback = [ = ](QDBusPendingCallWatcher * watcher)
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ namespace BlackSimPlugin
|
|||||||
this->rollsDeg.push_back(situation.getBank().value(BlackMisc::PhysicalQuantities::CAngleUnit::deg()));
|
this->rollsDeg.push_back(situation.getBank().value(BlackMisc::PhysicalQuantities::CAngleUnit::deg()));
|
||||||
this->headingsDeg.push_back(situation.getHeading().value(BlackMisc::PhysicalQuantities::CAngleUnit::deg()));
|
this->headingsDeg.push_back(situation.getHeading().value(BlackMisc::PhysicalQuantities::CAngleUnit::deg()));
|
||||||
this->onGrounds.push_back(situation.getOnGround() == BlackMisc::Aviation::CAircraftSituation::OnGround);
|
this->onGrounds.push_back(situation.getOnGround() == BlackMisc::Aviation::CAircraftSituation::OnGround);
|
||||||
|
this->groundSpeedKts.push_back(situation.getGroundSpeed().value(BlackMisc::PhysicalQuantities::CSpeedUnit::kts()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList callsigns; //!< List of callsigns
|
QStringList callsigns; //!< List of callsigns
|
||||||
@@ -101,12 +102,11 @@ namespace BlackSimPlugin
|
|||||||
this->rudders.push_back(0.0);
|
this->rudders.push_back(0.0);
|
||||||
this->ailerons.push_back(0.0);
|
this->ailerons.push_back(0.0);
|
||||||
this->landLights.push_back(parts.getLights().isLandingOn());
|
this->landLights.push_back(parts.getLights().isLandingOn());
|
||||||
//! \todo KB 2019-09 Missing taxi lights in FG
|
|
||||||
// this->taxiLights.push_back(parts.getLights().isTaxiOn());
|
|
||||||
this->beaconLights.push_back(parts.getLights().isBeaconOn());
|
this->beaconLights.push_back(parts.getLights().isBeaconOn());
|
||||||
this->strobeLights.push_back(parts.getLights().isStrobeOn());
|
this->strobeLights.push_back(parts.getLights().isStrobeOn());
|
||||||
this->navLights.push_back(parts.getLights().isNavOn());
|
this->navLights.push_back(parts.getLights().isNavOn());
|
||||||
this->lightPatterns.push_back(0);
|
this->lightPatterns.push_back(0);
|
||||||
|
this->taxiLights.push_back(parts.getLights().isTaxiOn());
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList callsigns; //!< List of callsigns
|
QStringList callsigns; //!< List of callsigns
|
||||||
@@ -125,6 +125,7 @@ namespace BlackSimPlugin
|
|||||||
QList<bool> strobeLights; //!< List of strobeLights
|
QList<bool> strobeLights; //!< List of strobeLights
|
||||||
QList<bool> navLights; //!< List of navLights
|
QList<bool> navLights; //!< List of navLights
|
||||||
QList<int> lightPatterns; //!< List of lightPatterns
|
QList<int> lightPatterns; //!< List of lightPatterns
|
||||||
|
QList<bool> taxiLights; //!< List of taxi lights
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Plane Transponders
|
//! Plane Transponders
|
||||||
@@ -213,6 +214,12 @@ namespace BlackSimPlugin
|
|||||||
//! Set the position of multiple traffic aircrafts
|
//! Set the position of multiple traffic aircrafts
|
||||||
void setPlanesPositions(const BlackSimPlugin::Flightgear::PlanesPositions &planesPositions);
|
void setPlanesPositions(const BlackSimPlugin::Flightgear::PlanesPositions &planesPositions);
|
||||||
|
|
||||||
|
//! Set the surfaces of multiple traffic aircrafts
|
||||||
|
void setPlanesSurfaces(const BlackSimPlugin::Flightgear::PlanesSurfaces &planesSurfaces);
|
||||||
|
|
||||||
|
//! Set the transponders of multiple traffic aircrafts
|
||||||
|
void setPlanesTransponders(const BlackSimPlugin::Flightgear::PlanesTransponders &planesTransponders);
|
||||||
|
|
||||||
//! Get remote aircrafts data (lat, lon, elevation and CG)
|
//! Get remote aircrafts data (lat, lon, elevation and CG)
|
||||||
void getRemoteAircraftData(const QStringList &callsigns, const RemoteAircraftDataCallback &setter) const;
|
void getRemoteAircraftData(const QStringList &callsigns, const RemoteAircraftDataCallback &setter) const;
|
||||||
|
|
||||||
|
|||||||
@@ -170,8 +170,7 @@ namespace BlackSimPlugin
|
|||||||
{
|
{
|
||||||
PlanesSurfaces surfaces;
|
PlanesSurfaces surfaces;
|
||||||
surfaces.push_back(callsign, parts);
|
surfaces.push_back(callsign, parts);
|
||||||
//! \todo KB 2091-09 FG parts sending missing
|
m_trafficProxy->setPlanesSurfaces(surfaces);
|
||||||
// m_trafficProxy->setPlanesSurfaces(surfaces);
|
|
||||||
u++;
|
u++;
|
||||||
}
|
}
|
||||||
return u > 0;
|
return u > 0;
|
||||||
@@ -533,6 +532,15 @@ namespace BlackSimPlugin
|
|||||||
newRemoteAircraft.getAircraftIcaoCode().getDesignator(),
|
newRemoteAircraft.getAircraftIcaoCode().getDesignator(),
|
||||||
newRemoteAircraft.getAirlineIcaoCode().getDesignator(),
|
newRemoteAircraft.getAirlineIcaoCode().getDesignator(),
|
||||||
livery);
|
livery);
|
||||||
|
|
||||||
|
PlanesPositions pos;
|
||||||
|
pos.push_back(newRemoteAircraft.getSituation());
|
||||||
|
m_trafficProxy->setPlanesPositions(pos);
|
||||||
|
|
||||||
|
PlanesSurfaces surfaces;
|
||||||
|
surfaces.push_back(newRemoteAircraft.getCallsign(), newRemoteAircraft.getParts());
|
||||||
|
m_trafficProxy->setPlanesSurfaces(surfaces);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -623,23 +631,25 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
// interpolation for all remote aircraft
|
// interpolation for all remote aircraft
|
||||||
PlanesPositions planesPositions;
|
PlanesPositions planesPositions;
|
||||||
|
PlanesSurfaces planesSurfaces;
|
||||||
PlanesTransponders planesTransponders;
|
PlanesTransponders planesTransponders;
|
||||||
|
|
||||||
int aircraftNumber = 0;
|
int aircraftNumber = 0;
|
||||||
const bool updateAllAircraft = this->isUpdateAllRemoteAircraft(currentTimestamp);
|
const bool updateAllAircraft = this->isUpdateAllRemoteAircraft(currentTimestamp);
|
||||||
const CCallsignSet callsingsInRange = this->getAircraftInRangeCallsigns();
|
const CCallsignSet callsignsInRange = this->getAircraftInRangeCallsigns();
|
||||||
for (const CFlightgearMPAircraft &flightgearAircraft : m_flightgearAircraftObjects)
|
for (const CFlightgearMPAircraft &flightgearAircraft : m_flightgearAircraftObjects)
|
||||||
{
|
{
|
||||||
const CCallsign callsign(flightgearAircraft.getCallsign());
|
const CCallsign callsign(flightgearAircraft.getCallsign());
|
||||||
const bool hasCallsign = !callsign.isEmpty();
|
const bool hasCallsign = !callsign.isEmpty();
|
||||||
if (!hasCallsign)
|
if (!hasCallsign)
|
||||||
{
|
{
|
||||||
|
// does not make sense to continue here
|
||||||
BLACK_VERIFY_X(false, Q_FUNC_INFO, "missing callsign");
|
BLACK_VERIFY_X(false, Q_FUNC_INFO, "missing callsign");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip no longer in range
|
// skip no longer in range
|
||||||
if (!callsingsInRange.contains(callsign)) { continue; }
|
if (!callsignsInRange.contains(callsign)) { continue; }
|
||||||
|
|
||||||
planesTransponders.callsigns.push_back(callsign.asString());
|
planesTransponders.callsigns.push_back(callsign.asString());
|
||||||
planesTransponders.codes.push_back(flightgearAircraft.getAircraft().getTransponderCode());
|
planesTransponders.codes.push_back(flightgearAircraft.getAircraft().getTransponderCode());
|
||||||
@@ -660,15 +670,7 @@ namespace BlackSimPlugin
|
|||||||
if (updateAllAircraft || !this->isEqualLastSent(interpolatedSituation))
|
if (updateAllAircraft || !this->isEqualLastSent(interpolatedSituation))
|
||||||
{
|
{
|
||||||
this->rememberLastSent(interpolatedSituation);
|
this->rememberLastSent(interpolatedSituation);
|
||||||
planesPositions.callsigns.push_back(interpolatedSituation.getCallsign().asString());
|
planesPositions.push_back(interpolatedSituation);
|
||||||
planesPositions.latitudesDeg.push_back(interpolatedSituation.latitude().value(CAngleUnit::deg()));
|
|
||||||
planesPositions.longitudesDeg.push_back(interpolatedSituation.longitude().value(CAngleUnit::deg()));
|
|
||||||
planesPositions.altitudesFt.push_back(interpolatedSituation.getAltitude().value(CLengthUnit::ft()));
|
|
||||||
planesPositions.pitchesDeg.push_back(interpolatedSituation.getPitch().value(CAngleUnit::deg()));
|
|
||||||
planesPositions.rollsDeg.push_back(interpolatedSituation.getBank().value(CAngleUnit::deg()));
|
|
||||||
planesPositions.headingsDeg.push_back(interpolatedSituation.getHeading().value(CAngleUnit::deg()));
|
|
||||||
planesPositions.groundSpeedKts.push_back(interpolatedSituation.getGroundSpeed().value(CSpeedUnit::kts()));
|
|
||||||
planesPositions.onGrounds.push_back(interpolatedSituation.getOnGround() == CAircraftSituation::OnGround);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -676,17 +678,37 @@ namespace BlackSimPlugin
|
|||||||
CLogMessage(this).warning(this->getInvalidSituationLogMessage(callsign, result.getInterpolationStatus()));
|
CLogMessage(this).warning(this->getInvalidSituationLogMessage(callsign, result.getInterpolationStatus()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CAircraftParts parts(result);
|
||||||
|
if (result.getPartsStatus().isSupportingParts() || parts.getPartsDetails() == CAircraftParts::GuessedParts)
|
||||||
|
{
|
||||||
|
if (updateAllAircraft || !this->isEqualLastSent(parts, callsign))
|
||||||
|
{
|
||||||
|
this->rememberLastSent(parts, callsign);
|
||||||
|
planesSurfaces.push_back(flightgearAircraft.getCallsign(), parts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // all callsigns
|
} // all callsigns
|
||||||
|
|
||||||
|
if (!planesTransponders.isEmpty())
|
||||||
|
{
|
||||||
|
m_trafficProxy->setPlanesTransponders(planesTransponders);
|
||||||
|
}
|
||||||
|
|
||||||
if (!planesPositions.isEmpty())
|
if (!planesPositions.isEmpty())
|
||||||
{
|
{
|
||||||
if (CBuildConfig::isLocalDeveloperDebugBuild())
|
if (CBuildConfig::isLocalDeveloperDebugBuild())
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(planesPositions.hasSameSizes(), Q_FUNC_INFO, "Mismatching sizes");
|
BLACK_VERIFY_X(planesPositions.hasSameSizes(), Q_FUNC_INFO, "Mismatching sizes");
|
||||||
}
|
}
|
||||||
m_trafficProxy->setPlanesPositions(planesPositions);
|
m_trafficProxy->setPlanesPositions(planesPositions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! planesSurfaces.isEmpty())
|
||||||
|
{
|
||||||
|
m_trafficProxy->setPlanesSurfaces(planesSurfaces);
|
||||||
|
}
|
||||||
|
|
||||||
// stats
|
// stats
|
||||||
this->finishUpdateRemoteAircraftAndSetStatistics(currentTimestamp);
|
this->finishUpdateRemoteAircraftAndSetStatistics(currentTimestamp);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user