Ref T171, interpolator / interpolation logger formatting

This commit is contained in:
Klaus Basan
2017-10-14 00:55:10 +02:00
parent cbe2cfaded
commit c3f3f266d0
6 changed files with 31 additions and 36 deletions

View File

@@ -110,14 +110,9 @@ namespace BlackMisc
CStatusMessage CInterpolationLogger::logStatusFileWriting(bool success, const QString &fileName)
{
if (success)
{
return CStatusMessage(static_cast<CInterpolationLogger *>(nullptr)).info("Written log file '%1'") << fileName;
}
else
{
return CStatusMessage(static_cast<CInterpolationLogger *>(nullptr)).error("Failed to write log file '%1'") << fileName;
}
return success ?
CStatusMessage(static_cast<CInterpolationLogger *>(nullptr)).info("Written log file '%1'") << fileName :
CStatusMessage(static_cast<CInterpolationLogger *>(nullptr)).error("Failed to write log file '%1'") << fileName;
}
void CInterpolationLogger::logInterpolation(const CInterpolationLogger::SituationLog &log)

View File

@@ -58,15 +58,15 @@ namespace BlackMisc
double groundFactor = -1; //!< current ground factor
double vtolAircraft = false; //!< VTOL aircraft
double deltaTimeMs = 0; //!< delta time to last situation
double simulationTimeFraction = -1; //!< time fraction, normally 0..1
double deltaTimeFractionMs = -1; //!< delta time fraction
bool useParts = false; //!< supporting aircraft parts
BlackMisc::Aviation::CCallsign callsign; //!< current callsign
BlackMisc::Aviation::CAircraftParts parts; //!< corresponding parts used in interpolator
BlackMisc::Aviation::CAircraftSituation oldSituation; //!< old situation
BlackMisc::Aviation::CAircraftSituation newSituation; //!< new situation
BlackMisc::Aviation::CAircraftSituation currentSituation; //!< interpolated situation
BlackMisc::PhysicalQuantities::CLength cgAboveGround; //!< center of gravity
double simulationTimeFraction = -1; //!< time fraction, normally 0..1
double deltaTimeFractionMs = -1; //!< delta time fraction
bool useParts = false; //!< supporting aircraft parts
Aviation::CCallsign callsign; //!< current callsign
Aviation::CAircraftParts parts; //!< corresponding parts used in interpolator
Aviation::CAircraftSituation oldSituation; //!< old situation
Aviation::CAircraftSituation newSituation; //!< new situation
Aviation::CAircraftSituation currentSituation; //!< interpolated situation
PhysicalQuantities::CLength cgAboveGround; //!< center of gravity
};
//! Log entry for parts interpolation
@@ -74,8 +74,8 @@ namespace BlackMisc
{
qint64 timestamp = -1; //!< current timestamp
bool empty = false; //!< empty parts?
BlackMisc::Aviation::CCallsign callsign; //!< current callsign
BlackMisc::Aviation::CAircraftParts parts; //!< parts to be logged
Aviation::CCallsign callsign; //!< current callsign
Aviation::CAircraftParts parts; //!< parts to be logged
};
//! Log current interpolation cycle, only stores in memory, for performance reasons
@@ -107,7 +107,7 @@ namespace BlackMisc
//! Create readable time
static QString msSinceEpochToTime(qint64 t1, qint64 t2, qint64 t3 = -1);
mutable QReadWriteLock m_lockLogs; //!< lock logging
mutable QReadWriteLock m_lockLogs; //!< lock logging
QList<PartsLog> m_partsLogs; //!< logs of parts
QList<SituationLog> m_situationLogs; //!< logs of interpolation
};

View File

@@ -45,8 +45,10 @@ namespace BlackMisc
}
template <typename Derived>
CAircraftSituation CInterpolator<Derived>::getInterpolatedSituation(qint64 currentTimeMsSinceEpoc,
const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, CInterpolationStatus &status)
CAircraftSituation CInterpolator<Derived>::getInterpolatedSituation(
qint64 currentTimeMsSinceEpoc,
const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints,
CInterpolationStatus &status)
{
status.reset();
CInterpolationLogger::SituationLog log;

View File

@@ -74,6 +74,8 @@ namespace BlackMisc
}
//! Attach an observer to read the interpolator's state for debugging
//! \remark situation logging requires CInterpolationHints::isLoggingInterpolation to be \c true
//! \remark parts logging has a \c bool \c log flag
void attachLogger(CInterpolationLogger *logger) { m_logger = logger; }
protected:

View File

@@ -26,12 +26,9 @@ namespace BlackMisc
{
switch (m_mode)
{
case ModeLinear:
return m_linear.getInterpolatedSituation(currentTimeSinceEpoc, setup, hints, status);
case ModeSpline:
return m_spline.getInterpolatedSituation(currentTimeSinceEpoc, setup, hints, status);
default:
break;
case ModeLinear: return m_linear.getInterpolatedSituation(currentTimeSinceEpoc, setup, hints, status);
case ModeSpline: return m_spline.getInterpolatedSituation(currentTimeSinceEpoc, setup, hints, status);
default: break;
}
return {};
}
@@ -41,12 +38,9 @@ namespace BlackMisc
{
switch (m_mode)
{
case ModeLinear:
return m_linear.getInterpolatedParts(currentTimeSinceEpoc, setup, partsStatus, log);
case ModeSpline:
return m_spline.getInterpolatedParts(currentTimeSinceEpoc, setup, partsStatus, log);
default:
break;
case ModeLinear: return m_linear.getInterpolatedParts(currentTimeSinceEpoc, setup, partsStatus, log);
case ModeSpline: return m_spline.getInterpolatedParts(currentTimeSinceEpoc, setup, partsStatus, log);
default: break;
}
return {};
}

View File

@@ -32,11 +32,13 @@ namespace BlackMisc
//! \copydoc CInterpolator::getInterpolatedSituation
BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(
qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, CInterpolationStatus &status);
qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetup &setup,
const CInterpolationHints &hints, CInterpolationStatus &status);
//! \copydoc CInterpolator::getInterpolatedParts
BlackMisc::Aviation::CAircraftParts getInterpolatedParts(
qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetup &setup, CPartsStatus &partsStatus, bool log = false);
qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetup &setup,
CPartsStatus &partsStatus, bool log = false);
//! \copydoc CInterpolator::addAircraftSituation
void addAircraftSituation(const BlackMisc::Aviation::CAircraftSituation &situation);