mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-11 06:25:33 +08:00
Use nested namespaces (C++17 feature)
This commit is contained in:
@@ -19,95 +19,92 @@
|
||||
#include <QString>
|
||||
#include <QtGlobal>
|
||||
|
||||
namespace BlackMisc
|
||||
namespace BlackMisc::Simulation
|
||||
{
|
||||
namespace Simulation
|
||||
//! Cubic spline interpolator
|
||||
class BLACKMISC_EXPORT CInterpolatorSpline : public CInterpolator<CInterpolatorSpline>
|
||||
{
|
||||
//! Cubic spline interpolator
|
||||
class BLACKMISC_EXPORT CInterpolatorSpline : public CInterpolator<CInterpolatorSpline>
|
||||
virtual void anchor() override;
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
CInterpolatorSpline(const Aviation::CCallsign &callsign,
|
||||
ISimulationEnvironmentProvider *envProvider, IInterpolationSetupProvider *setupProvider, IRemoteAircraftProvider *aircraftProvider,
|
||||
CInterpolationLogger *logger = nullptr) :
|
||||
CInterpolator(callsign, envProvider, setupProvider, aircraftProvider, logger) {}
|
||||
|
||||
//! Position arrays for interpolation
|
||||
struct BLACKMISC_EXPORT PosArray
|
||||
{
|
||||
virtual void anchor() override;
|
||||
//! Init all values to zero
|
||||
void initToZero();
|
||||
|
||||
//! Zero initialized position array
|
||||
static const PosArray &zeroPosArray();
|
||||
|
||||
//! 3 coordinates for spline interpolation
|
||||
//! @{
|
||||
std::array<double, 3> x, y, z, a, gnd, t, dx, dy, dz, da, dgnd;
|
||||
|
||||
//! Array size
|
||||
int size() const { return static_cast<int>(x.size()); }
|
||||
//! @}
|
||||
};
|
||||
|
||||
//! Cubic function that performs the actual interpolation
|
||||
class BLACKMISC_EXPORT CInterpolant : public IInterpolant
|
||||
{
|
||||
public:
|
||||
//! Default
|
||||
CInterpolant() : m_pa(PosArray::zeroPosArray()) {}
|
||||
|
||||
//! Constructor
|
||||
CInterpolatorSpline(const Aviation::CCallsign &callsign,
|
||||
ISimulationEnvironmentProvider *envProvider, IInterpolationSetupProvider *setupProvider, IRemoteAircraftProvider *aircraftProvider,
|
||||
CInterpolationLogger *logger = nullptr) :
|
||||
CInterpolator(callsign, envProvider, setupProvider, aircraftProvider, logger) {}
|
||||
CInterpolant(const PosArray &pa, const PhysicalQuantities::CLengthUnit &altitudeUnit, const CInterpolatorPbh &pbh);
|
||||
|
||||
//! Position arrays for interpolation
|
||||
struct BLACKMISC_EXPORT PosArray
|
||||
{
|
||||
//! Init all values to zero
|
||||
void initToZero();
|
||||
//! Perform the interpolation
|
||||
Aviation::CAircraftSituation interpolatePositionAndAltitude(const Aviation::CAircraftSituation ¤tSituation, bool interpolateGndFactor) const;
|
||||
|
||||
//! Zero initialized position array
|
||||
static const PosArray &zeroPosArray();
|
||||
//! Old situation
|
||||
const Aviation::CAircraftSituation &getOldSituation() const { return pbh().getOldSituation(); }
|
||||
|
||||
//! 3 coordinates for spline interpolation
|
||||
//! @{
|
||||
std::array<double, 3> x, y, z, a, gnd, t, dx, dy, dz, da, dgnd;
|
||||
//! New situation
|
||||
const Aviation::CAircraftSituation &getNewSituation() const { return pbh().getNewSituation(); }
|
||||
|
||||
//! Array size
|
||||
int size() const { return static_cast<int>(x.size()); }
|
||||
//! @}
|
||||
};
|
||||
//! Set the time values
|
||||
void setTimes(qint64 currentTimeMs, double timeFraction, qint64 interpolatedTimeMs);
|
||||
|
||||
//! Cubic function that performs the actual interpolation
|
||||
class BLACKMISC_EXPORT CInterpolant : public IInterpolant
|
||||
{
|
||||
public:
|
||||
//! Default
|
||||
CInterpolant() : m_pa(PosArray::zeroPosArray()) {}
|
||||
|
||||
//! Constructor
|
||||
CInterpolant(const PosArray &pa, const PhysicalQuantities::CLengthUnit &altitudeUnit, const CInterpolatorPbh &pbh);
|
||||
|
||||
//! Perform the interpolation
|
||||
Aviation::CAircraftSituation interpolatePositionAndAltitude(const Aviation::CAircraftSituation ¤tSituation, bool interpolateGndFactor) const;
|
||||
|
||||
//! Old situation
|
||||
const Aviation::CAircraftSituation &getOldSituation() const { return pbh().getOldSituation(); }
|
||||
|
||||
//! New situation
|
||||
const Aviation::CAircraftSituation &getNewSituation() const { return pbh().getNewSituation(); }
|
||||
|
||||
//! Set the time values
|
||||
void setTimes(qint64 currentTimeMs, double timeFraction, qint64 interpolatedTimeMs);
|
||||
|
||||
//! \private UNIT tests/ASSERT only
|
||||
const PosArray &getPa() const { return m_pa; }
|
||||
|
||||
private:
|
||||
PosArray m_pa; //!< current positions array, latest values last
|
||||
PhysicalQuantities::CLengthUnit m_altitudeUnit;
|
||||
qint64 m_currentTimeMsSinceEpoc { -1 };
|
||||
};
|
||||
|
||||
//! Strategy used by CInterpolator::getInterpolatedSituation
|
||||
CInterpolant getInterpolant(SituationLog &log);
|
||||
//! \private UNIT tests/ASSERT only
|
||||
const PosArray &getPa() const { return m_pa; }
|
||||
|
||||
private:
|
||||
//! Update the elevations used in CInterpolatorSpline::m_s
|
||||
bool updateElevations(bool canSkip);
|
||||
|
||||
//! Are any elevations missing in CInterpolatorSpline::m_s
|
||||
bool areAnyElevationsMissing() const;
|
||||
|
||||
//! Ground relevant
|
||||
bool isAnySituationNearGroundRelevant() const;
|
||||
|
||||
//! Fill the situations array
|
||||
bool fillSituationsArray();
|
||||
|
||||
qint64 m_prevSampleAdjustedTime = 0; //!< previous sample time + offset
|
||||
qint64 m_nextSampleAdjustedTime = 0; //!< previous sample time + offset
|
||||
qint64 m_prevSampleTime = 0; //!< previous sample "real time"
|
||||
qint64 m_nextSampleTime = 0; //!< next sample "real time"
|
||||
std::array<Aviation::CAircraftSituation, 3> m_s; //!< used situations
|
||||
CInterpolant m_interpolant;
|
||||
PosArray m_pa; //!< current positions array, latest values last
|
||||
PhysicalQuantities::CLengthUnit m_altitudeUnit;
|
||||
qint64 m_currentTimeMsSinceEpoc { -1 };
|
||||
};
|
||||
} // ns
|
||||
|
||||
//! Strategy used by CInterpolator::getInterpolatedSituation
|
||||
CInterpolant getInterpolant(SituationLog &log);
|
||||
|
||||
private:
|
||||
//! Update the elevations used in CInterpolatorSpline::m_s
|
||||
bool updateElevations(bool canSkip);
|
||||
|
||||
//! Are any elevations missing in CInterpolatorSpline::m_s
|
||||
bool areAnyElevationsMissing() const;
|
||||
|
||||
//! Ground relevant
|
||||
bool isAnySituationNearGroundRelevant() const;
|
||||
|
||||
//! Fill the situations array
|
||||
bool fillSituationsArray();
|
||||
|
||||
qint64 m_prevSampleAdjustedTime = 0; //!< previous sample time + offset
|
||||
qint64 m_nextSampleAdjustedTime = 0; //!< previous sample time + offset
|
||||
qint64 m_prevSampleTime = 0; //!< previous sample "real time"
|
||||
qint64 m_nextSampleTime = 0; //!< next sample "real time"
|
||||
std::array<Aviation::CAircraftSituation, 3> m_s; //!< used situations
|
||||
CInterpolant m_interpolant;
|
||||
};
|
||||
} // ns
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user