mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 00:16:51 +08:00
refactor: Move OnGround information to own class
This commit is contained in:
@@ -361,9 +361,9 @@ namespace BlackMisc::Simulation
|
||||
u"<td class=\"cur\">" % log.situationCurrent.getGroundElevation().valueRoundedWithUnit(ft, 1) % u" " % log.situationCurrent.getGroundElevationInfoAsString() % u"</td>" %
|
||||
|
||||
u"<td>" % QString::number(log.groundFactor) % u"</td>" %
|
||||
u"<td class=\"old\">" % situationOld.getOnGroundInfo() % u"</td>" %
|
||||
u"<td class=\"new\">" % situationNew.getOnGroundInfo() % u"</td>" %
|
||||
u"<td class=\"cur\">" % log.situationCurrent.getOnGroundInfo() % u"</td>" %
|
||||
u"<td class=\"old\">" % situationOld.getOnGroundInfo().toQString() % u"</td>" %
|
||||
u"<td class=\"new\">" % situationNew.getOnGroundInfo().toQString() % u"</td>" %
|
||||
u"<td class=\"cur\">" % log.situationCurrent.getOnGroundInfo().toQString() % u"</td>" %
|
||||
|
||||
// tableRows +=
|
||||
u"<td>" % log.cgAboveGround.valueRoundedWithUnit(ft, 0) % u"</td>" %
|
||||
|
||||
@@ -74,14 +74,6 @@ namespace BlackMisc::Simulation
|
||||
return cg;
|
||||
}
|
||||
|
||||
template <typename Derived>
|
||||
double CInterpolator<Derived>::groundInterpolationFactor()
|
||||
{
|
||||
// done here so we can change value without "larfer" recompilations
|
||||
static constexpr double f = 0.95;
|
||||
return f;
|
||||
}
|
||||
|
||||
template <typename Derived>
|
||||
CAircraftSituationList CInterpolator<Derived>::remoteAircraftSituationsAndChange(const CInterpolationAndRenderingSetupPerCallsign &setup)
|
||||
{
|
||||
@@ -181,10 +173,10 @@ namespace BlackMisc::Simulation
|
||||
if (setup.isNull() || !setup.isAircraftPartsEnabled()) { return sorted; }
|
||||
|
||||
bool details = false;
|
||||
if (situations.containsOnGroundDetails(CAircraftSituation::InFromParts))
|
||||
if (situations.containsOnGroundDetails(COnGroundInfo::InFromParts))
|
||||
{
|
||||
// if a client supports parts, all ground situations are supposed to be parts based
|
||||
details = situations.areAllOnGroundDetailsSame(CAircraftSituation::InFromParts);
|
||||
details = situations.areAllOnGroundDetailsSame(COnGroundInfo::InFromParts);
|
||||
BLACK_VERIFY_X(details, Q_FUNC_INFO, "Once gnd.from parts -> always gnd. from parts");
|
||||
}
|
||||
|
||||
@@ -300,7 +292,7 @@ namespace BlackMisc::Simulation
|
||||
}
|
||||
|
||||
// correct altitude itself
|
||||
if (!interpolateGndFlag && currentSituation.getOnGroundDetails() != CAircraftSituation::OnGroundByGuessing)
|
||||
if (!interpolateGndFlag && currentSituation.getOnGroundInfo().getGroundDetails() != COnGroundInfo::OnGroundByGuessing)
|
||||
{
|
||||
// just in case
|
||||
altCorrection = currentSituation.correctAltitude(true); // we have CG set
|
||||
@@ -377,7 +369,7 @@ namespace BlackMisc::Simulation
|
||||
{
|
||||
log.tsCurrent = m_currentTimeMsSinceEpoch;
|
||||
log.callsign = m_callsign;
|
||||
log.groundFactor = currentSituation.getOnGroundFactor();
|
||||
log.groundFactor = currentSituation.getOnGroundInfo().getGroundFactor();
|
||||
log.altCorrection = CAircraftSituation::altitudeCorrectionToString(altCorrection);
|
||||
log.situationCurrent = currentSituation;
|
||||
log.interpolantRecalc = interpolant.isRecalculated();
|
||||
@@ -524,7 +516,7 @@ namespace BlackMisc::Simulation
|
||||
CLength guessedCG = model.getCG();
|
||||
model.getAircraftIcaoCode().guessModelParameters(guessedCG, guessedVRotate);
|
||||
|
||||
if (situation.getOnGroundDetails() != CAircraftSituation::NotSetGroundDetails)
|
||||
if (situation.getOnGroundInfo().getGroundDetails() != COnGroundInfo::NotSetGroundDetails)
|
||||
{
|
||||
do
|
||||
{
|
||||
@@ -613,10 +605,10 @@ namespace BlackMisc::Simulation
|
||||
}
|
||||
else
|
||||
{
|
||||
if (situation.getOnGroundDetails() != CAircraftSituation::NotSetGroundDetails)
|
||||
if (situation.getOnGroundInfo().getGroundDetails() != COnGroundInfo::NotSetGroundDetails)
|
||||
{
|
||||
// we have no ground elevation but a ground info
|
||||
if (situation.getOnGroundDetails() == CAircraftSituation::OnGroundByGuessing)
|
||||
if (situation.getOnGroundInfo().getGroundDetails() == COnGroundInfo::OnGroundByGuessing)
|
||||
{
|
||||
// should be OK
|
||||
if (details) { *details = QStringLiteral("on ground, no elv."); }
|
||||
|
||||
@@ -113,10 +113,6 @@ namespace BlackMisc::Simulation
|
||||
//! Do logging
|
||||
bool doLogging() const;
|
||||
|
||||
//! Decides threshold when situation is considered on ground
|
||||
//! \sa BlackMisc::Aviation::CAircraftSituation::setOnGroundFromGroundFactorFromInterpolation
|
||||
static double groundInterpolationFactor();
|
||||
|
||||
const Aviation::CCallsign m_callsign; //!< corresponding callsign
|
||||
CAircraftModel m_model; //!< corresponding model (required for CG)
|
||||
|
||||
|
||||
@@ -84,21 +84,20 @@ namespace BlackMisc::Simulation
|
||||
|
||||
if (interpolateGndFactor)
|
||||
{
|
||||
const double startGroundFactor = m_startSituation.getOnGroundFactor();
|
||||
const double endGroundFactor = m_endSituation.getOnGroundFactor();
|
||||
const double startGroundFactor = m_startSituation.getOnGroundInfo().getGroundFactor();
|
||||
const double endGroundFactor = m_endSituation.getOnGroundInfo().getGroundFactor();
|
||||
if (CAircraftSituation::isGfEqualAirborne(startGroundFactor, endGroundFactor))
|
||||
{
|
||||
interpolatedSituation.setOnGround(false);
|
||||
interpolatedSituation.setOnGroundInfo({ COnGroundInfo::NotOnGround, COnGroundInfo::OnGroundByInterpolation });
|
||||
}
|
||||
else if (CAircraftSituation::isGfEqualOnGround(startGroundFactor, endGroundFactor))
|
||||
{
|
||||
interpolatedSituation.setOnGround(true);
|
||||
interpolatedSituation.setOnGroundInfo({ COnGroundInfo::OnGround, COnGroundInfo::OnGroundByInterpolation });
|
||||
}
|
||||
else
|
||||
{
|
||||
const double interpolatedGroundFactor = (endGroundFactor - startGroundFactor) * tf + startGroundFactor;
|
||||
interpolatedSituation.setOnGroundFactor(interpolatedGroundFactor);
|
||||
interpolatedSituation.setOnGroundFromGroundFactorFromInterpolation(groundInterpolationFactor());
|
||||
interpolatedSituation.setOnGroundInfo(COnGroundInfo(interpolatedGroundFactor));
|
||||
}
|
||||
}
|
||||
return interpolatedSituation;
|
||||
|
||||
@@ -218,7 +218,7 @@ namespace BlackMisc::Simulation
|
||||
const double a1 = m_s[1].getCorrectedAltitude(cg).value(altUnit);
|
||||
const double a2 = m_s[2].getCorrectedAltitude(cg).value(altUnit); // latest
|
||||
pa.a = { { a0, a1, a2 } };
|
||||
pa.gnd = { { m_s[0].getOnGroundFactor(), m_s[1].getOnGroundFactor(), m_s[2].getOnGroundFactor() } };
|
||||
pa.gnd = { { m_s[0].getOnGroundInfo().getGroundFactor(), m_s[1].getOnGroundInfo().getGroundFactor(), m_s[2].getOnGroundInfo().getGroundFactor() } };
|
||||
pa.da = getDerivatives(pa.t, pa.a);
|
||||
pa.dgnd = getDerivatives(pa.t, pa.gnd);
|
||||
|
||||
@@ -365,24 +365,20 @@ namespace BlackMisc::Simulation
|
||||
{
|
||||
const double gnd1 = m_pa.gnd[1];
|
||||
const double gnd2 = m_pa.gnd[2]; // latest
|
||||
do
|
||||
|
||||
if (CAircraftSituation::isGfEqualAirborne(gnd1, gnd2))
|
||||
{
|
||||
newSituation.setOnGroundDetails(CAircraftSituation::OnGroundByInterpolation);
|
||||
if (CAircraftSituation::isGfEqualAirborne(gnd1, gnd2))
|
||||
{
|
||||
newSituation.setOnGround(false);
|
||||
break;
|
||||
}
|
||||
if (CAircraftSituation::isGfEqualOnGround(gnd1, gnd2))
|
||||
{
|
||||
newSituation.setOnGround(true);
|
||||
break;
|
||||
}
|
||||
const double newGnd = evalSplineInterval(m_currentTimeMsSinceEpoc, t1, t2, gnd1, gnd2, m_pa.dgnd[1], m_pa.dgnd[2]);
|
||||
newSituation.setOnGroundFactor(newGnd);
|
||||
newSituation.setOnGroundFromGroundFactorFromInterpolation(groundInterpolationFactor());
|
||||
newSituation.setOnGroundInfo({ COnGroundInfo::NotOnGround, COnGroundInfo::OnGroundByInterpolation });
|
||||
}
|
||||
else if (CAircraftSituation::isGfEqualOnGround(gnd1, gnd2))
|
||||
{
|
||||
newSituation.setOnGroundInfo({ COnGroundInfo::OnGround, COnGroundInfo::OnGroundByInterpolation });
|
||||
}
|
||||
else
|
||||
{
|
||||
const double newGnd = evalSplineInterval(m_currentTimeMsSinceEpoc, t1, t2, gnd1, gnd2, m_pa.dgnd[1], m_pa.dgnd[2]);
|
||||
newSituation.setOnGroundInfo(COnGroundInfo(newGnd));
|
||||
}
|
||||
while (false);
|
||||
}
|
||||
return newSituation;
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ namespace BlackMisc::Simulation
|
||||
// unify all inbound ground information
|
||||
if (situation.hasInboundGroundDetails())
|
||||
{
|
||||
newSituationsList.setOnGroundDetails(situation.getOnGroundDetails());
|
||||
newSituationsList.setOnGroundDetails(situation.getOnGroundInfo().getGroundDetails());
|
||||
}
|
||||
}
|
||||
m_latestSituationByCallsign[cs] = situationCorrected;
|
||||
|
||||
Reference in New Issue
Block a user