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;
151 bool isWater)
override;
176 void onDBusServiceUnregistered();
189 void emitOwnAircraftModelChanged(
const QString &path,
const QString &filename,
const QString &livery,
192 void fastTimerTimeout();
193 void slowTimerTimeout();
195 void loadCslPackages();
200 void updateRemoteAircraft();
204 void requestRemoteAircraftDataFromXPlane();
211 void addNextPendingAircraft();
212 void triggerAddNextPendingAircraft();
216 int detectTimeoutAdding();
222 QPair<qint64, qint64> minMaxTimestampsAddInProgress()
const;
225 bool canAddAircraft()
const;
229 void onRemoteAircraftAdded(
const QString &callsign);
230 void onRemoteAircraftAddingFailed(
const QString &callsign);
231 void updateRemoteAircraftFromSimulator(
const QStringList &callsigns,
const QDoubleList &latitudesDeg,
232 const QDoubleList &longitudesDeg,
const QDoubleList &elevationsMeters,
233 const QBoolList &waterFlags,
const QDoubleList &verticalOffsetsMeters);
237 void disconnectFromDBus();
241 bool sendXSwiftBusSettings();
246 void onXSwiftBusSettingsChanged();
254 bool ignoreOutsideRange);
265 this, &CSimulatorXPlane::onXSwiftBusSettingsChanged
267 static constexpr qint64 TimeoutAdding = 10000;
270 CXSwiftBusServiceProxy *m_serviceProxy {
nullptr };
271 CXSwiftBusTrafficProxy *m_trafficProxy {
nullptr };
274 QTimer m_pendingAddedTimer;
275 unsigned int m_fastTimerCalls = 0;
276 unsigned int m_slowTimerCalls = 0;
278 CXPlaneMPAircraftObjects m_xplaneAircraftObjects;
286 XPlaneData m_xplaneData;
291 qint64 m_statsAddMaxTimeMs = -1;
292 qint64 m_statsAddCurrentTimeMs = -1;
295 void resetXPlaneData() { m_xplaneData = {}; }
318 void checkConnection();
319 void checkConnectionViaSessionBus();
320 void checkConnectionViaPeer(
const QString &address);
321 void checkConnectionCommon();
323 void serviceRegistered(
const QString &serviceName);
324 void onXSwiftBusServerSettingChanged();
330 this, &CSimulatorXPlaneListener::onXSwiftBusServerSettingChanged
338 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.
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.
X-Plane ISimulator implementation.
int physicallyRemoveAllRemoteAircraft()
Remove all remote aircraft and their data via ISimulator::clearAllRemoteAircraftData.
bool connectTo()
Connect to simulator.
bool followAircraft(const swift::misc::aviation::CCallsign &callsign)
Follow aircraft.
bool isConnected() const
Are we connected to the simulator?
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.
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.
void resetAircraftStatistics()
Reset the statistics.
bool updateOwnSimulatorSelcal(const swift::misc::aviation::CSelcal &selcal, const swift::misc::CIdentifier &originator)
Update own aircraft cockpit (usually from context)
void clearAllRemoteAircraftData()
Clear all aircraft related data, but do not physically remove the aircraft.
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 unload()
Driver will be unloaded.
bool updateOwnSimulatorCockpit(const swift::misc::simulation::CSimulatedAircraft &aircraft, const swift::misc::CIdentifier &originator)
Update own aircraft cockpit (usually from context)
swift::misc::aviation::CCallsignSet physicallyRenderedAircraft() const
Physically rendered (displayed in simulator) This shall only return aircraft handled in the simulator...
swift::misc::CStatusMessageList getInterpolationMessages(const swift::misc::aviation::CCallsign &callsign) const
Interpolation messages for callsign.
void setFlightNetworkConnected(bool connected)
Flight network has been connected.
bool physicallyAddRemoteAircraft(const swift::misc::simulation::CSimulatedAircraft &newRemoteAircraft)
Add new remote aircraft physically to the simulator.
bool physicallyRemoveRemoteAircraft(const swift::misc::aviation::CCallsign &callsign)
Remove remote aircraft from simulator.
QString getStatisticsSimulatorSpecific() const
Allows to print out simulator specific statistics.
void callbackReceivedRequestedElevation(const swift::misc::geo::CElevationPlane &plane, const swift::misc::aviation::CCallsign &callsign, bool isWater)
A requested elevation has been received.
void displayStatusMessage(const swift::misc::CStatusMessage &message) const
Display a status message in the simulator.
bool disconnectFrom()
Disconnect from simulator.
void displayTextMessage(const swift::misc::network::CTextMessage &message) const
Display a text message.
bool isPaused() const
Simulator paused?
Listener waits for xswiftbus service to show up.
CSimulatorXPlaneListener(const swift::misc::simulation::CSimulatorPluginInfo &info)
Constructor.
void checkImpl()
Plugin specific implementation to check.
void startImpl()
Plugin specific implementation to start listener.
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].