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