mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 02:06:08 +08:00
refactor: Move PBH interpolator to inidivdual Interpolants
This allows each interpolant to specify on its own which PBH
interpolator should be used. Currently only the linear PBH interpolator
is available, but another PBH interpolator will be added for velocity.
This removes some protected data from the IInterpolator interface as well,
which conforms to C++ Core Guideline C.113 ("Avoid protected data").
This commit is contained in:
@@ -17,9 +17,6 @@ namespace BlackMisc::Simulation
|
|||||||
//! "Real time" representing the interpolated situation
|
//! "Real time" representing the interpolated situation
|
||||||
qint64 getInterpolatedTime() const { return m_interpolatedTime; }
|
qint64 getInterpolatedTime() const { return m_interpolatedTime; }
|
||||||
|
|
||||||
//! Interpolator for pitch, bank, heading, groundspeed
|
|
||||||
const CInterpolatorPbh &pbh() const { return m_pbh; }
|
|
||||||
|
|
||||||
//! Situations available
|
//! Situations available
|
||||||
int getSituationsAvailable() const { return m_situationsAvailable; }
|
int getSituationsAvailable() const { return m_situationsAvailable; }
|
||||||
|
|
||||||
@@ -37,17 +34,16 @@ namespace BlackMisc::Simulation
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Default ctor
|
//! Default ctor
|
||||||
IInterpolant() {}
|
IInterpolant() = default;
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
IInterpolant(int situationsAvailable, const CInterpolatorPbh &pbh) : m_situationsAvailable(situationsAvailable), m_pbh(pbh) {}
|
explicit IInterpolant(int situationsAvailable) : m_situationsAvailable(situationsAvailable) {}
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
IInterpolant(qint64 interpolatedTime, int situationsAvailable) : m_interpolatedTime(interpolatedTime), m_situationsAvailable(situationsAvailable) {}
|
IInterpolant(qint64 interpolatedTime, int situationsAvailable) : m_interpolatedTime(interpolatedTime), m_situationsAvailable(situationsAvailable) {}
|
||||||
|
|
||||||
qint64 m_interpolatedTime = -1; //!< "Real time "of interpolated situation
|
qint64 m_interpolatedTime = -1; //!< "Real time "of interpolated situation
|
||||||
int m_situationsAvailable = 0; //!< used situations
|
int m_situationsAvailable = 0; //!< used situations
|
||||||
CInterpolatorPbh m_pbh; //!< the used PBH interpolator
|
|
||||||
bool m_valid = true; //!< valid?
|
bool m_valid = true; //!< valid?
|
||||||
bool m_recalculated = false; //!< recalculated interpolant
|
bool m_recalculated = false; //!< recalculated interpolant
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -245,12 +245,12 @@ namespace BlackMisc::Simulation
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (!isValidInterpolant) { break; }
|
if (!isValidInterpolant) { break; }
|
||||||
const CInterpolatorPbh pbh = interpolant.pbh();
|
|
||||||
|
|
||||||
// init interpolated situation
|
// init interpolated situation
|
||||||
currentSituation = this->initInterpolatedSituation(pbh.getStartSituation(), pbh.getEndSituation());
|
currentSituation = this->initInterpolatedSituation(pbh.getStartSituation(), pbh.getEndSituation());
|
||||||
|
|
||||||
// Pitch bank heading first, so follow up steps could use those values
|
// Pitch bank heading first, so follow up steps could use those values
|
||||||
|
const auto pbh = interpolant.pbh();
|
||||||
currentSituation.setHeading(pbh.getHeading());
|
currentSituation.setHeading(pbh.getHeading());
|
||||||
currentSituation.setPitch(pbh.getPitch());
|
currentSituation.setPitch(pbh.getPitch());
|
||||||
currentSituation.setBank(pbh.getBank());
|
currentSituation.setBank(pbh.getBank());
|
||||||
|
|||||||
@@ -23,12 +23,12 @@ using namespace BlackMisc::Simulation;
|
|||||||
|
|
||||||
namespace BlackMisc::Simulation
|
namespace BlackMisc::Simulation
|
||||||
{
|
{
|
||||||
CInterpolatorLinear::CInterpolant::CInterpolant(const CAircraftSituation &startSituation) : IInterpolant(1, CInterpolatorPbh(0, startSituation, startSituation)),
|
CInterpolatorLinear::CInterpolant::CInterpolant(const CAircraftSituation &startSituation) : IInterpolant(1),
|
||||||
m_startSituation(startSituation)
|
m_startSituation(startSituation), m_pbh(0, startSituation, startSituation)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CInterpolatorLinear::CInterpolant::CInterpolant(const CAircraftSituation &startSituation, const CInterpolatorPbh &pbh) : IInterpolant(1, pbh),
|
CInterpolatorLinear::CInterpolant::CInterpolant(const CAircraftSituation &startSituation, const CInterpolatorPbh &pbh) : IInterpolant(1),
|
||||||
m_startSituation(startSituation)
|
m_startSituation(startSituation), m_pbh(pbh)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CInterpolatorLinear::CInterpolant::CInterpolant(const CAircraftSituation &startSituation, const CAircraftSituation &endSituation, double timeFraction, qint64 interpolatedTime) : IInterpolant(interpolatedTime, 2),
|
CInterpolatorLinear::CInterpolant::CInterpolant(const CAircraftSituation &startSituation, const CAircraftSituation &endSituation, double timeFraction, qint64 interpolatedTime) : IInterpolant(interpolatedTime, 2),
|
||||||
|
|||||||
@@ -60,10 +60,13 @@ namespace BlackMisc
|
|||||||
//! End situation
|
//! End situation
|
||||||
const Aviation::CAircraftSituation &getEndSituation() const { return m_endSituation; }
|
const Aviation::CAircraftSituation &getEndSituation() const { return m_endSituation; }
|
||||||
|
|
||||||
|
CInterpolatorPbh pbh() const { return m_pbh; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Aviation::CAircraftSituation m_startSituation;
|
Aviation::CAircraftSituation m_startSituation;
|
||||||
Aviation::CAircraftSituation m_endSituation;
|
Aviation::CAircraftSituation m_endSituation;
|
||||||
double m_simulationTimeFraction = 0.0; //!< 0..1
|
double m_simulationTimeFraction = 0.0; //!< 0..1
|
||||||
|
CInterpolatorPbh m_pbh;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Get the interpolant for the given time point
|
//! Get the interpolant for the given time point
|
||||||
|
|||||||
@@ -77,10 +77,13 @@ namespace BlackMisc::Simulation
|
|||||||
//! \private UNIT tests/ASSERT only
|
//! \private UNIT tests/ASSERT only
|
||||||
const PosArray &getPa() const { return m_pa; }
|
const PosArray &getPa() const { return m_pa; }
|
||||||
|
|
||||||
|
CInterpolatorPbh pbh() const { return m_pbh; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PosArray m_pa; //!< current positions array, latest values last
|
PosArray m_pa; //!< current positions array, latest values last
|
||||||
PhysicalQuantities::CLengthUnit m_altitudeUnit;
|
PhysicalQuantities::CLengthUnit m_altitudeUnit;
|
||||||
qint64 m_currentTimeMsSinceEpoc { -1 };
|
qint64 m_currentTimeMsSinceEpoc { -1 };
|
||||||
|
CInterpolatorPbh m_pbh; //!< the used PBH interpolator
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Strategy used by CInterpolator::getInterpolatedSituation
|
//! Strategy used by CInterpolator::getInterpolatedSituation
|
||||||
|
|||||||
Reference in New Issue
Block a user