6 #ifndef SWIFT_SIMPLUGIN_SIMULATOR_XPLANE_H
7 #define SWIFT_SIMPLUGIN_SIMULATOR_XPLANE_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::xplane
63 class CXSwiftBusServiceProxy;
64 class CXSwiftBusTrafficProxy;
141 virtual void unload()
override;
151 bool isWater)
override;
177 void onDBusServiceUnregistered();
190 void emitOwnAircraftModelChanged(
const QString &path,
const QString &filename,
const QString &livery,
193 void fastTimerTimeout();
194 void slowTimerTimeout();
196 void loadCslPackages();
201 void updateRemoteAircraft();
205 void requestRemoteAircraftDataFromXPlane();
212 void addNextPendingAircraft();
213 void triggerAddNextPendingAircraft();
217 int detectTimeoutAdding();
223 QPair<qint64, qint64> minMaxTimestampsAddInProgress()
const;
226 bool canAddAircraft()
const;
230 void onRemoteAircraftAdded(
const QString &callsign);
231 void onRemoteAircraftAddingFailed(
const QString &callsign);
232 void updateRemoteAircraftFromSimulator(
const QStringList &callsigns,
const QDoubleList &latitudesDeg,
233 const QDoubleList &longitudesDeg,
const QDoubleList &elevationsMeters,
234 const QBoolList &waterFlags,
const QDoubleList &verticalOffsetsMeters);
238 void disconnectFromDBus();
242 bool sendXSwiftBusSettings();
247 void onXSwiftBusSettingsChanged();
255 bool ignoreOutsideRange);
266 this, &CSimulatorXPlane::onXSwiftBusSettingsChanged
268 static constexpr qint64 TimeoutAdding = 10000;
271 CXSwiftBusServiceProxy *m_serviceProxy {
nullptr };
272 CXSwiftBusTrafficProxy *m_trafficProxy {
nullptr };
275 QTimer m_pendingAddedTimer;
276 unsigned int m_fastTimerCalls = 0;
277 unsigned int m_slowTimerCalls = 0;
279 CXPlaneMPAircraftObjects m_xplaneAircraftObjects;
287 XPlaneData m_xplaneData;
292 qint64 m_statsAddMaxTimeMs = -1;
293 qint64 m_statsAddCurrentTimeMs = -1;
296 void resetXPlaneData() { m_xplaneData = {}; }
319 void checkConnection();
320 void checkConnectionViaSessionBus();
321 void checkConnectionViaPeer(
const QString &address);
322 void checkConnectionCommon();
324 void serviceRegistered(
const QString &serviceName);
325 void onXSwiftBusServerSettingChanged();
331 this, &CSimulatorXPlaneListener::onXSwiftBusServerSettingChanged
339 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.
QObject * parent() const const
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].