swift
Loading...
Searching...
No Matches
simulatoremulated.h
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
6#ifndef SWIFT_SIMPLUGIN_EMULATED_SIMULATOREMULATED_H
7#define SWIFT_SIMPLUGIN_EMULATED_SIMULATOREMULATED_H
8
9#include <QMap>
10#include <QPointer>
11#include <QTimer>
12
15
18#include "misc/pq/time.h"
24
25namespace swift::simplugin::emulated
26{
29 {
34
37
38 public:
40 CSimulatorEmulated(const swift::misc::simulation::CSimulatorPluginInfo &info,
41 swift::misc::simulation::IOwnAircraftProvider *ownAircraftProvider,
42 swift::misc::simulation::IRemoteAircraftProvider *remoteAircraftProvider,
43 swift::misc::network::IClientProvider *clientProvider, QObject *parent = nullptr);
44
46 ~CSimulatorEmulated() override;
47
48 // functions implemented
49 bool connectTo() override;
50 bool disconnectFrom() override;
51 void unload() override;
52 bool isConnected() const override;
53 bool isPaused() const override;
54 bool isSimulating() const override;
55 bool changeRemoteAircraftModel(const swift::misc::simulation::CSimulatedAircraft &aircraft) override;
56 bool changeRemoteAircraftEnabled(const swift::misc::simulation::CSimulatedAircraft &aircraft) override;
57 bool updateOwnSimulatorCockpit(const swift::misc::simulation::CSimulatedAircraft &aircraft,
58 const swift::misc::CIdentifier &originator) override;
59 bool updateOwnSimulatorSelcal(const swift::misc::aviation::CSelcal &selcal,
60 const swift::misc::CIdentifier &originator) override;
61 void displayStatusMessage(const swift::misc::CStatusMessage &message) const override;
62 void displayTextMessage(const swift::misc::network::CTextMessage &message) const override;
63 bool isPhysicallyRenderedAircraft(const swift::misc::aviation::CCallsign &callsign) const override;
64 swift::misc::aviation::CCallsignSet physicallyRenderedAircraft() const override;
65 swift::misc::CStatusMessageList
66 getInterpolationMessages(const swift::misc::aviation::CCallsign &callsign) const override;
67 bool testSendSituationAndParts(const swift::misc::aviation::CCallsign &callsign,
68 const swift::misc::aviation::CAircraftSituation &situation,
69 const swift::misc::aviation::CAircraftParts &parts) override;
70 bool requestElevation(const swift::misc::geo::ICoordinateGeodetic &reference,
71 const swift::misc::aviation::CCallsign &callsign) override;
72
73 // ----- functions just logged -------
74 bool logicallyAddRemoteAircraft(const swift::misc::simulation::CSimulatedAircraft &remoteAircraft) override;
75 bool logicallyRemoveRemoteAircraft(const swift::misc::aviation::CCallsign &callsign) override;
76 int physicallyRemoveMultipleRemoteAircraft(const swift::misc::aviation::CCallsignSet &callsigns) override;
77
78 // functions logged and used
85 bool parseCommandLine(const QString &commandLine, const swift::misc::CIdentifier &originator) override;
86
88 void setCombinedStatus(bool connected, bool simulating, bool paused);
89
91 swift::misc::simulation::CSimulatorInfo getEmulatedSimulator() const;
92
95 const swift::misc::simulation::CSimulatedAircraft &getInternalOwnAircraft() const { return m_myAircraft; }
96
100
105
109
113
117
119 bool setInterpolatorFetchTime(int timeMs);
120
122 bool isInterpolatorFetching() const;
123
125 static void registerHelp(); // cppcheck-suppress duplInheritedMember
126
127 signals:
130
131 protected:
135
137 bool parseDetails(const swift::misc::CSimpleCommandParser &parser) override;
138
139 private:
141 void setObjectName(const swift::misc::simulation::CSimulatorInfo &info);
142
144 bool canLog() const;
145
147 bool canDisplay() const;
148
150 void closeMonitor();
151
153 void onSettingsChanged();
154
156 void onSimulatorStatusChanged();
157
159 void connectOwnSignals();
160
163 void updateRemoteAircraft();
164
165 bool m_log = false;
166 bool m_paused = false;
167 bool m_connected = true;
168 bool m_simulating = true;
169 int m_countInterpolatedSituations = 0;
170 int m_countInterpolatedParts = 0;
171 QTimer m_interpolatorFetchTimer;
175 m_monitorWidget;
176 swift::misc::CConnectionGuard m_connectionGuard;
178 this, &CSimulatorEmulated::onSettingsChanged
179 };
181 m_interpolators;
182 };
183
186 {
188
189 public:
192
193 protected:
195 void startImpl() override;
196
198 void stopImpl() override;
199
201 void checkImpl() override;
202 };
203} // namespace swift::simplugin::emulated
204
205#endif // SWIFT_SIMPLUGIN_EMULATED_SIMULATOREMULATED_H
Interface to a simulator.
Definition simulator.h:59
Interface to a simulator listener.
Definition simulator.h:633
List of QMetaObject::Connection.
Class template for accessing a specific value in the CSettingsCache.
Utility methods for simple line parsing used with the command line.
Value object encapsulating information of aircraft's parts.
Value object encapsulating information of an aircraft's situation.
Value object encapsulating information of a callsign.
Definition callsign.h:30
COM system (aka "radio").
Definition comsystem.h:37
Value object for SELCAL.
Definition selcal.h:31
Comprehensive information of an aircraft.
Value object encapsulating a list of aircraft.
Simple hardcoded info about the corresponding simulator.
Direct in memory access to interpolation setup, normally implemented by simulator.
Common base class for simulator plugins.
bool updateOwnSimulatorSelcal(const swift::misc::aviation::CSelcal &selcal, const swift::misc::CIdentifier &originator)
Update own aircraft cockpit (usually from context).
bool isInterpolatorFetching() const
Is fetching from interpolator.
bool testSendSituationAndParts(const swift::misc::aviation::CCallsign &callsign, const swift::misc::aviation::CAircraftSituation &situation, const swift::misc::aviation::CAircraftParts &parts)
Send situation/parts for testing.
bool changeRemoteAircraftModel(const swift::misc::simulation::CSimulatedAircraft &aircraft)
Change remote aircraft per property.
swift::misc::simulation::CSimulatorInfo getEmulatedSimulator() const
The emulated simulated simulator.
bool disconnectFrom()
Disconnect from simulator.
bool physicallyAddRemoteAircraft(const swift::misc::simulation::CSimulatedAircraft &remoteAircraft)
Add new remote aircraft physically to the simulator.
void internalAircraftChanged()
Internal aircraft changed.
swift::misc::aviation::CCallsignSet physicallyRenderedAircraft() const
Physically rendered (displayed in simulator) This shall only return aircraft handled in the simulator...
CSimulatorEmulated(const swift::misc::simulation::CSimulatorPluginInfo &info, swift::misc::simulation::IOwnAircraftProvider *ownAircraftProvider, swift::misc::simulation::IRemoteAircraftProvider *remoteAircraftProvider, swift::misc::network::IClientProvider *clientProvider, QObject *parent=nullptr)
Constructor, parameters as in.
bool updateOwnSimulatorCockpit(const swift::misc::simulation::CSimulatedAircraft &aircraft, const swift::misc::CIdentifier &originator)
Update own aircraft cockpit (usually from context).
swift::misc::CStatusMessageList getInterpolationMessages(const swift::misc::aviation::CCallsign &callsign) const
Interpolation messages for callsign.
bool logicallyRemoveRemoteAircraft(const swift::misc::aviation::CCallsign &callsign)
Logically remove remote aircraft from simulator. Depending on max. aircraft, enabled status etc....
const swift::misc::simulation::CSimulatedAircraft & getInternalOwnAircraft() const
Internal own aircraft.
bool requestElevation(const swift::misc::geo::ICoordinateGeodetic &reference, const swift::misc::aviation::CCallsign &callsign)
Request elevation, there is no guarantee the requested elevation will be available in the provider.
bool changeInternalSituation(const swift::misc::aviation::CAircraftSituation &situation)
Simulator internal change of situation.
friend class CSimulatorEmulatedMonitorDialog
the monitor widget represents the simulator and needs access to internals (i.e.
void displayTextMessage(const swift::misc::network::CTextMessage &message) const
Display a text message.
bool changeInternalCom(const swift::misc::simulation::CSimulatedAircraft &aircraft)
Simulator internal change of COM values.
bool setInterpolatorFetchTime(int timeMs)
Interpolator fetch time, <=0 stops.
bool parseDetails(const swift::misc::CSimpleCommandParser &parser)
Parsed in derived classes.
bool changeInternalParts(const swift::misc::aviation::CAircraftParts &parts)
Simulator internal change of parts.
int physicallyRemoveMultipleRemoteAircraft(const swift::misc::aviation::CCallsignSet &callsigns)
Remove remote aircraft from simulator.
bool changeInternalSelcal(const swift::misc::aviation::CSelcal &selcal)
Simulator internal change of SELCAL.
bool changeRemoteAircraftEnabled(const swift::misc::simulation::CSimulatedAircraft &aircraft)
Aircraft got enabled / disabled.
bool logicallyAddRemoteAircraft(const swift::misc::simulation::CSimulatedAircraft &remoteAircraft)
Logically add a new aircraft. Depending on max. aircraft, enabled status etc. it will physically adde...
bool physicallyRemoveRemoteAircraft(const swift::misc::aviation::CCallsign &callsign)
Remove remote aircraft from simulator.
bool isConnected() const
Are we connected to the simulator?
bool isPhysicallyRenderedAircraft(const swift::misc::aviation::CCallsign &callsign) const
Is the aircraft rendered (displayed in simulator)? This shall only return true if the aircraft is rea...
void displayStatusMessage(const swift::misc::CStatusMessage &message) const
Display a status message in the simulator.
void setCombinedStatus(bool connected, bool simulating, bool paused)
UI setter.
int physicallyRemoveAllRemoteAircraft()
Remove all remote aircraft and their data via ISimulator::clearAllRemoteAircraftData.
void startImpl()
Plugin specific implementation to start listener.
CSimulatorEmulatedListener(const swift::misc::simulation::CSimulatorPluginInfo &info)
Constructor.
void checkImpl()
Plugin specific implementation to stop listener.
void stopImpl()
Plugin specific implementation to stop listener.
bool parseCommandLine(const QString &commandLine, const swift::misc::CIdentifier &originator)
Free functions in swift::misc.
QObject(QObject *parent)
Q_INTERFACES(...)
Q_OBJECTQ_OBJECT
QObject * parent() const const