swift
Loading...
Searching...
No Matches
interpolatormulti.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 2017 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
7
8using namespace swift::misc::aviation;
9
10namespace swift::misc::simulation
11{
15 : m_spline(callsign, p1, p2, p3, logger), m_linear(callsign, p1, p2, p3, logger)
16 {}
17
20 uint32_t aircraftNumber)
21 {
22 switch (setup.getInterpolatorMode())
23 {
24 case CInterpolationAndRenderingSetupBase::Linear:
25 return m_linear.getInterpolation(currentTimeSinceEpoch, setup, aircraftNumber);
26 case CInterpolationAndRenderingSetupBase::Spline:
27 return m_spline.getInterpolation(currentTimeSinceEpoch, setup, aircraftNumber);
28 default: break;
29 }
30
31 return {};
32 }
33
34 const CAircraftSituation &
36 {
37 switch (mode)
38 {
39 case CInterpolationAndRenderingSetupBase::Linear: return m_linear.getLastInterpolatedSituation();
40 case CInterpolationAndRenderingSetupBase::Spline: return m_spline.getLastInterpolatedSituation();
41 default: break;
42 }
44 }
45
47 {
48 m_linear.attachLogger(logger);
49 m_spline.attachLogger(logger);
50 }
51
53 {
54 m_linear.initCorrespondingModel(model);
55 m_spline.initCorrespondingModel(model);
56 }
57
58 const CStatusMessageList &
60 {
61 switch (mode)
62 {
63 case CInterpolationAndRenderingSetupBase::Spline: return m_spline.getInterpolationMessages();
64 case CInterpolationAndRenderingSetupBase::Linear: return m_linear.getInterpolationMessages();
65 default: break;
66 }
67 static const CStatusMessageList empty;
68 return empty;
69 }
70
72 {
73 switch (mode)
74 {
75 case CInterpolationAndRenderingSetupBase::Spline: return m_spline.getInterpolatorInfo();
76 case CInterpolationAndRenderingSetupBase::Linear: return m_linear.getInterpolatorInfo();
77 default: break;
78 }
79 return ("Illegal mode");
80 }
81
86 {
87 m_interpolator.reset(new CInterpolatorMulti(callsign, p1, p2, p3));
88 m_interpolator->attachLogger(logger);
89 }
90} // namespace swift::misc::simulation
Status messages, e.g. from Core -> GUI.
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
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.
Multiplexed interpolator which allows switching between modes at runtime.
CInterpolatorMulti(const aviation::CCallsign &callsign, ISimulationEnvironmentProvider *p1, IInterpolationSetupProvider *p2, IRemoteAircraftProvider *p3, CInterpolationLogger *logger=nullptr)
Constructor.
void initCorrespondingModel(const CAircraftModel &model)
Init, or re-init the corressponding model.
CInterpolationResult getInterpolation(qint64 currentTimeSinceEpoch, const CInterpolationAndRenderingSetupPerCallsign &setup, uint32_t aircraftNumber)
Get interpolated situation.
const aviation::CAircraftSituation & getLastInterpolatedSituation(CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const
Latest interpolation result.
QString getInterpolatorInfo(CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const
Info string.
const CStatusMessageList & getInterpolationMessages(CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const
Interpolation messages.
void attachLogger(CInterpolationLogger *logger)
Attach an observer to read the interpolator's state for debugging.
CInterpolatorMultiWrapper()=default
Default ctor, needed for QMap/QHash.
Direct in memory access to interpolation setup, normally implemented by simulator.
Direct thread safe in memory access to remote aircraft.