Ref T270, mark interpolator as unit test

* if we use "recycled" parts, we have to store also the last status
* mark unit test so "recycling" is disabled
* status flag for "reused"
This commit is contained in:
Klaus Basan
2018-06-02 14:16:50 +02:00
parent 84428b1284
commit c6f3d4e2f2
3 changed files with 15 additions and 2 deletions

View File

@@ -292,6 +292,8 @@ namespace BlackMisc
Q_ASSERT_X(m_partsToSituationInterpolationRatio >= 1 && m_partsToSituationInterpolationRatio < 11, Q_FUNC_INFO, "Wrong ratio"); Q_ASSERT_X(m_partsToSituationInterpolationRatio >= 1 && m_partsToSituationInterpolationRatio < 11, Q_FUNC_INFO, "Wrong ratio");
if (!m_unitTest && !m_lastParts.isNull() && ((m_interpolatedSituationsCounter + aircraftNumber) % m_partsToSituationInterpolationRatio) == 0) if (!m_unitTest && !m_lastParts.isNull() && ((m_interpolatedSituationsCounter + aircraftNumber) % m_partsToSituationInterpolationRatio) == 0)
{ {
m_currentPartsStatus = m_lastPartsStatus;
m_currentPartsStatus.setReusedParts(true);
return m_lastParts; return m_lastParts;
} }
@@ -312,6 +314,7 @@ namespace BlackMisc
} }
m_lastParts = parts; m_lastParts = parts;
m_lastPartsStatus = m_currentPartsStatus;
return parts; return parts;
} }
@@ -513,6 +516,7 @@ namespace BlackMisc
void CPartsStatus::reset() void CPartsStatus::reset()
{ {
m_supportsParts = false; m_supportsParts = false;
m_resusedParts = false;
} }
// see here for the reason of thess forward instantiations // see here for the reason of thess forward instantiations

View File

@@ -96,11 +96,18 @@ namespace BlackMisc
//! Set support flag //! Set support flag
void setSupportsParts(bool supports) { m_supportsParts = supports; } void setSupportsParts(bool supports) { m_supportsParts = supports; }
//! Is a reused parts, means using last value again
bool isReusedPArts() const { return m_resusedParts; }
//! Mark as reused
void setReusedParts(bool reused) { m_resusedParts = reused; }
//! Reset to default values //! Reset to default values
void reset(); void reset();
private: private:
bool m_supportsParts = false; //!< supports parts for given callsign bool m_supportsParts = false; //!< supports parts for given callsign
bool m_resusedParts = false; //!< reusing from last step
}; };
//! Combined results //! Combined results
@@ -248,6 +255,7 @@ namespace BlackMisc
CInterpolationAndRenderingSetupPerCallsign m_currentSetup; //!< used setup CInterpolationAndRenderingSetupPerCallsign m_currentSetup; //!< used setup
CInterpolationStatus m_currentInterpolationStatus; //!< this step's status CInterpolationStatus m_currentInterpolationStatus; //!< this step's status
CPartsStatus m_currentPartsStatus; //!< this step's status CPartsStatus m_currentPartsStatus; //!< this step's status
CPartsStatus m_lastPartsStatus; //!< status for last parts, used when last parts are re-used because of m_partsToSituationInterpolationRatio
int m_partsToSituationInterpolationRatio = 2; //!< ratio between parts and situation interpolation, 1..always, 2..every 2nd situation int m_partsToSituationInterpolationRatio = 2; //!< ratio between parts and situation interpolation, 1..always, 2..every 2nd situation
Aviation::CAircraftSituation m_lastSituation { Aviation::CAircraftSituation::null() }; //!< latest interpolation Aviation::CAircraftSituation m_lastSituation { Aviation::CAircraftSituation::null() }; //!< latest interpolation
Aviation::CAircraftParts m_lastParts { Aviation::CAircraftParts::null() }; //!< latest parts Aviation::CAircraftParts m_lastParts { Aviation::CAircraftParts::null() }; //!< latest parts

View File

@@ -54,10 +54,10 @@ namespace BlackMiscTest
{ {
void CTestInterpolatorLinear::basicInterpolatorTests() void CTestInterpolatorLinear::basicInterpolatorTests()
{ {
CCallsign cs("SWIFT"); const CCallsign cs("SWIFT");
CRemoteAircraftProviderDummy provider; CRemoteAircraftProviderDummy provider;
CInterpolatorLinear interpolator(cs, nullptr, nullptr, &provider); CInterpolatorLinear interpolator(cs, nullptr, nullptr, &provider);
// interpolator.markAsUnitTest(); interpolator.markAsUnitTest();
// fixed time so everything can be debugged // fixed time so everything can be debugged
const qint64 ts = 1425000000000; // QDateTime::currentMSecsSinceEpoch(); const qint64 ts = 1425000000000; // QDateTime::currentMSecsSinceEpoch();
@@ -115,6 +115,7 @@ namespace BlackMiscTest
// With one callsign in the lists (of dummy provider) it is somehow expected to be roughly the same performance // With one callsign in the lists (of dummy provider) it is somehow expected to be roughly the same performance
interpolator.resetLastInterpolation(); interpolator.resetLastInterpolation();
interpolator.markAsUnitTest();
for (int loops = 0; loops < 20; loops++) for (int loops = 0; loops < 20; loops++)
{ {
for (qint64 currentTime = startTimeMsSinceEpoch + offset; currentTime < ts + offset; currentTime += (deltaT / 20)) for (qint64 currentTime = startTimeMsSinceEpoch + offset; currentTime < ts + offset; currentTime += (deltaT / 20))