mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-23 13:55:36 +08:00
Clean up traffic module
This commit is contained in:
committed by
Mat Sutcliffe
parent
decf9222ad
commit
aea2f11b42
@@ -64,36 +64,6 @@ namespace BlackSimPlugin
|
|||||||
m_dbusInterface->callDBus(QLatin1String("cleanup"));
|
m_dbusInterface->callDBus(QLatin1String("cleanup"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CFGSwiftBusTrafficProxy::loadPlanesPackage(const QString &path)
|
|
||||||
{
|
|
||||||
return m_dbusInterface->callDBusRet<bool>(QLatin1String("loadPlanesPackage"), path);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CFGSwiftBusTrafficProxy::setDefaultIcao(const QString &defaultIcao)
|
|
||||||
{
|
|
||||||
m_dbusInterface->callDBus(QLatin1String("setDefaultIcao"), defaultIcao);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CFGSwiftBusTrafficProxy::setDrawingLabels(bool drawing)
|
|
||||||
{
|
|
||||||
m_dbusInterface->callDBus(QLatin1String("setDrawingLabels"), drawing);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CFGSwiftBusTrafficProxy::isDrawingLabels() const
|
|
||||||
{
|
|
||||||
return m_dbusInterface->callDBusRet<bool>(QLatin1String("isDrawingLabels"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void CFGSwiftBusTrafficProxy::setMaxPlanes(int planes)
|
|
||||||
{
|
|
||||||
m_dbusInterface->callDBus(QLatin1String("setMaxPlanes"), planes);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CFGSwiftBusTrafficProxy::setMaxDrawDistance(double nauticalMiles)
|
|
||||||
{
|
|
||||||
m_dbusInterface->callDBus(QLatin1String("setMaxDrawDistance"), nauticalMiles);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CFGSwiftBusTrafficProxy::addPlane(const QString &callsign, const QString &modelName, const QString &aircraftIcao, const QString &airlineIcao, const QString &livery)
|
void CFGSwiftBusTrafficProxy::addPlane(const QString &callsign, const QString &modelName, const QString &aircraftIcao, const QString &airlineIcao, const QString &livery)
|
||||||
{
|
{
|
||||||
m_dbusInterface->callDBus(QLatin1String("addPlane"), callsign, modelName, aircraftIcao, airlineIcao, livery);
|
m_dbusInterface->callDBus(QLatin1String("addPlane"), callsign, modelName, aircraftIcao, airlineIcao, livery);
|
||||||
@@ -117,18 +87,6 @@ namespace BlackSimPlugin
|
|||||||
planesPositions.headingsDeg, planesPositions.onGrounds);
|
planesPositions.headingsDeg, planesPositions.onGrounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFGSwiftBusTrafficProxy::setPlanesTransponders(const PlanesTransponders &planesTransponders)
|
|
||||||
{
|
|
||||||
m_dbusInterface->callDBus(QLatin1String("setPlanesTransponders"),
|
|
||||||
planesTransponders.callsigns, planesTransponders.codes,
|
|
||||||
planesTransponders.modeCs, planesTransponders.idents);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CFGSwiftBusTrafficProxy::setInterpolatorMode(const QString &callsign, bool spline)
|
|
||||||
{
|
|
||||||
m_dbusInterface->callDBus(QLatin1String("setInterpolatorMode"), callsign, spline);
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
||||||
@@ -147,31 +105,5 @@ namespace BlackSimPlugin
|
|||||||
};
|
};
|
||||||
m_dbusInterface->callDBusAsync(QLatin1String("getRemoteAircraftData"), callback, callsigns);
|
m_dbusInterface->callDBusAsync(QLatin1String("getRemoteAircraftData"), callback, callsigns);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFGSwiftBusTrafficProxy::getElevationAtPosition(const CCallsign &callsign, double latitudeDeg, double longitudeDeg, double altitudeMeters,
|
|
||||||
const ElevationCallback &setter) const
|
|
||||||
{
|
|
||||||
std::function<void(QDBusPendingCallWatcher *)> callback = [ = ](QDBusPendingCallWatcher * watcher)
|
|
||||||
{
|
|
||||||
QDBusPendingReply<QString, double> reply = *watcher;
|
|
||||||
if (!reply.isError())
|
|
||||||
{
|
|
||||||
const CCallsign cs(reply.argumentAt<0>());
|
|
||||||
const double elevationMeters = reply.argumentAt<1>();
|
|
||||||
const CAltitude elevationAlt(elevationMeters, CLengthUnit::m(), CLengthUnit::ft());
|
|
||||||
const CElevationPlane elevation(CLatitude(latitudeDeg, CAngleUnit::deg()),
|
|
||||||
CLongitude(longitudeDeg, CAngleUnit::deg()),
|
|
||||||
elevationAlt, CElevationPlane::singlePointRadius());
|
|
||||||
setter(elevation, cs);
|
|
||||||
}
|
|
||||||
watcher->deleteLater();
|
|
||||||
};
|
|
||||||
m_dbusInterface->callDBusAsync(QLatin1String("getElevationAtPosition"), callback, callsign.asString(), latitudeDeg, longitudeDeg, altitudeMeters);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CFGSwiftBusTrafficProxy::setFollowedAircraft(const QString &callsign)
|
|
||||||
{
|
|
||||||
m_dbusInterface->callDBus(QLatin1String("setFollowedAircraft"), callsign);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -162,24 +162,6 @@ namespace BlackSimPlugin
|
|||||||
//! Reverse the actions of initialize().
|
//! Reverse the actions of initialize().
|
||||||
void cleanup();
|
void cleanup();
|
||||||
|
|
||||||
//! Load a collection of planes from the given directory and return true if successful
|
|
||||||
bool loadPlanesPackage(const QString &path);
|
|
||||||
|
|
||||||
//! Set the ICAO code to use for aircraft without a model match
|
|
||||||
void setDefaultIcao(const QString &defaultIcao);
|
|
||||||
|
|
||||||
//! Set whether the plugin draws type and callsign labels above aircraft
|
|
||||||
void setDrawingLabels(bool drawing);
|
|
||||||
|
|
||||||
//! Get whether the plugin draws type and callsign labels above aircraft
|
|
||||||
bool isDrawingLabels() const;
|
|
||||||
|
|
||||||
//! Set the maximum number of aircraft.
|
|
||||||
void setMaxPlanes(int planes);
|
|
||||||
|
|
||||||
//! Set the maximum distance at which to draw aircraft (nautical miles).
|
|
||||||
void setMaxDrawDistance(double nauticalMiles);
|
|
||||||
|
|
||||||
//! Introduce a new traffic aircraft
|
//! Introduce a new traffic aircraft
|
||||||
void addPlane(const QString &callsign, const QString &modelName, const QString &aircraftIcao, const QString &airlineIcao, const QString &livery);
|
void addPlane(const QString &callsign, const QString &modelName, const QString &aircraftIcao, const QString &airlineIcao, const QString &livery);
|
||||||
|
|
||||||
@@ -192,21 +174,9 @@ 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 transponder of multiple traffic aircraft
|
|
||||||
void setPlanesTransponders(const BlackSimPlugin::Flightgear::PlanesTransponders &planesTransponders);
|
|
||||||
|
|
||||||
//! Set interpolator mode
|
|
||||||
void setInterpolatorMode(const QString &callsign, bool spline);
|
|
||||||
|
|
||||||
//! 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;
|
||||||
|
|
||||||
//! Get the ground elevation at an arbitrary position
|
|
||||||
void getElevationAtPosition(const BlackMisc::Aviation::CCallsign &callsign, double latitudeDeg, double longitudeDeg, double altitudeMeters,
|
|
||||||
const ElevationCallback &setter) const;
|
|
||||||
|
|
||||||
//! Sets the aircraft with callsign to be followed in plane view
|
|
||||||
void setFollowedAircraft(const QString &callsign);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BlackMisc::CGenericDBusInterface *m_dbusInterface = nullptr;
|
BlackMisc::CGenericDBusInterface *m_dbusInterface = nullptr;
|
||||||
|
|||||||
@@ -155,36 +155,6 @@ namespace BlackSimPlugin
|
|||||||
CSimulatorPluginCommon::clearAllRemoteAircraftData();
|
CSimulatorPluginCommon::clearAllRemoteAircraftData();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSimulatorFlightgear::requestElevation(const ICoordinateGeodetic &reference, const CCallsign &callsign)
|
|
||||||
{
|
|
||||||
if (this->isShuttingDownOrDisconnected()) { return false; }
|
|
||||||
if (reference.isNull()) { return false; }
|
|
||||||
|
|
||||||
CCoordinateGeodetic pos(reference);
|
|
||||||
if (!pos.hasMSLGeodeticHeight())
|
|
||||||
{
|
|
||||||
// testing showed: height has an influence on the returned result
|
|
||||||
// - the most accurate value seems to be returned if the height is close to the elevation
|
|
||||||
// - in normal scenarios there is no much difference of the results if 0 is used
|
|
||||||
// - in Lukla (9200ft MSL) the difference between 0 and 9200 is around 1ft
|
|
||||||
// - in the LOWW scenario using 50000ft MSL results in around 3ft too low elevation
|
|
||||||
static const CAltitude alt(0, CAltitude::MeanSeaLevel, CLengthUnit::ft());
|
|
||||||
pos.setGeodeticHeight(alt);
|
|
||||||
}
|
|
||||||
|
|
||||||
using namespace std::placeholders;
|
|
||||||
auto callback = std::bind(&CSimulatorFlightgear::callbackReceivedRequestedElevation, this, _1, _2);
|
|
||||||
|
|
||||||
// Request
|
|
||||||
m_trafficProxy->getElevationAtPosition(callsign,
|
|
||||||
pos.latitude().value(CAngleUnit::deg()),
|
|
||||||
pos.longitude().value(CAngleUnit::deg()),
|
|
||||||
pos.geodeticHeight().value(CLengthUnit::m()),
|
|
||||||
callback);
|
|
||||||
emit this->requestedElevation(callsign);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// convert flightgear squawk mode to swift squawk mode
|
// convert flightgear squawk mode to swift squawk mode
|
||||||
CTransponder::TransponderMode xpdrMode(int xplaneMode, bool ident)
|
CTransponder::TransponderMode xpdrMode(int xplaneMode, bool ident)
|
||||||
{
|
{
|
||||||
@@ -594,13 +564,6 @@ namespace BlackSimPlugin
|
|||||||
return this->getAircraftInRange().findByRendered(true).getCallsigns(); // just a poor workaround
|
return this->getAircraftInRange().findByRendered(true).getCallsigns(); // just a poor workaround
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSimulatorFlightgear::followAircraft(const CCallsign &callsign)
|
|
||||||
{
|
|
||||||
if (! m_trafficProxy || ! m_trafficProxy->isValid()) { return false; }
|
|
||||||
m_trafficProxy->setFollowedAircraft(callsign.toQString());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSimulatorFlightgear::updateRemoteAircraft()
|
void CSimulatorFlightgear::updateRemoteAircraft()
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "thread");
|
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "thread");
|
||||||
@@ -659,11 +622,6 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
} // all callsigns
|
} // all callsigns
|
||||||
|
|
||||||
if (!planesTransponders.isEmpty())
|
|
||||||
{
|
|
||||||
m_trafficProxy->setPlanesTransponders(planesTransponders);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!planesPositions.isEmpty())
|
if (!planesPositions.isEmpty())
|
||||||
{
|
{
|
||||||
if (CBuildConfig::isLocalDeveloperDebugBuild())
|
if (CBuildConfig::isLocalDeveloperDebugBuild())
|
||||||
|
|||||||
@@ -131,16 +131,12 @@ namespace BlackSimPlugin
|
|||||||
virtual BlackMisc::PhysicalQuantities::CTime getTimeSynchronizationOffset() const override { return BlackMisc::PhysicalQuantities::CTime(0, BlackMisc::PhysicalQuantities::CTimeUnit::hrmin()); }
|
virtual BlackMisc::PhysicalQuantities::CTime getTimeSynchronizationOffset() const override { return BlackMisc::PhysicalQuantities::CTime(0, BlackMisc::PhysicalQuantities::CTimeUnit::hrmin()); }
|
||||||
virtual bool isPhysicallyRenderedAircraft(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
virtual bool isPhysicallyRenderedAircraft(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
||||||
virtual BlackMisc::Aviation::CCallsignSet physicallyRenderedAircraft() const override;
|
virtual BlackMisc::Aviation::CCallsignSet physicallyRenderedAircraft() const override;
|
||||||
virtual bool followAircraft(const BlackMisc::Aviation::CCallsign &callsign) override;
|
|
||||||
virtual void unload() override;
|
virtual void unload() override;
|
||||||
virtual QString getStatisticsSimulatorSpecific() const override;
|
virtual QString getStatisticsSimulatorSpecific() const override;
|
||||||
virtual void resetAircraftStatistics() override;
|
virtual void resetAircraftStatistics() override;
|
||||||
virtual BlackMisc::CStatusMessageList getInterpolationMessages(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
virtual BlackMisc::CStatusMessageList getInterpolationMessages(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
//! \copydoc BlackMisc::Simulation::ISimulationEnvironmentProvider::requestElevation
|
|
||||||
virtual bool requestElevation(const BlackMisc::Geo::ICoordinateGeodetic &reference, const BlackMisc::Aviation::CCallsign &callsign) override;
|
|
||||||
|
|
||||||
//! Creates an appropriate dbus connection from the string describing it
|
//! Creates an appropriate dbus connection from the string describing it
|
||||||
static QDBusConnection connectionFromString(const QString &str);
|
static QDBusConnection connectionFromString(const QString &str);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user