mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 01:45:38 +08:00
Ref T683, "updateOwnSituationAndGroundElevation"
* function to use own positions "on ground" to calculate ground elevation * use this based on settings * adjusted simulators code
This commit is contained in:
committed by
Mat Sutcliffe
parent
fc2f7b4a12
commit
0360704b0b
@@ -1100,6 +1100,39 @@ namespace BlackCore
|
||||
// can be overridden
|
||||
}
|
||||
|
||||
bool ISimulator::updateOwnSituationAndGroundElevation(const CAircraftSituation &situation)
|
||||
{
|
||||
const bool updated = this->updateOwnSituation(situation);
|
||||
|
||||
// do not use every situation, but every deltaMs and only on ground
|
||||
constexpr qint64 deltaMs = 5000;
|
||||
if (situation.isOnGround() && situation.getTimeDifferenceAbsMs(m_lastRecordedGndElevationMs) > deltaMs)
|
||||
{
|
||||
m_lastRecordedGndElevationMs = situation.getMSecsSinceEpoch();
|
||||
const CSimulatorSettings settings = m_multiSettings.getSettings(this->getSimulatorInfo());
|
||||
if (settings.isRecordOwnAircraftGnd())
|
||||
{
|
||||
const CSimulatedAircraft ownAircraft = this->getOwnAircraft();
|
||||
CAltitude elevation = situation.getGroundElevation();
|
||||
if (elevation.isNull())
|
||||
{
|
||||
const CLength cg = ownAircraft.getModel().getCG();
|
||||
elevation = (cg.isNull() || situation.getAltitude().isNull()) ? CAltitude::null() : (situation.getAltitude().withOffset(cg * -1.0));
|
||||
}
|
||||
|
||||
if (!elevation.isNull())
|
||||
{
|
||||
const CCallsign cs = situation.hasCallsign() ? situation.getCallsign() : ownAircraft.getCallsign();
|
||||
const CLength radius = settings.getRecordedGndRadius().isNull() ? CElevationPlane::singlePointRadius() : settings.getRecordedGndRadius();
|
||||
const CElevationPlane ep(situation, radius);
|
||||
const bool remembered = this->rememberGroundElevation(cs, ep, radius);
|
||||
Q_UNUSED(remembered); // false means it was already in that cache, or something else is wrong
|
||||
}
|
||||
}
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
|
||||
CAircraftModelList ISimulator::getModelSet() const
|
||||
{
|
||||
const CSimulatorInfo simulator = this->getSimulatorInfo();
|
||||
|
||||
@@ -431,6 +431,7 @@ namespace BlackCore
|
||||
virtual int physicallyRemoveAllRemoteAircraft();
|
||||
|
||||
//! Set elevation and CG in the providers and for auto publishing
|
||||
//! \sa ISimulator::updateOwnSituationAndGroundElevation
|
||||
void rememberElevationAndSimulatorCG(const BlackMisc::Aviation::CCallsign &callsign, const QString &modelString, const BlackMisc::Geo::CElevationPlane &elevation, const BlackMisc::PhysicalQuantities::CLength &simulatorCG);
|
||||
|
||||
//! Emit the combined status
|
||||
@@ -535,6 +536,9 @@ namespace BlackCore
|
||||
//! Own model has been changed
|
||||
virtual void onOwnModelChanged(const BlackMisc::Simulation::CAircraftModel &newModel);
|
||||
|
||||
//! Update own aircraft position and if suitable use it to update ground elevation
|
||||
bool updateOwnSituationAndGroundElevation(const BlackMisc::Aviation::CAircraftSituation &situation);
|
||||
|
||||
//! Get the model set
|
||||
BlackMisc::Simulation::CAircraftModelList getModelSet() const;
|
||||
|
||||
@@ -554,6 +558,7 @@ namespace BlackCore
|
||||
qint64 m_statsUpdateAircraftTimeTotalMs = 0; //!< statistics total update time
|
||||
qint64 m_statsCurrentUpdateTimeMs = 0; //!< statistics current update time
|
||||
qint64 m_statsMaxUpdateTimeMs = 0; //!< statistics max.update time
|
||||
qint64 m_lastRecordedGndElevationMs = 0; //!< when gnd.elevation was last modified
|
||||
qint64 m_statsLastUpdateAircraftRequestedMs = 0; //!< when was the last aircraft update requested
|
||||
qint64 m_statsUpdateAircraftRequestedDeltaMs = 0; //!< delta time between 2 aircraft updates
|
||||
|
||||
|
||||
Reference in New Issue
Block a user