mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-09 05:28:09 +08:00
Ref T241, moved inner logger classes out CInterpolationLogger
Reason: More options, such as forward declaration
This commit is contained in:
@@ -128,7 +128,7 @@ namespace BlackMisc
|
||||
CStatusMessage(static_cast<CInterpolationLogger *>(nullptr)).error("Failed to write log file '%1'") << fileName;
|
||||
}
|
||||
|
||||
void CInterpolationLogger::logInterpolation(const CInterpolationLogger::SituationLog &log)
|
||||
void CInterpolationLogger::logInterpolation(const SituationLog &log)
|
||||
{
|
||||
QWriteLocker l(&m_lockSituations);
|
||||
m_situationLogs.push_back(log);
|
||||
@@ -138,7 +138,7 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
void CInterpolationLogger::logParts(const CInterpolationLogger::PartsLog &log)
|
||||
void CInterpolationLogger::logParts(const PartsLog &log)
|
||||
{
|
||||
QWriteLocker l(&m_lockParts);
|
||||
m_partsLogs.push_back(log);
|
||||
@@ -150,19 +150,19 @@ namespace BlackMisc
|
||||
m_maxSituations = max;
|
||||
}
|
||||
|
||||
QList<CInterpolationLogger::SituationLog> CInterpolationLogger::getSituationsLog() const
|
||||
QList<SituationLog> CInterpolationLogger::getSituationsLog() const
|
||||
{
|
||||
QReadLocker l(&m_lockSituations);
|
||||
return m_situationLogs;
|
||||
}
|
||||
|
||||
QList<CInterpolationLogger::PartsLog> CInterpolationLogger::getPartsLog() const
|
||||
QList<PartsLog> CInterpolationLogger::getPartsLog() const
|
||||
{
|
||||
QReadLocker l(&m_lockParts);
|
||||
return m_partsLogs;
|
||||
}
|
||||
|
||||
QList<CInterpolationLogger::SituationLog> CInterpolationLogger::getSituationsLog(const CCallsign &cs) const
|
||||
QList<SituationLog> CInterpolationLogger::getSituationsLog(const CCallsign &cs) const
|
||||
{
|
||||
const QList<SituationLog> copy(this->getSituationsLog());
|
||||
QList<SituationLog> logs;
|
||||
@@ -174,7 +174,7 @@ namespace BlackMisc
|
||||
return logs;
|
||||
}
|
||||
|
||||
QList<CInterpolationLogger::PartsLog> CInterpolationLogger::getPartsLog(const CCallsign &cs) const
|
||||
QList<PartsLog> CInterpolationLogger::getPartsLog(const CCallsign &cs) const
|
||||
{
|
||||
const QList<PartsLog> copy(this->getPartsLog());
|
||||
QList<PartsLog> logs;
|
||||
@@ -186,14 +186,14 @@ namespace BlackMisc
|
||||
return logs;
|
||||
}
|
||||
|
||||
CInterpolationLogger::SituationLog CInterpolationLogger::getLastSituationLog() const
|
||||
SituationLog CInterpolationLogger::getLastSituationLog() const
|
||||
{
|
||||
QReadLocker l(&m_lockSituations);
|
||||
if (m_situationLogs.isEmpty()) { return SituationLog(); }
|
||||
return m_situationLogs.last();
|
||||
}
|
||||
|
||||
CInterpolationLogger::SituationLog CInterpolationLogger::getLastSituationLog(const CCallsign &cs) const
|
||||
SituationLog CInterpolationLogger::getLastSituationLog(const CCallsign &cs) const
|
||||
{
|
||||
const QList<SituationLog> copy(this->getSituationsLog(cs));
|
||||
if (copy.isEmpty()) { return SituationLog(); }
|
||||
@@ -228,14 +228,14 @@ namespace BlackMisc
|
||||
return copy.last().parts;
|
||||
}
|
||||
|
||||
CInterpolationLogger::PartsLog CInterpolationLogger::getLastPartsLog() const
|
||||
PartsLog CInterpolationLogger::getLastPartsLog() const
|
||||
{
|
||||
QReadLocker l(&m_lockParts);
|
||||
if (m_partsLogs.isEmpty()) { return PartsLog(); }
|
||||
return m_partsLogs.last();
|
||||
}
|
||||
|
||||
CInterpolationLogger::PartsLog CInterpolationLogger::getLastPartsLog(const CCallsign &cs) const
|
||||
PartsLog CInterpolationLogger::getLastPartsLog(const CCallsign &cs) const
|
||||
{
|
||||
const QList<PartsLog> copy(this->getPartsLog(cs));
|
||||
if (copy.isEmpty()) { return PartsLog(); }
|
||||
@@ -463,7 +463,7 @@ namespace BlackMisc
|
||||
);
|
||||
}
|
||||
|
||||
QString CInterpolationLogger::PartsLog::toQString(const QString &separator) const
|
||||
QString PartsLog::toQString(const QString &separator) const
|
||||
{
|
||||
return QStringLiteral("CS: ") % callsign.asString() % separator %
|
||||
QStringLiteral("ts: ") % CInterpolationLogger::msSinceEpochToTimeAndTimestamp(tsCurrent) %
|
||||
@@ -471,7 +471,7 @@ namespace BlackMisc
|
||||
QStringLiteral("parts: ") % parts.toQString(true);
|
||||
}
|
||||
|
||||
const QString &CInterpolationLogger::SituationLog::interpolationType() const
|
||||
const QString &SituationLog::interpolationType() const
|
||||
{
|
||||
static const QString s("spline");
|
||||
static const QString l("linear");
|
||||
|
||||
@@ -28,6 +28,69 @@ namespace BlackMisc
|
||||
class CWorker;
|
||||
namespace Simulation
|
||||
{
|
||||
//! Log entry for situation interpolation
|
||||
struct BLACKMISC_EXPORT SituationLog
|
||||
{
|
||||
QChar interpolator; //!< what interpolator is used
|
||||
qint64 tsCurrent = -1; //!< current timestamp
|
||||
qint64 tsInterpolated = -1; //!< timestamp interpolated
|
||||
double groundFactor = -1; //!< current ground factor
|
||||
double vtolAircraft = false; //!< VTOL aircraft
|
||||
double simulationTimeFraction = -1; //!< time fraction, expected 0..1
|
||||
double deltaSampleTimesMs = -1; //!< delta time between samples (i.e. 2 situations)
|
||||
bool useParts = false; //!< supporting aircraft parts
|
||||
int noNetworkSituations = 0; //!< available network situations
|
||||
int noTransferredElevations = 0; //!< transferred elevation to n situations
|
||||
QString elevationInfo; //!< info about elevation retrieval
|
||||
Aviation::CCallsign callsign; //!< current callsign
|
||||
Aviation::CAircraftParts parts; //!< corresponding parts used in interpolator
|
||||
Aviation::CAircraftSituationList interpolationSituations; //!< the interpolator uses 2, 3 situations (oldest at end)
|
||||
Aviation::CAircraftSituation situationCurrent; //!< interpolated situation
|
||||
PhysicalQuantities::CLength cgAboveGround; //!< center of gravity
|
||||
CInterpolationAndRenderingSetup usedSetup; //!< used setup
|
||||
CInterpolationHints usedHints; //!< hints
|
||||
|
||||
//! Delta time between interpolation and current time
|
||||
double deltaCurrentToInterpolatedTime() const
|
||||
{
|
||||
return static_cast<double>(tsCurrent - tsInterpolated);
|
||||
}
|
||||
|
||||
//! Full name of interpolator
|
||||
const QString &interpolationType() const;
|
||||
|
||||
//! The oldest situation
|
||||
const Aviation::CAircraftSituation &oldestInterpolationSituation() const
|
||||
{
|
||||
return interpolationSituations.frontOrDefault();
|
||||
}
|
||||
|
||||
//! The newest situation
|
||||
const Aviation::CAircraftSituation &newestInterpolationSituation() const
|
||||
{
|
||||
return interpolationSituations.backOrDefault();
|
||||
}
|
||||
|
||||
//! To string
|
||||
QString toQString(
|
||||
bool withHints, bool withSetup,
|
||||
bool withCurrentSituation, bool withElevation,
|
||||
bool withOtherPositions, bool withDeltaTimes, const QString &separator = {" "}) const;
|
||||
};
|
||||
|
||||
//! Log entry for parts interpolation
|
||||
struct BLACKMISC_EXPORT PartsLog
|
||||
{
|
||||
qint64 tsCurrent = -1; //!< current timestamp
|
||||
bool empty = false; //!< empty parts?
|
||||
int noNetworkParts = 0; //!< available network situations
|
||||
Aviation::CCallsign callsign; //!< current callsign
|
||||
Aviation::CAircraftParts parts; //!< parts to be logged
|
||||
|
||||
//! To string
|
||||
QString toQString(const QString &separator = {" "}) const;
|
||||
};
|
||||
|
||||
//! Record internal state of interpolator for debugging
|
||||
class BLACKMISC_EXPORT CInterpolationLogger : public QObject
|
||||
{
|
||||
@@ -122,6 +185,15 @@ namespace BlackMisc
|
||||
//! All log.file patterns
|
||||
static const QStringList &filePatterns();
|
||||
|
||||
//! Create readable time
|
||||
static QString msSinceEpochToTime(qint64 ms);
|
||||
|
||||
//! Create readable time plus timestamp
|
||||
static QString msSinceEpochToTimeAndTimestamp(qint64 ms);
|
||||
|
||||
//! Create readable time
|
||||
static QString msSinceEpochToTime(qint64 t1, qint64 t2, qint64 t3 = -1);
|
||||
|
||||
private:
|
||||
//! Get log as HTML table
|
||||
static QString getHtmlInterpolationLog(const QList<SituationLog> &getSituationsLog);
|
||||
@@ -135,15 +207,6 @@ namespace BlackMisc
|
||||
//! Status of file operation
|
||||
static CStatusMessage logStatusFileWriting(bool success, const QString &fileName);
|
||||
|
||||
//! Create readable time
|
||||
static QString msSinceEpochToTime(qint64 ms);
|
||||
|
||||
//! Create readable time plus timestamp
|
||||
static QString msSinceEpochToTimeAndTimestamp(qint64 ms);
|
||||
|
||||
//! Create readable time
|
||||
static QString msSinceEpochToTime(qint64 t1, qint64 t2, qint64 t3 = -1);
|
||||
|
||||
mutable QReadWriteLock m_lockSituations; //!< lock logging situations
|
||||
mutable QReadWriteLock m_lockParts; //!< lock logging parts
|
||||
int m_maxSituations = 2500; //!< max.number of situations
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace BlackMisc
|
||||
{}
|
||||
|
||||
CInterpolatorLinear::Interpolant CInterpolatorLinear::getInterpolant(qint64 currentTimeMsSinceEpoc,
|
||||
const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, CInterpolationStatus &status, CInterpolationLogger::SituationLog &log) const
|
||||
const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, CInterpolationStatus &status, SituationLog &log) const
|
||||
{
|
||||
Q_UNUSED(setup);
|
||||
Q_UNUSED(hints);
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace BlackMisc
|
||||
|
||||
//! Get the interpolant for the given time point
|
||||
Interpolant getInterpolant(qint64 currentTimeMsSinceEpoc, const CInterpolationAndRenderingSetup &setup,
|
||||
const CInterpolationHints &hints, CInterpolationStatus &status, CInterpolationLogger::SituationLog &log) const;
|
||||
const CInterpolationHints &hints, CInterpolationStatus &status, SituationLog &log) const;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace BlackMisc
|
||||
|
||||
CInterpolatorSpline::Interpolant CInterpolatorSpline::getInterpolant(qint64 currentTimeMsSinceEpoc,
|
||||
const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, CInterpolationStatus &status,
|
||||
CInterpolationLogger::SituationLog &log)
|
||||
SituationLog &log)
|
||||
{
|
||||
Q_UNUSED(hints);
|
||||
Q_UNUSED(setup);
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace BlackMisc
|
||||
Interpolant getInterpolant(
|
||||
qint64 currentTimeMsSinceEpoc,
|
||||
const CInterpolationAndRenderingSetup &setup,
|
||||
const CInterpolationHints &hints, CInterpolationStatus &status, CInterpolationLogger::SituationLog &log);
|
||||
const CInterpolationHints &hints, CInterpolationStatus &status, SituationLog &log);
|
||||
|
||||
private:
|
||||
qint64 m_prevSampleAdjustedTime = 0; //!< previous sample time + offset
|
||||
|
||||
Reference in New Issue
Block a user