mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 07:35:48 +08:00
Ref T668, minor style changes and improvemments
This commit is contained in:
@@ -36,6 +36,12 @@ namespace BlackMisc
|
||||
//! Valid?
|
||||
void setValid(bool valid) { m_valid = valid; }
|
||||
|
||||
//! Is recalculated interpolant?
|
||||
bool isRecalculated() const { return m_recalculated; }
|
||||
|
||||
//! Set recalculated interpolant
|
||||
void setRecalculated(bool reCalculated) { m_recalculated = reCalculated; }
|
||||
|
||||
protected:
|
||||
//! Default ctor
|
||||
IInterpolant() {}
|
||||
@@ -50,6 +56,7 @@ namespace BlackMisc
|
||||
int m_situationsAvailable = 0; //!< used situations
|
||||
CInterpolatorPbh m_pbh; //!< the used PBH interpolator
|
||||
bool m_valid = true; //!< valid?
|
||||
bool m_recalculated = false; //!< recalculated interpolant
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace BlackMisc
|
||||
|
||||
CWorker *worker = CWorker::fromTask(this, "WriteInterpolationLog", [situations, parts]()
|
||||
{
|
||||
const CStatusMessageList msg = CInterpolationLogger::writeLogFile(situations, parts);
|
||||
const CStatusMessageList msg = CInterpolationLogger::writeLogFiles(situations, parts);
|
||||
CLogMessage::preformatted(msg);
|
||||
});
|
||||
return worker;
|
||||
@@ -67,7 +67,7 @@ namespace BlackMisc
|
||||
|
||||
QStringList CInterpolationLogger::getLatestLogFiles()
|
||||
{
|
||||
QStringList files({ "", ""});
|
||||
QStringList files({ "", "" });
|
||||
const QString logDir = CDirectoryUtils::logDirectory();
|
||||
QDir logs(logDir);
|
||||
if (!logs.exists()) { return files; }
|
||||
@@ -90,7 +90,7 @@ namespace BlackMisc
|
||||
return CDirectoryUtils::logDirectory();
|
||||
}
|
||||
|
||||
CStatusMessageList CInterpolationLogger::writeLogFile(const QList<SituationLog> &interpolation, const QList<PartsLog> &parts)
|
||||
CStatusMessageList CInterpolationLogger::writeLogFiles(const QList<SituationLog> &interpolation, const QList<PartsLog> &parts)
|
||||
{
|
||||
if (parts.isEmpty() && interpolation.isEmpty()) { return CStatusMessage(static_cast<CInterpolationLogger *>(nullptr)).warning(u"No data for log"); }
|
||||
static const QString html = QStringLiteral("Entries: %1\n\n%2");
|
||||
@@ -264,8 +264,9 @@ namespace BlackMisc
|
||||
if (logs.isEmpty()) { return {}; }
|
||||
static const QString tableHeader =
|
||||
QStringLiteral(
|
||||
"<thead><tr>"
|
||||
"<th title=\"changed situation\">cs.</th><th>Int</th>"
|
||||
u"<thead><tr>"
|
||||
u"<th title=\"changed situation\">cs.</th><th>Int</th>"
|
||||
u"<th title=\"recalculated interpolant\">recalc</th>"
|
||||
u"<th>CS</th><th>VTOL</th><th>timestamp</th><th>since</th>"
|
||||
u"<th>ts old</th><th>ts new</th><th>ts cur</th>"
|
||||
u"<th>Interpolation ts.</th><th>Sample Δt</th><th>fraction</th>"
|
||||
@@ -289,7 +290,7 @@ namespace BlackMisc
|
||||
{
|
||||
const CAircraftSituation situationOld = log.oldestInterpolationSituation();
|
||||
const CAircraftSituation situationNew = log.newestInterpolationSituation();
|
||||
const bool changedNewPosition = newPosTs != situationNew.getMSecsSinceEpoch();
|
||||
const bool changedNewPosition = (newPosTs != situationNew.getMSecsSinceEpoch());
|
||||
const bool changedParts = (lastParts != log.parts);
|
||||
newPosTs = situationNew.getMSecsSinceEpoch();
|
||||
lastParts = log.parts;
|
||||
@@ -300,6 +301,7 @@ namespace BlackMisc
|
||||
u"<tr>" %
|
||||
(changedNewPosition ? QStringLiteral("<td class=\"changed\">*</td>") : QStringLiteral("<td></td>")) %
|
||||
u"<td>" % log.interpolator % u"</td>" %
|
||||
u"<td>" % boolToYesNo(log.interpolantRecalc) % u"</td>"
|
||||
u"<td>" % log.callsign.asString() % u"</td>" %
|
||||
u"<td>" % boolToYesNo(log.vtolAircraft) % u"</td>" %
|
||||
u"<td>" % msSinceEpochToTime(log.tsCurrent) % u"</td>" %
|
||||
|
||||
@@ -33,17 +33,18 @@ namespace BlackMisc
|
||||
qint64 tsCurrent = -1; //!< current timestamp
|
||||
qint64 tsInterpolated = -1; //!< timestamp interpolated
|
||||
double groundFactor = -1; //!< current ground factor
|
||||
bool vtolAircraft = false; //!< VTOL aircraft
|
||||
double simTimeFraction = -1; //!< time fraction, expected 0..1
|
||||
double deltaSampleTimesMs = -1; //!< delta time between samples (i.e. 2 situations)
|
||||
bool useParts = false; //!< supporting aircraft parts
|
||||
bool vtolAircraft = false; //!< VTOL aircraft
|
||||
bool interpolantRecalc = false; //!< interpolant recalculated
|
||||
int noNetworkSituations = 0; //!< available network situations
|
||||
int noInvalidSituations = 0; //!< invalid situations, missing situations for timestampd
|
||||
QString elevationInfo; //!< info about elevation retrieval
|
||||
QString altCorrection; //!< info about altitude correction as CAircraftSituation::AltitudeCorrection
|
||||
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::CAircraftSituationList interpolationSituations; //!< the interpolator uses 2, 3 situations (latest at end)
|
||||
Aviation::CAircraftSituation situationCurrent; //!< interpolated situation
|
||||
Aviation::CAircraftSituationChange change; //!< change
|
||||
PhysicalQuantities::CLength cgAboveGround = PhysicalQuantities::CLength::null(); //!< center of gravity (CG)
|
||||
@@ -195,13 +196,13 @@ namespace BlackMisc
|
||||
|
||||
private:
|
||||
//! Get log as HTML table
|
||||
static QString getHtmlInterpolationLog(const QList<SituationLog> &getSituationsLog);
|
||||
static QString getHtmlInterpolationLog(const QList<SituationLog> &logs);
|
||||
|
||||
//! Get log as HTML table
|
||||
static QString getHtmlPartsLog(const QList<PartsLog> &getSituationsLog);
|
||||
static QString getHtmlPartsLog(const QList<PartsLog> &logs);
|
||||
|
||||
//! Write log to file
|
||||
static CStatusMessageList writeLogFile(const QList<SituationLog> &interpolation, const QList<PartsLog> &getPartsLog);
|
||||
static CStatusMessageList writeLogFiles(const QList<SituationLog> &interpolation, const QList<PartsLog> &getPartsLog);
|
||||
|
||||
//! Status of file operation
|
||||
static CStatusMessage logStatusFileWriting(bool success, const QString &fileName);
|
||||
|
||||
@@ -309,6 +309,7 @@ namespace BlackMisc
|
||||
log.groundFactor = currentSituation.getOnGroundFactor();
|
||||
log.altCorrection = CAircraftSituation::altitudeCorrectionToString(altCorrection);
|
||||
log.situationCurrent = currentSituation;
|
||||
log.interpolantRecalc = interpolant.isRecalculated();
|
||||
log.change = m_pastSituationsChange;
|
||||
log.usedSetup = m_currentSetup;
|
||||
log.elevationInfo = this->getElevationsFoundMissedInfo();
|
||||
@@ -316,7 +317,10 @@ namespace BlackMisc
|
||||
log.sceneryOffset = m_currentSceneryOffset;
|
||||
log.noInvalidSituations = m_invalidSituations;
|
||||
log.noNetworkSituations = m_currentSituations.sizeInt();
|
||||
log.useParts = this->isRemoteAircraftSupportingParts(m_callsign);
|
||||
m_logger->logInterpolation(log);
|
||||
|
||||
// if (log.interpolantRecalc) { CLogMessage(this).debug(u"Recalc %1") << log.callsign.asString(); }
|
||||
}
|
||||
|
||||
// bye
|
||||
|
||||
@@ -36,22 +36,22 @@ namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
CInterpolatorLinear::CInterpolant::CInterpolant(const CAircraftSituation &situation) :
|
||||
IInterpolant(1, CInterpolatorPbh(0, situation, situation)),
|
||||
m_oldSituation(situation)
|
||||
CInterpolatorLinear::CInterpolant::CInterpolant(const CAircraftSituation &oldSituation) :
|
||||
IInterpolant(1, CInterpolatorPbh(0, oldSituation, oldSituation)),
|
||||
m_oldSituation(oldSituation)
|
||||
{ }
|
||||
|
||||
CInterpolatorLinear::CInterpolant::CInterpolant(const CAircraftSituation &situation, const CInterpolatorPbh &pbh) :
|
||||
CInterpolatorLinear::CInterpolant::CInterpolant(const CAircraftSituation &oldSituation, const CInterpolatorPbh &pbh) :
|
||||
IInterpolant(1, pbh),
|
||||
m_oldSituation(situation)
|
||||
m_oldSituation(oldSituation)
|
||||
{ }
|
||||
|
||||
CInterpolatorLinear::CInterpolant::CInterpolant(const CAircraftSituation &situation1, const CAircraftSituation &situation2, double timeFraction, qint64 interpolatedTime) :
|
||||
CInterpolatorLinear::CInterpolant::CInterpolant(const CAircraftSituation &oldSituation, const CAircraftSituation &newSituation, double timeFraction, qint64 interpolatedTime) :
|
||||
IInterpolant(interpolatedTime, 2),
|
||||
m_oldSituation(situation1), m_newSituation(situation2),
|
||||
m_oldSituation(oldSituation), m_newSituation(newSituation),
|
||||
m_simulationTimeFraction(timeFraction)
|
||||
{
|
||||
m_pbh = CInterpolatorPbh(m_simulationTimeFraction, situation1, situation2);
|
||||
m_pbh = CInterpolatorPbh(m_simulationTimeFraction, oldSituation, newSituation);
|
||||
}
|
||||
|
||||
void CInterpolatorLinear::anchor()
|
||||
@@ -118,7 +118,9 @@ namespace BlackMisc
|
||||
CAircraftSituation oldSituation = m_interpolant.getOldSituation();
|
||||
CAircraftSituation newSituation = m_interpolant.getNewSituation();
|
||||
|
||||
if (m_situationsLastModifiedUsed < m_situationsLastModified)
|
||||
const bool recalculated = m_situationsLastModifiedUsed < m_situationsLastModified;
|
||||
m_interpolant.setRecalculated(recalculated);
|
||||
if (recalculated)
|
||||
{
|
||||
m_situationsLastModifiedUsed = m_situationsLastModified;
|
||||
|
||||
@@ -211,8 +213,9 @@ namespace BlackMisc
|
||||
log.deltaSampleTimesMs = sampleDeltaTimeMs;
|
||||
log.tsInterpolated = interpolatedTime;
|
||||
log.interpolationSituations.clear();
|
||||
log.interpolationSituations.push_back(newSituation); // newest at front
|
||||
log.interpolationSituations.push_back(oldSituation); // oldest at back
|
||||
log.interpolationSituations.push_back(oldSituation); // oldest at front
|
||||
log.interpolationSituations.push_back(newSituation); // latest at back
|
||||
log.interpolantRecalc = recalculated;
|
||||
}
|
||||
|
||||
m_interpolant = { oldSituation, newSituation, simulationTimeFraction, interpolatedTime };
|
||||
|
||||
@@ -45,9 +45,9 @@ namespace BlackMisc
|
||||
//! Constructor
|
||||
//! @{
|
||||
CInterpolant() {}
|
||||
CInterpolant(const Aviation::CAircraftSituation &situation);
|
||||
CInterpolant(const Aviation::CAircraftSituation &situation, const CInterpolatorPbh &pbh);
|
||||
CInterpolant(const Aviation::CAircraftSituation &situation1, const Aviation::CAircraftSituation &situation2, double timeFraction, qint64 interpolatedTime);
|
||||
CInterpolant(const Aviation::CAircraftSituation &oldSituation);
|
||||
CInterpolant(const Aviation::CAircraftSituation &oldSituation, const CInterpolatorPbh &pbh);
|
||||
CInterpolant(const Aviation::CAircraftSituation &oldSituation, const Aviation::CAircraftSituation &newSituation, double timeFraction, qint64 interpolatedTime);
|
||||
//! @}
|
||||
|
||||
//! Perform the interpolation
|
||||
|
||||
@@ -266,6 +266,7 @@ namespace BlackMisc
|
||||
log.deltaSampleTimesMs = dt2;
|
||||
log.simTimeFraction = timeFraction;
|
||||
log.tsInterpolated = interpolatedTime; // without offsets
|
||||
log.interpolantRecalc = m_interpolant.isRecalculated();
|
||||
}
|
||||
|
||||
return m_interpolant;
|
||||
|
||||
Reference in New Issue
Block a user