6 #ifndef SWIFT_SIMPLUGIN_SIMULATOR_FLIGHTGEAR_H
7 #define SWIFT_SIMPLUGIN_SIMULATOR_FLIGHTGEAR_H
9 #include <QDBusConnection>
15 #include <QStringList>
38 class QDBusServiceWatcher;
45 class CAircraftSituation;
54 class CSimulatedAircraft;
55 class CSimulatorPluginInfo;
56 class IOwnAircraftProvider;
57 class IRemoteAircraftProvider;
61 namespace swift::simplugin::flightgear
63 extern int FGSWIFTBUS_API_VERSION;
64 extern QList<int> incompatibleVersions;
65 class CFGSwiftBusServiceProxy;
66 class CFGSwiftBusTrafficProxy;
136 virtual void unload()
override;
157 virtual bool isPaused()
const override {
return false; }
162 void onDBusServiceUnregistered();
171 using QDoubleList = QList<double>;
173 void emitOwnAircraftModelChanged(
const QString &path,
const QString &filename,
const QString &livery,
174 const QString &icao,
const QString &modelString,
const QString &name,
175 const QString &description);
176 void fastTimerTimeout();
177 void slowTimerTimeout();
181 void updateRemoteAircraft();
185 void requestRemoteAircraftDataFromFlightgear();
192 void addNextPendingAircraft();
193 void triggerAddNextPendingAircraft();
197 int detectTimeoutAdding();
203 QPair<qint64, qint64> minMaxTimestampsAddInProgress()
const;
206 bool canAddAircraft()
const;
210 void onRemoteAircraftAdded(
const QString &callsign);
211 void onRemoteAircraftAddingFailed(
const QString &callsign);
212 void updateRemoteAircraftFromSimulator(
const QStringList &callsigns,
const QDoubleList &latitudesDeg,
213 const QDoubleList &longitudesDeg,
const QDoubleList &elevationsMeters,
214 const QDoubleList &verticalOffsetsMeters);
218 void disconnectFromDBus();
224 static constexpr qint64 TimeoutAdding = 10000;
225 QDBusConnection m_dBusConnection {
"default" };
226 QDBusServiceWatcher *m_watcher {
nullptr };
227 CFGSwiftBusServiceProxy *m_serviceProxy {
nullptr };
228 CFGSwiftBusTrafficProxy *m_trafficProxy {
nullptr };
231 QTimer m_airportUpdater;
232 QTimer m_pendingAddedTimer;
239 CFlightgearMPAircraftObjects m_flightgearAircraftObjects;
240 FlightgearData m_flightgearData;
243 qint64 m_statsAddMaxTimeMs = -1;
244 qint64 m_statsAddCurrentTimeMs = -1;
246 bool m_simulatorPaused =
false;
249 void resetFlightgearData() { m_flightgearData = {}; }
272 void checkConnection();
273 void checkConnectionViaSessionBus();
274 void checkConnectionViaPeer(
const QString &address);
275 void checkConnectionCommon();
277 void serviceRegistered(
const QString &serviceName);
278 void fgSwiftBusServerSettingChanged();
280 QTimer m_timer {
this };
281 QDBusConnection m_conn {
"default" };
283 this, &CSimulatorFlightgearListener::fgSwiftBusServerSettingChanged
291 Q_PLUGIN_METADATA(IID
"org.swift-project.swift_core.simulatorinterface" FILE
"simulatorflightgear.json")
Factory pattern class to create instances of ISimulator.
Interface to a simulator.
Interface to a simulator listener.
Value object encapsulating information identifying a component of a modular distributed swift process...
Streamable status message, e.g.
Status messages, e.g. from Core -> GUI.
Value object encapsulating information of aircraft's parts.
Value object encapsulating information of an aircraft's situation.
Value object encapsulating information of a callsign.
Value object for a set of callsigns.
Geodetic coordinate, a position in 3D space relative to the reference geoid.
Value object encapsulating information of a text message.
Direct in memory access to client (network client) data.
Comprehensive information of an aircraft.
Value object encapsulating a list of aircraft.
Describing a simulator plugin.
Direct threadsafe in memory access to own aircraft.
Direct thread safe in memory access to remote aircraft.
Common base class for simulator plugins.
Factory for creating CSimulatorFlightgear instance.
virtual swift::core::ISimulatorListener * createListener(const swift::misc::simulation::CSimulatorPluginInfo &info)
Simulator listener instance.
virtual swift::core::ISimulator * create(const swift::misc::simulation::CSimulatorPluginInfo &info, swift::misc::simulation::IOwnAircraftProvider *ownAircraftProvider, swift::misc::simulation::IRemoteAircraftProvider *remoteAircraftProvider, swift::misc::network::IClientProvider *clientProvider)
Create a new instance of a driver.
Flightgear ISimulator implementation.
virtual swift::misc::CStatusMessageList getInterpolationMessages(const swift::misc::aviation::CCallsign &callsign) const
Interpolation messages for callsign.
virtual bool updateOwnSimulatorSelcal(const swift::misc::aviation::CSelcal &selcal, const swift::misc::CIdentifier &originator)
Update own aircraft cockpit (usually from context)
virtual void displayTextMessage(const swift::misc::network::CTextMessage &message) const
Display a text message.
virtual bool physicallyAddRemoteAircraft(const swift::misc::simulation::CSimulatedAircraft &newRemoteAircraft)
Add new remote aircraft physically to the simulator.
virtual bool updateOwnSimulatorCockpit(const swift::misc::simulation::CSimulatedAircraft &aircraft, const swift::misc::CIdentifier &originator)
Update own aircraft cockpit (usually from context)
virtual int physicallyRemoveAllRemoteAircraft()
Remove all remote aircraft and their data via ISimulator::clearAllRemoteAircraftData.
virtual 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.
virtual bool physicallyRemoveRemoteAircraft(const swift::misc::aviation::CCallsign &callsign)
Remove remote aircraft from simulator.
virtual bool isConnected() const
Are we connected to the simulator?
CSimulatorFlightgear(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.
virtual swift::misc::aviation::CCallsignSet physicallyRenderedAircraft() const
Physically rendered (displayed in simulator) This shall only return aircraft handled in the simulator...
virtual void resetAircraftStatistics()
Reset the statistics.
virtual ~CSimulatorFlightgear()
Dtor.
virtual void displayStatusMessage(const swift::misc::CStatusMessage &message) const
Display a status message in the simulator.
virtual QString getStatisticsSimulatorSpecific() const
Allows to print out simulator specific statistics.
virtual bool isPaused() const
Simulator paused?
virtual bool disconnectFrom()
Disconnect from simulator.
virtual 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...
virtual bool connectTo()
Connect to simulator.
virtual void clearAllRemoteAircraftData()
Clear all aircraft related data, but do not physically remove the aircraft.
virtual void unload()
Driver will be unloaded.
virtual 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.
Listener waits for fgswiftbus service to show up.
virtual void stopImpl()
Plugin specific implementation to stop listener.
CSimulatorFlightgearListener(const swift::misc::simulation::CSimulatorPluginInfo &info)
Constructor.
virtual void startImpl()
Plugin specific implementation to start listener.
virtual void checkImpl()
Plugin specific implementation to check.
Free functions in swift::misc.
QString aircraftModelPath
Aircraft model path.
int com2StandbyKhz
COM2 standby [kHz].
double pressureAltitudeFt
Pressure altitude [inhg].
double pitchDeg
Pitch [deg].
QList< double > enginesN1Percentage
N1 per engine [%].
double longitudeDeg
Latitude [deg].
double latitudeDeg
Longitude [deg].
bool xpdrIdent
Is transponder in ident?
int com1StandbyKhz
COM1 standby [kHz].
int com1ActiveKhz
COM1 active [kHz].
double volumeCom1
Volume com1 [0..1].
double rollRateRadPerSec
Roll angular velocity [rad/s].
double groundElevation
Ground Elevation [m].
int xpdrCode
Transpondder code.
double velocityZMs
z velocity [m/s]
double pitchRateRadPerSec
Pitch angular velocity [rad/s].
double groundspeedKts
Ground speed [kts].
bool navLightsOn
NAV lights on?
bool taxiLightsOn
Taxi lights on?
double trueHeadingDeg
True heading [deg].
double gearReployRatio
Gear deployment ratio [%].
int xpdrMode
Transponder mode (off=0,stdby=1-2, >2 on)
bool landingLightsOn
Landing lights on?
bool onGroundAll
All wheels on ground?
double velocityYMs
y velocity [m/s]
QString aircraftIcaoCode
Aircraft ICAO code.
double velocityXMs
x velocity [m/s]
double speedBrakeRatio
Speed break ratio [%].
bool strobeLightsOn
Strobe lights on?
double yawRateRadPerSec
Yaw angular velocity [rad/s].
double volumeCom2
Volume com2 [0..1].
double rollDeg
Roll [deg].
int com2ActiveKhz
COM2 active [kHz].
double flapsReployRatio
Flaps deployment ratio [%].
bool beaconLightsOn
Beacon lights on?
double altitudeFt
Altitude [ft].