mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 06:35:52 +08:00
refs #865, allow to enable interpolator/parts logging
* removed debug messages from interpolator * added callsign to getInterpolatedParts / getInterpolatedSituation signatures * config for logging via CInterpolationAndRenderingSetup::addCallsignToLog etc.
This commit is contained in:
committed by
Mathew Sutcliffe
parent
c84bf93862
commit
af15929b30
@@ -159,7 +159,7 @@ namespace BlackCore
|
||||
if (enabled)
|
||||
{
|
||||
// are we already visible?
|
||||
if (!isPhysicallyRenderedAircraft(callsign))
|
||||
if (!this->isPhysicallyRenderedAircraft(callsign))
|
||||
{
|
||||
this->physicallyAddRemoteAircraft(aircraft);
|
||||
}
|
||||
@@ -182,16 +182,10 @@ namespace BlackCore
|
||||
IInterpolator::InterpolationStatus interpolationStatus;
|
||||
CInterpolationHints &hints = m_hints[aircraft.getCallsign()];
|
||||
hints.setVtolAircraft(aircraft.isVtol());
|
||||
const CAircraftSituation as(m_interpolator->getInterpolatedSituation(callsign, time, hints, interpolationStatus));
|
||||
if (interpolationStatus.didInterpolationSucceed())
|
||||
{
|
||||
aircraft.setSituation(as);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
const CAircraftSituation currentSituation(m_interpolator->getInterpolatedSituation(callsign, time, hints, interpolationStatus));
|
||||
if (!interpolationStatus.didInterpolationSucceed()) { return false; }
|
||||
aircraft.setSituation(currentSituation);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CSimulatorCommon::reloadWeatherSettings()
|
||||
@@ -360,16 +354,65 @@ namespace BlackCore
|
||||
if (commandLine.isEmpty()) { return false; }
|
||||
CSimpleCommandParser parser(
|
||||
{
|
||||
".plugin", ".drv", ".driver"
|
||||
".plugin", ".drv", ".driver",
|
||||
});
|
||||
parser.parse(commandLine);
|
||||
if (!parser.isKnownCommand()) { return false; }
|
||||
|
||||
// .plugin unload
|
||||
if (parser.matchesPart(1, "unload"))
|
||||
{
|
||||
this->unload();
|
||||
return true;
|
||||
}
|
||||
|
||||
// .plugin loginterpolator etc.
|
||||
if (parser.part(1).startsWith("logint") && parser.hasPart(2))
|
||||
{
|
||||
if (!this->m_interpolator) { return false; }
|
||||
const QString p = parser.part(2).toLower();
|
||||
if (p == "off" || p == "false")
|
||||
{
|
||||
this->m_interpolationRenderingSetup.clearInterpolatorLogCallsigns();
|
||||
this->m_interpolator->setInterpolatorSetup(this->m_interpolationRenderingSetup);
|
||||
CStatusMessage(this).info("Disabled interpolation logging");
|
||||
return true;
|
||||
}
|
||||
if (p == "clear" || p == "clr")
|
||||
{
|
||||
this->m_interpolator->clearLog();
|
||||
CStatusMessage(this).info("Cleared interpolation logging");
|
||||
return true;
|
||||
}
|
||||
if (p == "write" || p == "save")
|
||||
{
|
||||
// stop logging
|
||||
this->m_interpolationRenderingSetup.clearInterpolatorLogCallsigns();
|
||||
this->m_interpolator->setInterpolatorSetup(this->m_interpolationRenderingSetup);
|
||||
|
||||
// write
|
||||
this->m_interpolator->writeLogInBackground();
|
||||
CLogMessage(this).info("Started writing interpolation log");
|
||||
return true;
|
||||
}
|
||||
|
||||
const QString cs = p.toUpper();
|
||||
if (!CCallsign::isValidAircraftCallsign(cs)) { return false; }
|
||||
if (this->getAircraftInRangeCallsigns().contains(cs))
|
||||
{
|
||||
this->m_interpolationRenderingSetup.addCallsignToLog(CCallsign(cs));
|
||||
this->m_interpolator->setInterpolatorSetup(this->m_interpolationRenderingSetup);
|
||||
CLogMessage(this).info("Will log interpolation for '%1'") << cs;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
CLogMessage(this).warning("Cannot log interpolation for '%1', no aircraft in range") << cs;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// driver specific cmd line arguments
|
||||
return this->parseDetails(parser);
|
||||
}
|
||||
|
||||
|
||||
@@ -83,6 +83,18 @@ namespace BlackCore
|
||||
virtual void setWeatherActivated(bool activated) override;
|
||||
virtual void unload() override;
|
||||
virtual int physicallyRemoveMultipleRemoteAircraft(const BlackMisc::Aviation::CCallsignSet &callsigns) override;
|
||||
|
||||
//! \copydoc ISimulator::parseCommandLine
|
||||
//! \ingroup commandline
|
||||
//! @{
|
||||
//! <pre>
|
||||
//! .plugin unload unload plugin
|
||||
//! .plugin logint callsign log interpolator for callsign
|
||||
//! .plugin logint off no log information for interpolator
|
||||
//! .plugin logint write write interpolator log to file
|
||||
//! .plugin logint clear clear current log
|
||||
//! </pre>
|
||||
//! @}
|
||||
virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) override;
|
||||
// --------- ISimulator implementations ------------
|
||||
|
||||
|
||||
@@ -71,7 +71,6 @@ namespace BlackGui
|
||||
connect(ui->cb_DebugContextSimulator, &QCheckBox::stateChanged, this, &CInternalsComponent::ps_enableDebug);
|
||||
|
||||
connect(ui->cb_DebugDriver, &QCheckBox::stateChanged, this, &CInternalsComponent::ps_enableDebug);
|
||||
connect(ui->cb_DebugInterpolator, &QCheckBox::stateChanged, this, &CInternalsComponent::ps_enableDebug);
|
||||
connect(ui->cb_ForceFullInterpolation, &QCheckBox::stateChanged, this, &CInternalsComponent::ps_enableDebug);
|
||||
connect(ui->cb_EnableParts, &QCheckBox::stateChanged, this, &CInternalsComponent::ps_enableDebug);
|
||||
|
||||
@@ -192,12 +191,11 @@ namespace BlackGui
|
||||
else if (sender == ui->cb_DebugContextNetwork) { sGui->getIContextNetwork()->setDebugEnabled(debug);}
|
||||
else if (sender == ui->cb_DebugContextOwnAircraft) { sGui->getIContextOwnAircraft()->setDebugEnabled(debug); }
|
||||
else if (sender == ui->cb_DebugContextSimulator) { sGui->getIContextSimulator()->setDebugEnabled(debug);}
|
||||
else if (sender == ui->cb_DebugDriver || sender == ui->cb_EnableParts || sender == ui->cb_DebugInterpolator || sender == ui->cb_ForceFullInterpolation)
|
||||
else if (sender == ui->cb_DebugDriver || sender == ui->cb_EnableParts || sender == ui->cb_ForceFullInterpolation)
|
||||
{
|
||||
CInterpolationAndRenderingSetup setup;
|
||||
setup.setForceFullInterpolation(ui->cb_ForceFullInterpolation->isChecked());
|
||||
setup.setDriverDebuggingMessages(ui->cb_DebugDriver->isChecked());
|
||||
setup.setInterpolatorDebuggingMessages(ui->cb_DebugInterpolator->isChecked());
|
||||
setup.setEnabledAircraftParts(ui->cb_EnableParts->isChecked());
|
||||
sGui->getIContextSimulator()->setInterpolationAndRenderingSetup(setup);
|
||||
}
|
||||
|
||||
@@ -108,17 +108,10 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="cb_DebugInterpolator">
|
||||
<property name="text">
|
||||
<string>Interpolator dbg. msgs.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="cb_ForceFullInterpolation">
|
||||
<property name="text">
|
||||
<string>force full interpol.</string>
|
||||
<string>force full interpolation</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -136,6 +136,26 @@ namespace BlackMisc
|
||||
return rt;
|
||||
}
|
||||
|
||||
void CInterpolationAndRenderingSetup::addCallsignToLog(const BlackMisc::Aviation::CCallsign &callsign)
|
||||
{
|
||||
m_callsignsToLog.insert(callsign);
|
||||
}
|
||||
|
||||
void CInterpolationAndRenderingSetup::removeCallsignFromLog(const BlackMisc::Aviation::CCallsign &callsign)
|
||||
{
|
||||
m_callsignsToLog.remove(callsign);
|
||||
}
|
||||
|
||||
void CInterpolationAndRenderingSetup::clearInterpolatorLogCallsigns()
|
||||
{
|
||||
m_callsignsToLog.clear();
|
||||
}
|
||||
|
||||
BlackMisc::Aviation::CCallsignSet CInterpolationAndRenderingSetup::getLogCallsigns() const
|
||||
{
|
||||
return m_callsignsToLog;
|
||||
}
|
||||
|
||||
QString CInterpolationAndRenderingSetup::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#ifndef BLACKMISC_SIMULATION_INTERPOLATIONRENDERINGSETUP_H
|
||||
#define BLACKMISC_SIMULATION_INTERPOLATIONRENDERINGSETUP_H
|
||||
|
||||
#include "blackmisc/aviation/callsignset.h"
|
||||
#include "blackmisc/pq/length.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
@@ -46,12 +47,6 @@ namespace BlackMisc
|
||||
//! Considered as "all aircraft"
|
||||
static int InfiniteAircraft();
|
||||
|
||||
//! Debugging messages
|
||||
bool showInterpolatorDebugMessages() const { return m_interpolatorDebugMessage; }
|
||||
|
||||
//! Debugging messages
|
||||
void setInterpolatorDebuggingMessages(bool debug) { m_interpolatorDebugMessage = debug; }
|
||||
|
||||
//! Debugging messages
|
||||
bool showSimulatorDebugMessages() const { return m_simulatorDebugMessages; }
|
||||
|
||||
@@ -106,6 +101,18 @@ namespace BlackMisc
|
||||
//! Text describing the restrictions
|
||||
QString getRenderRestrictionText() const;
|
||||
|
||||
//! Add a callsign which will be logged
|
||||
void addCallsignToLog(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
//! Remove a callsign from logging
|
||||
void removeCallsignFromLog(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
//! Clear all interpolator log callsigns
|
||||
void clearInterpolatorLogCallsigns();
|
||||
|
||||
//! Callsigns for logging
|
||||
BlackMisc::Aviation::CCallsignSet getLogCallsigns() const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
@@ -122,6 +129,7 @@ namespace BlackMisc
|
||||
bool m_enabledAircraftParts = true; //! Update aircraft parts
|
||||
int m_maxRenderedAircraft = InfiniteAircraft(); //!< max.rendered aircraft
|
||||
BlackMisc::PhysicalQuantities::CLength m_maxRenderedDistance { 0, nullptr }; //!< max.distance for rendering
|
||||
BlackMisc::Aviation::CCallsignSet m_callsignsToLog;
|
||||
|
||||
BLACK_METACLASS(
|
||||
CInterpolationAndRenderingSetup,
|
||||
@@ -130,7 +138,8 @@ namespace BlackMisc
|
||||
BLACK_METAMEMBER(forceFullInterpolation),
|
||||
BLACK_METAMEMBER(enabledAircraftParts),
|
||||
BLACK_METAMEMBER(maxRenderedAircraft),
|
||||
BLACK_METAMEMBER(maxRenderedDistance)
|
||||
BLACK_METAMEMBER(maxRenderedDistance),
|
||||
BLACK_METAMEMBER(callsignsToLog, 0, DisabledForComparison)
|
||||
);
|
||||
};
|
||||
} // namespace
|
||||
|
||||
@@ -100,14 +100,16 @@ namespace BlackMisc
|
||||
//! \threadsafe
|
||||
//! \remark public only for XP driver
|
||||
virtual BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(
|
||||
const BlackMisc::Aviation::CCallsign &callsign,
|
||||
const BlackMisc::Aviation::CAircraftSituationList &situations, qint64 currentTimeSinceEpoc,
|
||||
const CInterpolationHints &hints, InterpolationStatus &status) const = 0;
|
||||
|
||||
//! Parts before given offset time (aka pending parts)
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Aviation::CAircraftParts getInterpolatedParts(
|
||||
const BlackMisc::Aviation::CAircraftPartsList &parts, qint64 cutoffTime,
|
||||
PartsStatus &partsStatus) const;
|
||||
const Aviation::CCallsign &callsign,
|
||||
const BlackMisc::Aviation::CAircraftPartsList &parts, qint64 cutoffTime,
|
||||
PartsStatus &partsStatus) const;
|
||||
|
||||
//! Parts before given offset time (aka pending parts)
|
||||
//! \threadsafe
|
||||
|
||||
@@ -40,7 +40,10 @@ namespace BlackMisc
|
||||
using IInterpolator::getInterpolatedSituation;
|
||||
|
||||
//! \copydoc IInterpolator::getInterpolatedSituation
|
||||
virtual BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(const BlackMisc::Aviation::CAircraftSituationList &situations, qint64 currentTimeSinceEpoc, const BlackMisc::Simulation::CInterpolationHints &hints, InterpolationStatus &status) const override;
|
||||
virtual BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(
|
||||
const BlackMisc::Aviation::CCallsign &callsign,
|
||||
const BlackMisc::Aviation::CAircraftSituationList &situations, qint64 currentTimeSinceEpoc,
|
||||
const BlackMisc::Simulation::CInterpolationHints &hints, InterpolationStatus &status) const override;
|
||||
|
||||
//! Log category
|
||||
static QString getLogCategory() { return "swift.interpolatorlinear"; }
|
||||
|
||||
@@ -44,9 +44,13 @@ namespace XBus
|
||||
|
||||
BlackMisc::Simulation::CInterpolationHints CTraffic::Plane::hints(BlackMisc::Simulation::IInterpolator *interpolator) const
|
||||
{
|
||||
// \todo MS 865 CInterpolationAndRenderingSetup allows to setup interpolation in the GUI, e.g.
|
||||
// also to disable aircraft parts / or logging parts (log file). I wonder if you want to consider it here
|
||||
// e.g. interpolator->getInterpolatorSetup().getLogCallsigns().contains(callsign)
|
||||
// if the setup is needed more than once, store it here to avoid multiple locks
|
||||
BlackMisc::Simulation::CInterpolationHints hints;
|
||||
BlackMisc::Simulation::IInterpolator::PartsStatus status;
|
||||
hints.setAircraftParts(interpolator->getInterpolatedParts(parts, -1, status));
|
||||
hints.setAircraftParts(interpolator->getInterpolatedParts(callsign, parts, -1, status));
|
||||
hints.setElevationProvider([this](const auto &situation)
|
||||
{
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
@@ -338,7 +342,7 @@ namespace XBus
|
||||
if (plane->situations.size() < 3) { return xpmpData_Unavailable; } // avoid sudden movements when a pilot connects
|
||||
|
||||
BlackMisc::Simulation::IInterpolator::InterpolationStatus status;
|
||||
const auto situation = m_interpolator->getInterpolatedSituation(plane->situations, -1, plane->hints(m_interpolator), status);
|
||||
const auto situation = m_interpolator->getInterpolatedSituation(plane->callsign, plane->situations, -1, plane->hints(m_interpolator), status);
|
||||
if (! status.didInterpolationSucceed()) { return xpmpData_Unavailable; }
|
||||
if (! status.hasChangedPosition()) { return xpmpData_Unchanged; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user