mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-18 03:15:34 +08:00
refactor: Move spline specific verification method to InterpolatorSpline
This commit is contained in:
@@ -153,43 +153,6 @@ namespace BlackMisc::Simulation
|
|||||||
this->initCorrespondingModel();
|
this->initCorrespondingModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CInterpolator::verifyInterpolationSituations(const CAircraftSituation &oldest, const CAircraftSituation &newer, const CAircraftSituation &latest, const CInterpolationAndRenderingSetupPerCallsign &setup)
|
|
||||||
{
|
|
||||||
if (!CBuildConfig::isLocalDeveloperDebugBuild()) { return true; }
|
|
||||||
CAircraftSituationList situations;
|
|
||||||
|
|
||||||
// oldest last, null ignored
|
|
||||||
if (!latest.isNull()) { situations.push_back(latest); }
|
|
||||||
if (!newer.isNull()) { situations.push_back(newer); }
|
|
||||||
if (!oldest.isNull()) { situations.push_back(oldest); }
|
|
||||||
|
|
||||||
const bool sorted = situations.isSortedAdjustedLatestFirstWithoutNullPositions();
|
|
||||||
if (setup.isNull() || !setup.isAircraftPartsEnabled()) { return sorted; }
|
|
||||||
|
|
||||||
bool details = false;
|
|
||||||
if (situations.containsOnGroundDetails(COnGroundInfo::InFromParts))
|
|
||||||
{
|
|
||||||
// if a client supports parts, all ground situations are supposed to be parts based
|
|
||||||
details = situations.areAllOnGroundDetailsSame(COnGroundInfo::InFromParts);
|
|
||||||
BLACK_VERIFY_X(details, Q_FUNC_INFO, "Once gnd.from parts -> always gnd. from parts");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const CAircraftSituation &s : situations)
|
|
||||||
{
|
|
||||||
if (!s.hasGroundElevation()) { continue; }
|
|
||||||
BLACK_VERIFY_X(!s.getGroundElevation().isZeroEpsilonConsidered(), Q_FUNC_INFO, "Suspicous 0 gnd. value");
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if middle situation is missing
|
|
||||||
if (latest.hasGroundElevation() && oldest.hasGroundElevation())
|
|
||||||
{
|
|
||||||
BLACK_VERIFY_X(newer.hasGroundElevation(), Q_FUNC_INFO, "Middle ground elevation is missing");
|
|
||||||
}
|
|
||||||
|
|
||||||
// result
|
|
||||||
return sorted && details;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QStringList &CInterpolator::getLogCategories()
|
const QStringList &CInterpolator::getLogCategories()
|
||||||
{
|
{
|
||||||
static const QStringList cats { CLogCategories::interpolator() };
|
static const QStringList cats { CLogCategories::interpolator() };
|
||||||
|
|||||||
@@ -145,10 +145,6 @@ namespace BlackMisc::Simulation
|
|||||||
|
|
||||||
bool m_unitTest = false; //!< mark as unit test
|
bool m_unitTest = false; //!< mark as unit test
|
||||||
|
|
||||||
//! Verify gnd flag, times, ... true means "OK"
|
|
||||||
bool verifyInterpolationSituations(const Aviation::CAircraftSituation &oldest, const Aviation::CAircraftSituation &newer, const Aviation::CAircraftSituation &latest,
|
|
||||||
const CInterpolationAndRenderingSetupPerCallsign &setup = CInterpolationAndRenderingSetupPerCallsign::null());
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CInterpolationLogger *m_logger = nullptr; //!< optional interpolation logger
|
CInterpolationLogger *m_logger = nullptr; //!< optional interpolation logger
|
||||||
QTimer m_initTimer; //!< timer to init model, will be deleted when interpolator is deleted and cancel the call
|
QTimer m_initTimer; //!< timer to init model, will be deleted when interpolator is deleted and cancel the call
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ namespace BlackMisc::Simulation
|
|||||||
|
|
||||||
if (CBuildConfig::isLocalDeveloperDebugBuild())
|
if (CBuildConfig::isLocalDeveloperDebugBuild())
|
||||||
{
|
{
|
||||||
const bool verified = this->verifyInterpolationSituations(m_s[0], m_s[1], m_s[2]); // oldest -> latest, only verify order
|
const bool verified = verifyInterpolationSituations(m_s[0], m_s[1], m_s[2]); // oldest -> latest, only verify order
|
||||||
if (!verified)
|
if (!verified)
|
||||||
{
|
{
|
||||||
static const QString vm("Unverified situations, m0-2 (oldest latest) %1 %2 %3");
|
static const QString vm("Unverified situations, m0-2 (oldest latest) %1 %2 %3");
|
||||||
@@ -418,4 +418,42 @@ namespace BlackMisc::Simulation
|
|||||||
}();
|
}();
|
||||||
return pa;
|
return pa;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CInterpolatorSpline::verifyInterpolationSituations(const CAircraftSituation &oldest, const CAircraftSituation &newer, const CAircraftSituation &latest, const CInterpolationAndRenderingSetupPerCallsign &setup)
|
||||||
|
{
|
||||||
|
if (!CBuildConfig::isLocalDeveloperDebugBuild()) { return true; }
|
||||||
|
CAircraftSituationList situations;
|
||||||
|
|
||||||
|
// oldest last, null ignored
|
||||||
|
if (!latest.isNull()) { situations.push_back(latest); }
|
||||||
|
if (!newer.isNull()) { situations.push_back(newer); }
|
||||||
|
if (!oldest.isNull()) { situations.push_back(oldest); }
|
||||||
|
|
||||||
|
const bool sorted = situations.isSortedAdjustedLatestFirstWithoutNullPositions();
|
||||||
|
if (setup.isNull() || !setup.isAircraftPartsEnabled()) { return sorted; }
|
||||||
|
|
||||||
|
bool details = false;
|
||||||
|
if (situations.containsOnGroundDetails(COnGroundInfo::InFromParts))
|
||||||
|
{
|
||||||
|
// if a client supports parts, all ground situations are supposed to be parts based
|
||||||
|
details = situations.areAllOnGroundDetailsSame(COnGroundInfo::InFromParts);
|
||||||
|
BLACK_VERIFY_X(details, Q_FUNC_INFO, "Once gnd.from parts -> always gnd. from parts");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const CAircraftSituation &s : situations)
|
||||||
|
{
|
||||||
|
if (!s.hasGroundElevation()) { continue; }
|
||||||
|
BLACK_VERIFY_X(!s.getGroundElevation().isZeroEpsilonConsidered(), Q_FUNC_INFO, "Suspicous 0 gnd. value");
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if middle situation is missing
|
||||||
|
if (latest.hasGroundElevation() && oldest.hasGroundElevation())
|
||||||
|
{
|
||||||
|
BLACK_VERIFY_X(newer.hasGroundElevation(), Q_FUNC_INFO, "Middle ground elevation is missing");
|
||||||
|
}
|
||||||
|
|
||||||
|
// result
|
||||||
|
return sorted && details;
|
||||||
|
}
|
||||||
|
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -101,6 +101,10 @@ namespace BlackMisc::Simulation
|
|||||||
//! Fill the situations array
|
//! Fill the situations array
|
||||||
bool fillSituationsArray();
|
bool fillSituationsArray();
|
||||||
|
|
||||||
|
//! Verify gnd flag, times, ... true means "OK"
|
||||||
|
static bool verifyInterpolationSituations(const Aviation::CAircraftSituation &oldest, const Aviation::CAircraftSituation &newer, const Aviation::CAircraftSituation &latest,
|
||||||
|
const CInterpolationAndRenderingSetupPerCallsign &setup = CInterpolationAndRenderingSetupPerCallsign::null());
|
||||||
|
|
||||||
qint64 m_prevSampleAdjustedTime = 0; //!< previous sample time + offset
|
qint64 m_prevSampleAdjustedTime = 0; //!< previous sample time + offset
|
||||||
qint64 m_nextSampleAdjustedTime = 0; //!< previous sample time + offset
|
qint64 m_nextSampleAdjustedTime = 0; //!< previous sample time + offset
|
||||||
qint64 m_prevSampleTime = 0; //!< previous sample "real time"
|
qint64 m_prevSampleTime = 0; //!< previous sample "real time"
|
||||||
|
|||||||
Reference in New Issue
Block a user