4 #ifndef SWIFT_SIM_XSWIFTBUS_SERVICE_H
5 #define SWIFT_SIM_XSWIFTBUS_SERVICE_H
14 #include "dbusobject.h"
17 #include "terrainprobe.h"
18 #include <XPLM/XPLMNavigation.h>
25 #define XSWIFTBUS_SERVICE_INTERFACENAME "org.swift_project.xswiftbus.service"
26 #define XSWIFTBUS_SERVICE_OBJECTPATH "/xswiftbus/service"
46 static const std::string s(XSWIFTBUS_SERVICE_INTERFACENAME);
53 static const std::string s(XSWIFTBUS_SERVICE_OBJECTPATH);
70 void addTextMessage(
const std::string &text,
double red,
double green,
double blue);
135 return m_pressureAlt.isValid() ? m_pressureAlt.
get() : std::numeric_limits<double>::quiet_NaN();
291 std::vector<double> list;
293 list.reserve(
static_cast<std::vector<double>::size_type
>(number));
294 for (
int engineNumber = 0; engineNumber < number; ++engineNumber)
296 list.push_back(m_enginesN1Percentage.
getAt(engineNumber));
330 void emitAircraftModelChanged(
const std::string &path,
const std::string &filename,
const std::string &livery,
331 const std::string &icao,
const std::string &modelString,
const std::string &name,
332 const std::string &description);
334 void emitSceneryLoaded();
337 bool m_popupMessageWindow =
true;
338 bool m_disappearMessageWindow =
true;
339 int m_disapperMessageWindowTimeMs = 5000;
340 std::chrono::system_clock::time_point m_disappearMessageWindowTime;
341 CTerrainProbe m_terrainProbe;
344 void updateMessageBoxFromSettings();
346 struct FramePeriodSampler;
347 std::unique_ptr<FramePeriodSampler> m_framePeriodSampler;
349 DataRef<xplane::data::sim::graphics::scenery::async_scenery_load_in_progress> m_sceneryIsLoading;
350 int m_sceneryWasLoading = 0;
352 StringDataRef<xplane::data::sim::aircraft::view::acf_livery_path> m_liveryPath;
353 StringDataRef<xplane::data::sim::aircraft::view::acf_ICAO> m_icao;
354 StringDataRef<xplane::data::sim::aircraft::view::acf_descrip> m_descrip;
355 DataRef<xplane::data::sim::time::paused> m_paused;
356 DataRef<xplane::data::sim::time::use_system_time> m_useSystemTime;
357 DataRef<xplane::data::sim::flightmodel::position::latitude> m_latitude;
358 DataRef<xplane::data::sim::flightmodel::position::longitude> m_longitude;
359 DataRef<xplane::data::sim::flightmodel::position::elevation> m_elevation;
360 DataRef<xplane::data::sim::flightmodel2::position::pressure_altitude> m_pressureAlt;
361 DataRef<xplane::data::sim::flightmodel::position::y_agl> m_agl;
362 DataRef<xplane::data::sim::flightmodel::position::groundspeed> m_groundSpeed;
363 DataRef<xplane::data::sim::flightmodel::position::indicated_airspeed2> m_indicatedAirspeed;
364 DataRef<xplane::data::sim::flightmodel::position::true_airspeed> m_trueAirspeed;
365 DataRef<xplane::data::sim::flightmodel::position::theta> m_pitch;
366 DataRef<xplane::data::sim::flightmodel::position::phi> m_roll;
367 DataRef<xplane::data::sim::flightmodel::position::psi> m_heading;
368 DataRef<xplane::data::sim::flightmodel::position::local_vx> m_velocityX;
369 DataRef<xplane::data::sim::flightmodel::position::local_vy> m_velocityY;
370 DataRef<xplane::data::sim::flightmodel::position::local_vz> m_velocityZ;
371 DataRef<xplane::data::sim::flightmodel::position::Prad> m_rollVelocity;
372 DataRef<xplane::data::sim::flightmodel::position::Qrad> m_pitchVelocity;
373 DataRef<xplane::data::sim::flightmodel::position::Rrad> m_headingVelocity;
374 DataRef<xplane::data::sim::flightmodel::failures::onground_any> m_onGroundAny;
375 DataRef<xplane::data::sim::flightmodel::failures::onground_all> m_onGroundAll;
376 DataRef<xplane::data::sim::cockpit2::radios::actuators::com1_frequency_hz_833> m_com1Active;
377 DataRef<xplane::data::sim::cockpit2::radios::actuators::com1_standby_frequency_hz_833> m_com1Standby;
378 DataRef<xplane::data::sim::cockpit2::radios::actuators::audio_com_selection>
380 DataRef<xplane::data::sim::cockpit2::radios::actuators::com1_power> m_com1Power;
381 DataRef<xplane::data::sim::cockpit2::radios::actuators::audio_volume_com1> m_com1Volume;
382 DataRef<xplane::data::sim::cockpit2::radios::actuators::audio_selection_com1> m_com1Listening;
383 DataRef<xplane::data::sim::cockpit2::radios::actuators::com2_frequency_hz_833> m_com2Active;
384 DataRef<xplane::data::sim::cockpit2::radios::actuators::com2_standby_frequency_hz_833> m_com2Standby;
385 DataRef<xplane::data::sim::cockpit2::radios::actuators::com2_power> m_com2Power;
386 DataRef<xplane::data::sim::cockpit2::radios::actuators::audio_volume_com2> m_com2Volume;
387 DataRef<xplane::data::sim::cockpit2::radios::actuators::audio_selection_com2> m_com2Listening;
388 DataRef<xplane::data::sim::cockpit::radios::transponder_code> m_xpdrCode;
389 DataRef<xplane::data::sim::cockpit::radios::transponder_mode> m_xpdrMode;
390 DataRef<xplane::data::sim::cockpit::radios::transponder_id> m_xpdrIdent;
391 DataRef<xplane::data::sim::cockpit::electrical::beacon_lights_on> m_beaconLightsOn;
392 DataRef<xplane::data::sim::cockpit::electrical::landing_lights_on> m_landingLightsOn;
393 DataRef<xplane::data::sim::cockpit::electrical::nav_lights_on> m_navLightsOn;
394 DataRef<xplane::data::sim::cockpit::electrical::strobe_lights_on> m_strobeLightsOn;
395 DataRef<xplane::data::sim::cockpit::electrical::taxi_light_on> m_taxiLightsOn;
396 DataRef<xplane::data::sim::flightmodel2::controls::flap_handle_deploy_ratio> m_flapsReployRatio;
397 ArrayDataRef<xplane::data::sim::flightmodel2::gear::deploy_ratio> m_gearReployRatio;
398 DataRef<xplane::data::sim::aircraft::engine::acf_num_engines> m_numberOfEngines;
399 ArrayDataRef<xplane::data::sim::flightmodel::engine::ENGN_N1_> m_enginesN1Percentage;
400 DataRef<xplane::data::sim::flightmodel2::controls::speedbrake_ratio> m_speedBrakeRatio;
401 DataRef<xplane::data::sim::weather::barometer_sealevel_inhg> m_qnhInhg;
DataRefType getAt(int index) const
Get the value of a single element.
Class which builds upon CMessageBox with a scrollback buffer and commands for user control.
void toggle()
Toggles the visibility of the message box.
xswiftbus service object which is accessible through DBus
int getXPlaneVersionMinor() const
Get minor version number.
bool isCom1Transmitting() const
Is COM1 transmitting?
std::string getAircraftName() const
Get name of current aircraft model.
double getRollDeg() const
Get aircraft roll in degrees.
bool getCom2Power() const
Get the COM2 power on/off.
float getCom1Volume() const
Get the COM1 volume 0..1.
double getFlapsDeployRatio() const
Get flaps deploy ratio, where 0.0 is flaps fully retracted, and 1.0 is flaps fully extended.
float getCom2Volume() const
Get the COM2 volume 0..1.
int getCom1ActiveKhz() const
Get the current COM1 active frequency in kHz.
void toggleMessageBoxVisibility()
Toggles the visibility of the message box.
void setDisappearMessageWindow(bool enabled)
Enable/disable message window disappearing again after x ms.
virtual ~CService()
Destructor.
double getLongitudeDeg() const
Get aircraft longitude in degrees.
double getAltitudeMslM() const
Get aircraft altitude in meters.
double getGroundSpeedMps() const
Get aircraft groundspeed in meters per second.
std::string getAircraftIcaoCode() const
Get the ICAO code of the current aircraft model.
std::string getAircraftModelString() const
Get canonical swift model string of current aircraft model.
int getComSelection() const
COM Selection 6/7.
bool isPaused() const
True if sim is paused.
int getCom2StandbyKhz() const
Get the current COM2 standby frequency in kHz.
double getTrueAirspeedKias() const
Get aircraft TAS in meters per second.
double getRollRadPerSec() const
Get aircraft angular velocity in radians per second.
int getXPlaneVersionMajor() const
Get major version number.
bool isCom2Receiving() const
Is COM2 receiving?
std::tuple< double, double, double, double > getFrameStats()
Frames-per-second, averaged over the last 500 frames, or since this function was last called,...
void resetFrameTotals()
Reset the monitoring of total miles and minutes lost due to low frame rate.
double getLocalZVelocityMps() const
Get aircraft local velocity in world coordinates meters per second.
CService(CSettingsProvider *settingsProvider)
Constructor.
DBusHandlerResult dbusMessageHandler(const CDBusMessage &message)
DBus message handler.
bool getTaxiLightsOn() const
Get whether taxi lights are on.
double getPitchRadPerSec() const
Get aircraft angular velocity in radians per second.
double getSpeedBrakeRatio() const
Get the ratio how much the speedbrakes surfaces are extended (0.0 is fully retracted,...
double getHeadingRadPerSec() const
Get aircraft angular velocity in radians per second.
double getPitchDeg() const
Get aircraft pitch in degrees above horizon.
std::string getXPlaneInstallationPath() const
Get root of X-Plane install path.
std::string getCommitHash() const
Returns the SHA1 of the last commit that could influence xswiftbus.
void onAircraftModelChanged()
Called by XPluginReceiveMessage when the model changes.
int getTransponderCode() const
Get the current transponder code in decimal.
std::string getXPlanePreferencesPath() const
Get full path to X-Plane preferences file.
double getGearDeployRatio() const
Get gear deploy ratio, where 0 is up and 1 is down.
double getLocalYVelocityMps() const
Get aircraft local velocity in world coordinates meters per second.
bool getTransponderIdent() const
Get whether we are currently squawking ident.
bool isCom2Selected() const
COM Selection 6/7.
bool getCom2Listening() const
Get the COM2 listening yes/no.
int getCom1StandbyKhz() const
Get the current COM1 standby frequency in kHz.
bool getCom1Listening() const
Get the COM1 listening yes/no.
bool getAnyWheelOnGround() const
Get whether any wheel is on the ground.
void setTransponderMode(int mode)
Set the current transponder mode (depends on the aircraft, 0 and 1 usually mean standby,...
void setCom1StandbyKhz(int freq)
Set the current COM1 standby frequency in kHz.
bool getCom1Power() const
Get the COM1 power on/off.
std::string getVersionNumber() const
Returns the xswiftbus version number.
bool getLandingLightsOn() const
Get whether landing lights are on.
bool isCom1Receiving() const
Is COM1 receiving?
void onSceneryLoaded()
Called by XPluginReceiveMessage when some scenery is loaded.
double getHeightAglM() const
Get aircraft height in meters.
std::string getAircraftDescription() const
Get the description of the current aircraft model.
void setTransponderCode(int code)
Set the current transponder code in decimal.
void setDisappearMessageWindowTimeMs(int durationMs)
Enable/disable message window disappearing after x ms.
static const std::string & ObjectPath()
DBus object path.
void setPopupMessageWindow(bool enabled)
Enable/disable message window popping up for new messages.
double getIndicatedAirspeedKias() const
Get aircraft IAS in knots.
void setCom2ActiveKhz(int freq)
Set the current COM2 active frequency in kHz.
double getLocalXVelocityMps() const
Get aircraft local velocity in world coordinates meters per second.
bool getBeaconLightsOn() const
Get whether beacon lights are on.
int process()
Perform generic processing.
double getPressureAltitudeFt() const
Get aircraft pressure altitude in feet in standard atmosphere in X-Plane 12. NaN in earlier versions ...
bool getStrobeLightsOn() const
Get whether strobe lights are on.
std::string getAircraftModelPath() const
Get full path to current aircraft model.
bool isCom1Selected() const
COM Selection 6/7.
void addTextMessage(const std::string &text, double red, double green, double blue)
Add a text message to the on-screen display, with RGB components in the range [0,1].
static const std::string & InterfaceName()
DBus interface name.
double getLatitudeDeg() const
Get aircraft latitude in degrees.
int getCom2ActiveKhz() const
Get the current COM2 active frequency in kHz.
bool isCom2Transmitting() const
Is COM2 transmitting?
double getTrueHeadingDeg() const
Get aircraft true heading in degrees.
std::string getAircraftLivery() const
Get current aircraft livery.
double getQNHInHg() const
Get barometric pressure at sea level in inches of mercury.
void setCom1ActiveKhz(int freq)
Set the current COM1 active frequency in kHz.
void setCom2StandbyKhz(int freq)
Set the current COM2 standby frequency in kHz.
int getTransponderMode() const
Get the current transponder mode (depends on the aircraft, 0 and 1 usually mean standby,...
int getNumberOfEngines() const
Get the number of engines of current aircraft.
std::string getSettingsJson() const
Get settings in JSON format.
bool isUsingRealTime() const
True if sim time is tracking operating system time.
double getGroundElevation() const
Get elevation of ground under the plane in meters.
std::vector< double > getEngineN1Percentage() const
Get the N1 speed as percent of max (per engine)
std::string getAircraftModelFilename() const
Get base filename of current aircraft model.
void setSettingsJson(const std::string &jsonString)
Set settings.
bool getAllWheelsOnGround() const
Get whether all wheels are on the ground.
bool getNavLightsOn() const
Get whether nav lights are on.
Something owning the settings.
std::array< double, 3 > getElevation(double degreesLatitude, double degreesLongitude, double metersAltitude) const
Get the elevation in meters at the given point in OpenGL space.
void set(DataRefType d)
Set the value of the dataref (if it is writable)
DataRefType get() const
Get the value of the dataref.
std::string get() const
Get the value of the whole string.
Plugin loaded by X-Plane which publishes a DBus service.