Ref T180, added utility function getInterpolatorInfo() allowing to log some info about interpolator

This commit is contained in:
Klaus Basan
2017-11-03 20:47:42 +01:00
parent 88872f9f3a
commit e5261c3e99
8 changed files with 53 additions and 8 deletions

View File

@@ -275,6 +275,19 @@ namespace BlackMisc
m_aircraftParts.front().setTimeOffsetMs(offset);
}
template<typename Derived>
QString CInterpolator<Derived>::getInterpolatorInfo() const
{
return QStringLiteral("Callsign: ") %
m_callsign.asString() %
QStringLiteral(" situations: ") %
QString::number(m_aircraftSituations.size()) %
QStringLiteral(" parts: ") %
QString::number(m_aircraftParts.size()) %
QStringLiteral(" 1st interpolation: ") %
boolToYesNo(m_isFirstInterpolation);
}
template <typename Derived>
void CInterpolator<Derived>::setGroundElevationFromHint(const CInterpolationHints &hints, CAircraftSituation &situation, bool override)
{

View File

@@ -78,6 +78,9 @@ namespace BlackMisc
//! \remark parts logging has a \c bool \c log flag
void attachLogger(CInterpolationLogger *logger) { m_logger = logger; }
//! Get an interpolator info string (for debug info)
QString getInterpolatorInfo() const;
protected:
BlackMisc::Aviation::CAircraftSituationList m_aircraftSituations; //!< recent situations for one aircraft
BlackMisc::Aviation::CAircraftPartsList m_aircraftParts; //!< recent parts for one aircraft

View File

@@ -56,10 +56,13 @@ namespace BlackMisc
//! \copydoc CInterpolator::hasAircraftParts
bool hasAircraftParts() const { return false; }
//! \copydoc CInterpolator::getInterpolatorInfo
QString getInterpolatorInfo() const { return this->objectName(); }
//! \copydoc CInterpolator::attachLogger
void attachLogger(CInterpolationLogger *) {}
};
}
}
} // ns
} // ns
#endif

View File

@@ -120,6 +120,17 @@ namespace BlackMisc
}
}
QString CInterpolatorMulti::getInterpolatorInfo() const
{
switch (m_mode)
{
case ModeSpline: return m_spline.getInterpolatorInfo();
case ModeLinear: return m_linear.getInterpolatorInfo();
default: break;
}
return ("Illegal mode");
}
CInterpolatorMulti::Mode CInterpolatorMulti::modeFromString(const QString &mode)
{
if (mode.contains("spli"), Qt::CaseInsensitive) { return ModeSpline; }

View File

@@ -77,6 +77,9 @@ namespace BlackMisc
//! Toogle interpolator Mode
void toggleMode();
//! Info string
QString getInterpolatorInfo() const;
//! Mode from string
static Mode modeFromString(const QString &mode);
@@ -96,6 +99,7 @@ namespace BlackMisc
/**
* CInterpolatorMulti which can be used with QMap/QHash
* \remark Use case is emulated driver
*/
class BLACKMISC_EXPORT CInterpolatorMultiWrapper
{

View File

@@ -20,7 +20,7 @@ namespace BlackSimPlugin
CSimConnectObject::CSimConnectObject()
{ }
CSimConnectObject::CSimConnectObject(const BlackMisc::Simulation::CSimulatedAircraft &aircraft,
CSimConnectObject::CSimConnectObject(const CSimulatedAircraft &aircraft,
DWORD requestId,
CInterpolationLogger *logger) :
m_aircraft(aircraft), m_requestId(requestId), m_validRequestId(true),
@@ -92,6 +92,12 @@ namespace BlackSimPlugin
return m_interpolator->setMode(mode);
}
QString CSimConnectObject::getInterpolatorInfo() const
{
Q_ASSERT(m_interpolator);
return m_interpolator->getInterpolatorInfo();
}
bool CSimConnectObjects::setSimConnectObjectIdForRequestId(DWORD requestId, DWORD objectId, bool resetSentParts)
{
// First check, if this request id belongs to us

View File

@@ -129,6 +129,9 @@ namespace BlackSimPlugin
//! Set interpolator mode
bool setInterpolatorMode(BlackMisc::Simulation::CInterpolatorMulti::Mode mode);
//! Interpolator info
QString getInterpolatorInfo() const;
private:
BlackMisc::Simulation::CSimulatedAircraft m_aircraft; //!< corresponding aircraft
DWORD m_requestId = 0;

View File

@@ -680,17 +680,19 @@ namespace BlackSimPlugin
if (!simObject.getAircraftModelString().isEmpty())
{
m_addPendingAircraft.push_back(simObject.getAircraft());
CLogMessage(this).warning("Aircraft removed, '%1' '%2' object id '%3' out of reality bubble or other reason") << callsign.toQString() << simObject.getAircraftModelString() << objectID;
CLogMessage(this).warning("Aircraft removed, '%1' '%2' object id '%3' out of reality bubble or other reason. Interpolator: %4")
<< callsign.toQString() << simObject.getAircraftModelString()
<< objectID << simObject.getInterpolatorInfo();
}
else
{
CLogMessage(this).warning("Removed %1 from simulator, but was not initiated by us: %1 '%2' object id %3") << callsign.toQString() << simObject.getAircraftModelString() << objectID;
CLogMessage(this).warning("Removed '%1' from simulator, but was not initiated by us: %1 '%2' object id %3") << callsign.toQString() << simObject.getAircraftModelString() << objectID;
}
}
// in all cases we remove
const int c = m_simConnectObjects.remove(callsign);
const bool removed = (c > 0);
const bool removedAny = (c > 0);
const bool updated = this->updateAircraftRendered(simObject.getCallsign(), false);
if (updated)
{
@@ -702,12 +704,12 @@ namespace BlackSimPlugin
{
const CSimulatedAircraft aircraftAddAgain = m_aircraftToAddAgainWhenRemoved.findFirstByCallsign(callsign);
m_aircraftToAddAgainWhenRemoved.removeByCallsign(callsign);
QTimer::singleShot(1000, this, [ = ]
QTimer::singleShot(2500, this, [ = ]
{
this->physicallyAddRemoteAircraftImpl(aircraftAddAgain, AddedAfterRemoved);
});
}
return removed;
return removedAny;
}
bool CSimulatorFsxCommon::setSimConnectObjectId(DWORD requestId, DWORD objectId)