swift
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
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...

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

Public Member Functions

const aviation::CAircraftSituationgetLastInterpolatedSituation () const
 Latest interpolation result.
 
CInterpolationResult getInterpolation (qint64 currentTimeSinceEpoch, const CInterpolationAndRenderingSetupPerCallsign &setup, uint32_t aircraftNumber)
 Get interpolated situation. More...
 
void attachLogger (CInterpolationLogger *logger)
 Attach an observer to read the interpolator's state for debugging. More...
 
bool hasAttachedLogger () const
 Is logger attached?
 
QString getInterpolatorInfo () const
 Get an interpolator info string (for debug info)
 
void resetLastInterpolation ()
 Reset last interpolation to null. More...
 
void initCorrespondingModel (const CAircraftModel &model={})
 Init, or re-init the corressponding model. More...
 
void markAsUnitTest ()
 Mark as unit test.
 
int getInvalidSituationsCount () const
 Get count of invalid situations.
 
const CStatusMessageListgetInterpolationMessages () 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::CLengthgetModelCG () 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) More...
 
geo::CElevationPlane findClosestElevationWithinRangeOrRequest (const geo::ICoordinateGeodetic &reference, const physical_quantities::CLength &range, const aviation::CCallsign &callsign)
 Find closest elevation or request elevation. More...
 
geo::CElevationPlane averageElevationOfOnGroundAircraft (const aviation::CAircraftSituation &reference, const physical_quantities::CLength &range, int minValues, int sufficientValues) const
 Average elevation of "on ground" cached values. More...
 
aviation::CAltitude highestElevation () const
 Highest elevation. More...
 
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. More...
 
bool requestElevation (const aviation::CAircraftSituation &situation)
 Request elevation, there is no guarantee the requested elevation will be available in the provider. More...
 
QPair< int, int > getElevationsFoundMissed () const
 Elevations found/missed statistics. More...
 
QString getElevationsFoundMissedInfo () const
 Elevations found/missed statistics info as string. More...
 
QPair< qint64, qint64 > getElevationRequestTimes () const
 The elevation request times. More...
 
QString getElevationRequestTimesInfo () const
 Elevation request times. More...
 
CSimulatorPluginInfo getSimulatorPluginInfo () const
 Get the represented plugin. More...
 
CSimulatorInfo getSimulatorInfo () const
 Get the represented plugin. More...
 
QString getSimulatorNameAndVersion () const
 Version and simulator details info. More...
 
CAircraftModel getDefaultModel () const
 Default model. More...
 
physical_quantities::CLength getSimulatorCG (const aviation::CCallsign &callsign) const
 Get CG per callsign, NULL if not found. More...
 
physical_quantities::CLength getSimulatorOrDbCG (const aviation::CCallsign &callsign, const physical_quantities::CLength &dbCG) const
 Get CG per callsign, NULL if not found. More...
 
bool hasSimulatorCG (const aviation::CCallsign &callsign) const
 Has a CG? More...
 
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. More...
 
- Protected Member Functions inherited from swift::misc::IProviderAware< ISimulationEnvironmentProvider >
 IProviderAware (ISimulationEnvironmentProvider *provider=nullptr)
 Ctor.
 
virtual ~IProviderAware ()
 Dtor.
 
bool hasProvider () const
 Has provider?
 
ISimulationEnvironmentProvider * getProvider () const
 Provider.
 
void setProvider (ISimulationEnvironmentProvider *provider)
 Set the provider. More...
 
ISimulationEnvironmentProvider * provider ()
 Provider.
 
const ISimulationEnvironmentProvider * provider () const
 Const 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. More...
 
CInterpolationAndRenderingSetupGlobal getInterpolationSetupGlobal () const
 The global setup. More...
 
- Protected Member Functions inherited from swift::misc::IProviderAware< IInterpolationSetupProvider >
 IProviderAware (IInterpolationSetupProvider *provider=nullptr)
 Ctor.
 
virtual ~IProviderAware ()
 Dtor.
 
bool hasProvider () const
 Has provider?
 
IInterpolationSetupProvider * getProvider () const
 Provider.
 
void setProvider (IInterpolationSetupProvider *provider)
 Set the provider. More...
 
IInterpolationSetupProvider * provider ()
 Provider.
 
const IInterpolationSetupProvider * provider () const
 Const provider.
 
- Protected Member Functions inherited from swift::misc::simulation::CRemoteAircraftAware
 CRemoteAircraftAware ()
 Default constructor.
 
 CRemoteAircraftAware (IRemoteAircraftProvider *remoteAircraftProvider)
 Constructor.
 
virtual ~CRemoteAircraftAware ()
 Destructor.
 
CSimulatedAircraftList getAircraftInRange () const
 All remote aircraft. More...
 
bool isAircraftInRange (const aviation::CCallsign &callsign) const
 Is aircraft in range? More...
 
bool isVtolAircraft (const aviation::CCallsign &callsign) const
 Is VTOL aircraft? More...
 
int getAircraftInRangeCount () const
 Count remote aircraft. More...
 
aviation::CCallsignSet getAircraftInRangeCallsigns () const
 Unique callsigns for aircraft in range. More...
 
CSimulatedAircraft getAircraftInRangeForCallsign (const aviation::CCallsign &callsign) const
 Aircraft for callsign. More...
 
CAircraftModel getAircraftInRangeModelForCallsign (const aviation::CCallsign &callsign) const
 Aircraft model for callsign. More...
 
CAirspaceAircraftSnapshot getLatestAirspaceAircraftSnapshot () const
 Current snapshot. More...
 
aviation::CAircraftSituationList remoteAircraftSituations (const aviation::CCallsign &callsign) const
 Rendered aircraft situations (per callsign, time history) More...
 
aviation::CAircraftSituation remoteAircraftSituation (const aviation::CCallsign &callsign, int index) const
 Rendered aircraft situations (per callsign and index) More...
 
aviation::CAircraftSituationList latestRemoteAircraftSituations () const
 Latest aircraft situation for all callsigns. More...
 
aviation::CAircraftSituationList latestOnGroundProviderElevations () const
 Latest aircraft situation "on ground" having a provider elevation. More...
 
int remoteAircraftSituationsCount (const aviation::CCallsign &callsign) const
 Number of remote aircraft situations for callsign. More...
 
aviation::CAircraftPartsList remoteAircraftParts (const aviation::CCallsign &callsign) const
 All parts (per callsign, time history) More...
 
int remoteAircraftPartsCount (const aviation::CCallsign &callsign) const
 All parts (per callsign, time history) More...
 
aviation::CAircraftSituationChangeList remoteAircraftSituationChanges (const aviation::CCallsign &callsign) const
 Aircraft changes. More...
 
aviation::CCallsignSet remoteAircraftSupportingParts () const
 Remote aircraft supporting parts. More...
 
bool isRemoteAircraftSupportingParts (const aviation::CCallsign &callsign) const
 Is remote aircraft supporting parts? More...
 
int getRemoteAircraftSupportingPartsCount () const
 Number of aircraft supporting parts. More...
 
bool updateAircraftEnabled (const aviation::CCallsign &callsign, bool enabledForRendering)
 Enable/disable aircraft and follow up logic like sending signals. More...
 
bool setAircraftEnabledFlag (const aviation::CCallsign &callsign, bool enabledForRendering)
 Just set enable/disable aircraft flag, no further logic. More...
 
bool updateMultipleAircraftEnabled (const aviation::CCallsignSet &callsigns, bool enabledForRendering)
 Enable/disable aircraft. More...
 
bool updateAircraftModel (const aviation::CCallsign &callsign, const CAircraftModel &model, const CIdentifier &originator)
 Change model. More...
 
bool updateAircraftNetworkModel (const aviation::CCallsign &callsign, const CAircraftModel &model, const CIdentifier &originator)
 Change network model. More...
 
bool updateAircraftRendered (const aviation::CCallsign &callsign, bool rendered)
 Set aircraft rendered. More...
 
bool updateMultipleAircraftRendered (const aviation::CCallsignSet &callsigns, bool rendered)
 Set aircraft rendered. More...
 
int updateAircraftGroundElevation (const aviation::CCallsign &callsign, const geo::CElevationPlane &elevation, aviation::CAircraftSituation::GndElevationInfo info, bool *updateAircraftGroundElevation)
 Update the ground elevation. More...
 
bool updateCG (const aviation::CCallsign &callsign, const physical_quantities::CLength &cg)
 Update the CG. More...
 
aviation::CCallsignSet updateCGForModel (const QString &modelString, const physical_quantities::CLength &cg)
 Update the CG for this model string. More...
 
bool updateCGAndModelString (const aviation::CCallsign &callsign, const physical_quantities::CLength &cg, const QString &modelString)
 Update the CG and model string. More...
 
void updateMarkAllAsNotRendered ()
 Mark all as not rendered. More...
 
int aircraftSituationsAdded () const
 Number of situations added. More...
 
int aircraftPartsAdded () const
 Number of parts added. More...
 
qint64 situationsLastModified (const aviation::CCallsign &callsign) const
 When last modified. More...
 
qint64 partsLastModified (const aviation::CCallsign &callsign) const
 When last modified. More...
 
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. More...
 
void setRemoteAircraftProvider (IRemoteAircraftProvider *remoteAircraftProvider)
 Set remote aircraft provider.
 
IRemoteAircraftProvidergetRemoteAircraftProvider () const
 Get the aircraft provider.
 
- Protected Member Functions inherited from swift::misc::IProviderAware< IRemoteAircraftProvider >
 IProviderAware (IRemoteAircraftProvider *provider=nullptr)
 Ctor.
 
virtual ~IProviderAware ()
 Dtor.
 
bool hasProvider () const
 Has provider?
 
IRemoteAircraftProvider * getProvider () const
 Provider.
 
void setProvider (IRemoteAircraftProvider *provider)
 Set the provider. More...
 
IRemoteAircraftProvider * provider ()
 Provider.
 
const IRemoteAircraftProvider * provider () const
 Const 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. More...
 
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 More...
 
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 More...
 
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 .... More...
 

Private Member Functions

virtual const IInterpolantgetInterpolant (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.

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.

◆ 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 171 of file interpolator.cpp.

◆ 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 723 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 636 of file interpolator.cpp.

Member Data Documentation

◆ 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_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_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.


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