6 #ifndef SWIFT_SIMPLUGIN_SIMULATOR_XPLANE_H
7 #define SWIFT_SIMPLUGIN_SIMULATOR_XPLANE_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::xplane
63 class CXSwiftBusServiceProxy;
64 class CXSwiftBusTrafficProxy;
141 virtual void unload()
override;
151 bool isWater)
override;
177 void onDBusServiceUnregistered();
187 using QDoubleList = QList<double>;
188 using QBoolList = QList<bool>;
190 void emitOwnAircraftModelChanged(
const QString &path,
const QString &filename,
const QString &livery,
191 const QString &icao,
const QString &modelString,
const QString &name,
192 const QString &description);
193 void fastTimerTimeout();
194 void slowTimerTimeout();
196 void loadCslPackages();
197 QString findCslPackage(
const QString &modelFileName);
201 void updateRemoteAircraft();
204 void updateAirportsInRange();
208 void requestRemoteAircraftDataFromXPlane();
215 void addNextPendingAircraft();
216 void triggerAddNextPendingAircraft();
220 int detectTimeoutAdding();
226 QPair<qint64, qint64> minMaxTimestampsAddInProgress()
const;
229 bool canAddAircraft()
const;
233 void onRemoteAircraftAdded(
const QString &callsign);
234 void onRemoteAircraftAddingFailed(
const QString &callsign);
235 void updateRemoteAircraftFromSimulator(
const QStringList &callsigns,
const QDoubleList &latitudesDeg,
236 const QDoubleList &longitudesDeg,
const QDoubleList &elevationsMeters,
237 const QBoolList &waterFlags,
const QDoubleList &verticalOffsetsMeters);
241 void disconnectFromDBus();
245 bool sendXSwiftBusSettings();
250 void onXSwiftBusSettingsChanged();
258 bool ignoreOutsideRange);
269 this, &CSimulatorXPlane::onXSwiftBusSettingsChanged
271 static constexpr qint64 TimeoutAdding = 10000;
272 QDBusConnection m_dBusConnection {
"default" };
273 QDBusServiceWatcher *m_watcher {
nullptr };
274 CXSwiftBusServiceProxy *m_serviceProxy {
nullptr };
275 CXSwiftBusTrafficProxy *m_trafficProxy {
nullptr };
278 QTimer m_airportUpdater;
279 QTimer m_pendingAddedTimer;
280 unsigned int m_fastTimerCalls = 0;
281 unsigned int m_slowTimerCalls = 0;
283 CXPlaneMPAircraftObjects m_xplaneAircraftObjects;
291 XPlaneData m_xplaneData;
296 qint64 m_statsAddMaxTimeMs = -1;
297 qint64 m_statsAddCurrentTimeMs = -1;
300 void resetXPlaneData() { m_xplaneData = {}; }
323 void checkConnection();
324 void checkConnectionViaSessionBus();
325 void checkConnectionViaPeer(
const QString &address);
326 void checkConnectionCommon();
328 void serviceRegistered(
const QString &serviceName);
329 void onXSwiftBusServerSettingChanged();
331 QTimer m_timer {
this };
332 QDBusConnection m_DBusConnection {
"default" };
333 QString m_dBusServerAddress;
335 this, &CSimulatorXPlaneListener::onXSwiftBusServerSettingChanged
343 Q_PLUGIN_METADATA(IID
"org.swift-project.swift_core.simulatorinterface" FILE
"simulatorxplane.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.
Plane of same elevation, can be a single point or larger area (e.g. airport)
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.
Physical unit length (length)
Aircraft model (used by another pilot, my models on disk)
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 CSimulatorXPlane 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.
X-Plane ISimulator implementation.
virtual int physicallyRemoveAllRemoteAircraft()
Remove all remote aircraft and their data via ISimulator::clearAllRemoteAircraftData.
virtual ~CSimulatorXPlane()
Dtor.
virtual bool connectTo()
Connect to simulator.
virtual bool followAircraft(const swift::misc::aviation::CCallsign &callsign)
Follow aircraft.
virtual bool isConnected() const
Are we connected to the simulator?
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.
CSimulatorXPlane(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 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.
virtual void resetAircraftStatistics()
Reset the statistics.
virtual bool updateOwnSimulatorSelcal(const swift::misc::aviation::CSelcal &selcal, const swift::misc::CIdentifier &originator)
Update own aircraft cockpit (usually from context)
virtual void clearAllRemoteAircraftData()
Clear all aircraft related data, but do not physically remove the aircraft.
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 isPaused() const
Simulator paused?
virtual void unload()
Driver will be unloaded.
virtual bool updateOwnSimulatorCockpit(const swift::misc::simulation::CSimulatedAircraft &aircraft, const swift::misc::CIdentifier &originator)
Update own aircraft cockpit (usually from context)
virtual swift::misc::aviation::CCallsignSet physicallyRenderedAircraft() const
Physically rendered (displayed in simulator) This shall only return aircraft handled in the simulator...
virtual swift::misc::CStatusMessageList getInterpolationMessages(const swift::misc::aviation::CCallsign &callsign) const
Interpolation messages for callsign.
virtual void setFlightNetworkConnected(bool connected)
Flight network has been connected.
virtual bool physicallyAddRemoteAircraft(const swift::misc::simulation::CSimulatedAircraft &newRemoteAircraft)
Add new remote aircraft physically to the simulator.
virtual bool physicallyRemoveRemoteAircraft(const swift::misc::aviation::CCallsign &callsign)
Remove remote aircraft from simulator.
virtual QString getStatisticsSimulatorSpecific() const
Allows to print out simulator specific statistics.
virtual void callbackReceivedRequestedElevation(const swift::misc::geo::CElevationPlane &plane, const swift::misc::aviation::CCallsign &callsign, bool isWater)
A requested elevation has been received.
virtual void displayStatusMessage(const swift::misc::CStatusMessage &message) const
Display a status message in the simulator.
virtual bool disconnectFrom()
Disconnect from simulator.
virtual void displayTextMessage(const swift::misc::network::CTextMessage &message) const
Display a text message.
Listener waits for xswiftbus service to show up.
CSimulatorXPlaneListener(const swift::misc::simulation::CSimulatorPluginInfo &info)
Constructor.
virtual void checkImpl()
Plugin specific implementation to check.
virtual void startImpl()
Plugin specific implementation to start listener.
virtual void stopImpl()
Plugin specific implementation to stop listener.
Free functions in swift::misc.
double rollDeg
Roll [deg].
int com2StandbyKhz
COM2 standby [kHz].
double headingRadPerSec
Heading angular velocity [rad/s].
double groundspeedMs
Ground speed [m/s].
bool isCom1Receiving
COM1 receiving.
double com2Volume
COM2 volume 0..1.
double groundElevation
Elevation of ground [m].
double com1Volume
COM1 volume 0..1.
double longitudeDeg
Latitude [deg].
double localXVelocityMs
Local x velocity [m/s].
int xpdrMode
Transponder mode (off=0,stdby=1,on=2,test=3)
int com1ActiveKhz
COM1 active [kHz].
bool beaconLightsOn
Beacon lights on?
bool isCom1Transmitting
COM1 transmittings.
QString aircraftModelPath
Aircraft model path.
double flapsDeployRatio
Flaps deployment ratio [%].
double localZVelocityMs
Local z velocity [m/s].
bool taxiLightsOn
Taxi lights on?
bool isCom2Transmitting
COM2 transmittings.
bool strobeLightsOn
Strobe lights on?
double rollRadPerSec
Roll angular velocity [rad/s].
int xpdrCode
Transpondder code.
double gearDeployRatio
Gear deployment ratio [%].
double trueHeadingDeg
True heading [deg].
bool xpdrIdent
Is transponder in ident?
int com2ActiveKhz
COM2 active [kHz].
double altitudeM
Altitude [m].
QString aircraftIcaoCode
Aircraft ICAO code.
bool onGroundAll
All wheels on ground?
double latitudeDeg
Longitude [deg].
bool isCom2Receiving
COM2 receiving.
double heightAglM
Height AGL [m].
bool navLightsOn
NAV lights on?
double pitchRadPerSec
Pitch angular velocity [rad/s].
QList< double > enginesN1Percentage
N1 per engine [%].
double pitchDeg
Pitch [deg].
double speedBrakeRatio
Speed break ratio [%].
double seaLevelPressureInHg
Sea level pressure [inhg].
int com1StandbyKhz
COM1 standby [kHz].
double pressureAltitudeFt
Pressure altitude [ft, XP12].
bool landingLightsOn
Landing lights on?
double localYVelocityMs
Local y velocity [m/s].