refs #863 Change interpolation setup member to be a method parameter instead.

This commit is contained in:
Mathew Sutcliffe
2017-02-05 16:51:55 +00:00
parent 36474f65a0
commit 2181702c5c
12 changed files with 58 additions and 63 deletions

View File

@@ -35,11 +35,8 @@ namespace BlackMisc
this->setObjectName(objectName);
}
IInterpolator::~IInterpolator()
{ }
BlackMisc::Aviation::CAircraftSituation IInterpolator::getInterpolatedSituation(
const CCallsign &callsign, qint64 currentTimeSinceEpoc,
const CCallsign &callsign, qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetup &setup,
const CInterpolationHints &hints, InterpolationStatus &status) const
{
// has to be thread safe
@@ -47,13 +44,15 @@ namespace BlackMisc
status.reset();
Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "empty callsign");
auto currentSituation = this->getInterpolatedSituation(callsign, this->remoteAircraftSituations(callsign), currentTimeSinceEpoc, hints, status);
auto currentSituation = this->getInterpolatedSituation(callsign, this->remoteAircraftSituations(callsign), currentTimeSinceEpoc, setup, hints, status);
currentSituation.setCallsign(callsign); // make sure callsign is correct
return currentSituation;
}
CAircraftParts IInterpolator::getInterpolatedParts(const CCallsign &callsign, const CAircraftPartsList &parts, qint64 currentTimeMsSinceEpoch, IInterpolator::PartsStatus &partsStatus, bool log) const
CAircraftParts IInterpolator::getInterpolatedParts(const CCallsign &callsign, const CAircraftPartsList &parts, qint64 currentTimeMsSinceEpoch,
const CInterpolationAndRenderingSetup &setup, IInterpolator::PartsStatus &partsStatus, bool log) const
{
Q_UNUSED(setup);
partsStatus.reset();
if (currentTimeMsSinceEpoch < 0) { currentTimeMsSinceEpoch = QDateTime::currentMSecsSinceEpoch(); }
@@ -114,27 +113,16 @@ namespace BlackMisc
return currentParts;
}
CAircraftParts IInterpolator::getInterpolatedParts(const CCallsign &callsign, qint64 currentTimeMsSinceEpoch, IInterpolator::PartsStatus &partsStatus, bool log) const
CAircraftParts IInterpolator::getInterpolatedParts(const CCallsign &callsign, qint64 currentTimeMsSinceEpoch,
const CInterpolationAndRenderingSetup &setup, IInterpolator::PartsStatus &partsStatus, bool log) const
{
Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "empty callsign");
partsStatus.reset();
return this->getInterpolatedParts(callsign, this->remoteAircraftParts(callsign, -1), currentTimeMsSinceEpoch, partsStatus, log);
}
void IInterpolator::setInterpolatorSetup(const CInterpolationAndRenderingSetup &setup)
{
QWriteLocker l(&m_lockSetup);
m_setup = setup;
return this->getInterpolatedParts(callsign, this->remoteAircraftParts(callsign, -1), currentTimeMsSinceEpoch, setup, partsStatus, log);
}
CWorker *IInterpolator::writeLogInBackground()
{
// make sure logging is stopped
{
QWriteLocker l(&m_lockSetup);
m_setup.clearInterpolatorLogCallsigns();
}
QList<InterpolationLog> interpolation;
QList<PartsLog> parts;
{
@@ -209,12 +197,6 @@ namespace BlackMisc
}
}
CInterpolationAndRenderingSetup IInterpolator::getInterpolatorSetup() const
{
QReadLocker l(&m_lockSetup);
return m_setup;
}
void IInterpolator::logInterpolation(const IInterpolator::InterpolationLog &log) const
{
QWriteLocker l(&m_lockLogs);

View File

@@ -39,9 +39,6 @@ namespace BlackMisc
Q_OBJECT
public:
//! Virtual destructor
virtual ~IInterpolator();
//! Log category
static QString getLogCategory() { return "swift.interpolator"; }
@@ -96,7 +93,7 @@ namespace BlackMisc
//! \threadsafe
virtual BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(
const BlackMisc::Aviation::CCallsign &callsign, qint64 currentTimeSinceEpoc,
const CInterpolationHints &hints, InterpolationStatus &status) const;
const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, InterpolationStatus &status) const;
//! Current interpolated situation, to be implemented by subclass
//! \threadsafe
@@ -104,24 +101,20 @@ namespace BlackMisc
virtual BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(
const BlackMisc::Aviation::CCallsign &callsign,
const BlackMisc::Aviation::CAircraftSituationList &situations, qint64 currentTimeSinceEpoc,
const CInterpolationHints &hints, InterpolationStatus &status) const = 0;
const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, InterpolationStatus &status) const = 0;
//! Parts before given offset time (aka pending parts)
//! \threadsafe
virtual BlackMisc::Aviation::CAircraftParts getInterpolatedParts(
const Aviation::CCallsign &callsign,
const BlackMisc::Aviation::CAircraftPartsList &parts, qint64 cutoffTime,
PartsStatus &partsStatus, bool log = false) const;
const CInterpolationAndRenderingSetup &setup, PartsStatus &partsStatus, bool log = false) const;
//! Parts before given offset time (aka pending parts)
//! \threadsafe
virtual BlackMisc::Aviation::CAircraftParts getInterpolatedParts(
const BlackMisc::Aviation::CCallsign &callsign, qint64 cutoffTime,
PartsStatus &partsStatus, bool log = false) const;
//! Enable debug messages etc.
//! \threadsafe
void setInterpolatorSetup(const CInterpolationAndRenderingSetup &setup);
const CInterpolationAndRenderingSetup &setup, PartsStatus &partsStatus, bool log = false) const;
//! Write a log in background
//! \threadsafe
@@ -130,11 +123,6 @@ namespace BlackMisc
//! Clear log file
void clearLog();
//! Enable log messages etc.
//! \threadsafe
//! \remark public for FS9 to get setup in Fs9Client
CInterpolationAndRenderingSetup getInterpolatorSetup() const;
//! Takes input between 0 and 1 and returns output between 0 and 1 smoothed with an S-shaped curve.
//!
//! Useful for making interpolation seem smoother, efficiently as it just uses simple arithmetic.
@@ -201,8 +189,6 @@ namespace BlackMisc
//! Set on ground flag
static void setGroundFlagFromInterpolator(const CInterpolationHints &hints, double groundFactor, BlackMisc::Aviation::CAircraftSituation &situation);
CInterpolationAndRenderingSetup m_setup; //!< allows to enable/disable debug/log messages
private:
//! Write log to file
static CStatusMessageList writeLogFile(const QList<InterpolationLog> &interpolation, const QList<PartsLog> &parts);
@@ -216,7 +202,6 @@ namespace BlackMisc
//! Create readable time
static QString msSinceEpochToTime(qint64 t1, qint64 t2, qint64 t3 = -1);
mutable QReadWriteLock m_lockSetup; //!< lock setup
mutable QReadWriteLock m_lockLogs; //!< lock logging
mutable QList<PartsLog> m_partsLogs; //!< logs of parts
mutable QList<InterpolationLog> m_interpolationLogs; //!< logs of interpolation

View File

@@ -40,12 +40,12 @@ namespace BlackMisc
{
namespace Simulation
{
CAircraftSituation CInterpolatorLinear::getInterpolatedSituation(const CCallsign &callsign, const CAircraftSituationList &situations, qint64 currentTimeMsSinceEpoc, const CInterpolationHints &hints, InterpolationStatus &status) const
CAircraftSituation CInterpolatorLinear::getInterpolatedSituation(const CCallsign &callsign, const CAircraftSituationList &situations, qint64 currentTimeMsSinceEpoc,
const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, InterpolationStatus &status) const
{
//
// function has to be thread safe
//
const CInterpolationAndRenderingSetup setup = this->getInterpolatorSetup();
status.reset();
// any data at all?

View File

@@ -42,7 +42,7 @@ namespace BlackMisc
//! \copydoc IInterpolator::getInterpolatedSituation
virtual BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(
const BlackMisc::Aviation::CCallsign &callsign,
const BlackMisc::Aviation::CAircraftSituationList &situations, qint64 currentTimeSinceEpoc,
const BlackMisc::Aviation::CAircraftSituationList &situations, qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetup &setup,
const BlackMisc::Simulation::CInterpolationHints &hints, InterpolationStatus &status) const override;
//! Log category