6 #ifndef SWIFT_SIMPLUGIN_SIMULATOR_FLIGHTGEAR_H
7 #define SWIFT_SIMPLUGIN_SIMULATOR_FLIGHTGEAR_H
9 #include <QDBusConnection>
15 #include <QStringList>
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;
65 class CFGSwiftBusServiceProxy;
66 class CFGSwiftBusTrafficProxy;
161 void onDBusServiceUnregistered();
172 void emitOwnAircraftModelChanged(
const QString &path,
const QString &filename,
const QString &livery,
175 void fastTimerTimeout();
176 void slowTimerTimeout();
180 void updateRemoteAircraft();
184 void requestRemoteAircraftDataFromFlightgear();
191 void addNextPendingAircraft();
192 void triggerAddNextPendingAircraft();
196 int detectTimeoutAdding();
202 QPair<qint64, qint64> minMaxTimestampsAddInProgress()
const;
205 bool canAddAircraft()
const;
209 void onRemoteAircraftAdded(
const QString &callsign);
210 void onRemoteAircraftAddingFailed(
const QString &callsign);
211 void updateRemoteAircraftFromSimulator(
const QStringList &callsigns,
const QDoubleList &latitudesDeg,
212 const QDoubleList &longitudesDeg,
const QDoubleList &elevationsMeters,
213 const QDoubleList &verticalOffsetsMeters);
217 void disconnectFromDBus();
223 static constexpr qint64 TimeoutAdding = 10000;
226 CFGSwiftBusServiceProxy *m_serviceProxy {
nullptr };
227 CFGSwiftBusTrafficProxy *m_trafficProxy {
nullptr };
230 QTimer m_pendingAddedTimer;
237 CFlightgearMPAircraftObjects m_flightgearAircraftObjects;
238 FlightgearData m_flightgearData;
241 qint64 m_statsAddMaxTimeMs = -1;
242 qint64 m_statsAddCurrentTimeMs = -1;
244 bool m_simulatorPaused =
false;
247 void resetFlightgearData() { m_flightgearData = {}; }
270 void checkConnection();
271 void checkConnectionViaSessionBus();
272 void checkConnectionViaPeer(
const QString &address);
273 void checkConnectionCommon();
275 void serviceRegistered(
const QString &serviceName);
276 void fgSwiftBusServerSettingChanged();
281 this, &CSimulatorFlightgearListener::fgSwiftBusServerSettingChanged
289 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.
swift::core::ISimulatorListener * createListener(const swift::misc::simulation::CSimulatorPluginInfo &info)
Simulator listener instance.
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.
swift::misc::CStatusMessageList getInterpolationMessages(const swift::misc::aviation::CCallsign &callsign) const
Interpolation messages for callsign.
bool updateOwnSimulatorSelcal(const swift::misc::aviation::CSelcal &selcal, const swift::misc::CIdentifier &originator)
Update own aircraft cockpit (usually from context)
void displayTextMessage(const swift::misc::network::CTextMessage &message) const
Display a text message.
bool physicallyAddRemoteAircraft(const swift::misc::simulation::CSimulatedAircraft &newRemoteAircraft)
Add new remote aircraft physically to the simulator.
bool updateOwnSimulatorCockpit(const swift::misc::simulation::CSimulatedAircraft &aircraft, const swift::misc::CIdentifier &originator)
Update own aircraft cockpit (usually from context)
int physicallyRemoveAllRemoteAircraft()
Remove all remote aircraft and their data via ISimulator::clearAllRemoteAircraftData.
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 isPaused() const
Simulator paused?
bool physicallyRemoveRemoteAircraft(const swift::misc::aviation::CCallsign &callsign)
Remove remote aircraft from simulator.
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.
swift::misc::aviation::CCallsignSet physicallyRenderedAircraft() const
Physically rendered (displayed in simulator) This shall only return aircraft handled in the simulator...
void resetAircraftStatistics()
Reset the statistics.
~CSimulatorFlightgear()
Dtor.
void displayStatusMessage(const swift::misc::CStatusMessage &message) const
Display a status message in the simulator.
QString getStatisticsSimulatorSpecific() const
Allows to print out simulator specific statistics.
bool disconnectFrom()
Disconnect from 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...
bool connectTo()
Connect to simulator.
void clearAllRemoteAircraftData()
Clear all aircraft related data, but do not physically remove the aircraft.
void unload()
Driver will be unloaded.
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.
void stopImpl()
Plugin specific implementation to stop listener.
CSimulatorFlightgearListener(const swift::misc::simulation::CSimulatorPluginInfo &info)
Constructor.
void startImpl()
Plugin specific implementation to start listener.
void checkImpl()
Plugin specific implementation to check.
Free functions in swift::misc.
QObject * parent() const const
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].