swift
Loading...
Searching...
No Matches
interpolator.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 2014 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#ifndef SWIFT_MISC_SIMULATION_INTERPOLATION_INTERPOLATOR_H
7#define SWIFT_MISC_SIMULATION_INTERPOLATION_INTERPOLATOR_H
8
9#include <QString>
10#include <QStringList>
11#include <QTimer>
12#include <QtGlobal>
13
30
31namespace swift::misc::simulation
32{
36
45 protected CRemoteAircraftAware
46 {
47 public:
49 static const QStringList &getLogCategories();
50
53
59 CInterpolationResult getInterpolation(qint64 currentTimeSinceEpoch,
61 uint32_t aircraftNumber);
62
65 void attachLogger(CInterpolationLogger *logger) { m_logger = logger; }
66
68 bool hasAttachedLogger() const { return m_logger; }
69
71 QString getInterpolatorInfo() const;
72
75 void resetLastInterpolation();
76
79 void initCorrespondingModel(const CAircraftModel &model = {});
80
82 void markAsUnitTest();
83
86
89
91 bool hasInterpolationMessages() const { return !m_interpolationMessages.isEmpty(); }
92
93 protected:
96 IInterpolationSetupProvider *setupProvider, IRemoteAircraftProvider *remoteProvider,
97 CInterpolationLogger *logger);
98
100 const physical_quantities::CLength &getModelCG() const { return m_model.getCG(); }
101
103 bool doLogging() const;
104
107
108 // values for current interpolation step
110 qint64 m_lastInvalidLogTs = -1;
121 2;
125
131
137
138 private:
139 CInterpolationLogger *m_logger = nullptr;
140 QTimer m_initTimer;
141 bool m_unitTest = false;
142
148 bool initIniterpolationStepData(qint64 currentTimeSinceEpoch,
149 const CInterpolationAndRenderingSetupPerCallsign &setup, int aircraftNumber);
150
152 aviation::CAircraftSituation initInterpolatedSituation(const aviation::CAircraftSituation &oldSituation,
153 const aviation::CAircraftSituation &newSituation) const;
154
156 aviation::CAircraftSituation getInterpolatedSituation();
157
159 aviation::CAircraftParts getInterpolatedParts();
160
162 aviation::CAircraftParts getInterpolatedOrGuessedParts(int aircraftNumber);
163
165 static aviation::CAircraftParts guessParts(const aviation::CAircraftSituation &situation,
167 const simulation::CAircraftModel &model);
168
170 void logParts(const aviation::CAircraftParts &parts, int partsNo, bool empty) const;
171
175 remoteAircraftSituationsAndChange(const CInterpolationAndRenderingSetupPerCallsign &setup);
176
178 physical_quantities::CLength getAndFetchModelCG(const physical_quantities::CLength &dbCG);
179
185 static bool presetGroundElevation(aviation::CAircraftSituation &situationToPreset,
186 const aviation::CAircraftSituation &oldSituation,
187 const aviation::CAircraftSituation &newSituation,
189
191 void deferredInit();
192
194 const swift::misc::aviation::CAircraftParts &logAndReturnNullParts(const QString &info, bool log);
195
197 virtual const IInterpolant &getInterpolant(SituationLog &log) = 0;
198 };
199} // namespace swift::misc::simulation
200// namespace
201#endif // SWIFT_MISC_SIMULATION_INTERPOLATION_INTERPOLATOR_H
Status messages, e.g. from Core -> GUI.
Value object encapsulating information of aircraft's parts.
static const CAircraftParts & null()
NULL parts object.
Value object about changes in situations.
Value object encapsulating information of an aircraft's situation.
static const CAircraftSituation & null()
Null situation.
Value object encapsulating information of a callsign.
Definition callsign.h:30
Physical unit length (length).
Definition length.h:18
Aircraft model (used by another pilot, my models on disk).
Value object for interpolator and rendering per callsign.
Record internal state of interpolator for debugging.
Base class for interpolating (calculate positions inbetween updates). One instance is responsible for...
const CStatusMessageList & getInterpolationMessages() const
Interpolation messages.
int m_partsToSituationGuessingRatio
ratio between parts guessing and situation interpolation
bool hasInterpolationMessages() const
Do we have interpolation messages.
int m_partsToSituationInterpolationRatio
ratio between parts and situation interpolation, 1..always, 2..every 2nd situation
qint64 m_situationsLastModified
when situations were last modified
aviation::CAircraftParts m_lastParts
latest parts
CInterpolator(const aviation::CCallsign &callsign, ISimulationEnvironmentProvider *simEnvProvider, IInterpolationSetupProvider *setupProvider, IRemoteAircraftProvider *remoteProvider, CInterpolationLogger *logger)
Constructor.
const physical_quantities::CLength & getModelCG() const
Center of gravity.
const aviation::CAircraftSituation & getLastInterpolatedSituation() const
Latest interpolation result.
static const QStringList & getLogCategories()
Log categories.
CInterpolationStatus m_currentInterpolationStatus
this step's situation status
physical_quantities::CLength m_currentSceneryOffset
calculated scenery offset if any
CInterpolationAndRenderingSetupPerCallsign m_currentSetup
used setup
CPartsStatus m_currentPartsStatus
this step's parts status
aviation::CAircraftSituation m_lastSituation
latest interpolation
qint64 m_situationsLastModifiedUsed
interpolant based on situations last updated
void attachLogger(CInterpolationLogger *logger)
Attach an observer to read the interpolator's state for debugging.
int m_interpolatedSituationsCounter
counter for each interpolated situations: used for statistics, every n-th interpolation ....
aviation::CAircraftSituationChange m_pastSituationsChange
situations change of provider (i.e.
CStatusMessageList m_interpolationMessages
interpolation messages
CPartsStatus m_lastPartsStatus
status for last parts, used when last parts are re-used because of m_partsToSituationInterpolationRat...
aviation::CAircraftSituationList m_currentSituations
current situations obtained by remoteAircraftSituationsAndChange
const aviation::CCallsign m_callsign
corresponding callsign
bool hasAttachedLogger() const
Is logger attached?
virtual const IInterpolant & getInterpolant(SituationLog &log)=0
Get the interpolant for the given time point.
qint64 m_lastInvalidLogTs
last invalid situation timestamp
int m_invalidSituations
mainly when there are no new situations
CAircraftModel m_model
corresponding model (required for CG)
int getInvalidSituationsCount() const
Get count of invalid situations.
Linear interpolator, calculation inbetween positions.
Direct in memory access to interpolation setup, normally implemented by simulator.
Direct thread safe in memory access to remote aircraft.
Log entry for situation interpolation.
#define SWIFT_MISC_EXPORT
Export a class or function from the library.