mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-03 16:25:54 +08:00
Ref T259, Ref T243 prepared sim.env.provider to request elevations
This commit is contained in:
@@ -922,7 +922,7 @@ namespace BlackCore
|
|||||||
CAircraftSituation correctedSituation(situation);
|
CAircraftSituation correctedSituation(situation);
|
||||||
if (!correctedSituation.hasGroundElevation() && !correctedSituation.canLikelySkipNearGroundInterpolation())
|
if (!correctedSituation.hasGroundElevation() && !correctedSituation.canLikelySkipNearGroundInterpolation())
|
||||||
{
|
{
|
||||||
const CElevationPlane ep = this->findClosestElevationWithinRange(correctedSituation, correctedSituation.getDistancePerTime(1000));
|
const CElevationPlane ep = this->findClosestElevationWithinRange(correctedSituation, correctedSituation.getDistancePerTime(1000), true);
|
||||||
correctedSituation.setGroundElevation(ep);
|
correctedSituation.setGroundElevation(ep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,14 @@ namespace BlackCore
|
|||||||
return setup;
|
return setup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ISimulator::requestElevation(const Geo::ICoordinateGeodetic &reference) const
|
||||||
|
{
|
||||||
|
if (this->isShuttingDown()) { return false; }
|
||||||
|
if (reference.isNull()) { return false; }
|
||||||
|
Q_UNUSED(reference);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void ISimulator::registerHelp()
|
void ISimulator::registerHelp()
|
||||||
{
|
{
|
||||||
if (CSimpleCommandParser::registered("BlackCore::ISimulator")) { return; }
|
if (CSimpleCommandParser::registered("BlackCore::ISimulator")) { return; }
|
||||||
@@ -56,11 +64,11 @@ namespace BlackCore
|
|||||||
QString ISimulator::statusToString(SimulatorStatus status)
|
QString ISimulator::statusToString(SimulatorStatus status)
|
||||||
{
|
{
|
||||||
QStringList s;
|
QStringList s;
|
||||||
if (status.testFlag(Unspecified)) s << "Unspecified";
|
if (status.testFlag(Unspecified)) { s << QStringLiteral("Unspecified"); }
|
||||||
if (status.testFlag(Disconnected)) s << "Disconnected";
|
if (status.testFlag(Disconnected)) { s << QStringLiteral("Disconnected"); }
|
||||||
if (status.testFlag(Connected)) s << "Connected";
|
if (status.testFlag(Connected)) { s << QStringLiteral("Connected"); }
|
||||||
if (status.testFlag(Simulating)) s << "Simulating";
|
if (status.testFlag(Simulating)) { s << QStringLiteral("Simulating"); }
|
||||||
if (status.testFlag(Paused)) s << "Paused";
|
if (status.testFlag(Paused)) { s << QStringLiteral("Paused"); }
|
||||||
return s.join(", ");
|
return s.join(", ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -180,6 +180,10 @@ namespace BlackCore
|
|||||||
//! Is overall (swift) application shutting down
|
//! Is overall (swift) application shutting down
|
||||||
virtual bool isShuttingDown() const = 0;
|
virtual bool isShuttingDown() const = 0;
|
||||||
|
|
||||||
|
//! \copydoc BlackMisc::Simulation::ISimulationEnvironmentProvider::requestElevation
|
||||||
|
//! \remark needs to be overridden if the concrete driver supports such an option
|
||||||
|
virtual bool requestElevation(const BlackMisc::Geo::ICoordinateGeodetic &reference) const override;
|
||||||
|
|
||||||
//! \copydoc BlackMisc::IProvider::asQObject
|
//! \copydoc BlackMisc::IProvider::asQObject
|
||||||
virtual QObject *asQObject() override { return this; }
|
virtual QObject *asQObject() override { return this; }
|
||||||
|
|
||||||
|
|||||||
@@ -91,14 +91,21 @@ namespace BlackMisc
|
|||||||
return delta;
|
return delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
CElevationPlane ISimulationEnvironmentProvider::findClosestElevationWithinRange(const ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range) const
|
CElevationPlane ISimulationEnvironmentProvider::findClosestElevationWithinRange(const ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range, bool autoRequest) const
|
||||||
{
|
{
|
||||||
const CCoordinateGeodetic coordinate = this->getElevationCoordinates().findClosestWithinRange(reference, minRange(range));
|
const CCoordinateGeodetic coordinate = this->getElevationCoordinates().findClosestWithinRange(reference, minRange(range));
|
||||||
const bool found = !coordinate.isNull();
|
const bool found = !coordinate.isNull();
|
||||||
{
|
{
|
||||||
QWriteLocker l{&m_lockElvCoordinates };
|
QWriteLocker l{&m_lockElvCoordinates };
|
||||||
if (found) { m_elvFound++; }
|
if (found)
|
||||||
else { m_elvMissed++; }
|
{
|
||||||
|
m_elvFound++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_elvMissed++;
|
||||||
|
if (autoRequest) { this->requestElevation(reference); }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return CElevationPlane(coordinate, reference); // plane with radis = distance to reference
|
return CElevationPlane(coordinate, reference); // plane with radis = distance to reference
|
||||||
}
|
}
|
||||||
@@ -189,10 +196,16 @@ namespace BlackMisc
|
|||||||
this->clearCGs();
|
this->clearCGs();
|
||||||
}
|
}
|
||||||
|
|
||||||
CElevationPlane CSimulationEnvironmentAware::findClosestElevationWithinRange(const ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range) const
|
CElevationPlane CSimulationEnvironmentAware::findClosestElevationWithinRange(const ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range, bool autoRequest) const
|
||||||
{
|
{
|
||||||
if (!this->hasProvider()) { return CElevationPlane::null(); }
|
if (!this->hasProvider()) { return CElevationPlane::null(); }
|
||||||
return this->provider()->findClosestElevationWithinRange(reference, range);
|
return this->provider()->findClosestElevationWithinRange(reference, range, autoRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CSimulationEnvironmentAware::requestElevation(const ICoordinateGeodetic &reference) const
|
||||||
|
{
|
||||||
|
if (!this->hasProvider()) { return false; }
|
||||||
|
return this->provider()->requestElevation(reference);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPair<int, int> CSimulationEnvironmentAware::getElevationsFoundMissed() const
|
QPair<int, int> CSimulationEnvironmentAware::getElevationsFoundMissed() const
|
||||||
|
|||||||
@@ -38,7 +38,11 @@ namespace BlackMisc
|
|||||||
|
|
||||||
//! Find closest elevation
|
//! Find closest elevation
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
Geo::CElevationPlane findClosestElevationWithinRange(const Geo::ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range) const;
|
Geo::CElevationPlane findClosestElevationWithinRange(const Geo::ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range, bool autoRequest = false) const;
|
||||||
|
|
||||||
|
//! Request elevation, there is no guaranteed the requested elevation will be available in the provider
|
||||||
|
//! \threadsafe
|
||||||
|
virtual bool requestElevation(const Geo::ICoordinateGeodetic &reference) const = 0;
|
||||||
|
|
||||||
//! Elevations found/missed statistics
|
//! Elevations found/missed statistics
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
@@ -142,7 +146,10 @@ namespace BlackMisc
|
|||||||
void setSimulationEnvironmentProvider(ISimulationEnvironmentProvider *provider) { this->setProvider(provider); }
|
void setSimulationEnvironmentProvider(ISimulationEnvironmentProvider *provider) { this->setProvider(provider); }
|
||||||
|
|
||||||
//! \copydoc ISimulationEnvironmentProvider::findClosestElevationWithinRange
|
//! \copydoc ISimulationEnvironmentProvider::findClosestElevationWithinRange
|
||||||
Geo::CElevationPlane findClosestElevationWithinRange(const Geo::ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range) const;
|
Geo::CElevationPlane findClosestElevationWithinRange(const Geo::ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range, bool autoRequest = false) const;
|
||||||
|
|
||||||
|
//! \copydoc ISimulationEnvironmentProvider::findClosestElevationWithinRange
|
||||||
|
bool requestElevation(const Geo::ICoordinateGeodetic &reference) const;
|
||||||
|
|
||||||
//! \copydoc ISimulationEnvironmentProvider::getElevationsFoundMissed
|
//! \copydoc ISimulationEnvironmentProvider::getElevationsFoundMissed
|
||||||
QPair<int, int> getElevationsFoundMissed() const;
|
QPair<int, int> getElevationsFoundMissed() const;
|
||||||
|
|||||||
@@ -112,6 +112,12 @@ namespace BlackSimPlugin
|
|||||||
m_watcher = nullptr;
|
m_watcher = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CSimulatorXPlane::requestElevation(const Geo::ICoordinateGeodetic &reference) const
|
||||||
|
{
|
||||||
|
//! \todo KB 2018-04 implement a function fetching the probe value (async) and write it back to provider
|
||||||
|
return ISimulator::requestElevation(reference);
|
||||||
|
}
|
||||||
|
|
||||||
// convert xplane squawk mode to swift squawk mode
|
// convert xplane squawk mode to swift squawk mode
|
||||||
CTransponder::TransponderMode xpdrMode(int xplaneMode, bool ident)
|
CTransponder::TransponderMode xpdrMode(int xplaneMode, bool ident)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -104,6 +104,9 @@ namespace BlackSimPlugin
|
|||||||
virtual void unload() override;
|
virtual void unload() override;
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
|
//! \copydoc BlackMisc::Simulation::ISimulationEnvironmentProvider::requestElevation
|
||||||
|
virtual bool requestElevation(const BlackMisc::Geo::ICoordinateGeodetic &reference) const 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