Ref T259, Ref T243 renaming to CInterpolationAndRenderingSetupPerCallsign

This commit is contained in:
Klaus Basan
2018-03-19 20:07:31 +01:00
parent f5d1217b48
commit 333a92ff63
18 changed files with 48 additions and 50 deletions

View File

@@ -47,7 +47,7 @@ namespace BlackMisc
Aviation::CAircraftSituationList interpolationSituations; //!< the interpolator uses 2, 3 situations (oldest at end)
Aviation::CAircraftSituation situationCurrent; //!< interpolated situation
PhysicalQuantities::CLength cgAboveGround; //!< center of gravity
CInterpolationAndRenderingSetup usedSetup; //!< used setup
CInterpolationAndRenderingSetupPerCallsign usedSetup; //!< used setup
CInterpolationHints usedHints; //!< hints
//! Delta time between interpolation and current time

View File

@@ -54,7 +54,7 @@ namespace BlackMisc
template <typename Derived>
CAircraftSituation CInterpolator<Derived>::getInterpolatedSituation(
qint64 currentTimeMsSinceEpoc,
const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints,
const CInterpolationAndRenderingSetupPerCallsign &setup, const CInterpolationHints &hints,
CInterpolationStatus &status)
{
Q_ASSERT_X(!m_callsign.isEmpty(), Q_FUNC_INFO, "Missing callsign");
@@ -224,9 +224,8 @@ namespace BlackMisc
}
template <typename Derived>
CAircraftParts CInterpolator<Derived>::getInterpolatedParts(
qint64 currentTimeMsSinceEpoch,
const CInterpolationAndRenderingSetup &setup, CPartsStatus &partsStatus, bool log) const
CAircraftParts CInterpolator<Derived>::getInterpolatedParts(qint64 currentTimeMsSinceEpoch,
const CInterpolationAndRenderingSetupPerCallsign &setup, CPartsStatus &partsStatus, bool log) const
{
// (!) this code is used by linear and spline interpolator
Q_UNUSED(setup);

View File

@@ -45,12 +45,11 @@ namespace BlackMisc
const CLogCategoryList &getLogCategories();
//! Current interpolated situation
Aviation::CAircraftSituation getInterpolatedSituation(
qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, CInterpolationStatus &status);
Aviation::CAircraftSituation getInterpolatedSituation(qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetupPerCallsign &setup, const CInterpolationHints &hints, CInterpolationStatus &status);
//! Parts before given offset time (aka pending parts)
Aviation::CAircraftParts getInterpolatedParts(
qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetup &setup, CPartsStatus &partsStatus, bool log = false) const;
qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetupPerCallsign &setup, CPartsStatus &partsStatus, bool log = false) const;
//! Add a new aircraft situation
void addAircraftSituation(const Aviation::CAircraftSituation &situation);

View File

@@ -38,11 +38,11 @@ namespace BlackMisc
//! \copydoc CInterpolator::getInterpolatedSituation
BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(
qint64, const CInterpolationAndRenderingSetup &, const CInterpolationHints &, CInterpolationStatus &) { return {}; }
qint64, const CInterpolationAndRenderingSetupGlobal &, const CInterpolationHints &, CInterpolationStatus &) { return {}; }
//! \copydoc CInterpolator::getInterpolatedParts
BlackMisc::Aviation::CAircraftParts getInterpolatedParts(
qint64, const CInterpolationAndRenderingSetup &, CPartsStatus &, bool = false) const { return {}; }
qint64, const CInterpolationAndRenderingSetupGlobal &, CPartsStatus &, bool = false) const { return {}; }
//! \copydoc CInterpolator::addAircraftSituation
void addAircraftSituation(const BlackMisc::Aviation::CAircraftSituation &) {}

View File

@@ -50,7 +50,7 @@ namespace BlackMisc
{}
CInterpolatorLinear::Interpolant CInterpolatorLinear::getInterpolant(qint64 currentTimeMsSinceEpoc,
const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, CInterpolationStatus &status, SituationLog &log) const
const CInterpolationAndRenderingSetupPerCallsign &setup, const CInterpolationHints &hints, CInterpolationStatus &status, SituationLog &log) const
{
Q_UNUSED(setup);
Q_UNUSED(hints);
@@ -68,7 +68,7 @@ namespace BlackMisc
// find the first situation earlier than the current time
const CAircraftSituationList &validSituations = m_aircraftSituations; // if needed, we could also copy here
const auto pivot = std::partition_point(validSituations.begin(), validSituations.end(), [ = ](auto && s) { return s.getAdjustedMSecsSinceEpoch() > currentTimeMsSinceEpoc; });
const auto pivot = std::partition_point(validSituations.begin(), validSituations.end(), [ = ](auto &&s) { return s.getAdjustedMSecsSinceEpoch() > currentTimeMsSinceEpoc; });
const auto situationsNewer = makeRange(validSituations.begin(), pivot);
const auto situationsOlder = makeRange(pivot, validSituations.end());
@@ -159,7 +159,7 @@ namespace BlackMisc
return { oldSituation, newSituation, simulationTimeFraction, interpolatedTime };
}
CCoordinateGeodetic CInterpolatorLinear::Interpolant::interpolatePosition(const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints) const
CCoordinateGeodetic CInterpolatorLinear::Interpolant::interpolatePosition(const CInterpolationAndRenderingSetupPerCallsign &setup, const CInterpolationHints &hints) const
{
Q_UNUSED(setup);
Q_UNUSED(hints);
@@ -175,7 +175,7 @@ namespace BlackMisc
return currentPosition;
}
CAltitude CInterpolatorLinear::Interpolant::interpolateAltitude(const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints) const
CAltitude CInterpolatorLinear::Interpolant::interpolateAltitude(const CInterpolationAndRenderingSetupPerCallsign &setup, const CInterpolationHints &hints) const
{
Q_UNUSED(setup);
Q_UNUSED(hints);

View File

@@ -49,8 +49,8 @@ namespace BlackMisc
//! Perform the interpolation
//! @{
Geo::CCoordinateGeodetic interpolatePosition(const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints) const;
Aviation::CAltitude interpolateAltitude(const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints) const;
Geo::CCoordinateGeodetic interpolatePosition(const CInterpolationAndRenderingSetupPerCallsign &setup, const CInterpolationHints &hints) const;
Aviation::CAltitude interpolateAltitude(const CInterpolationAndRenderingSetupPerCallsign &setup, const CInterpolationHints &hints) const;
//! @}
//! Interpolator for pitch, bank, heading, groundspeed
@@ -75,7 +75,7 @@ namespace BlackMisc
};
//! Get the interpolant for the given time point
Interpolant getInterpolant(qint64 currentTimeMsSinceEpoc, const CInterpolationAndRenderingSetup &setup,
Interpolant getInterpolant(qint64 currentTimeMsSinceEpoc, const CInterpolationAndRenderingSetupPerCallsign &setup,
const CInterpolationHints &hints, CInterpolationStatus &status, SituationLog &log) const;
};
} // ns

View File

@@ -23,9 +23,8 @@ namespace BlackMisc
m_linear(callsign, this)
{}
CAircraftSituation CInterpolatorMulti::getInterpolatedSituation(
qint64 currentTimeSinceEpoc,
const CInterpolationAndRenderingSetup &setup,
CAircraftSituation CInterpolatorMulti::getInterpolatedSituation(qint64 currentTimeSinceEpoc,
const CInterpolationAndRenderingSetupPerCallsign &setup,
const CInterpolationHints &hints, CInterpolationStatus &status)
{
switch (m_mode)
@@ -38,7 +37,7 @@ namespace BlackMisc
}
CAircraftParts CInterpolatorMulti::getInterpolatedParts(
qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetup &setup,
qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetupPerCallsign &setup,
CPartsStatus &partsStatus, bool log) const
{
switch (m_mode)

View File

@@ -33,13 +33,12 @@ namespace BlackMisc
//! \copydoc CInterpolator::getInterpolatedSituation
Aviation::CAircraftSituation getInterpolatedSituation(
qint64 currentTimeSinceEpoc,
const CInterpolationAndRenderingSetup &setup,
const CInterpolationAndRenderingSetupPerCallsign &setup,
const CInterpolationHints &hints, CInterpolationStatus &status);
//! \copydoc CInterpolator::getInterpolatedParts
Aviation::CAircraftParts getInterpolatedParts(
qint64 currentTimeSinceEpoc,
const CInterpolationAndRenderingSetup &setup,
Aviation::CAircraftParts getInterpolatedParts(qint64 currentTimeSinceEpoc,
const CInterpolationAndRenderingSetupPerCallsign &setup,
CPartsStatus &partsStatus, bool log = false) const;
//! \copydoc CInterpolator::addAircraftSituation

View File

@@ -96,7 +96,7 @@ namespace BlackMisc
}
CInterpolatorSpline::Interpolant CInterpolatorSpline::getInterpolant(qint64 currentTimeMsSinceEpoc,
const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, CInterpolationStatus &status,
const CInterpolationAndRenderingSetupPerCallsign &setup, const CInterpolationHints &hints, CInterpolationStatus &status,
SituationLog &log)
{
Q_UNUSED(hints);
@@ -117,7 +117,7 @@ namespace BlackMisc
// find the first situation earlier than the current time
const CAircraftSituationList &validSituations = m_aircraftSituations; // if needed, we could also copy here
const auto pivot = std::partition_point(validSituations.begin(), validSituations.end(), [ = ](auto && s) { return s.getAdjustedMSecsSinceEpoch() > currentTimeMsSinceEpoc; });
const auto pivot = std::partition_point(validSituations.begin(), validSituations.end(), [ = ](auto &&s) { return s.getAdjustedMSecsSinceEpoch() > currentTimeMsSinceEpoc; });
const auto situationsNewer = makeRange(validSituations.begin(), pivot);
const auto situationsOlder = makeRange(pivot, validSituations.end());
@@ -205,7 +205,7 @@ namespace BlackMisc
return m_interpolant;
}
CCoordinateGeodetic CInterpolatorSpline::Interpolant::interpolatePosition(const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints) const
CCoordinateGeodetic CInterpolatorSpline::Interpolant::interpolatePosition(const CInterpolationAndRenderingSetupPerCallsign &setup, const CInterpolationHints &hints) const
{
Q_UNUSED(setup);
Q_UNUSED(hints);
@@ -219,7 +219,7 @@ namespace BlackMisc
return currentPosition;
}
CAltitude CInterpolatorSpline::Interpolant::interpolateAltitude(const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints) const
CAltitude CInterpolatorSpline::Interpolant::interpolateAltitude(const CInterpolationAndRenderingSetupPerCallsign &setup, const CInterpolationHints &hints) const
{
Q_UNUSED(setup);
Q_UNUSED(hints);

View File

@@ -63,8 +63,8 @@ namespace BlackMisc
//! Perform the interpolation
//! @{
Geo::CCoordinateGeodetic interpolatePosition(const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints) const;
Aviation::CAltitude interpolateAltitude(const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints) const;
Geo::CCoordinateGeodetic interpolatePosition(const CInterpolationAndRenderingSetupPerCallsign &setup, const CInterpolationHints &hints) const;
Aviation::CAltitude interpolateAltitude(const CInterpolationAndRenderingSetupPerCallsign &setup, const CInterpolationHints &hints) const;
//! @}
//! Interpolator for pitch, bank, heading, groundspeed
@@ -91,10 +91,9 @@ namespace BlackMisc
};
//! Strategy used by CInterpolator::getInterpolatedSituation
Interpolant getInterpolant(
qint64 currentTimeMsSinceEpoc,
const CInterpolationAndRenderingSetup &setup,
const CInterpolationHints &hints, CInterpolationStatus &status, SituationLog &log);
Interpolant getInterpolant(qint64 currentTimeMsSinceEpoc,
const CInterpolationAndRenderingSetupPerCallsign &setup,
const CInterpolationHints &hints, CInterpolationStatus &status, SituationLog &log);
private:
qint64 m_prevSampleAdjustedTime = 0; //!< previous sample time + offset

View File

@@ -430,12 +430,12 @@ namespace BlackSimPlugin
void CSimulatorEmulated::fetchFromInterpolator()
{
const qint64 now = QDateTime::currentMSecsSinceEpoch();
const CInterpolationAndRenderingSetup setup = this->getInterpolationAndRenderingSetup(); // threadsafe copy
for (const CSimulatedAircraft &aircraft : m_renderedAircraft)
{
const CCallsign cs = aircraft.getCallsign();
if (!m_interpolators.contains(cs)) { continue; }
const bool log = setup.isLogCallsign(cs);
const CInterpolationAndRenderingSetupPerCallsign setup = this->getInterpolationSetupPerCallsignOrDefault(cs); // threadsafe copy
const bool log = setup.logInterpolation();
CInterpolatorMulti *im = m_interpolators[cs];
CInterpolationStatus statusInterpolation;
CPartsStatus statusParts;

View File

@@ -162,7 +162,7 @@ namespace BlackSimPlugin
CAircraftSituation CSimConnectObject::getInterpolatedSituation(
qint64 currentTimeSinceEpoc,
const CInterpolationAndRenderingSetup &setup,
const CInterpolationAndRenderingSetupPerCallsign &setup,
const CInterpolationHints &hints, CInterpolationStatus &status) const
{
Q_ASSERT(m_interpolator);
@@ -170,7 +170,8 @@ namespace BlackSimPlugin
}
CAircraftParts CSimConnectObject::getInterpolatedParts(
qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetup &setup,
qint64 currentTimeSinceEpoc,
const CInterpolationAndRenderingSetupPerCallsign &setup,
CPartsStatus &partsStatus, bool log) const
{
Q_ASSERT(m_interpolator);

View File

@@ -163,13 +163,13 @@ namespace BlackSimPlugin
//! \copydoc BlackMisc::Simulation::CInterpolator::getInterpolatedSituation
BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(
qint64 currentTimeSinceEpoc,
const BlackMisc::Simulation::CInterpolationAndRenderingSetup &setup,
const BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign &setup,
const BlackMisc::Simulation::CInterpolationHints &hints, BlackMisc::Simulation::CInterpolationStatus &status) const;
//! \copydoc BlackMisc::Simulation::CInterpolator::getInterpolatedParts
BlackMisc::Aviation::CAircraftParts getInterpolatedParts(
qint64 currentTimeSinceEpoc,
const BlackMisc::Simulation::CInterpolationAndRenderingSetup &setup,
const BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign &setup,
BlackMisc::Simulation::CPartsStatus &partsStatus, bool log) const;
//! Interpolator

View File

@@ -91,7 +91,7 @@ namespace BlackSimPlugin
CAircraftSituation CXPlaneMPAircraft::getInterpolatedSituation(
qint64 currentTimeSinceEpoc,
const CInterpolationAndRenderingSetup &setup,
const CInterpolationAndRenderingSetupPerCallsign &setup,
const CInterpolationHints &hints, CInterpolationStatus &status) const
{
Q_ASSERT(m_interpolator);
@@ -99,7 +99,8 @@ namespace BlackSimPlugin
}
CAircraftParts CXPlaneMPAircraft::getInterpolatedParts(
qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetup &setup,
qint64 currentTimeSinceEpoc,
const CInterpolationAndRenderingSetupPerCallsign &setup,
CPartsStatus &partsStatus, bool log) const
{
Q_ASSERT(m_interpolator);

View File

@@ -89,13 +89,13 @@ namespace BlackSimPlugin
//! \copydoc BlackMisc::Simulation::CInterpolator::getInterpolatedSituation
BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(
qint64 currentTimeSinceEpoc,
const BlackMisc::Simulation::CInterpolationAndRenderingSetup &setup,
const BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign &setup,
const BlackMisc::Simulation::CInterpolationHints &hints, BlackMisc::Simulation::CInterpolationStatus &status) const;
//! \copydoc BlackMisc::Simulation::CInterpolator::getInterpolatedParts
BlackMisc::Aviation::CAircraftParts getInterpolatedParts(
qint64 currentTimeSinceEpoc,
const BlackMisc::Simulation::CInterpolationAndRenderingSetup &setup,
const BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign &setup,
BlackMisc::Simulation::CPartsStatus &partsStatus, bool log) const;
//! Interpolator

View File

@@ -16,6 +16,7 @@
#include "utils.h"
#include "blackmisc/simulation/interpolator.h"
#include "blackmisc/simulation/interpolationhints.h"
#include "blackmisc/aviation/aircraftsituation.h"
#include "blackmisc/aviation/callsign.h"
#include "blackmisc/verify.h"
#include "XPMPMultiplayer.h"
@@ -56,7 +57,7 @@ namespace XSwiftBus
using namespace BlackMisc::Aviation;
using namespace BlackMisc::Simulation;
CInterpolationAndRenderingSetup setup;
CInterpolationAndRenderingSetupPerCallsign setup;
CInterpolationHints hints;
CPartsStatus status;
constexpr double fudgeFactor = 3.0; //! \fixme Value should be different for each plane, derived from the CSL model geometry
@@ -429,9 +430,9 @@ namespace XSwiftBus
}
else
{
BlackMisc::Simulation::CInterpolationAndRenderingSetup setup;
BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign setup;
BlackMisc::Simulation::CInterpolationStatus status;
const auto situation = plane->interpolator.getInterpolatedSituation(-1, setup, plane->hints(), status);
BlackMisc::Aviation::CAircraftSituation situation = plane->interpolator.getInterpolatedSituation(-1, setup, plane->hints(), status);
if (! status.hasValidSituation()) { return xpmpData_Unavailable; }
//! \fixme KB 2018-01 commented out with T229. Change detection needs to go somewhere else

View File

@@ -85,7 +85,7 @@ namespace BlackMiscTest
// interpolation functional check
CInterpolationStatus status;
const CInterpolationHints hints;
const CInterpolationAndRenderingSetup setup;
const CInterpolationAndRenderingSetupPerCallsign setup;
double latOld = 360.0;
double lngOld = 360.0;
for (qint64 currentTime = ts - 2 * deltaT + offset; currentTime < ts + offset; currentTime += (deltaT / 20))

View File

@@ -49,7 +49,7 @@ namespace BlackMiscTest
// interpolation functional check
CPartsStatus status;
const CInterpolationAndRenderingSetup setup;
const CInterpolationAndRenderingSetupPerCallsign setup;
qint64 oldestTs = parts.oldestTimestampMsecsSinceEpoch();
// Testing for a time >> last time