Ref T231, Ref T236, Ref T238 improved logging of situation/parts logging

* "dot" commands to log parts/situations
* log can also be displayed in simulator (if simulator can display text messages)
* fixed missings locks for m_interpolationRenderingSetup
* more detailed output
* renamings
* using hints in log
This commit is contained in:
Klaus Basan
2018-01-28 05:08:25 +01:00
parent 5f6f822ccd
commit cd5fdfaf14
9 changed files with 333 additions and 121 deletions

View File

@@ -36,6 +36,15 @@ namespace BlackMisc
return validPlane ? this->m_elevationPlane.getAltitude() : CAltitude::null();
}
CAltitude CInterpolationHints::getGroundElevation(const CAircraftSituation &situation, const CLength &validRadius, bool useProvider, bool forceProvider) const
{
const bool validPlane = m_elevationPlane.isWithinRange(situation, CLength::maxValue(validRadius, m_elevationPlane.getRadius()));
Q_ASSERT_X(!(forceProvider && !useProvider), Q_FUNC_INFO, "Invalid parameter combination");
if (forceProvider && useProvider && m_elevationProvider) { return m_elevationProvider(situation); }
if (!validPlane && useProvider && m_elevationProvider) { return m_elevationProvider(situation); }
return validPlane ? this->m_elevationPlane.getAltitude() : CAltitude::null();
}
void CInterpolationHints::resetElevationPlane()
{
m_elevationPlane = CElevationPlane();

View File

@@ -63,6 +63,10 @@ namespace BlackMisc
//! \see setElevationPlane
Aviation::CAltitude getGroundElevation(const Aviation::CAircraftSituation &situation, bool useProvider, bool forceProvider = false) const;
//! Get elevation from CInterpolationHints::getElevationProvider or CInterpolationHints::getElevation
//! \remark if validRadius is >= Geo::CElevationPlane::radius use validRadius
Aviation::CAltitude getGroundElevation(const Aviation::CAircraftSituation &situation, const PhysicalQuantities::CLength &validRadius, bool useProvider, bool forceProvider = false) const;
//! Check if elevation is within radius and can be used
bool isWithinRange(const Geo::ICoordinateGeodetic &coordinate) const;

View File

@@ -186,18 +186,32 @@ namespace BlackMisc
return logs;
}
CInterpolationLogger::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
{
const QList<SituationLog> copy(this->getSituationsLog(cs));
if (copy.isEmpty()) { return SituationLog(); }
return copy.last();
}
CAircraftSituation CInterpolationLogger::getLastSituation() const
{
QReadLocker l(&m_lockSituations);
if (m_situationLogs.isEmpty()) { return CAircraftSituation(); }
return m_situationLogs.last().currentSituation;
return m_situationLogs.last().situationCurrent;
}
CAircraftSituation CInterpolationLogger::getLastSituation(const CCallsign &cs) const
{
const QList<SituationLog> copy(this->getSituationsLog(cs));
if (copy.isEmpty()) { return CAircraftSituation(); }
return copy.last().currentSituation;
return copy.last().situationCurrent;
}
CAircraftParts CInterpolationLogger::getLastParts() const
@@ -214,6 +228,20 @@ namespace BlackMisc
return copy.last().parts;
}
CInterpolationLogger::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
{
const QList<PartsLog> copy(this->getPartsLog(cs));
if (copy.isEmpty()) { return PartsLog(); }
return copy.last();
}
const QString &CInterpolationLogger::filePatternInterpolationLog()
{
static const QString p("*interpolation.html");
@@ -235,113 +263,113 @@ namespace BlackMisc
QString CInterpolationLogger::getHtmlInterpolationLog(const QList<SituationLog> &logs)
{
if (logs.isEmpty()) { return {}; }
const QString tableHeader =
QLatin1String("<thead><tr>") %
QLatin1String("<th title=\"changed situation\">cs.</th><th>Int</th>") %
QLatin1String("<th>CS</th><th>VTOL</th><th>timestamp</th><th>since</th>") %
QLatin1String("<th>ts old</th><th>ts new</th><th>ts cur</th>") %
QLatin1String("<th>&Delta;t</th><th>&Delta;t fr.</th><th>fraction</th>") %
QLatin1String("<th>lat.old</th><th>lat.new</th><th>lat.cur</th>") %
QLatin1String("<th>lng.old</th><th>lng.new</th><th>lng.cur</th>") %
QLatin1String("<th>alt.old</th><th>alt.new</th><th>alt.cur</th>") %
QLatin1String("<th>elv.old</th><th>elv.new</th><th>elv.cur</th>") %
QLatin1String("<th>gnd.factor</th>") %
QLatin1String("<th>onGnd.old</th><th>onGnd.new</th><th>onGnd.cur</th>") %
QLatin1String("<th>CG</th>") %
QLatin1String("<th>parts</th><th title=\"changed parts\">cp.</th><th>parts details</th>") %
QLatin1String("</tr></thead>\n");
static const QString tableHeader =
QStringLiteral("<thead><tr>") %
QStringLiteral("<th title=\"changed situation\">cs.</th><th>Int</th>") %
QStringLiteral("<th>CS</th><th>VTOL</th><th>timestamp</th><th>since</th>") %
QStringLiteral("<th>ts old</th><th>ts new</th><th>ts cur</th>") %
QStringLiteral("<th>Interpolation ts.</th><th>Sample &Delta;t</th><th>fraction</th>") %
QStringLiteral("<th>lat.old</th><th>lat.new</th><th>lat.cur</th>") %
QStringLiteral("<th>lng.old</th><th>lng.new</th><th>lng.cur</th>") %
QStringLiteral("<th>alt.old</th><th>alt.new</th><th>alt.cur</th>") %
QStringLiteral("<th>elv.old</th><th>elv.new</th><th>elv.cur</th>") %
QStringLiteral("<th>gnd.factor</th>") %
QStringLiteral("<th>onGnd.old</th><th>onGnd.new</th><th>onGnd.cur</th>") %
QStringLiteral("<th>CG</th>") %
QStringLiteral("<th>parts</th><th title=\"changed parts\">cp.</th><th>parts details</th>") %
QStringLiteral("</tr></thead>\n");
static const CLengthUnit ft = CLengthUnit::ft();
const SituationLog firstLog = logs.first();
qint64 newPosTs = firstLog.newSituation.getMSecsSinceEpoch();
qint64 newPosTs = firstLog.situationNew.getMSecsSinceEpoch();
CAircraftParts lastParts; // default, so shown if parts are different from default
QString tableRows("<tbody>\n");
for (const SituationLog &log : logs)
{
const bool changedNewPosition = newPosTs != log.newSituation.getMSecsSinceEpoch();
const bool changedParts = lastParts != log.parts;
newPosTs = log.newSituation.getMSecsSinceEpoch();
const bool changedNewPosition = newPosTs != log.situationNew.getMSecsSinceEpoch();
const bool changedParts = (lastParts != log.parts);
newPosTs = log.situationNew.getMSecsSinceEpoch();
lastParts = log.parts;
// concatenating in multiple steps, otherwise C4503 warnings
tableRows +=
QLatin1String("<tr>") %
(changedNewPosition ? QLatin1String("<td class=\"changed\">*</td>") : QLatin1String("<td></td>")) %
QLatin1String("<td>") % log.interpolator % QLatin1String("</td>") %
QLatin1String("<td>") % log.callsign.asString() % QLatin1String("</td>") %
QLatin1String("<td>") % boolToYesNo(log.vtolAircraft) % QLatin1String("</td>") %
QLatin1String("<td>") % msSinceEpochToTime(log.timestamp) % QLatin1String("</td>") %
QLatin1String("<td>") % QString::number(log.timestamp - firstLog.timestamp) % QLatin1String("</td>") %
QStringLiteral("<tr>") %
(changedNewPosition ? QStringLiteral("<td class=\"changed\">*</td>") : QStringLiteral("<td></td>")) %
QStringLiteral("<td>") % log.interpolator % QStringLiteral("</td>") %
QStringLiteral("<td>") % log.callsign.asString() % QStringLiteral("</td>") %
QStringLiteral("<td>") % boolToYesNo(log.vtolAircraft) % QStringLiteral("</td>") %
QStringLiteral("<td>") % msSinceEpochToTime(log.tsCurrent) % QStringLiteral("</td>") %
QStringLiteral("<td>") % QString::number(log.tsCurrent - firstLog.tsCurrent) % QStringLiteral("</td>") %
QLatin1String("<td class=\"old\">") % msSinceEpochToTime(log.oldSituation.getAdjustedMSecsSinceEpoch()) % QLatin1Char('-') % QString::number(log.oldSituation.getTimeOffsetMs()) % QLatin1String("</td>") %
QLatin1String("<td class=\"new\">") % msSinceEpochToTime(log.newSituation.getAdjustedMSecsSinceEpoch()) % QLatin1Char('-') % QString::number(log.newSituation.getTimeOffsetMs()) % QLatin1String("</td>") %
QLatin1String("<td class=\"cur\">") % msSinceEpochToTime(log.currentSituation.getAdjustedMSecsSinceEpoch()) % QLatin1Char('-') % QString::number(log.currentSituation.getTimeOffsetMs()) % QLatin1String("</td>") %
QStringLiteral("<td class=\"old\">") % log.situationOld.getTimestampAndOffset(true) % QStringLiteral("</td>") %
QStringLiteral("<td class=\"new\">") % log.situationNew.getTimestampAndOffset(true) % QStringLiteral("</td>") %
QStringLiteral("<td class=\"cur\">") % log.situationCurrent.getTimestampAndOffset(true) % QStringLiteral("</td>") %
QLatin1String("<td>") % QString::number(log.deltaTimeMs) % QLatin1String("</td>") %
QLatin1String("<td>") % QString::number(log.deltaTimeFractionMs) % QLatin1String("</td>") %
QLatin1String("<td>") % QString::number(log.simulationTimeFraction) % QLatin1String("</td>");
QStringLiteral("<td>") % msSinceEpochToTime(log.tsInterpolated) % QStringLiteral("</td>") %
QStringLiteral("<td>") % QString::number(log.deltaSampleTimesMs) % QStringLiteral("ms</td>") %
QStringLiteral("<td>") % QString::number(log.simulationTimeFraction) % QStringLiteral("</td>");
tableRows +=
QLatin1String("<td class=\"old\">") % log.oldSituation.latitudeAsString() % QLatin1String("</td>") %
QLatin1String("<td class=\"new\">") % log.newSituation.latitudeAsString() % QLatin1String("</td>") %
QLatin1String("<td class=\"cur\">") % log.currentSituation.latitudeAsString() % QLatin1String("</td>") %
QStringLiteral("<td class=\"old\">") % log.situationOld.latitudeAsString() % QStringLiteral("</td>") %
QStringLiteral("<td class=\"new\">") % log.situationNew.latitudeAsString() % QStringLiteral("</td>") %
QStringLiteral("<td class=\"cur\">") % log.situationCurrent.latitudeAsString() % QStringLiteral("</td>") %
QLatin1String("<td class=\"old\">") % log.oldSituation.longitudeAsString() % QLatin1String("</td>") %
QLatin1String("<td class=\"new\">") % log.newSituation.longitudeAsString() % QLatin1String("</td>") %
QLatin1String("<td class=\"cur\">") % log.currentSituation.longitudeAsString() % QLatin1String("</td>");
QStringLiteral("<td class=\"old\">") % log.situationOld.longitudeAsString() % QStringLiteral("</td>") %
QStringLiteral("<td class=\"new\">") % log.situationNew.longitudeAsString() % QStringLiteral("</td>") %
QStringLiteral("<td class=\"cur\">") % log.situationCurrent.longitudeAsString() % QStringLiteral("</td>");
tableRows +=
QLatin1String("<td class=\"old\">") % log.oldSituation.getAltitude().valueRoundedWithUnit(ft, 1) % QLatin1String("</td>") %
QLatin1String("<td class=\"new\">") % log.newSituation.getAltitude().valueRoundedWithUnit(ft, 1) % QLatin1String("</td>") %
QLatin1String("<td class=\"cur\">") % log.currentSituation.getAltitude().valueRoundedWithUnit(ft, 1) % QLatin1String("</td>") %
QStringLiteral("<td class=\"old\">") % log.situationOld.getAltitude().valueRoundedWithUnit(ft, 1) % QStringLiteral("</td>") %
QStringLiteral("<td class=\"new\">") % log.situationNew.getAltitude().valueRoundedWithUnit(ft, 1) % QStringLiteral("</td>") %
QStringLiteral("<td class=\"cur\">") % log.situationCurrent.getAltitude().valueRoundedWithUnit(ft, 1) % QStringLiteral("</td>") %
QLatin1String("<td class=\"old\">") % log.oldSituation.getGroundElevation().valueRoundedWithUnit(ft, 1) % QLatin1String("</td>") %
QLatin1String("<td class=\"new\">") % log.newSituation.getGroundElevation().valueRoundedWithUnit(ft, 1) % QLatin1String("</td>") %
QLatin1String("<td class=\"cur\">") % log.currentSituation.getGroundElevation().valueRoundedWithUnit(ft, 1) % QLatin1String("</td>") %
QStringLiteral("<td class=\"old\">") % log.situationOld.getGroundElevation().valueRoundedWithUnit(ft, 1) % QStringLiteral("</td>") %
QStringLiteral("<td class=\"new\">") % log.situationNew.getGroundElevation().valueRoundedWithUnit(ft, 1) % QStringLiteral("</td>") %
QStringLiteral("<td class=\"cur\">") % log.situationCurrent.getGroundElevation().valueRoundedWithUnit(ft, 1) % QStringLiteral("</td>") %
QLatin1String("<td>") % QString::number(log.groundFactor) % QLatin1String("</td>") %
QLatin1String("<td class=\"old\">") % log.oldSituation.getOnGroundInfo() % QLatin1String("</td>") %
QLatin1String("<td class=\"new\">") % log.newSituation.getOnGroundInfo() % QLatin1String("</td>") %
QLatin1String("<td class=\"cur\">") % log.currentSituation.getOnGroundInfo() % QLatin1String("</td>");
QStringLiteral("<td>") % QString::number(log.groundFactor) % QStringLiteral("</td>") %
QStringLiteral("<td class=\"old\">") % log.situationOld.getOnGroundInfo() % QStringLiteral("</td>") %
QStringLiteral("<td class=\"new\">") % log.situationNew.getOnGroundInfo() % QStringLiteral("</td>") %
QStringLiteral("<td class=\"cur\">") % log.situationCurrent.getOnGroundInfo() % QStringLiteral("</td>");
tableRows +=
QLatin1String("<td>") % log.cgAboveGround.valueRoundedWithUnit(CLengthUnit::ft(), 0) % QLatin1String("</td>") %
QLatin1String("<td>") % boolToYesNo(log.useParts) % QLatin1String("</td>") %
(changedParts ? QLatin1String("<td class=\"changed\">*</td>") : QLatin1String("<td></td>")) %
QLatin1String("<td>") % (log.useParts ? log.parts.toQString(true) : QLatin1String("")) % QLatin1String("</td>") %
QLatin1String("</tr>\n");
QStringLiteral("<td>") % log.cgAboveGround.valueRoundedWithUnit(ft, 0) % QStringLiteral("</td>") %
QStringLiteral("<td>") % boolToYesNo(log.useParts) % QStringLiteral("</td>") %
(changedParts ? QStringLiteral("<td class=\"changed\">*</td>") : QStringLiteral("<td></td>")) %
QStringLiteral("<td>") % (log.useParts ? log.parts.toQString(true) : QStringLiteral("")) % QStringLiteral("</td>") %
QStringLiteral("</tr>\n");
}
tableRows += QLatin1String("</tbody>\n");
return QLatin1String("<table class=\"small\">\n") % tableHeader % tableRows % QLatin1String("</table>\n");
tableRows += QStringLiteral("</tbody>\n");
return QStringLiteral("<table class=\"small\">\n") % tableHeader % tableRows % QStringLiteral("</table>\n");
}
QString CInterpolationLogger::getHtmlPartsLog(const QList<PartsLog> &logs)
{
if (logs.isEmpty()) { return {}; }
const QString tableHeader =
QLatin1String("<thead><tr>") %
QLatin1String("<th>CS</th><th>timestamp</th>") %
QLatin1String("<th>c.</th>") %
QLatin1String("<th>parts</th>") %
QLatin1String("</tr></thead>\n");
static const QString tableHeader =
QStringLiteral("<thead><tr>") %
QStringLiteral("<th>CS</th><th>timestamp</th>") %
QStringLiteral("<th>c.</th>") %
QStringLiteral("<th>parts</th>") %
QStringLiteral("</tr></thead>\n");
CAircraftParts lastParts; // default, so shown if parts are different from default
QString tableRows("<tbody>\n");
for (const PartsLog &log : logs)
{
const bool changedParts = lastParts != log.parts;
const bool changedParts = (lastParts != log.parts);
lastParts = log.parts;
tableRows +=
QLatin1String("<tr>") %
QLatin1String("<td>") % log.callsign.asString() % QLatin1String("</td>") %
QLatin1String("<td>") % msSinceEpochToTime(log.timestamp) % QLatin1String("</td>") %
(changedParts ? QLatin1String("<td class=\"changed\">*</td>") : QLatin1String("<td></td>")) %
QLatin1String("<td>") % (log.empty ? QLatin1String("empty") : log.parts.toQString()) % QLatin1String("</td>");
QStringLiteral("<tr>") %
QStringLiteral("<td>") % log.callsign.asString() % QStringLiteral("</td>") %
QStringLiteral("<td>") % msSinceEpochToTime(log.tsCurrent) % QStringLiteral("</td>") %
(changedParts ? QStringLiteral("<td class=\"changed\">*</td>") : QStringLiteral("<td></td>")) %
QStringLiteral("<td>") % (log.empty ? QStringLiteral("empty") : log.parts.toQString()) % QStringLiteral("</td>");
}
tableRows += QLatin1String("</tbody>\n");
return QLatin1String("<table class=\"small\">\n") % tableHeader % tableRows % QLatin1String("</table>\n");
tableRows += QStringLiteral("</tbody>\n");
return QStringLiteral("<table class=\"small\">\n") % tableHeader % tableRows % QStringLiteral("</table>\n");
}
void CInterpolationLogger::clearLog()
@@ -362,10 +390,86 @@ namespace BlackMisc
return QDateTime::fromMSecsSinceEpoch(ms).toString(dateFormat);
}
QString CInterpolationLogger::msSinceEpochToTimeAndTimestamp(qint64 ms)
{
return CInterpolationLogger::msSinceEpochToTime(ms) % QStringLiteral("/") % QString::number(ms);
}
QString CInterpolationLogger::msSinceEpochToTime(qint64 t1, qint64 t2, qint64 t3)
{
if (t3 < 0) return QString("%1 %2").arg(msSinceEpochToTime(t1), msSinceEpochToTime(t2));
return QString("%1 %2 %3").arg(msSinceEpochToTime(t1), msSinceEpochToTime(t2), msSinceEpochToTime(t3));
static const QString s2("%1 %2");
if (t3 < 0) { return s2.arg(msSinceEpochToTime(t1), msSinceEpochToTime(t2)); }
static const QString s3("%1 %2 %3");
return s3.arg(msSinceEpochToTime(t1), msSinceEpochToTime(t2), msSinceEpochToTime(t3));
}
QString CInterpolationLogger::SituationLog::toQString(
bool withCurrentSituation, bool withHints, bool withSetup,
bool withElevation, bool withOtherPositions, bool withDeltaTimes, const QString &separator) const
{
return QStringLiteral("CS: ") % callsign.asString() % separator %
QStringLiteral("ts: ") % CInterpolationLogger::msSinceEpochToTimeAndTimestamp(tsCurrent) %
QStringLiteral(" type: ") % this->interpolationType() %
QStringLiteral(" gnd.fa.: ") % QString::number(groundFactor) %
(
withHints ?
separator % QStringLiteral("hints: ") % usedHints.toQString(true) :
QStringLiteral("")
) %
(
withSetup ?
separator % QStringLiteral("setup: ") % usedSetup.toQString(true) :
QStringLiteral("")
) %
(
withElevation ?
separator %
QStringLiteral("transf.elv.: ") % QString::number(noTransferredElevations) :
QStringLiteral("")
) %
(
withDeltaTimes ?
separator %
QStringLiteral("int.time: ") % CInterpolationLogger::msSinceEpochToTimeAndTimestamp(tsCurrent) %
QStringLiteral(" sample dt: ") % QString::number(deltaSampleTimesMs) % QStringLiteral("ms") %
QStringLiteral(" fr.[0-1]: ") % QString::number(simulationTimeFraction) %
QStringLiteral(" old pos.: ") % situationOld.getTimestampAndOffset(true) %
QStringLiteral(" new pos.: ") % situationNew.getTimestampAndOffset(true) :
QStringLiteral("")
) %
(
withCurrentSituation ?
separator %
QStringLiteral("sit.: ") % situationCurrent.toQString(true) :
QStringLiteral("")
) %
(
withOtherPositions ?
separator %
QStringLiteral("old: ") % situationOld.toQString(true) %
separator %
QStringLiteral("new: ") % situationNew.toQString(true) :
QStringLiteral("")
);
}
QString CInterpolationLogger::PartsLog::toQString(const QString &separator) const
{
return QStringLiteral("CS: ") % callsign.asString() % separator %
QStringLiteral("ts: ") % CInterpolationLogger::msSinceEpochToTimeAndTimestamp(tsCurrent) %
separator %
QStringLiteral("parts: ") % parts.toQString(true);
}
const QString &CInterpolationLogger::SituationLog::interpolationType() const
{
static const QString s("spline");
static const QString l("linear");
static const QString u("unknown");
if (interpolator == 's') { return s; }
if (interpolator == 'l') { return l; }
return u;
}
} // namespace
} // namespace

View File

@@ -13,6 +13,7 @@
#define BLACKMISC_SIMULATION_INTERPOLATIONLOGGER_H
#include "interpolationrenderingsetup.h"
#include "interpolationhints.h"
#include "blackmisc/simulation/remoteaircraftprovider.h"
#include "blackmisc/aviation/aircraftpartslist.h"
#include "blackmisc/aviation/aircraftsituation.h"
@@ -52,31 +53,51 @@ namespace BlackMisc
static QString getLogDirectory();
//! Log entry for situation interpolation
struct SituationLog
struct BLACKMISC_EXPORT SituationLog
{
QChar interpolator; //!< what interpolator is used
qint64 timestamp = -1; //!< current timestamp
qint64 tsCurrent = -1; //!< current timestamp
qint64 tsInterpolated = -1; //!< timestamp interpolated
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
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 noTransferredElevations = 0; //!< transferred elevation to n situations
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
Aviation::CAircraftSituation situationOld; //!< old situation
Aviation::CAircraftSituation situationNew; //!< new situation
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;
//! To string
QString toQString(
bool withCurrentSituation, bool withHints, bool withSetup, bool withElevation,
bool withOtherPositions, bool withDeltaTimes, const QString &separator = {" "}) const;
};
//! Log entry for parts interpolation
struct PartsLog
struct BLACKMISC_EXPORT PartsLog
{
qint64 timestamp = -1; //!< current timestamp
qint64 tsCurrent = -1; //!< current timestamp
bool empty = false; //!< empty parts?
Aviation::CCallsign callsign; //!< current callsign
Aviation::CAircraftParts parts; //!< parts to be logged
//! To string
QString toQString(const QString &separator = {" "}) const;
};
//! Log current interpolation cycle, only stores in memory, for performance reasons
@@ -108,6 +129,14 @@ namespace BlackMisc
//! \threadsafe
QList<PartsLog> getPartsLog(const Aviation::CCallsign &cs) const;
//! Get last log
//! \threadsafe
SituationLog getLastSituationLog() const;
//! Get last log
//! \threadsafe
SituationLog getLastSituationLog(const Aviation::CCallsign &cs) const;
//! Get last situation
//! \threadsafe
Aviation::CAircraftSituation getLastSituation() const;
@@ -124,6 +153,14 @@ namespace BlackMisc
//! \threadsafe
Aviation::CAircraftParts getLastParts(const Aviation::CCallsign &cs) const;
//! Get last parts
//! \threadsafe
PartsLog getLastPartsLog() const;
//! Get last parts
//! \threadsafe
PartsLog getLastPartsLog(const Aviation::CCallsign &cs) const;
//! File pattern for interpolation log
static const QString &filePatternInterpolationLog();
@@ -149,12 +186,15 @@ namespace BlackMisc
//! 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
mutable QReadWriteLock m_lockParts; //!< lock logging
int m_maxSituations = 2500;
mutable QReadWriteLock m_lockSituations; //!< lock logging situations
mutable QReadWriteLock m_lockParts; //!< lock logging parts
int m_maxSituations = 2500; //!< max.number of situations
QList<PartsLog> m_partsLogs; //!< logs of parts
QList<SituationLog> m_situationLogs; //!< logs of interpolation
};

View File

@@ -157,7 +157,7 @@ namespace BlackMisc
return m_callsignsToLog;
}
bool CInterpolationAndRenderingSetup::logCallsign(const Aviation::CCallsign &callsign) const
bool CInterpolationAndRenderingSetup::isLogCallsign(const Aviation::CCallsign &callsign) const
{
return m_callsignsToLog.contains(callsign);
}

View File

@@ -114,7 +114,7 @@ namespace BlackMisc
BlackMisc::Aviation::CCallsignSet getLogCallsigns() const;
//! Log the given callsign?
bool logCallsign(const Aviation::CCallsign &callsign) const;
bool isLogCallsign(const Aviation::CCallsign &callsign) const;
//! \copydoc BlackMisc::Mixin::String::toQString
QString convertToQString(bool i18n = false) const;

View File

@@ -140,11 +140,10 @@ namespace BlackMisc
{
log.timestamp = currentTimeMsSinceEpoc;
log.callsign = m_callsign;
log.cgAboveGround = hints.getCGAboveGround();
log.vtolAircraft = hints.isVtolAircraft();
log.currentSituation = currentSituation;
log.useParts = hints.hasAircraftParts();
log.parts = hints.getAircraftParts();
log.groundFactor = groundFactor;
log.situationCurrent = currentSituation;
log.usedHints = hints;
log.usedSetup = setup;
m_logger->logInterpolation(log);
}