swift
Loading...
Searching...
No Matches
swift::misc::simulation::CInterpolator Class Referenceabstract

Base class for interpolating (calculate positions inbetween updates). One instance is responsible for one aircraft This class provides the high level functions for interpolation (called from the simulator plugin), logging functionality, as well as the logic to interpolate aircraft parts. Information for the position interpolation (basically aircraft updates from FSD) are provided from this class. More...

#include <interpolator.h>

Inheritance diagram for swift::misc::simulation::CInterpolator:
[legend]

Public Member Functions

const aviation::CAircraftSituation & getLastInterpolatedSituation () const
 Latest interpolation result.
CInterpolationResult getInterpolation (qint64 currentTimeSinceEpoch, const CInterpolationAndRenderingSetupPerCallsign &setup, uint32_t aircraftNumber)
 Get interpolated situation.
void attachLogger (CInterpolationLogger *logger)
 Attach an observer to read the interpolator's state for debugging.
bool hasAttachedLogger () const
 Is logger attached?
QString getInterpolatorInfo () const
 Get an interpolator info string (for debug info).
void resetLastInterpolation ()
 Reset last interpolation to null.
void initCorrespondingModel (const CAircraftModel &model={})
 Init, or re-init the corressponding model.
void markAsUnitTest ()
 Mark as unit test.
int getInvalidSituationsCount () const
 Get count of invalid situations.
const CStatusMessageList & getInterpolationMessages () const
 Interpolation messages.
bool hasInterpolationMessages () const
 Do we have interpolation messages.

Static Public Member Functions

static const QStringList & getLogCategories ()
 Log categories.

Protected Member Functions

 CInterpolator (const aviation::CCallsign &callsign, ISimulationEnvironmentProvider *simEnvProvider, IInterpolationSetupProvider *setupProvider, IRemoteAircraftProvider *remoteProvider, CInterpolationLogger *logger)
 Constructor.
const physical_quantities::CLength & getModelCG () const
 Center of gravity.
bool doLogging () const
 Do logging.
Protected Member Functions inherited from swift::misc::simulation::CSimulationEnvironmentAware
 CSimulationEnvironmentAware ()
 Default constructor.
 CSimulationEnvironmentAware (ISimulationEnvironmentProvider *simEnvProvider)
 Constructor.
void setSimulationEnvironmentProvider (ISimulationEnvironmentProvider *provider)
 Set the provider.
geo::CElevationPlane findClosestElevationWithinRange (const geo::ICoordinateGeodetic &reference, const physical_quantities::CLength &range) const
 Find closest elevation (or return NULL).
geo::CElevationPlane findClosestElevationWithinRangeOrRequest (const geo::ICoordinateGeodetic &reference, const physical_quantities::CLength &range, const aviation::CCallsign &callsign)
 Find closest elevation or request elevation.
geo::CElevationPlane averageElevationOfOnGroundAircraft (const aviation::CAircraftSituation &reference, const physical_quantities::CLength &range, int minValues, int sufficientValues) const
 Average elevation of "on ground" cached values.
aviation::CAltitude highestElevation () const
 Highest elevation.
bool requestElevation (const geo::ICoordinateGeodetic &reference, const aviation::CCallsign &callsign)
 Request elevation, there is no guarantee the requested elevation will be available in the provider.
bool requestElevation (const aviation::CAircraftSituation &situation)
 Request elevation, there is no guarantee the requested elevation will be available in the provider.
QPair< int, int > getElevationsFoundMissed () const
 Elevations found/missed statistics.
QString getElevationsFoundMissedInfo () const
 Elevations found/missed statistics info as string.
QPair< qint64, qint64 > getElevationRequestTimes () const
 The elevation request times.
QString getElevationRequestTimesInfo () const
 Elevation request times.
CSimulatorPluginInfo getSimulatorPluginInfo () const
 Get the represented plugin.
CSimulatorInfo getSimulatorInfo () const
 Get the represented plugin.
QString getSimulatorNameAndVersion () const
 Version and simulator details info.
CAircraftModel getDefaultModel () const
 Default model.
physical_quantities::CLength getSimulatorCG (const aviation::CCallsign &callsign) const
 Get CG per callsign, NULL if not found.
physical_quantities::CLength getSimulatorOrDbCG (const aviation::CCallsign &callsign, const physical_quantities::CLength &dbCG) const
 Get CG per callsign, NULL if not found.
bool hasSimulatorCG (const aviation::CCallsign &callsign) const
 Has a CG?
bool cleanElevationValues (const aviation::CAircraftSituation &reference, const physical_quantities::CLength &range, bool forced=false)
 Remove cached elevations outside range, "forced" cleans always, otherwise only if max.values are reached.
Protected Member Functions inherited from swift::misc::IProviderAware< ISimulationEnvironmentProvider >
 IProviderAware (ISimulationEnvironmentProvider *provider=nullptr)
 Ctor.
virtual ~IProviderAware ()=default
 Dtor.
bool hasProvider () const
 Has provider?
ISimulationEnvironmentProvider * getProvider () const
 Provider.
void setProvider (ISimulationEnvironmentProvider *provider)
 Set the provider.
ISimulationEnvironmentProvider * provider ()
 Provider.
Protected Member Functions inherited from swift::misc::simulation::CInterpolationSetupAware
 CInterpolationSetupAware ()
 Default constructor.
 CInterpolationSetupAware (IInterpolationSetupProvider *setupProvider)
 Constructor.
void setInterpolationSetupProvider (IInterpolationSetupProvider *provider)
 Provider.
CInterpolationAndRenderingSetupPerCallsign getInterpolationSetupPerCallsignOrDefault (const aviation::CCallsign &callsign) const
 Get the setup for callsign, if not existing the global setup.
CInterpolationAndRenderingSetupGlobal getInterpolationSetupGlobal () const
 The global setup.
Protected Member Functions inherited from swift::misc::IProviderAware< IInterpolationSetupProvider >
 IProviderAware (IInterpolationSetupProvider *provider=nullptr)
 Ctor.
virtual ~IProviderAware ()=default
 Dtor.
bool hasProvider () const
 Has provider?
IInterpolationSetupProvider * getProvider () const
 Provider.
void setProvider (IInterpolationSetupProvider *provider)
 Set the provider.
IInterpolationSetupProvider * provider ()
 Provider.
Protected Member Functions inherited from swift::misc::simulation::CRemoteAircraftAware
 CRemoteAircraftAware ()
 Default constructor.
 CRemoteAircraftAware (IRemoteAircraftProvider *remoteAircraftProvider)
 Constructor.
 ~CRemoteAircraftAware ()=default
 Destructor.
CSimulatedAircraftList getAircraftInRange () const
 All remote aircraft.
bool isAircraftInRange (const aviation::CCallsign &callsign) const
 Is aircraft in range?
bool isVtolAircraft (const aviation::CCallsign &callsign) const
 Is VTOL aircraft?
int getAircraftInRangeCount () const
 Count remote aircraft.
aviation::CCallsignSet getAircraftInRangeCallsigns () const
 Unique callsigns for aircraft in range.
CSimulatedAircraft getAircraftInRangeForCallsign (const aviation::CCallsign &callsign) const
 Aircraft for callsign.
CAircraftModel getAircraftInRangeModelForCallsign (const aviation::CCallsign &callsign) const
 Aircraft model for callsign.
CAirspaceAircraftSnapshot getLatestAirspaceAircraftSnapshot () const
 Current snapshot.
aviation::CAircraftSituationList remoteAircraftSituations (const aviation::CCallsign &callsign) const
 Rendered aircraft situations (per callsign, time history).
aviation::CAircraftSituation remoteAircraftSituation (const aviation::CCallsign &callsign, int index) const
 Rendered aircraft situations (per callsign and index).
aviation::CAircraftSituationList latestRemoteAircraftSituations () const
 Latest aircraft situation for all callsigns.
aviation::CAircraftSituationList latestOnGroundProviderElevations () const
 Latest aircraft situation "on ground" having a provider elevation.
int remoteAircraftSituationsCount (const aviation::CCallsign &callsign) const
 Number of remote aircraft situations for callsign.
aviation::CAircraftPartsList remoteAircraftParts (const aviation::CCallsign &callsign) const
 All parts (per callsign, time history).
int remoteAircraftPartsCount (const aviation::CCallsign &callsign) const
 All parts (per callsign, time history).
aviation::CAircraftSituationChangeList remoteAircraftSituationChanges (const aviation::CCallsign &callsign) const
 Aircraft changes.
aviation::CCallsignSet remoteAircraftSupportingParts () const
 Remote aircraft supporting parts.
bool isRemoteAircraftSupportingParts (const aviation::CCallsign &callsign) const
 Is remote aircraft supporting parts?
int getRemoteAircraftSupportingPartsCount () const
 Number of aircraft supporting parts.
bool updateAircraftEnabled (const aviation::CCallsign &callsign, bool enabledForRendering)
 Enable/disable aircraft and follow up logic like sending signals.
bool setAircraftEnabledFlag (const aviation::CCallsign &callsign, bool enabledForRendering)
 Just set enable/disable aircraft flag, no further logic.
bool updateMultipleAircraftEnabled (const aviation::CCallsignSet &callsigns, bool enabledForRendering)
 Enable/disable aircraft.
bool updateAircraftModel (const aviation::CCallsign &callsign, const CAircraftModel &model, const CIdentifier &originator)
 Change model.
bool updateAircraftNetworkModel (const aviation::CCallsign &callsign, const CAircraftModel &model, const CIdentifier &originator)
 Change network model.
bool updateAircraftRendered (const aviation::CCallsign &callsign, bool rendered)
 Set aircraft rendered.
bool updateMultipleAircraftRendered (const aviation::CCallsignSet &callsigns, bool rendered)
 Set aircraft rendered.
int updateAircraftGroundElevation (const aviation::CCallsign &callsign, const geo::CElevationPlane &elevation, aviation::CAircraftSituation::GndElevationInfo info, bool *updateAircraftGroundElevation)
 Update the ground elevation.
bool updateCG (const aviation::CCallsign &callsign, const physical_quantities::CLength &cg)
 Update the CG.
aviation::CCallsignSet updateCGForModel (const QString &modelString, const physical_quantities::CLength &cg)
 Update the CG for this model string.
bool updateCGAndModelString (const aviation::CCallsign &callsign, const physical_quantities::CLength &cg, const QString &modelString)
 Update the CG and model string.
void updateMarkAllAsNotRendered ()
 Mark all as not rendered.
int aircraftSituationsAdded () const
 Number of situations added.
int aircraftPartsAdded () const
 Number of parts added.
qint64 situationsLastModified (const aviation::CCallsign &callsign) const
 When last modified.
qint64 partsLastModified (const aviation::CCallsign &callsign) const
 When last modified.
geo::CElevationPlane averageElevationOfNonMovingAircraft (const aviation::CAircraftSituation &reference, const physical_quantities::CLength &range, int minValues=1) const
 Average elevation of aircraft in given range, which are NOT moving.
void setRemoteAircraftProvider (IRemoteAircraftProvider *remoteAircraftProvider)
 Set remote aircraft provider.
IRemoteAircraftProvider * getRemoteAircraftProvider () const
 Get the aircraft provider.
Protected Member Functions inherited from swift::misc::IProviderAware< IRemoteAircraftProvider >
 IProviderAware (IRemoteAircraftProvider *provider=nullptr)
 Ctor.
virtual ~IProviderAware ()=default
 Dtor.
bool hasProvider () const
 Has provider?
IRemoteAircraftProvider * getProvider () const
 Provider.
void setProvider (IRemoteAircraftProvider *provider)
 Set the provider.
IRemoteAircraftProvider * provider ()
 Provider.

Protected Attributes

const aviation::CCallsign m_callsign
 corresponding callsign
CAircraftModel m_model
 corresponding model (required for CG)
qint64 m_currentTimeMsSinceEpoch = -1
 current time
qint64 m_lastInvalidLogTs = -1
 last invalid situation timestamp
aviation::CAircraftSituationList m_currentSituations
 current situations obtained by remoteAircraftSituationsAndChange
aviation::CAircraftSituationChange m_pastSituationsChange
 situations change of provider (i.e.
CInterpolationAndRenderingSetupPerCallsign m_currentSetup
 used setup
CInterpolationStatus m_currentInterpolationStatus
 this step's situation status
CPartsStatus m_currentPartsStatus
 this step's parts status
CPartsStatus m_lastPartsStatus
 status for last parts, used when last parts are re-used because of m_partsToSituationInterpolationRatio
int m_partsToSituationInterpolationRatio
 ratio between parts and situation interpolation, 1..always, 2..every 2nd situation
int m_partsToSituationGuessingRatio = 5
 ratio between parts guessing and situation interpolation
int m_invalidSituations = 0
 mainly when there are no new situations
CStatusMessageList m_interpolationMessages
 interpolation messages
aviation::CAircraftSituation m_lastSituation { aviation::CAircraftSituation::null() }
 latest interpolation
aviation::CAircraftParts m_lastParts { aviation::CAircraftParts::null() }
 latest parts
physical_quantities::CLength m_currentSceneryOffset
 calculated scenery offset if any
qint64 m_situationsLastModified { -1 }
 when situations were last modified
qint64 m_situationsLastModifiedUsed { -1 }
 interpolant based on situations last updated
int m_interpolatedSituationsCounter
 counter for each interpolated situations: used for statistics, every n-th interpolation ....

Private Member Functions

virtual const IInterpolant & getInterpolant (SituationLog &log)=0
 Get the interpolant for the given time point.

Detailed Description

Base class for interpolating (calculate positions inbetween updates). One instance is responsible for one aircraft This class provides the high level functions for interpolation (called from the simulator plugin), logging functionality, as well as the logic to interpolate aircraft parts. Information for the position interpolation (basically aircraft updates from FSD) are provided from this class.

Definition at line 42 of file interpolator.h.

Constructor & Destructor Documentation

◆ CInterpolator()

swift::misc::simulation::CInterpolator::CInterpolator ( const aviation::CCallsign & callsign,
ISimulationEnvironmentProvider * simEnvProvider,
IInterpolationSetupProvider * setupProvider,
IRemoteAircraftProvider * remoteProvider,
CInterpolationLogger * logger )
protected

Constructor.

Definition at line 38 of file interpolator.cpp.

Member Function Documentation

◆ attachLogger()

void swift::misc::simulation::CInterpolator::attachLogger ( CInterpolationLogger * logger)
inline

Attach an observer to read the interpolator's state for debugging.

Remarks
parts logging has a bool log flag

Definition at line 65 of file interpolator.h.

◆ doLogging()

bool swift::misc::simulation::CInterpolator::doLogging ( ) const
protected

Do logging.

Definition at line 511 of file interpolator.cpp.

◆ getInterpolant()

virtual const IInterpolant & swift::misc::simulation::CInterpolator::getInterpolant ( SituationLog & log)
privatepure virtual

Get the interpolant for the given time point.

Implemented in swift::misc::simulation::CInterpolatorLinear, and swift::misc::simulation::CInterpolatorSpline.

◆ getInterpolation()

CInterpolationResult swift::misc::simulation::CInterpolator::getInterpolation ( qint64 currentTimeSinceEpoch,
const CInterpolationAndRenderingSetupPerCallsign & setup,
uint32_t aircraftNumber )

Get interpolated situation.

Parameters
currentTimeSinceEpochmilliseconds since epoch for which the situation should be interpolated
setupinterpolation setup
aircraftNumbernumber used to spread the computational load of part interpolation
Returns
interpolation result

Definition at line 186 of file interpolator.cpp.

◆ getInterpolationMessages()

const CStatusMessageList & swift::misc::simulation::CInterpolator::getInterpolationMessages ( ) const
inline

Interpolation messages.

Definition at line 88 of file interpolator.h.

◆ getInterpolatorInfo()

QString swift::misc::simulation::CInterpolator::getInterpolatorInfo ( ) const

Get an interpolator info string (for debug info).

Definition at line 693 of file interpolator.cpp.

◆ getInvalidSituationsCount()

int swift::misc::simulation::CInterpolator::getInvalidSituationsCount ( ) const
inline

Get count of invalid situations.

Definition at line 85 of file interpolator.h.

◆ getLastInterpolatedSituation()

const aviation::CAircraftSituation & swift::misc::simulation::CInterpolator::getLastInterpolatedSituation ( ) const
inline

Latest interpolation result.

Definition at line 52 of file interpolator.h.

◆ getLogCategories()

const QStringList & swift::misc::simulation::CInterpolator::getLogCategories ( )
static

Log categories.

Definition at line 180 of file interpolator.cpp.

◆ getModelCG()

const physical_quantities::CLength & swift::misc::simulation::CInterpolator::getModelCG ( ) const
inlineprotected

Center of gravity.

Definition at line 100 of file interpolator.h.

◆ hasAttachedLogger()

bool swift::misc::simulation::CInterpolator::hasAttachedLogger ( ) const
inline

Is logger attached?

Definition at line 68 of file interpolator.h.

◆ hasInterpolationMessages()

bool swift::misc::simulation::CInterpolator::hasInterpolationMessages ( ) const
inline

Do we have interpolation messages.

Definition at line 91 of file interpolator.h.

◆ initCorrespondingModel()

void swift::misc::simulation::CInterpolator::initCorrespondingModel ( const CAircraftModel & model = {})

Init, or re-init the corressponding model.

Remarks
either by passing a model or using the provider

Definition at line 791 of file interpolator.cpp.

◆ markAsUnitTest()

void swift::misc::simulation::CInterpolator::markAsUnitTest ( )

Mark as unit test.

Definition at line 808 of file interpolator.cpp.

◆ resetLastInterpolation()

void swift::misc::simulation::CInterpolator::resetLastInterpolation ( )

Reset last interpolation to null.

Remarks
mainly needed in UNIT tests

Definition at line 701 of file interpolator.cpp.

Member Data Documentation

◆ m_callsign

const aviation::CCallsign swift::misc::simulation::CInterpolator::m_callsign
protected

corresponding callsign

Definition at line 105 of file interpolator.h.

◆ m_currentInterpolationStatus

CInterpolationStatus swift::misc::simulation::CInterpolator::m_currentInterpolationStatus
protected

this step's situation status

Definition at line 116 of file interpolator.h.

◆ m_currentPartsStatus

CPartsStatus swift::misc::simulation::CInterpolator::m_currentPartsStatus
protected

this step's parts status

Definition at line 117 of file interpolator.h.

◆ m_currentSceneryOffset

physical_quantities::CLength swift::misc::simulation::CInterpolator::m_currentSceneryOffset
protected
Initial value:

calculated scenery offset if any

Definition at line 128 of file interpolator.h.

◆ m_currentSetup

CInterpolationAndRenderingSetupPerCallsign swift::misc::simulation::CInterpolator::m_currentSetup
protected

used setup

Definition at line 115 of file interpolator.h.

◆ m_currentSituations

aviation::CAircraftSituationList swift::misc::simulation::CInterpolator::m_currentSituations
protected

current situations obtained by remoteAircraftSituationsAndChange

Definition at line 112 of file interpolator.h.

◆ m_currentTimeMsSinceEpoch

qint64 swift::misc::simulation::CInterpolator::m_currentTimeMsSinceEpoch = -1
protected

current time

Definition at line 109 of file interpolator.h.

◆ m_interpolatedSituationsCounter

int swift::misc::simulation::CInterpolator::m_interpolatedSituationsCounter
protected
Initial value:
{
0
}

counter for each interpolated situations: used for statistics, every n-th interpolation ....

Definition at line 134 of file interpolator.h.

◆ m_interpolationMessages

CStatusMessageList swift::misc::simulation::CInterpolator::m_interpolationMessages
protected

interpolation messages

Definition at line 124 of file interpolator.h.

◆ m_invalidSituations

int swift::misc::simulation::CInterpolator::m_invalidSituations = 0
protected

mainly when there are no new situations

Definition at line 123 of file interpolator.h.

◆ m_lastInvalidLogTs

qint64 swift::misc::simulation::CInterpolator::m_lastInvalidLogTs = -1
protected

last invalid situation timestamp

Definition at line 110 of file interpolator.h.

◆ m_lastParts

aviation::CAircraftParts swift::misc::simulation::CInterpolator::m_lastParts { aviation::CAircraftParts::null() }
protected

latest parts

Definition at line 127 of file interpolator.h.

◆ m_lastPartsStatus

CPartsStatus swift::misc::simulation::CInterpolator::m_lastPartsStatus
protected

status for last parts, used when last parts are re-used because of m_partsToSituationInterpolationRatio

Definition at line 118 of file interpolator.h.

◆ m_lastSituation

aviation::CAircraftSituation swift::misc::simulation::CInterpolator::m_lastSituation { aviation::CAircraftSituation::null() }
protected

latest interpolation

Definition at line 126 of file interpolator.h.

◆ m_model

CAircraftModel swift::misc::simulation::CInterpolator::m_model
protected

corresponding model (required for CG)

Definition at line 106 of file interpolator.h.

◆ m_partsToSituationGuessingRatio

int swift::misc::simulation::CInterpolator::m_partsToSituationGuessingRatio = 5
protected

ratio between parts guessing and situation interpolation

Definition at line 122 of file interpolator.h.

◆ m_partsToSituationInterpolationRatio

int swift::misc::simulation::CInterpolator::m_partsToSituationInterpolationRatio
protected
Initial value:
=
2

ratio between parts and situation interpolation, 1..always, 2..every 2nd situation

Definition at line 120 of file interpolator.h.

◆ m_pastSituationsChange

aviation::CAircraftSituationChange swift::misc::simulation::CInterpolator::m_pastSituationsChange
protected

situations change of provider (i.e.

network) situations

Definition at line 114 of file interpolator.h.

◆ m_situationsLastModified

qint64 swift::misc::simulation::CInterpolator::m_situationsLastModified { -1 }
protected

when situations were last modified

Definition at line 132 of file interpolator.h.

◆ m_situationsLastModifiedUsed

qint64 swift::misc::simulation::CInterpolator::m_situationsLastModifiedUsed { -1 }
protected

interpolant based on situations last updated

Definition at line 133 of file interpolator.h.


The documentation for this class was generated from the following files: