mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-04 17:30:12 +08:00
Ref T270, improved setup/logger handling
* utility functions to enable logging * logger access and access to log messages
This commit is contained in:
@@ -487,11 +487,9 @@ namespace BlackCore
|
||||
if (parser.hasPart(2))
|
||||
{
|
||||
const CCallsign cs(parser.part(2));
|
||||
CInterpolationAndRenderingSetupPerCallsign setup = this->getInterpolationSetupPerCallsignOrDefault(cs);
|
||||
const bool changed = setup.setInterpolatorMode(part1);
|
||||
const bool changed = this->setInterpolationMode(part1, cs);
|
||||
if (changed)
|
||||
{
|
||||
this->setInterpolationSetupPerCallsign(setup, cs);
|
||||
emit this->interpolationAndRenderingSetupChanged();
|
||||
}
|
||||
CLogMessage(this).info(changed ? "Changed interpolation mode for '%1'" : "Unchanged interpolation mode for '%1'") << cs.asString();
|
||||
@@ -761,6 +759,23 @@ namespace BlackCore
|
||||
this->physicallyRemoveRemoteAircraft(remoteCallsign);
|
||||
}
|
||||
|
||||
QString CSimulatorCommon::latestLoggedDataFormatted(const CCallsign &cs) const
|
||||
{
|
||||
const SituationLog s = m_interpolationLogger.getLastSituationLog(cs);
|
||||
const PartsLog p = m_interpolationLogger.getLastPartsLog(cs);
|
||||
|
||||
static const QString sep("\n------\n");
|
||||
QString dm;
|
||||
if (s.tsCurrent > 0)
|
||||
{
|
||||
dm = QStringLiteral("Setup: ") % s.usedSetup.toQString(true) %
|
||||
QStringLiteral("\n\n") %
|
||||
QStringLiteral("Situation: ") % s.toQString(false, true, true, true, true, sep);
|
||||
}
|
||||
if (p.tsCurrent > 0) { dm += (dm.isEmpty() ? QStringLiteral("") : QStringLiteral("\n\n")) % QStringLiteral("Parts: ") % p.toQString(sep); }
|
||||
return dm;
|
||||
}
|
||||
|
||||
void CSimulatorCommon::displayLoggedSituationInSimulator(const CCallsign &cs, bool stopLogging, int times)
|
||||
{
|
||||
if (cs.isEmpty()) { return; }
|
||||
@@ -781,18 +796,7 @@ namespace BlackCore
|
||||
return;
|
||||
}
|
||||
|
||||
const SituationLog s = m_interpolationLogger.getLastSituationLog(cs);
|
||||
const PartsLog p = m_interpolationLogger.getLastPartsLog(cs);
|
||||
|
||||
QString dm;
|
||||
static const QString sep("\n------\n");
|
||||
if (s.tsCurrent > 0)
|
||||
{
|
||||
dm = QStringLiteral("Setup: ") % s.usedSetup.toQString(true) %
|
||||
QStringLiteral("\n\n") %
|
||||
QStringLiteral("Situation: ") % s.toQString(false, true, true, true, true, sep);
|
||||
}
|
||||
if (p.tsCurrent > 0) { dm += (dm.isEmpty() ? QStringLiteral("") : QStringLiteral("\n\n")) % QStringLiteral("Parts: ") % p.toQString(sep); }
|
||||
const QString dm = this->latestLoggedDataFormatted(cs);
|
||||
if (!dm.isEmpty())
|
||||
{
|
||||
this->displayStatusMessage(CStatusMessage(this).info(dm));
|
||||
|
||||
@@ -114,6 +114,12 @@ namespace BlackCore
|
||||
//! Counter removed aircraft
|
||||
int getStatisticsPhysicallyRemovedAircraft() const { return m_statsPhysicallyRemovedAircraft; }
|
||||
|
||||
//! Access to logger
|
||||
const BlackMisc::Simulation::CInterpolationLogger &interpolationLogger() const { return m_interpolationLogger; }
|
||||
|
||||
//! The latest logged data formatted
|
||||
QString latestLoggedDataFormatted(const BlackMisc::Aviation::CCallsign &cs) const;
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CSimulatorCommon(const BlackMisc::Simulation::CSimulatorPluginInfo &info,
|
||||
|
||||
@@ -64,6 +64,13 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
bool CInterpolationAndRenderingSetupBase::setLogInterpolation(bool log)
|
||||
{
|
||||
if (m_logInterpolation == log) { return false; }
|
||||
m_logInterpolation = log;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CInterpolationAndRenderingSetupBase::setEnabledAircraftParts(bool enabled)
|
||||
{
|
||||
if (m_enabledAircraftParts == enabled) { return false; }
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace BlackMisc
|
||||
bool logInterpolation() const { return m_logInterpolation; }
|
||||
|
||||
//! Log.interpolation
|
||||
void setLogInterpolation(bool log) { m_logInterpolation = log; }
|
||||
bool setLogInterpolation(bool log);
|
||||
|
||||
//! Full interpolation (skip optimizations like checking if aircraft moves etc.)
|
||||
bool isForcingVtolInterpolation() const { return m_forceVtolInterpolation; }
|
||||
|
||||
@@ -57,6 +57,24 @@ namespace BlackMisc
|
||||
return callsigns;
|
||||
}
|
||||
|
||||
bool IInterpolationSetupProvider::setInterpolationMode(const QString &modeAsString, const CCallsign &callsign)
|
||||
{
|
||||
CInterpolationAndRenderingSetupPerCallsign setup = this->getInterpolationSetupPerCallsignOrDefault(callsign);
|
||||
if (!setup.setInterpolatorMode(modeAsString)) { return false; }
|
||||
|
||||
// changed value
|
||||
return this->setInterpolationSetupPerCallsign(setup, callsign, true);
|
||||
}
|
||||
|
||||
bool IInterpolationSetupProvider::setLogInterpolation(bool log, const CCallsign &callsign)
|
||||
{
|
||||
CInterpolationAndRenderingSetupPerCallsign setup = this->getInterpolationSetupPerCallsignOrDefault(callsign);
|
||||
if (!setup.setLogInterpolation(log)) { return false; }
|
||||
|
||||
// changed value
|
||||
return this->setInterpolationSetupPerCallsign(setup, callsign, true);
|
||||
}
|
||||
|
||||
bool IInterpolationSetupProvider::setInterpolationSetupGlobal(const CInterpolationAndRenderingSetupGlobal &setup)
|
||||
{
|
||||
{
|
||||
|
||||
@@ -50,6 +50,14 @@ namespace BlackMisc
|
||||
//! \threadsafe
|
||||
Aviation::CCallsignSet getLogCallsigns() const;
|
||||
|
||||
//! Set mode as string
|
||||
//! \threadsafe
|
||||
bool setInterpolationMode(const QString &modeAsString, const Aviation::CCallsign &callsign);
|
||||
|
||||
//! Enable/disable logging
|
||||
//! \threadsafe
|
||||
bool setLogInterpolation(bool log, const Aviation::CCallsign &callsign);
|
||||
|
||||
protected:
|
||||
//! Set the global setup
|
||||
//! \threadsafe
|
||||
|
||||
Reference in New Issue
Block a user