mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-01 06:35:41 +08:00
refs #895, also log when parts are empty
* added empty flag * move logging into own function (because it is called in multiple places now)
This commit is contained in:
committed by
Mathew Sutcliffe
parent
aa14c564b0
commit
a27717cf8b
@@ -228,7 +228,7 @@ namespace BlackMisc
|
|||||||
QLatin1String("<td>") % log.callsign.asString() % QLatin1String("</td>") %
|
QLatin1String("<td>") % log.callsign.asString() % QLatin1String("</td>") %
|
||||||
QLatin1String("<td>") % msSinceEpochToTime(log.timestamp) % QLatin1String("</td>") %
|
QLatin1String("<td>") % msSinceEpochToTime(log.timestamp) % QLatin1String("</td>") %
|
||||||
(changedParts ? QLatin1String("<td class=\"changed\">*</td>") : QLatin1String("<td></td>")) %
|
(changedParts ? QLatin1String("<td class=\"changed\">*</td>") : QLatin1String("<td></td>")) %
|
||||||
QLatin1String("<td>") % log.parts.toQString() % QLatin1String("</td>");
|
QLatin1String("<td>") % (log.empty ? QLatin1String("empty") : log.parts.toQString()) % QLatin1String("</td>");
|
||||||
}
|
}
|
||||||
tableRows += QLatin1String("</tbody>\n");
|
tableRows += QLatin1String("</tbody>\n");
|
||||||
return QLatin1String("<table class=\"small\">\n") % tableHeader % tableRows % QLatin1String("</table>\n");
|
return QLatin1String("<table class=\"small\">\n") % tableHeader % tableRows % QLatin1String("</table>\n");
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ namespace BlackMisc
|
|||||||
qint64 timestamp = -1; //!< current timestamp
|
qint64 timestamp = -1; //!< current timestamp
|
||||||
BlackMisc::Aviation::CCallsign callsign; //!< current callsign
|
BlackMisc::Aviation::CCallsign callsign; //!< current callsign
|
||||||
BlackMisc::Aviation::CAircraftParts parts; //!< parts to be logged
|
BlackMisc::Aviation::CAircraftParts parts; //!< parts to be logged
|
||||||
|
bool empty = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Log current interpolation cycle, only stores in memory, for performance reasons
|
//! Log current interpolation cycle, only stores in memory, for performance reasons
|
||||||
|
|||||||
@@ -182,6 +182,14 @@ namespace BlackMisc
|
|||||||
partsStatus.reset();
|
partsStatus.reset();
|
||||||
if (currentTimeMsSinceEpoch < 0) { currentTimeMsSinceEpoch = QDateTime::currentMSecsSinceEpoch(); }
|
if (currentTimeMsSinceEpoch < 0) { currentTimeMsSinceEpoch = QDateTime::currentMSecsSinceEpoch(); }
|
||||||
|
|
||||||
|
// log for empty parts aircraft parts
|
||||||
|
if (m_aircraftParts.isEmpty())
|
||||||
|
{
|
||||||
|
static const CAircraftParts emptyParts;
|
||||||
|
this->logParts(currentTimeMsSinceEpoch, emptyParts, true, log);
|
||||||
|
emptyParts;
|
||||||
|
}
|
||||||
|
|
||||||
// find the first parts not in the correct order, keep only the parts before that one
|
// find the first parts not in the correct order, keep only the parts before that one
|
||||||
const auto end = std::is_sorted_until(m_aircraftParts.begin(), m_aircraftParts.end(), [](auto && a, auto && b) { return b.getAdjustedMSecsSinceEpoch() < a.getAdjustedMSecsSinceEpoch(); });
|
const auto end = std::is_sorted_until(m_aircraftParts.begin(), m_aircraftParts.end(), [](auto && a, auto && b) { return b.getAdjustedMSecsSinceEpoch() < a.getAdjustedMSecsSinceEpoch(); });
|
||||||
const auto validParts = makeRange(m_aircraftParts.begin(), end);
|
const auto validParts = makeRange(m_aircraftParts.begin(), end);
|
||||||
@@ -226,18 +234,22 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
while (false);
|
while (false);
|
||||||
|
|
||||||
if (m_logger && log)
|
this->logParts(currentTimeMsSinceEpoch, currentParts, false, log);
|
||||||
{
|
|
||||||
CInterpolationLogger::PartsLog log;
|
|
||||||
log.callsign = m_callsign;
|
|
||||||
log.timestamp = currentTimeMsSinceEpoch;
|
|
||||||
log.parts = currentParts;
|
|
||||||
m_logger->logParts(log);
|
|
||||||
}
|
|
||||||
|
|
||||||
return currentParts;
|
return currentParts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename Derived>
|
||||||
|
void CInterpolator<Derived>::logParts(qint64 timestamp, const CAircraftParts &parts, bool empty, bool log)
|
||||||
|
{
|
||||||
|
if (!log || !m_logger) { return; }
|
||||||
|
CInterpolationLogger::PartsLog logInfo;
|
||||||
|
logInfo.callsign = m_callsign;
|
||||||
|
logInfo.timestamp = timestamp;
|
||||||
|
logInfo.parts = parts;
|
||||||
|
logInfo.empty = empty;
|
||||||
|
m_logger->logParts(logInfo);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Derived>
|
template <typename Derived>
|
||||||
void CInterpolator<Derived>::addAircraftSituation(const CAircraftSituation &situation)
|
void CInterpolator<Derived>::addAircraftSituation(const CAircraftSituation &situation)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -88,6 +88,9 @@ namespace BlackMisc
|
|||||||
private:
|
private:
|
||||||
CInterpolationLogger *m_logger = nullptr;
|
CInterpolationLogger *m_logger = nullptr;
|
||||||
|
|
||||||
|
//! Log parts
|
||||||
|
void logParts(qint64 timestamp, const Aviation::CAircraftParts &parts, bool empty, bool log);
|
||||||
|
|
||||||
Derived *derived() { return static_cast<Derived *>(this); }
|
Derived *derived() { return static_cast<Derived *>(this); }
|
||||||
const Derived *derived() const { return static_cast<const Derived *>(this); }
|
const Derived *derived() const { return static_cast<const Derived *>(this); }
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user