Initial FlightGear plugin commit

This commit is contained in:
ltoenning
2019-01-19 16:40:10 +01:00
committed by Mat Sutcliffe
parent a4dae5335d
commit 68cf4fa63d
22 changed files with 3625 additions and 1 deletions

View File

@@ -0,0 +1,32 @@
load(common_pre)
QT += core dbus widgets network
TARGET = simulatorflightgear
TEMPLATE = lib
CONFIG += plugin shared
CONFIG += blackmisc blackcore blackgui blackconfig simulatorplugincommon
DEPENDPATH += . $$SourceRoot/src
INCLUDEPATH += . $$SourceRoot/src
unix:!macx {
INCLUDEPATH *= /usr/include/dbus-1.0
INCLUDEPATH *= /usr/lib/x86_64-linux-gnu/dbus-1.0/include
}
SOURCES += *.cpp
HEADERS += *.h
DISTFILES += simulatorxplane.json
DESTDIR = $$DestRoot/bin/plugins/simulator
win32 {
dlltarget.path = $$PREFIX/bin/plugins/simulator
INSTALLS += dlltarget
} else {
target.path = $$PREFIX/bin/plugins/simulator
INSTALLS += target
}
load(common_post)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,314 @@
/* Copyright (C) 2013
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
//! \file
#ifndef BLACKSIMPLUGIN_SIMULATOR_XPLANE_H
#define BLACKSIMPLUGIN_SIMULATOR_XPLANE_H
#include "xplanempaircraft.h"
#include "plugins/simulator/xplaneconfig/simulatorxplaneconfig.h"
#include "plugins/simulator/plugincommon/simulatorplugincommon.h"
#include "blackmisc/simulation/aircraftmodellist.h"
#include "blackmisc/simulation/data/modelcaches.h"
#include "blackmisc/simulation/settings/simulatorsettings.h"
#include "blackmisc/simulation/settings/mysettings.h"
#include "blackmisc/simulation/simulatedaircraftlist.h"
#include "blackmisc/weather/weathergrid.h"
#include "blackmisc/aviation/airportlist.h"
#include "blackmisc/aviation/callsignset.h"
#include "blackmisc/geo/coordinategeodetic.h"
#include "blackmisc/pq/time.h"
#include "blackmisc/pq/units.h"
#include "blackmisc/settingscache.h"
#include "blackmisc/statusmessage.h"
#include "blackmisc/identifier.h"
#include "blackmisc/pixmap.h"
#include "blackmisc/sequence.h"
#include <QDBusConnection>
#include <QList>
#include <QObject>
#include <QString>
#include <QStringList>
#include <QHash>
#include <QPair>
#include <QTimer>
class QDBusServiceWatcher;
namespace BlackMisc
{
namespace Aviation
{
class CAircraftParts;
class CAircraftSituation;
class CCallsign;
}
namespace Network { class CTextMessage; }
namespace Simulation
{
class CSimulatedAircraft;
class CSimulatorPluginInfo;
class IOwnAircraftProvider;
class IRemoteAircraftProvider;
}
namespace Weather { class IWeatherGridProvider; }
}
namespace BlackSimPlugin
{
namespace XPlane
{
class CXSwiftBusServiceProxy;
class CXSwiftBusTrafficProxy;
class CXSwiftBusWeatherProxy;
//! X-Plane data
struct XPlaneData
{
QString aircraftModelPath; //!< Aircraft model path
QString aircraftIcaoCode; //!< Aircraft ICAO code
double latitudeDeg; //!< Longitude [deg]
double longitudeDeg; //!< Latitude [deg]
double altitudeM; //!< Altitude [m]
double groundspeedMs; //!< Ground speed [m/s]
double pitchDeg; //!< Pitch [deg]
double rollDeg; //!< Roll [deg]
double trueHeadingDeg; //!< True heading [deg]
bool onGroundAll; //!< All wheels on ground?
int com1ActiveKhz; //!< COM1 active [kHz]
int com1StandbyKhz; //!< COM1 standby [kHz]
int com2ActiveKhz; //!< COM2 active [kHz]
int com2StandbyKhz; //!< COM2 standby [kHz]
int xpdrCode; //!< Transpondder code
int xpdrMode; //!< Transponder mode (off=0,stdby=1,on=2,test=3)
bool xpdrIdent; //!< Is transponder in ident?
bool beaconLightsOn; //!< Beacon lights on?
bool landingLightsOn; //!< Landing lights on?
bool navLightsOn; //!< NAV lights on?
bool strobeLightsOn; //!< Strobe lights on?
bool taxiLightsOn; //!< Taxi lights on?
double flapsReployRatio; //!< Flaps deployment ratio [%]
double gearReployRatio; //!< Gear deployment ratio [%]
QList<double> enginesN1Percentage; //!< N1 per engine [%]
double speedBrakeRatio; //!< Speed break ratio [%]
double seaLevelPressureInHg; //!< Sea level pressure [inhg]
};
//! X-Plane ISimulator implementation
class CSimulatorXPlane : public Common::CSimulatorPluginCommon
{
Q_OBJECT
public:
//! Constructor
CSimulatorXPlane(const BlackMisc::Simulation::CSimulatorPluginInfo &info,
BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider,
BlackMisc::Simulation::IRemoteAircraftProvider *remoteAircraftProvider,
BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider,
BlackMisc::Network::IClientProvider *clientProvider,
QObject *parent = nullptr);
//! Dtor
virtual ~CSimulatorXPlane() override;
//! \name ISimulator implementations
//! @{
virtual bool isTimeSynchronized() const override { return false; } // TODO: Can we query the XP intrinisc feature?
virtual bool connectTo() override;
virtual bool disconnectFrom() override;
virtual bool updateOwnSimulatorCockpit(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const BlackMisc::CIdentifier &originator) override;
virtual bool updateOwnSimulatorSelcal(const BlackMisc::Aviation::CSelcal &selcal, const BlackMisc::CIdentifier &originator) override;
virtual void displayStatusMessage(const BlackMisc::CStatusMessage &message) const override;
virtual void displayTextMessage(const BlackMisc::Network::CTextMessage &message) const override;
virtual BlackMisc::Aviation::CAirportList getAirportsInRange(bool recalculateDistance) const override;
virtual bool setTimeSynchronization(bool enable, const BlackMisc::PhysicalQuantities::CTime &offset) override;
virtual BlackMisc::PhysicalQuantities::CTime getTimeSynchronizationOffset() const override { return BlackMisc::PhysicalQuantities::CTime(0, BlackMisc::PhysicalQuantities::CTimeUnit::hrmin()); }
virtual bool isPhysicallyRenderedAircraft(const BlackMisc::Aviation::CCallsign &callsign) const override;
virtual BlackMisc::Aviation::CCallsignSet physicallyRenderedAircraft() const override;
virtual bool followAircraft(const BlackMisc::Aviation::CCallsign &callsign) override;
virtual void unload() override;
virtual QString getStatisticsSimulatorSpecific() const override;
virtual void resetAircraftStatistics() override;
virtual BlackMisc::CStatusMessageList getInterpolationMessages(const BlackMisc::Aviation::CCallsign &callsign) const override;
//! @}
//! \copydoc BlackMisc::Simulation::ISimulationEnvironmentProvider::requestElevation
virtual bool requestElevation(const BlackMisc::Geo::ICoordinateGeodetic &reference, const BlackMisc::Aviation::CCallsign &callsign) override;
//! Creates an appropriate dbus connection from the string describing it
static QDBusConnection connectionFromString(const QString &str);
protected:
//! \name ISimulator implementations
//! @{
virtual bool isConnected() const override;
virtual bool physicallyAddRemoteAircraft(const BlackMisc::Simulation::CSimulatedAircraft &newRemoteAircraft) override;
virtual bool physicallyRemoveRemoteAircraft(const BlackMisc::Aviation::CCallsign &callsign) override;
virtual int physicallyRemoveAllRemoteAircraft() override;
virtual void clearAllRemoteAircraftData() override;
virtual void injectWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid) override;
virtual bool isPaused() const override
{
//! \todo XP: provide correct pause state
return false;
}
//! @}
private slots:
void serviceUnregistered();
private:
enum DBusMode
{
Session,
P2P
};
using QDoubleList = QList<double>;
void setAirportsInRange(const QStringList &icaoCodes, const QStringList &names, const BlackMisc::CSequence<double> &lats, const BlackMisc::CSequence<double> &lons, const BlackMisc::CSequence<double> &alts);
void emitOwnAircraftModelChanged(const QString &path, const QString &filename, const QString &livery, const QString &icao,
const QString &modelString, const QString &name, const QString &description);
void fastTimerTimeout();
void slowTimerTimeout();
void loadCslPackages();
QString findCslPackage(const QString &modelFileName);
//! Update remote aircraft
//! \remark this is where the interpolated data are set
void updateRemoteAircraft();
//! Update airports
void updateAirportsInRange();
//! Request elevation and CG from XPlane @{
void requestRemoteAircraftDataFromXPlane();
void requestRemoteAircraftDataFromXPlane(const BlackMisc::Aviation::CCallsignSet &callsigns);
void triggerRequestRemoteAircraftDataFromXPlane(const BlackMisc::Aviation::CCallsignSet &callsigns);
//! @}
//! Adding new aircraft @{
void addNextPendingAircraft();
void triggerAddNextPendingAircraft();
//! @}
//! Detect timeouts on adding
int detectTimeoutAdding();
//! Trigger a removal of an aircraft
void triggerRemoveAircraft(const BlackMisc::Aviation::CCallsign &callsign, qint64 deferMs);
//! Timestamps of aircraft currently adding
QPair<qint64, qint64> minMaxTimestampsAddInProgress() const;
//! Can the next aircraft be added?
bool canAddAircraft() const;
//! Callbacks from simulator @{
void onRemoteAircraftAdded(const QString &callsign);
void onRemoteAircraftAddingFailed(const QString &callsign);
void updateRemoteAircraftFromSimulator(const QStringList &callsigns, const QDoubleList &latitudesDeg, const QDoubleList &longitudesDeg,
const QDoubleList &elevationsMeters, const QDoubleList &verticalOffsetsMeters);
//! @}
//! Dsiconnect from DBus
void disconnectFromDBus();
DBusMode m_dbusMode;
BlackMisc::CSettingReadOnly<BlackMisc::Simulation::Settings::TXSwiftBusServer> m_xswiftbusServerSetting { this };
static constexpr qint64 TimeoutAdding = 10000;
QDBusConnection m_dBusConnection { "default" };
QDBusServiceWatcher *m_watcher { nullptr };
CXSwiftBusServiceProxy *m_serviceProxy { nullptr };
CXSwiftBusTrafficProxy *m_trafficProxy { nullptr };
CXSwiftBusWeatherProxy *m_weatherProxy { nullptr };
QTimer m_fastTimer;
QTimer m_slowTimer;
QTimer m_airportUpdater;
QTimer m_pendingAddedTimer;
BlackMisc::Aviation::CAirportList m_airportsInRange; //!< aiports in range of own aircraft
BlackMisc::CData<BlackMisc::Simulation::Data::TModelSetCacheXP> m_modelSet { this }; //!< XPlane model set
BlackMisc::Simulation::CSimulatedAircraftList m_pendingToBeAddedAircraft; //!< aircraft to be added
QHash<BlackMisc::Aviation::CCallsign, qint64> m_addingInProgressAircraft; //!< aircraft just adding
BlackMisc::Simulation::CSimulatedAircraftList m_aircraftAddedFailed; //! aircraft for which adding failed
CXPlaneMPAircraftObjects m_xplaneAircraftObjects; //!< XPlane multiplayer aircraft
XPlaneData m_xplaneData; //!< XPlane data
// statistics
qint64 m_statsAddMaxTimeMs = -1;
qint64 m_statsAddCurrentTimeMs = -1;
//! Reset the XPlane data
void resetXPlaneData()
{
m_xplaneData = { "", "", 0, 0, 0, 0, 0, 0, 0, false, 122800, 122800, 122800, 122800, 2000, 0, false, false, false, false,
false, false, 0, 0, {}, 0.0, 0.0
};
}
};
//! Listener waits for xswiftbus service to show up
class CSimulatorXPlaneListener : public BlackCore::ISimulatorListener
{
Q_OBJECT
public:
//! Constructor
CSimulatorXPlaneListener(const BlackMisc::Simulation::CSimulatorPluginInfo &info);
protected:
//! \copydoc BlackCore::ISimulatorListener::startImpl
virtual void startImpl() override;
//! \copydoc BlackCore::ISimulatorListener::stopImpl
virtual void stopImpl() override;
//! \copydoc BlackCore::ISimulatorListener::checkImpl
virtual void checkImpl() override;
private:
void checkConnection();
void checkConnectionViaBus(const QString &address);
void checkConnectionViaPeer(const QString &address);
void checkConnectionCommon();
void serviceRegistered(const QString &serviceName);
void xSwiftBusServerSettingChanged();
QTimer m_timer { this };
QDBusConnection m_conn { "default" };
BlackMisc::CSettingReadOnly<BlackMisc::Simulation::Settings::TXSwiftBusServer> m_xswiftbusServerSetting { this, &CSimulatorXPlaneListener::xSwiftBusServerSettingChanged };
};
//! Factory for creating CSimulatorXPlane instance
class CSimulatorXPlaneFactory : public QObject, public BlackCore::ISimulatorFactory
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.swift-project.blackcore.simulatorinterface" FILE "simulatorxplane.json")
Q_INTERFACES(BlackCore::ISimulatorFactory)
public:
//! \copydoc BlackCore::ISimulatorFactory::create
virtual BlackCore::ISimulator *create(const BlackMisc::Simulation::CSimulatorPluginInfo &info,
BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider,
BlackMisc::Simulation::IRemoteAircraftProvider *remoteAircraftProvider,
BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider,
BlackMisc::Network::IClientProvider *clientProvider) override;
//! \copydoc BlackCore::ISimulatorFactory::createListener
virtual BlackCore::ISimulatorListener *createListener(const BlackMisc::Simulation::CSimulatorPluginInfo &info) override { return new CSimulatorXPlaneListener(info); }
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,7 @@
{
"identifier" : "org.swift-project.plugins.simulator.flightgear",
"name" : "Flightgear",
"simulator" : "flightgear",
"description" : "Support for the Flightgear simulator via the xswiftbus plugin.",
"config" : "org.swift-project.plugins.simulator.flightgear.config"
}

View File

@@ -0,0 +1,73 @@
/* Copyright (C) 2018
* swift Project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
#include "xplanempaircraft.h"
#include "blackcore/simulator.h"
#include "blackmisc/simulation/interpolatormulti.h"
using namespace BlackCore;
using namespace BlackMisc;
using namespace BlackMisc::Aviation;
using namespace BlackMisc::Simulation;
namespace BlackSimPlugin
{
namespace XPlane
{
CXPlaneMPAircraft::CXPlaneMPAircraft()
{ }
CXPlaneMPAircraft::CXPlaneMPAircraft(
const CSimulatedAircraft &aircraft, ISimulator *simulator, CInterpolationLogger *logger) :
m_aircraft(aircraft),
m_interpolator(QSharedPointer<CInterpolatorMulti>::create(aircraft.getCallsign(), simulator, simulator, simulator->getRemoteAircraftProvider(), logger))
{
m_interpolator->attachLogger(logger);
m_interpolator->initCorrespondingModel(aircraft.getModel());
}
void CXPlaneMPAircraft::setSimulatedAircraft(const CSimulatedAircraft &simulatedAircraft)
{
m_aircraft = simulatedAircraft;
}
QString CXPlaneMPAircraft::getInterpolatorInfo(CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const
{
Q_ASSERT(m_interpolator);
return m_interpolator->getInterpolatorInfo(mode);
}
void CXPlaneMPAircraft::attachInterpolatorLogger(CInterpolationLogger *logger) const
{
Q_ASSERT(m_interpolator);
m_interpolator->attachLogger(logger);
}
CInterpolationResult CXPlaneMPAircraft::getInterpolation(qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetupPerCallsign &setup, int aircraftNumber) const
{
Q_ASSERT(m_interpolator);
return m_interpolator->getInterpolation(currentTimeSinceEpoc, setup, aircraftNumber);
}
CStatusMessageList CXPlaneMPAircraft::getInterpolationMessages(CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const
{
return this->getInterpolator() ? this->getInterpolator()->getInterpolationMessages(mode) : CStatusMessageList();
}
CCallsignSet CXPlaneMPAircraftObjects::getAllCallsigns() const
{
return CCallsignSet(this->keys());
}
QStringList CXPlaneMPAircraftObjects::getAllCallsignStrings(bool sorted) const
{
return this->getAllCallsigns().getCallsignStrings(sorted);
}
} // namespace
} // namespace

View File

@@ -0,0 +1,94 @@
/* Copyright (C) 2018
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
//! \file
#ifndef BLACKSIMPLUGIN_XPLANE_XPLANEMPAIRCRAFT_H
#define BLACKSIMPLUGIN_XPLANE_XPLANEMPAIRCRAFT_H
#include "blackmisc/simulation/simulatedaircraft.h"
#include "blackmisc/simulation/interpolatormulti.h"
#include <QSharedPointer>
#include <QStringList>
namespace BlackCore { class ISimulator; }
namespace BlackSimPlugin
{
namespace XPlane
{
//! Class representing a X-Plane multiplayer aircraft
class CXPlaneMPAircraft
{
public:
//! Constructor
CXPlaneMPAircraft();
//! Constructor providing initial situation/parts
CXPlaneMPAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraft,
BlackCore::ISimulator *simulator,
BlackMisc::Simulation::CInterpolationLogger *logger);
//! Destructor
~CXPlaneMPAircraft() {}
//! Set simulated aircraft
void setSimulatedAircraft(const BlackMisc::Simulation::CSimulatedAircraft &simulatedAircraft);
//! Get callsign
const BlackMisc::Aviation::CCallsign &getCallsign() const { return m_aircraft.getCallsign(); }
//! Simulated aircraft (as added)
const BlackMisc::Simulation::CSimulatedAircraft &getAircraft() const { return m_aircraft; }
//! Simulated aircraft model string
const QString &getAircraftModelString() const { return m_aircraft.getModelString(); }
//! \copydoc BlackMisc::Simulation::CInterpolator::getInterpolatorInfo
QString getInterpolatorInfo(BlackMisc::Simulation::CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const;
//! \copydoc BlackMisc::Simulation::CInterpolator::attachLogger
void attachInterpolatorLogger(BlackMisc::Simulation::CInterpolationLogger *logger) const;
//! \copydoc BlackMisc::Simulation::CInterpolator::getInterpolation
BlackMisc::Simulation::CInterpolationResult getInterpolation(qint64 currentTimeSinceEpoc, const BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign &setup, int aircraftNumber) const;
//! \copydoc BlackMisc::Simulation::CInterpolator::getInterpolationMessages
BlackMisc::CStatusMessageList getInterpolationMessages(BlackMisc::Simulation::CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const;
//! Interpolator
BlackMisc::Simulation::CInterpolatorMulti *getInterpolator() const { return m_interpolator.data(); }
private:
BlackMisc::Simulation::CSimulatedAircraft m_aircraft; //!< corresponding aircraft
QSharedPointer<BlackMisc::Simulation::CInterpolatorMulti> m_interpolator; //!< shared pointer because CSimConnectObject can be copied
};
//! Simulator objects (aka AI aircraft)
class CXPlaneMPAircraftObjects : public QHash<BlackMisc::Aviation::CCallsign, CXPlaneMPAircraft>
{
public:
//! Get all callsigns
BlackMisc::Aviation::CCallsignSet getAllCallsigns() const;
//! Get all callsign strings
QStringList getAllCallsignStrings(bool sorted = false) const;
//! Get all callsign strings as string
QString getAllCallsignStringsAsString(bool sorted = false, const QString &separator = ", ") const;
//! Toggle interpolator modes
void toggleInterpolatorModes();
//! Toggle interpolator modes
void toggleInterpolatorMode(const BlackMisc::Aviation::CCallsign &callsign);
};
} // namespace
} // namespace
#endif // guard

View File

@@ -0,0 +1,510 @@
/* Copyright (C) 2013
* swift Project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
#include "xswiftbusserviceproxy.h"
#include "simulatorxplane.h"
#include <QLatin1String>
#include <QPointer>
class QDBusConnection;
#define XSWIFTBUS_SERVICE_SERVICENAME "org.swift-project.xswiftbus"
namespace BlackSimPlugin
{
namespace XPlane
{
CXSwiftBusServiceProxy::CXSwiftBusServiceProxy(QDBusConnection &connection, QObject *parent, bool dummy) : QObject(parent)
{
m_dbusInterface = new BlackMisc::CGenericDBusInterface(XSWIFTBUS_SERVICE_SERVICENAME, ObjectPath(), InterfaceName(), connection, this);
if (!dummy)
{
bool s;
s = connection.connect(QString(), "/xswiftbus/service", "org.swift_project.xswiftbus.service",
"aircraftModelChanged", this,
SIGNAL(aircraftModelChanged(QString, QString, QString, QString, QString, QString, QString)));
Q_ASSERT(s);
s = connection.connect(QString(), "/xswiftbus/service", "org.swift_project.xswiftbus.service",
"airportsInRangeUpdated", this,
SIGNAL(airportsInRangeUpdated(QStringList, QStringList, QList<double>, QList<double>, QList<double>)));
Q_ASSERT(s);
}
}
QString CXSwiftBusServiceProxy::getVersionNumber()
{
return m_dbusInterface->callDBusRet<QString>(QLatin1String("getVersionNumber"));
}
void CXSwiftBusServiceProxy::getOwnAircraftSituationData(XPlaneData *o_xplaneData)
{
QPointer<CXSwiftBusServiceProxy> myself(this);
std::function<void(QDBusPendingCallWatcher *)> callback = [ = ](QDBusPendingCallWatcher * watcher)
{
if (!myself) { return; }
QDBusPendingReply<double, double, double, double, double, double, double, double> reply = *watcher;
if (!reply.isError())
{
o_xplaneData->latitudeDeg = reply.argumentAt<0>();
o_xplaneData->longitudeDeg = reply.argumentAt<1>();
o_xplaneData->altitudeM = reply.argumentAt<2>();
o_xplaneData->groundspeedMs = reply.argumentAt<3>();
o_xplaneData->pitchDeg = reply.argumentAt<4>();
o_xplaneData->rollDeg = reply.argumentAt<5>();
o_xplaneData->trueHeadingDeg = reply.argumentAt<6>();
o_xplaneData->seaLevelPressureInHg = reply.argumentAt<7>();
}
watcher->deleteLater();
};
m_dbusInterface->callDBusAsync(QLatin1String("getOwnAircraftSituationData"), callback);
}
void CXSwiftBusServiceProxy::addTextMessage(const QString &text, double red, double green, double blue)
{
m_dbusInterface->callDBus(QLatin1String("addTextMessage"), text, red, green, blue);
}
void CXSwiftBusServiceProxy::updateAirportsInRange()
{
m_dbusInterface->callDBus(QLatin1String("updateAirportsInRange"));
}
QString CXSwiftBusServiceProxy::getAircraftModelPath() const
{
return m_dbusInterface->callDBusRet<QString>(QLatin1String("getAircraftModelPath"));
}
void CXSwiftBusServiceProxy::getAircraftModelPathAsync(QString *o_modelPath)
{
m_dbusInterface->callDBusAsync(QLatin1String("getAircraftModelPath"), setterCallback(o_modelPath));
}
QString CXSwiftBusServiceProxy::getAircraftModelFilename() const
{
return m_dbusInterface->callDBusRet<QString>(QLatin1String("getAircraftModelFilename"));
}
void CXSwiftBusServiceProxy::getAircraftModelFilenameAsync(QString *o_modelFilename)
{
m_dbusInterface->callDBusAsync(QLatin1String("getAircraftModelFilename"), setterCallback(o_modelFilename));
}
QString CXSwiftBusServiceProxy::getAircraftLivery() const
{
return m_dbusInterface->callDBusRet<QString>(QLatin1String("getAircraftLivery"));
}
void CXSwiftBusServiceProxy::getAircraftLiveryAsync(QString *o_modelLivery)
{
m_dbusInterface->callDBusAsync(QLatin1String("getAircraftLivery"), setterCallback(o_modelLivery));
}
QString CXSwiftBusServiceProxy::getAircraftIcaoCode() const
{
return m_dbusInterface->callDBusRet<QString>(QLatin1String("getAircraftIcaoCode"));
}
void CXSwiftBusServiceProxy::getAircraftIcaoCodeAsync(QString *o_icaoCode)
{
m_dbusInterface->callDBusAsync(QLatin1String("getAircraftIcaoCode"), setterCallback(o_icaoCode));
}
QString CXSwiftBusServiceProxy::getAircraftDescription() const
{
return m_dbusInterface->callDBusRet<QString>(QLatin1String("getAircraftDescription"));
}
void CXSwiftBusServiceProxy::getAircraftDescriptionAsync(QString *o_description)
{
m_dbusInterface->callDBusAsync(QLatin1String("getAircraftDescription"), setterCallback(o_description));
}
QString CXSwiftBusServiceProxy::getAircraftModelString() const
{
return m_dbusInterface->callDBusRet<QString>(QLatin1String("getAircraftModelString"));
}
void CXSwiftBusServiceProxy::getAircraftModelStringAsync(QString *o_modelString)
{
m_dbusInterface->callDBusAsync(QLatin1String("getAircraftModelString"), setterCallback(o_modelString));
}
QString CXSwiftBusServiceProxy::getAircraftName() const
{
return m_dbusInterface->callDBusRet<QString>(QLatin1String("getAircraftName"));
}
void CXSwiftBusServiceProxy::getAircraftNameAsync(QString *o_name)
{
m_dbusInterface->callDBusAsync(QLatin1String("getAircraftName"), setterCallback(o_name));
}
int CXSwiftBusServiceProxy::getXPlaneVersionMajor() const
{
return m_dbusInterface->callDBusRet<int>(QLatin1String("getXPlaneVersionMajor"));
}
void CXSwiftBusServiceProxy::getXPlaneVersionMajorAsync(int *o_versionMajor)
{
m_dbusInterface->callDBusAsync(QLatin1String("getXPlaneVersionMajor"), setterCallback(o_versionMajor));
}
int CXSwiftBusServiceProxy::getXPlaneVersionMinor() const
{
return m_dbusInterface->callDBusRet<int>(QLatin1String("getXPlaneVersionMinor"));
}
void CXSwiftBusServiceProxy::getXPlaneVersionMinorAsync(int *o_versionMinor)
{
m_dbusInterface->callDBusAsync(QLatin1String("getXPlaneVersionMinor"), setterCallback(o_versionMinor));
}
QString CXSwiftBusServiceProxy::getXPlaneInstallationPath() const
{
return m_dbusInterface->callDBusRet<QString>(QLatin1String("getXPlaneInstallationPath"));
}
void CXSwiftBusServiceProxy::getXPlaneInstallationPathAsync(QString *o_installPath)
{
m_dbusInterface->callDBusAsync(QLatin1String("getXPlaneInstallationPath"), setterCallback(o_installPath));
}
QString CXSwiftBusServiceProxy::getXPlanePreferencesPath() const
{
return m_dbusInterface->callDBusRet<QString>(QLatin1String("getXPlanePreferencesPath"));
}
void CXSwiftBusServiceProxy::getXPlanePreferencesPathAsync(QString *o_prefsPath)
{
m_dbusInterface->callDBusAsync(QLatin1String("getXPlanePreferencesPath"), setterCallback(o_prefsPath));
}
bool CXSwiftBusServiceProxy::isPaused() const
{
return m_dbusInterface->callDBusRet<bool>(QLatin1String("isPaused"));
}
void CXSwiftBusServiceProxy::isPausedAsync(bool *o_paused)
{
m_dbusInterface->callDBusAsync(QLatin1String("isPaused"), setterCallback(o_paused));
}
bool CXSwiftBusServiceProxy::isUsingRealTime() const
{
return m_dbusInterface->callDBusRet<bool>(QLatin1String("isUsingRealTime"));
}
void CXSwiftBusServiceProxy::isUsingRealTimeAsync(bool *o_isRealTime)
{
m_dbusInterface->callDBusAsync(QLatin1String("isUsingRealTime"), setterCallback(o_isRealTime));
}
double CXSwiftBusServiceProxy::getLatitudeDeg() const
{
return m_dbusInterface->callDBusRet<double>(QLatin1String("getLatitudeDeg"));
}
void CXSwiftBusServiceProxy::getLatitudeDegAsync(double *o_latitude)
{
m_dbusInterface->callDBusAsync(QLatin1String("getLatitudeDeg"), setterCallback(o_latitude));
}
double CXSwiftBusServiceProxy::getLongitudeDeg() const
{
return m_dbusInterface->callDBusRet<double>(QLatin1String("getLongitudeDeg"));
}
void CXSwiftBusServiceProxy::getLongitudeDegAsync(double *o_longitude)
{
m_dbusInterface->callDBusAsync(QLatin1String("getLongitudeDeg"), setterCallback(o_longitude));
}
double CXSwiftBusServiceProxy::getAltitudeMslM() const
{
return m_dbusInterface->callDBusRet<double>(QLatin1String("getAltitudeMslM"));
}
void CXSwiftBusServiceProxy::getAltitudeMslMAsync(double *o_altitude)
{
m_dbusInterface->callDBusAsync(QLatin1String("getAltitudeMslM"), setterCallback(o_altitude));
}
double CXSwiftBusServiceProxy::getHeightAglM() const
{
return m_dbusInterface->callDBusRet<double>(QLatin1String("getHeightAglM"));
}
void CXSwiftBusServiceProxy::getHeightAglMAsync(double *o_height)
{
m_dbusInterface->callDBusAsync(QLatin1String("getHeightAglM"), setterCallback(o_height));
}
double CXSwiftBusServiceProxy::getGroundSpeedMps() const
{
return m_dbusInterface->callDBusRet<double>(QLatin1String("getGroundSpeedMps"));
}
void CXSwiftBusServiceProxy::getGroundSpeedMpsAsync(double *o_groundspeed)
{
m_dbusInterface->callDBusAsync(QLatin1String("getGroundSpeedMps"), setterCallback(o_groundspeed));
}
double CXSwiftBusServiceProxy::getIndicatedAirspeedKias() const
{
return m_dbusInterface->callDBusRet<double>(QLatin1String("getIndicatedAirspeedKias"));
}
void CXSwiftBusServiceProxy::getIndicatedAirspeedKiasAsync(double *o_ias)
{
m_dbusInterface->callDBusAsync(QLatin1String("getIndicatedAirspeedKias"), setterCallback(o_ias));
}
double CXSwiftBusServiceProxy::getTrueAirspeedKias() const
{
return m_dbusInterface->callDBusRet<double>(QLatin1String("getTrueAirspeedKias"));
}
void CXSwiftBusServiceProxy::getTrueAirspeedKiasAsync(double *o_tas)
{
m_dbusInterface->callDBusAsync(QLatin1String("getTrueAirspeedKias"), setterCallback(o_tas));
}
double CXSwiftBusServiceProxy::getPitchDeg() const
{
return m_dbusInterface->callDBusRet<double>(QLatin1String("getPitchDeg"));
}
void CXSwiftBusServiceProxy::getPitchDegAsync(double *o_pitch)
{
m_dbusInterface->callDBusAsync(QLatin1String("getPitchDeg"), setterCallback(o_pitch));
}
double CXSwiftBusServiceProxy::getRollDeg() const
{
return m_dbusInterface->callDBusRet<double>(QLatin1String("getRollDeg"));
}
void CXSwiftBusServiceProxy::getRollDegAsync(double *o_roll)
{
m_dbusInterface->callDBusAsync(QLatin1String("getRollDeg"), setterCallback(o_roll));
}
double CXSwiftBusServiceProxy::getTrueHeadingDeg() const
{
return m_dbusInterface->callDBusRet<double>(QLatin1String("getTrueHeadingDeg"));
}
void CXSwiftBusServiceProxy::getTrueHeadingDegAsync(double *o_heading)
{
m_dbusInterface->callDBusAsync(QLatin1String("getTrueHeadingDeg"), setterCallback(o_heading));
}
bool CXSwiftBusServiceProxy::getAnyWheelOnGround() const
{
return m_dbusInterface->callDBusRet<bool>(QLatin1String("getAnyWheelOnGround"));
}
void CXSwiftBusServiceProxy::getAnyWheelOnGroundAsync(bool *o_anyWheel)
{
m_dbusInterface->callDBusAsync(QLatin1String("getAnyWheelOnGround"), setterCallback(o_anyWheel));
}
bool CXSwiftBusServiceProxy::getAllWheelsOnGround() const
{
return m_dbusInterface->callDBusRet<bool>(QLatin1String("getAllWheelsOnGround"));
}
void CXSwiftBusServiceProxy::getAllWheelsOnGroundAsync(bool *o_allWheels)
{
m_dbusInterface->callDBusAsync(QLatin1String("getAllWheelsOnGround"), setterCallback(o_allWheels));
}
int CXSwiftBusServiceProxy::getCom1ActiveKhz() const
{
return m_dbusInterface->callDBusRet<int>(QLatin1String("getCom1ActiveKhz"));
}
void CXSwiftBusServiceProxy::getCom1ActiveKhzAsync(int *o_com1Active)
{
m_dbusInterface->callDBusAsync(QLatin1String("getCom1ActiveKhz"), setterCallback(o_com1Active));
}
int CXSwiftBusServiceProxy::getCom1StandbyKhz() const
{
return m_dbusInterface->callDBusRet<int>(QLatin1String("getCom1StandbyKhz"));
}
void CXSwiftBusServiceProxy::getCom1StandbyKhzAsync(int *o_com1Standby)
{
m_dbusInterface->callDBusAsync(QLatin1String("getCom1StandbyKhz"), setterCallback(o_com1Standby));
}
int CXSwiftBusServiceProxy::getCom2ActiveKhz() const
{
return m_dbusInterface->callDBusRet<int>(QLatin1String("getCom2ActiveKhz"));
}
void CXSwiftBusServiceProxy::getCom2ActiveKhzAsync(int *o_com2Active)
{
m_dbusInterface->callDBusAsync(QLatin1String("getCom2ActiveKhz"), setterCallback(o_com2Active));
}
int CXSwiftBusServiceProxy::getCom2StandbyKhz() const
{
return m_dbusInterface->callDBusRet<int>(QLatin1String("getCom2StandbyKhz"));
}
void CXSwiftBusServiceProxy::getCom2StandbyKhzAsync(int *o_com2Standby)
{
m_dbusInterface->callDBusAsync(QLatin1String("getCom2StandbyKhz"), setterCallback(o_com2Standby));
}
int CXSwiftBusServiceProxy::getTransponderCode() const
{
return m_dbusInterface->callDBusRet<int>(QLatin1String("getTransponderCode"));
}
void CXSwiftBusServiceProxy::getTransponderCodeAsync(int *o_xpdrCode)
{
m_dbusInterface->callDBusAsync(QLatin1String("getTransponderCode"), setterCallback(o_xpdrCode));
}
int CXSwiftBusServiceProxy::getTransponderMode() const
{
return m_dbusInterface->callDBusRet<int>(QLatin1String("getTransponderMode"));
}
void CXSwiftBusServiceProxy::getTransponderModeAsync(int *o_xpdrMode)
{
m_dbusInterface->callDBusAsync(QLatin1String("getTransponderMode"), setterCallback(o_xpdrMode));
}
bool CXSwiftBusServiceProxy::getTransponderIdent() const
{
return m_dbusInterface->callDBusRet<bool>(QLatin1String("getTransponderIdent"));
}
void CXSwiftBusServiceProxy::getTransponderIdentAsync(bool *o_ident)
{
m_dbusInterface->callDBusAsync(QLatin1String("getTransponderIdent"), setterCallback(o_ident));
}
bool CXSwiftBusServiceProxy::getBeaconLightsOn() const
{
return m_dbusInterface->callDBusRet<bool>(QLatin1String("getBeaconLightsOn"));
}
void CXSwiftBusServiceProxy::getBeaconLightsOnAsync(bool *o_beaconLightsOn)
{
m_dbusInterface->callDBusAsync(QLatin1String("getBeaconLightsOn"), setterCallback(o_beaconLightsOn));
}
bool CXSwiftBusServiceProxy::getLandingLightsOn() const
{
return m_dbusInterface->callDBusRet<bool>(QLatin1String("getLandingLightsOn"));
}
void CXSwiftBusServiceProxy::getLandingLightsOnAsync(bool *o_landingLightsOn)
{
m_dbusInterface->callDBusAsync(QLatin1String("getLandingLightsOn"), setterCallback(o_landingLightsOn));
}
bool CXSwiftBusServiceProxy::getNavLightsOn() const
{
return m_dbusInterface->callDBusRet<bool>(QLatin1String("getNavLightsOn"));
}
void CXSwiftBusServiceProxy::getNavLightsOnAsync(bool *o_navLightsOn)
{
m_dbusInterface->callDBusAsync(QLatin1String("getNavLightsOn"), setterCallback(o_navLightsOn));
}
bool CXSwiftBusServiceProxy::getStrobeLightsOn() const
{
return m_dbusInterface->callDBusRet<bool>(QLatin1String("getStrobeLightsOn"));
}
void CXSwiftBusServiceProxy::getStrobeLightsOnAsync(bool *o_strobeLightsOn)
{
m_dbusInterface->callDBusAsync(QLatin1String("getStrobeLightsOn"), setterCallback(o_strobeLightsOn));
}
bool CXSwiftBusServiceProxy::getTaxiLightsOn() const
{
return m_dbusInterface->callDBusRet<bool>(QLatin1String("getTaxiLightsOn"));
}
void CXSwiftBusServiceProxy::getTaxiLightsOnAsync(bool *o_taxiLightsOn)
{
m_dbusInterface->callDBusAsync(QLatin1String("getTaxiLightsOn"), setterCallback(o_taxiLightsOn));
}
double CXSwiftBusServiceProxy::getQNHInHg() const
{
return m_dbusInterface->callDBusRet<double>(QLatin1String("getQNHInHg"));
}
void CXSwiftBusServiceProxy::getQNHInHgAsync(double *o_qnh)
{
m_dbusInterface->callDBusAsync(QLatin1String("getQNHInHg"), setterCallback(o_qnh));
}
void CXSwiftBusServiceProxy::setCom1ActiveKhz(int freq)
{
m_dbusInterface->callDBus(QLatin1String("setCom1ActiveKhz"), freq);
}
void CXSwiftBusServiceProxy::setCom1StandbyKhz(int freq)
{
m_dbusInterface->callDBus(QLatin1String("setCom1StandbyKhz"), freq);
}
void CXSwiftBusServiceProxy::setCom2ActiveKhz(int freq)
{
m_dbusInterface->callDBus(QLatin1String("setCom2ActiveKhz"), freq);
}
void CXSwiftBusServiceProxy::setCom2StandbyKhz(int freq)
{
m_dbusInterface->callDBus(QLatin1String("setCom2StandbyKhz"), freq);
}
void CXSwiftBusServiceProxy::setTransponderCode(int code)
{
m_dbusInterface->callDBus(QLatin1String("setTransponderCode"), code);
}
void CXSwiftBusServiceProxy::setTransponderMode(int mode)
{
m_dbusInterface->callDBus(QLatin1String("setTransponderMode"), mode);
}
double CXSwiftBusServiceProxy::getFlapsDeployRatio() const
{
return m_dbusInterface->callDBusRet<double>(QLatin1String("getFlapsDeployRatio"));
}
void CXSwiftBusServiceProxy::getFlapsDeployRatioAsync(double *o_flapsDeployRatio)
{
m_dbusInterface->callDBusAsync(QLatin1String("getFlapsDeployRatio"), setterCallback(o_flapsDeployRatio));
}
double CXSwiftBusServiceProxy::getGearDeployRatio() const
{
return m_dbusInterface->callDBusRet<double>(QLatin1String("getGearDeployRatio"));
}
void CXSwiftBusServiceProxy::getGearDeployRatioAsync(double *o_gearDeployRatio)
{
m_dbusInterface->callDBusAsync(QLatin1String("getGearDeployRatio"), setterCallback(o_gearDeployRatio));
}
int CXSwiftBusServiceProxy::getNumberOfEngines() const
{
return m_dbusInterface->callDBusRet<int>(QLatin1String("getNumberOfEngines"));
}
void CXSwiftBusServiceProxy::getNumberOfEnginesAsync(double *o_numberOfEngines)
{
m_dbusInterface->callDBusAsync(QLatin1String("getNumberOfEngines"), setterCallback(o_numberOfEngines));
}
QList<double> CXSwiftBusServiceProxy::getEngineN1Percentage() const
{
return m_dbusInterface->callDBusRet<QList<double>>(QLatin1String("getEngineN1Percentage"));
}
void CXSwiftBusServiceProxy::getEngineN1PercentageAsync(QList<double> *o_engineN1Percentage)
{
m_dbusInterface->callDBusAsync(QLatin1String("getEngineN1Percentage"), setterCallback(o_engineN1Percentage));
}
double CXSwiftBusServiceProxy::getSpeedBrakeRatio() const
{
return m_dbusInterface->callDBusRet<double>(QLatin1String("getSpeedBrakeRatio"));
}
void CXSwiftBusServiceProxy::getSpeedBrakeRatioAsync(double *o_speedBrakeRatio)
{
m_dbusInterface->callDBusAsync(QLatin1String("getSpeedBrakeRatio"), setterCallback(o_speedBrakeRatio));
}
} // ns
} // ns

View File

@@ -0,0 +1,394 @@
/* Copyright (C) 2013
* swift Project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
//! \file
#ifndef BLACKSIMPLUGIN_XSWIFTBUS_SERVICE_PROXY_H
#define BLACKSIMPLUGIN_XSWIFTBUS_SERVICE_PROXY_H
#include "blackmisc/genericdbusinterface.h"
#include <QDBusError>
#include <QDBusPendingReply>
#include <QList>
#include <QObject>
#include <QString>
#include <QStringList>
#include <functional>
// clazy:excludeall=const-signal-or-slot
class QDBusConnection;
class QDBusPendingCallWatcher;
//! \cond PRIVATE
#define XSWIFTBUS_SERVICE_INTERFACENAME "org.swift_project.xswiftbus.service"
#define XSWIFTBUS_SERVICE_OBJECTPATH "/xswiftbus/service"
//! \endcond
namespace BlackSimPlugin
{
namespace XPlane
{
struct XPlaneData;
/*!
* Proxy object connected to a real XSwiftBus::CService object via DBus
*/
class CXSwiftBusServiceProxy : public QObject
{
Q_OBJECT
public:
//! Service name
static const QString &InterfaceName()
{
static const QString s(XSWIFTBUS_SERVICE_INTERFACENAME);
return s;
}
//! Service path
static const QString &ObjectPath()
{
static const QString s(XSWIFTBUS_SERVICE_OBJECTPATH);
return s;
}
//! Constructor
CXSwiftBusServiceProxy(QDBusConnection &connection, QObject *parent = nullptr, bool dummy = false);
//! Does the remote object exist?
bool isValid() const { return m_dbusInterface->isValid(); }
//! Cancel all current async slot calls
void cancelAllPendingAsyncCalls() { m_dbusInterface->cancelAllPendingAsyncCalls(); }
private:
BlackMisc::CGenericDBusInterface *m_dbusInterface = nullptr;
// Returns a function object which can be passed to CGenericDBusInterface::callDBusAsync.
template <typename T>
std::function<void(QDBusPendingCallWatcher *)> setterCallback(T *obj)
{
return [this, obj](QDBusPendingCallWatcher * watcher)
{
QDBusPendingReply<T> reply = *watcher;
if (reply.isError()) { emit this->asyncMethodError(reply.error()); }
else { *obj = reply; }
watcher->deleteLater();
};
}
signals:
//! Emitted if an asynchronous method call caused a DBus error
BLACK_NO_RELAY void asyncMethodError(QDBusError error);
//! Own aircraft model changed
void aircraftModelChanged(
const QString &path, const QString &filename, const QString &livery,
const QString &icao, const QString &modelString, const QString &name, const QString &description);
//! Airports in range are updated
void airportsInRangeUpdated(const QStringList &icaoCodes, const QStringList &names, const QList<double> &lats, const QList<double> &lons, const QList<double> &alts);
public slots:
//! Get XSwiftBus version number
QString getVersionNumber();
//! Get own aircraft situation data
void getOwnAircraftSituationData(BlackSimPlugin::XPlane::XPlaneData *o_xplaneData);
//! \copydoc XSwiftBus::CService::addTextMessage
void addTextMessage(const QString &text, double red, double green, double blue);
//! \copydoc XSwiftBus::CService::updateAirportsInRange
void updateAirportsInRange();
//! \copydoc XSwiftBus::CService::getAircraftModelPath
//! @{
QString getAircraftModelPath() const;
void getAircraftModelPathAsync(QString *o_modelPath);
//! @}
//! \copydoc XSwiftBus::CService::getAircraftModelFilename
//! @{
QString getAircraftModelFilename() const;
void getAircraftModelFilenameAsync(QString *o_modelFilename);
//! @}
//! \copydoc XSwiftBus::CService::getAircraftLivery
//! @{
QString getAircraftLivery() const;
void getAircraftLiveryAsync(QString *o_modelLivery);
//! @}
//! \copydoc XSwiftBus::CService::getAircraftIcaoCode
//! @{
QString getAircraftIcaoCode() const;
void getAircraftIcaoCodeAsync(QString *o_icaoCode);
//! @}
//! \copydoc XSwiftBus::CService::getAircraftDescription
//! @{
QString getAircraftDescription() const;
void getAircraftDescriptionAsync(QString *o_description);
//! @}
//! \copydoc XSwiftBus::CService::getAircraftModelString
//! @{
QString getAircraftModelString() const;
void getAircraftModelStringAsync(QString *o_modelString);
//! @}
//! \copydoc XSwiftBus::CService::getAircraftName
//! @{
QString getAircraftName() const;
void getAircraftNameAsync(QString *o_name);
//! @}
//! \copydoc XSwiftBus::CService::getXPlaneVersionMajor
//! @{
int getXPlaneVersionMajor() const;
void getXPlaneVersionMajorAsync(int *o_versionMajor);
//! @}
//! \copydoc XSwiftBus::CService::getXPlaneVersionMinor
//! @{
int getXPlaneVersionMinor() const;
void getXPlaneVersionMinorAsync(int *o_versionMinor);
//! @}
//! \copydoc XSwiftBus::CService::getXPlaneInstallationPath
//! @{
QString getXPlaneInstallationPath() const;
void getXPlaneInstallationPathAsync(QString *o_installPath);
//! @}
//! \copydoc XSwiftBus::CService::getXPlanePreferencesPath
//! @{
QString getXPlanePreferencesPath() const;
void getXPlanePreferencesPathAsync(QString *o_prefsPath);
//! @}
//! \copydoc XSwiftBus::CService::isPaused
//! @{
bool isPaused() const;
void isPausedAsync(bool *o_paused);
//! @}
//! \copydoc XSwiftBus::CService::isUsingRealTime
//! @{
bool isUsingRealTime() const;
void isUsingRealTimeAsync(bool *o_isRealTime);
//! @}
//! \copydoc XSwiftBus::CService::getLatitudeDeg
//! @{
double getLatitudeDeg() const;
void getLatitudeDegAsync(double *o_latitude);
//! @}
//! \copydoc XSwiftBus::CService::getLongitudeDeg
//! @{
double getLongitudeDeg() const;
void getLongitudeDegAsync(double *o_longitude);
//! @}
//! \copydoc XSwiftBus::CService::getAltitudeMslM
//! @{
double getAltitudeMslM() const;
void getAltitudeMslMAsync(double *o_altitude);
//! @}
//! \copydoc XSwiftBus::CService::getHeightAglM
//! @{
double getHeightAglM() const;
void getHeightAglMAsync(double *o_height);
//! @}
//! \copydoc XSwiftBus::CService::getGroundSpeedMps
//! @{
double getGroundSpeedMps() const;
void getGroundSpeedMpsAsync(double *o_groundspeed);
//! @}
//! \copydoc XSwiftBus::CService::getIndicatedAirspeedKias
//! @{
double getIndicatedAirspeedKias() const;
void getIndicatedAirspeedKiasAsync(double *o_ias);
//! @}
//! \copydoc XSwiftBus::CService::getTrueAirspeedKias
//! @{
double getTrueAirspeedKias() const;
void getTrueAirspeedKiasAsync(double *o_tas);
//! @}
//! \copydoc XSwiftBus::CService::getPitchDeg
//! @{
double getPitchDeg() const;
void getPitchDegAsync(double *o_pitch);
//! @}
//! \copydoc XSwiftBus::CService::getRollDeg
//! @{
double getRollDeg() const;
void getRollDegAsync(double *o_roll);
//! @}
//! \copydoc XSwiftBus::CService::getTrueHeadingDeg
//! @{
double getTrueHeadingDeg() const;
void getTrueHeadingDegAsync(double *o_heading);
//! @}
//! Get whether any wheel is on the ground
//! @{
bool getAnyWheelOnGround() const;
void getAnyWheelOnGroundAsync(bool *o_anyWheel);
//! @}
//! Get whether all wheels are on the ground
//! @{
bool getAllWheelsOnGround() const;
void getAllWheelsOnGroundAsync(bool *o_allWheels);
//! @}
//! \copydoc XSwiftBus::CService::getCom1ActiveKhz
//! @{
int getCom1ActiveKhz() const;
void getCom1ActiveKhzAsync(int *o_com1Active);
//! @}
//! \copydoc XSwiftBus::CService::getCom1StandbyKhz
//! @{
int getCom1StandbyKhz() const;
void getCom1StandbyKhzAsync(int *o_com1Standby);
//! @}
//! \copydoc XSwiftBus::CService::getCom2ActiveKhz
//! @{
int getCom2ActiveKhz() const;
void getCom2ActiveKhzAsync(int *o_com2Active);
//! @}
//! \copydoc XSwiftBus::CService::getCom2StandbyKhz
//! @{
int getCom2StandbyKhz() const;
void getCom2StandbyKhzAsync(int *o_com2Standby);
//! @}
//! \copydoc XSwiftBus::CService::getTransponderCode
//! @{
int getTransponderCode() const;
void getTransponderCodeAsync(int *o_xpdrCode);
//! @}
//! \copydoc XSwiftBus::CService::getTransponderMode
//! @{
int getTransponderMode() const;
void getTransponderModeAsync(int *o_xpdrMode);
//! @}
//! \copydoc XSwiftBus::CService::getTransponderIdent
//! @{
bool getTransponderIdent() const;
void getTransponderIdentAsync(bool *o_ident);
//! @}
//! \copydoc XSwiftBus::CService::getLandingLightsOn
//! @{
bool getBeaconLightsOn() const;
void getBeaconLightsOnAsync(bool *o_beaconLightsOn);
//! @}
//! \copydoc XSwiftBus::CService::getLandingLightsOn
//! @{
bool getLandingLightsOn() const;
void getLandingLightsOnAsync(bool *o_landingLightsOn);
//! @}
//! \copydoc XSwiftBus::CService::getNavLightsOn
//! @{
bool getNavLightsOn() const;
void getNavLightsOnAsync(bool *o_navLightsOn);
//! @}
//! \copydoc XSwiftBus::CService::getStrobeLightsOn
//! @{
bool getStrobeLightsOn() const;
void getStrobeLightsOnAsync(bool *o_strobeLightsOn);
//! @}
//! \copydoc XSwiftBus::CService::getTaxiLightsOn
//! @{
bool getTaxiLightsOn() const;
void getTaxiLightsOnAsync(bool *o_taxiLightsOn);
//! @}
//! \copydoc XSwiftBus::CService::getQNHInHg
//! @{
double getQNHInHg() const;
void getQNHInHgAsync(double *o_qnh);
//! @}
//! \copydoc XSwiftBus::CService::setCom1ActiveKhz
void setCom1ActiveKhz(int freq);
//! \copydoc XSwiftBus::CService::setCom1StandbyKhz
void setCom1StandbyKhz(int freq);
//! \copydoc XSwiftBus::CService::setCom2ActiveKhz
void setCom2ActiveKhz(int freq);
//! \copydoc XSwiftBus::CService::setCom2StandbyKhz
void setCom2StandbyKhz(int freq);
//! \copydoc XSwiftBus::CService::setTransponderCode
void setTransponderCode(int code);
//! \copydoc XSwiftBus::CService::setTransponderMode
void setTransponderMode(int mode);
//! \copydoc XSwiftBus::CService::getFlapsDeployRatio
//! @{
double getFlapsDeployRatio() const;
void getFlapsDeployRatioAsync(double *o_flapsDeployRatio);
//! @}
//! \copydoc XSwiftBus::CService::getGearDeployRatio
//! @{
double getGearDeployRatio() const;
void getGearDeployRatioAsync(double *o_gearDeployRatio);
//! @}
//! \copydoc XSwiftBus::CService::getNumberOfEngines
//! @{
int getNumberOfEngines() const;
void getNumberOfEnginesAsync(double *o_numberOfEngines);
//! @}
//! \copydoc XSwiftBus::CService::getEngineN1Percentage
//! @{
QList<double> getEngineN1Percentage() const;
void getEngineN1PercentageAsync(QList<double> *o_engineN1Percentage);
//! @}
//! \copydoc XSwiftBus::CService::getSpeedBrakeRatio
//! @{
double getSpeedBrakeRatio() const;
void getSpeedBrakeRatioAsync(double *o_speedBrakeRatio);
//! @}
};
}
}
#endif // guard

View File

@@ -0,0 +1,189 @@
/* Copyright (C) 2013
* swift Project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
#include "xswiftbustrafficproxy.h"
#include <QLatin1String>
#include <QDBusConnection>
#define XSWIFTBUS_SERVICENAME "org.swift-project.xswiftbus"
using namespace BlackMisc::Aviation;
using namespace BlackMisc::Geo;
using namespace BlackMisc::PhysicalQuantities;
namespace BlackSimPlugin
{
namespace XPlane
{
CXSwiftBusTrafficProxy::CXSwiftBusTrafficProxy(QDBusConnection &connection, QObject *parent, bool dummy) : QObject(parent)
{
m_dbusInterface = new BlackMisc::CGenericDBusInterface(XSWIFTBUS_SERVICENAME, ObjectPath(), InterfaceName(), connection, this);
if (!dummy)
{
bool s;
s = connection.connect(QString(), "/xswiftbus/traffic", "org.swift_project.xswiftbus.traffic",
"simFrame", this, SIGNAL(simFrame()));
Q_ASSERT(s);
s = connection.connect(QString(), "/xswiftbus/traffic", "org.swift_project.xswiftbus.traffic",
"remoteAircraftAdded", this, SIGNAL(remoteAircraftAdded(QString)));
Q_ASSERT(s);
s = connection.connect(QString(), "/xswiftbus/traffic", "org.swift_project.xswiftbus.traffic",
"remoteAircraftAddingFailed", this, SIGNAL(remoteAircraftAddingFailed(QString)));
Q_ASSERT(s);
}
}
MultiplayerAcquireInfo CXSwiftBusTrafficProxy::acquireMultiplayerPlanes()
{
QDBusPendingReply<bool, QString> reply = m_dbusInterface->asyncCall(QLatin1String("acquireMultiplayerPlanes"));
reply.waitForFinished();
if (reply.isError())
{
BlackMisc::CLogMessage(this).debug(u"CXSwiftBusTrafficProxy::acquireMultiplayerPlanes returned: %1") << reply.error().message();
}
MultiplayerAcquireInfo info;
info.hasAcquired = reply.argumentAt<0>();
info.owner = reply.argumentAt<1>();
return info;
}
bool CXSwiftBusTrafficProxy::initialize()
{
return m_dbusInterface->callDBusRet<bool>(QLatin1String("initialize"));
}
void CXSwiftBusTrafficProxy::cleanup()
{
m_dbusInterface->callDBus(QLatin1String("cleanup"));
}
bool CXSwiftBusTrafficProxy::loadPlanesPackage(const QString &path)
{
return m_dbusInterface->callDBusRet<bool>(QLatin1String("loadPlanesPackage"), path);
}
void CXSwiftBusTrafficProxy::setDefaultIcao(const QString &defaultIcao)
{
m_dbusInterface->callDBus(QLatin1String("setDefaultIcao"), defaultIcao);
}
void CXSwiftBusTrafficProxy::setDrawingLabels(bool drawing)
{
m_dbusInterface->callDBus(QLatin1String("setDrawingLabels"), drawing);
}
bool CXSwiftBusTrafficProxy::isDrawingLabels() const
{
return m_dbusInterface->callDBusRet<bool>(QLatin1String("isDrawingLabels"));
}
void CXSwiftBusTrafficProxy::setMaxPlanes(int planes)
{
m_dbusInterface->callDBus(QLatin1String("setMaxPlanes"), planes);
}
void CXSwiftBusTrafficProxy::setMaxDrawDistance(double nauticalMiles)
{
m_dbusInterface->callDBus(QLatin1String("setMaxDrawDistance"), nauticalMiles);
}
void CXSwiftBusTrafficProxy::addPlane(const QString &callsign, const QString &modelName, const QString &aircraftIcao, const QString &airlineIcao, const QString &livery)
{
m_dbusInterface->callDBus(QLatin1String("addPlane"), callsign, modelName, aircraftIcao, airlineIcao, livery);
}
void CXSwiftBusTrafficProxy::removePlane(const QString &callsign)
{
m_dbusInterface->callDBus(QLatin1String("removePlane"), callsign);
}
void CXSwiftBusTrafficProxy::removeAllPlanes()
{
m_dbusInterface->callDBus(QLatin1String("removeAllPlanes"));
}
void CXSwiftBusTrafficProxy::setPlanesPositions(const PlanesPositions &planesPositions)
{
m_dbusInterface->callDBus(QLatin1String("setPlanesPositions"),
planesPositions.callsigns, planesPositions.latitudesDeg, planesPositions.longitudesDeg,
planesPositions.altitudesFt, planesPositions.pitchesDeg, planesPositions.rollsDeg,
planesPositions.headingsDeg, planesPositions.onGrounds);
}
void CXSwiftBusTrafficProxy::setPlanesSurfaces(const PlanesSurfaces &planesSurfaces)
{
m_dbusInterface->callDBus(QLatin1String("setPlanesSurfaces"),
planesSurfaces.callsigns, planesSurfaces.gears, planesSurfaces.flaps,
planesSurfaces.spoilers, planesSurfaces.speedBrakes, planesSurfaces.slats,
planesSurfaces.wingSweeps, planesSurfaces.thrusts, planesSurfaces.elevators,
planesSurfaces.rudders, planesSurfaces.ailerons,
planesSurfaces.landLights, planesSurfaces.beaconLights, planesSurfaces.strobeLights,
planesSurfaces.navLights, planesSurfaces.lightPatterns);
}
void CXSwiftBusTrafficProxy::setPlanesTransponders(const PlanesTransponders &planesTransponders)
{
m_dbusInterface->callDBus(QLatin1String("setPlanesTransponders"),
planesTransponders.callsigns, planesTransponders.codes,
planesTransponders.modeCs, planesTransponders.idents);
}
void CXSwiftBusTrafficProxy::setInterpolatorMode(const QString &callsign, bool spline)
{
m_dbusInterface->callDBus(QLatin1String("setInterpolatorMode"), callsign, spline);
}
void CXSwiftBusTrafficProxy::getRemoteAircraftData(const QStringList &callsigns, const RemoteAircraftDataCallback &setter) const
{
std::function<void(QDBusPendingCallWatcher *)> callback = [ = ](QDBusPendingCallWatcher * watcher)
{
QDBusPendingReply<QStringList, QList<double>, QList<double>, QList<double>, QList<double>> reply = *watcher;
if (!reply.isError())
{
const QStringList callsigns = reply.argumentAt<0>();
const QList<double> latitudesDeg = reply.argumentAt<1>();
const QList<double> longitudesDeg = reply.argumentAt<2>();
const QList<double> elevationsM = reply.argumentAt<3>();
const QList<double> verticalOffsets = reply.argumentAt<4>();
setter(callsigns, latitudesDeg, longitudesDeg, elevationsM, verticalOffsets);
}
watcher->deleteLater();
};
m_dbusInterface->callDBusAsync(QLatin1String("getRemoteAircraftData"), callback, callsigns);
}
void CXSwiftBusTrafficProxy::getElevationAtPosition(const CCallsign &callsign, double latitudeDeg, double longitudeDeg, double altitudeMeters,
const ElevationCallback &setter) const
{
std::function<void(QDBusPendingCallWatcher *)> callback = [ = ](QDBusPendingCallWatcher * watcher)
{
QDBusPendingReply<QString, double> reply = *watcher;
if (!reply.isError())
{
const CCallsign cs(reply.argumentAt<0>());
const double elevationMeters = reply.argumentAt<1>();
const CAltitude elevationAlt(elevationMeters, CLengthUnit::m(), CLengthUnit::ft());
const CElevationPlane elevation(CLatitude(latitudeDeg, CAngleUnit::deg()),
CLongitude(longitudeDeg, CAngleUnit::deg()),
elevationAlt, CElevationPlane::singlePointRadius());
setter(elevation, cs);
}
watcher->deleteLater();
};
m_dbusInterface->callDBusAsync(QLatin1String("getElevationAtPosition"), callback, callsign.asString(), latitudeDeg, longitudeDeg, altitudeMeters);
}
void CXSwiftBusTrafficProxy::setFollowedAircraft(const QString &callsign)
{
m_dbusInterface->callDBus(QLatin1String("setFollowedAircraft"), callsign);
}
}
}

View File

@@ -0,0 +1,221 @@
/* Copyright (C) 2013
* swift Project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
//! \file
#ifndef BLACKSIMPLUGIN_XSWIFTBUS_TRAFFIC_PROXY_H
#define BLACKSIMPLUGIN_XSWIFTBUS_TRAFFIC_PROXY_H
#include "blackmisc/genericdbusinterface.h"
#include "blackmisc/aviation/callsign.h"
#include "blackmisc/geo/elevationplane.h"
#include <QObject>
#include <QString>
#include <QStringList>
// clazy:excludeall=const-signal-or-slot
class QDBusConnection;
//! \cond PRIVATE
#define XSWIFTBUS_TRAFFIC_INTERFACENAME "org.swift_project.xswiftbus.traffic"
#define XSWIFTBUS_TRAFFIC_OBJECTPATH "/xswiftbus/traffic"
//! \endcond
namespace BlackSimPlugin
{
namespace XPlane
{
//! List of doubles
using QDoubleList = QList<double>;
//! Planes positions
struct PlanesPositions
{
//! Is empty?
bool isEmpty() const { return callsigns.isEmpty(); }
//! Check function
bool hasSameSizes() const
{
const int s = callsigns.size();
if (s != latitudesDeg.size()) { return false; }
if (s != longitudesDeg.size()) { return false; }
if (s != altitudesFt.size()) { return false; }
if (s != pitchesDeg.size()) { return false; }
if (s != rollsDeg.size()) { return false; }
if (s != headingsDeg.size()) { return false; }
return true;
}
QStringList callsigns; //!< List of callsigns
QList<double> latitudesDeg; //!< List of latitudes
QList<double> longitudesDeg; //!< List of longitudes
QList<double> altitudesFt; //!< List of altitudes
QList<double> pitchesDeg; //!< List of pitches
QList<double> rollsDeg; //!< List of rolls
QList<double> headingsDeg; //!< List of headings
QList<bool> onGrounds; //!< List of onGrounds
};
//! Planes surfaces
struct PlanesSurfaces
{
//! Is empty?
bool isEmpty() const { return callsigns.isEmpty(); }
QStringList callsigns; //!< List of callsigns
QList<double> gears; //!< List of gears
QList<double> flaps; //!< List of flaps
QList<double> spoilers; //!< List of spoilers
QList<double> speedBrakes; //!< List of speedBrakes
QList<double> slats; //!< List of slats
QList<double> wingSweeps; //!< List of wingSweeps
QList<double> thrusts; //!< List of thrusts
QList<double> elevators; //!< List of elevators
QList<double> rudders; //!< List of rudders
QList<double> ailerons; //!< List of ailerons
QList<bool> landLights; //!< List of landLights
QList<bool> beaconLights; //!< List of beaconLights
QList<bool> strobeLights; //!< List of strobeLights
QList<bool> navLights; //!< List of navLights
QList<int> lightPatterns; //!< List of lightPatterns
};
//! Plane Transponders
struct PlanesTransponders
{
//! Is empty?
bool isEmpty() const { return callsigns.isEmpty(); }
QStringList callsigns; //!< List of callsigns
QList<int> codes; //!< List of transponder codes
QList<bool> modeCs; //!< List of active mode C's
QList<bool> idents; //!< List of active idents
};
//! Multiplayer Acquire Info
struct MultiplayerAcquireInfo
{
bool hasAcquired; //!< Has XSwiftBus acquired multiplayer planes?
QString owner; //!< Name of the plugin having multiplayer planes acquired
};
/*!
* Proxy object connected to a real XSwiftBus::CTraffic object via DBus
*/
class CXSwiftBusTrafficProxy : public QObject
{
Q_OBJECT
public:
//! Elevation callback
using ElevationCallback = std::function<void (const BlackMisc::Geo::CElevationPlane &, const BlackMisc::Aviation::CCallsign &)>;
//! Remote aircrafts data callback
using RemoteAircraftDataCallback = std::function<void (const QStringList &, const QDoubleList &, const QDoubleList &, const QDoubleList &, const QDoubleList &)>;
//! Service name
static const QString &InterfaceName()
{
static QString s(XSWIFTBUS_TRAFFIC_INTERFACENAME);
return s;
}
//! Service path
static const QString &ObjectPath()
{
static QString s(XSWIFTBUS_TRAFFIC_OBJECTPATH);
return s;
}
//! Constructor
CXSwiftBusTrafficProxy(QDBusConnection &connection, QObject *parent = nullptr, bool dummy = false);
//! Does the remote object exist?
bool isValid() const { return m_dbusInterface->isValid(); }
signals:
//! Simulator frame
//! \remark from simulator to driver
void simFrame();
//! Remote aircraft successfully added
void remoteAircraftAdded(const QString &callsign);
//! Remote aircraft adding failed
void remoteAircraftAddingFailed(const QString &callsign);
public slots:
//! \copydoc XSwiftBus::CTraffic::acquireMultiplayerPlanes
MultiplayerAcquireInfo acquireMultiplayerPlanes();
//! \copydoc XSwiftBus::CTraffic::initialize
bool initialize();
//! \copydoc XSwiftBus::CTraffic::cleanup
void cleanup();
//! \copydoc XSwiftBus::CTraffic::loadPlanesPackage
bool loadPlanesPackage(const QString &path);
//! \copydoc XSwiftBus::CTraffic::setDefaultIcao
void setDefaultIcao(const QString &defaultIcao);
//! \copydoc XSwiftBus::CTraffic::setDrawingLabels
void setDrawingLabels(bool drawing);
//! \copydoc XSwiftBus::CTraffic::isDrawingLabels
bool isDrawingLabels() const;
//! \copydoc XSwiftBus::CTraffic::setMaxPlanes
void setMaxPlanes(int planes);
//! \copydoc XSwiftBus::CTraffic::setMaxDrawDistance
void setMaxDrawDistance(double nauticalMiles);
//! \copydoc XSwiftBus::CTraffic::addPlane
void addPlane(const QString &callsign, const QString &modelName, const QString &aircraftIcao, const QString &airlineIcao, const QString &livery);
//! \copydoc XSwiftBus::CTraffic::removePlane
void removePlane(const QString &callsign);
//! \copydoc XSwiftBus::CTraffic::removeAllPlanes
void removeAllPlanes();
//! \copydoc XSwiftBus::CTraffic::setPlanesPositions
void setPlanesPositions(const BlackSimPlugin::XPlane::PlanesPositions &planesPositions);
//! \copydoc XSwiftBus::CTraffic::setPlanesSurfaces
void setPlanesSurfaces(const BlackSimPlugin::XPlane::PlanesSurfaces &planesSurfaces);
//! \copydoc XSwiftBus::CTraffic::setPlanesTransponders
void setPlanesTransponders(const BlackSimPlugin::XPlane::PlanesTransponders &planesTransponders);
//! \deprecated XSwiftBus::CTraffic::setInterpolatorMode
void setInterpolatorMode(const QString &callsign, bool spline);
//! \copydoc XSwiftBus::CTraffic::getRemoteAircraftData
void getRemoteAircraftData(const QStringList &callsigns, const RemoteAircraftDataCallback &setter) const;
//! \copydoc XSwiftBus::CTraffic::getElevationAtPosition
void getElevationAtPosition(const BlackMisc::Aviation::CCallsign &callsign, double latitudeDeg, double longitudeDeg, double altitudeMeters,
const ElevationCallback &setter) const;
//! \copydoc XSwiftBus::CTraffic::setFollowedAircraft
void setFollowedAircraft(const QString &callsign);
private:
BlackMisc::CGenericDBusInterface *m_dbusInterface = nullptr;
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,89 @@
/* Copyright (C) 2015
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
#include "xswiftbusweatherproxy.h"
#include <QLatin1String>
class QDBusConnection;
#define XSWIFTBUS_SERVICENAME "org.swift-project.xswiftbus"
namespace BlackSimPlugin
{
namespace XPlane
{
CXSwiftBusWeatherProxy::CXSwiftBusWeatherProxy(QDBusConnection &connection, QObject *parent) : QObject(parent)
{
m_dbusInterface = new BlackMisc::CGenericDBusInterface(XSWIFTBUS_SERVICENAME, ObjectPath(), InterfaceName(), connection, this);
}
bool CXSwiftBusWeatherProxy::isUsingRealWeather() const
{
return m_dbusInterface->callDBusRet<bool>(QLatin1String("isUsingRealWeather"));
}
void CXSwiftBusWeatherProxy::setUseRealWeather(bool enable)
{
m_dbusInterface->callDBus(QLatin1String("setUseRealWeather"), enable);
}
void CXSwiftBusWeatherProxy::setVisibility(double visibilityM)
{
m_dbusInterface->callDBus(QLatin1String("setVisibility"), visibilityM);
}
void CXSwiftBusWeatherProxy::setTemperature(int degreesC)
{
m_dbusInterface->callDBus(QLatin1String("setTemperature"), degreesC);
}
void CXSwiftBusWeatherProxy::setDewPoint(int degreesC)
{
m_dbusInterface->callDBus(QLatin1String("setDewPoint"), degreesC);
}
void CXSwiftBusWeatherProxy::setQNH(double inHg)
{
m_dbusInterface->callDBus(QLatin1String("setQNH"), inHg);
}
void CXSwiftBusWeatherProxy::setPrecipitationRatio(double precipRatio)
{
m_dbusInterface->callDBus(QLatin1String("setPrecipitationRatio"), precipRatio);
}
void CXSwiftBusWeatherProxy::setThunderstormRatio(double cbRatio)
{
m_dbusInterface->callDBus(QLatin1String("setThunderstormRatio"), cbRatio);
}
void CXSwiftBusWeatherProxy::setTurbulenceRatio(double turbulenceRatio)
{
m_dbusInterface->callDBus(QLatin1String("setTurbulenceRatio"), turbulenceRatio);
}
void CXSwiftBusWeatherProxy::setRunwayFriction(int friction)
{
m_dbusInterface->callDBus(QLatin1String("setRunwayFriction"), friction);
}
void CXSwiftBusWeatherProxy::setCloudLayer(int layer, int baseM, int topsM, int type, int coverage)
{
m_dbusInterface->callDBus(QLatin1String("setCloudLayer"), layer, baseM, topsM, type, coverage);
}
void CXSwiftBusWeatherProxy::setWindLayer(int layer, int altitudeM, double directionDeg, int speedKt, int shearDirectionDeg, int shearSpeedKt, int turbulence)
{
m_dbusInterface->callDBus(QLatin1String("setWindLayer"), layer, altitudeM, directionDeg, speedKt, shearDirectionDeg, shearSpeedKt, turbulence);
}
}
}

View File

@@ -0,0 +1,106 @@
/* Copyright (C) 2015
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
//! \file
#ifndef BLACKSIMPLUGIN_XSWIFTBUS_WEATHER_PROXY_H
#define BLACKSIMPLUGIN_XSWIFTBUS_WEATHER_PROXY_H
#include "blackmisc/genericdbusinterface.h"
#include <QObject>
#include <QString>
// clazy:excludeall=const-signal-or-slot
class QDBusConnection;
//! \cond PRIVATE
#define XSWIFTBUS_WEATHER_INTERFACENAME "org.swift_project.xswiftbus.weather"
#define XSWIFTBUS_WEATHER_OBJECTPATH "/xswiftbus/weather"
//! \endcond
namespace BlackSimPlugin
{
namespace XPlane
{
/*!
* Proxy object connected to a real XSwiftBus::CWeather object via DBus
*/
class CXSwiftBusWeatherProxy : public QObject
{
Q_OBJECT
public:
//! Service name
static const QString &InterfaceName()
{
static QString s(XSWIFTBUS_WEATHER_INTERFACENAME);
return s;
}
//! Service path
static const QString &ObjectPath()
{
static QString s(XSWIFTBUS_WEATHER_OBJECTPATH);
return s;
}
//! Constructor
CXSwiftBusWeatherProxy(QDBusConnection &connection, QObject *parent = nullptr);
//! Does the remote object exist?
bool isValid() const { return m_dbusInterface->isValid(); }
private:
BlackMisc::CGenericDBusInterface *m_dbusInterface = nullptr;
public slots:
//! \copydoc XSwiftBus::CWeather::isUsingRealWeather
bool isUsingRealWeather() const;
//! \copydoc XSwiftBus::CWeather::setUseRealWeather
void setUseRealWeather(bool enable);
//! \copydoc XSwiftBus::CWeather::setVisibility
void setVisibility(double visibilityM);
//! \copydoc XSwiftBus::CWeather::setTemperature
void setTemperature(int degreesC);
//! \copydoc XSwiftBus::CWeather::setDewPoint
void setDewPoint(int degreesC);
//! \copydoc XSwiftBus::CWeather::setQNH
void setQNH(double inHg);
//! \copydoc XSwiftBus::CWeather::setPrecipitationRatio
void setPrecipitationRatio(double precipRatio);
//! \copydoc XSwiftBus::CWeather::setThunderstormRatio
void setThunderstormRatio(double cbRatio);
//! \copydoc XSwiftBus::CWeather::setTurbulenceRatio
void setTurbulenceRatio(double turbulenceRatio);
//! \copydoc XSwiftBus::CWeather::setRunwayFriction
void setRunwayFriction(int friction);
//! \copydoc XSwiftBus::CWeather::setCloudLayer
void setCloudLayer(int layer, int baseM, int topsM, int type, int coverage);
//! \copydoc XSwiftBus::CWeather::setWindLayer
void setWindLayer(int layer, int altitudeM, double directionDeg, int speedKt, int shearDirectionDeg, int shearSpeedKt, int turbulence);
};
}
}
#endif // guard

View File

@@ -0,0 +1,29 @@
load(common_pre)
QT += core dbus network widgets
TARGET = simulatorflightgearconfig
TEMPLATE = lib
CONFIG += plugin shared
CONFIG += blackmisc blackcore blackgui
DEPENDPATH += . $$SourceRoot/src
INCLUDEPATH += . $$SourceRoot/src
SOURCES += *.cpp
HEADERS += *.h
FORMS += *.ui
DISTFILES += simulatorxplaneconfig.json
DESTDIR = $$DestRoot/bin/plugins/simulator
win32 {
dlltarget.path = $$PREFIX/bin/plugins/simulator
INSTALLS += dlltarget
} else {
target.path = $$PREFIX/bin/plugins/simulator
INSTALLS += target
}
load(common_post)

View File

@@ -0,0 +1,30 @@
/* Copyright (C) 2015
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
#include "simulatorxplaneconfig.h"
#include "simulatorxplaneconfigwindow.h"
class QWidget;
namespace BlackSimPlugin
{
namespace XPlane
{
CSimulatorXPlaneConfig::CSimulatorXPlaneConfig(QObject *parent) : QObject(parent)
{
}
BlackGui::CPluginConfigWindow *CSimulatorXPlaneConfig::createConfigWindow(QWidget *parent)
{
CSimulatorXPlaneConfigWindow* w = new CSimulatorXPlaneConfigWindow(parent);
return w;
}
}
}

View File

@@ -0,0 +1,50 @@
/* Copyright (C) 2015
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
//! \file
#ifndef BLACKSIMPLUGIN_SIMULATOR_XPLANE_CONFIG_H
#define BLACKSIMPLUGIN_SIMULATOR_XPLANE_CONFIG_H
#include "blackgui/pluginconfig.h"
#include "blackmisc/settingscache.h"
#include <QObject>
#include <QString>
class QWidget;
namespace BlackGui { class CPluginConfigWindow; }
namespace BlackSimPlugin
{
namespace XPlane
{
/*!
* Config plugin for the X-Plane plugin.
*/
class CSimulatorXPlaneConfig : public QObject, public BlackGui::IPluginConfig
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.swift-project.blackgui.pluginconfiginterface" FILE "simulatorxplaneconfig.json")
Q_INTERFACES(BlackGui::IPluginConfig)
public:
//! Ctor
CSimulatorXPlaneConfig(QObject *parent = nullptr);
//! Dtor
virtual ~CSimulatorXPlaneConfig() {}
//! \copydoc BlackGui::IPluginConfig::createConfigWindow()
BlackGui::CPluginConfigWindow *createConfigWindow(QWidget *parent) override;
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,3 @@
{
"identifier" : "org.swift-project.plugins.simulator.flightgear.config"
}

View File

@@ -0,0 +1,55 @@
/* Copyright (C) 2015
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
#include "simulatorxplaneconfigwindow.h"
#include "blackcore/application.h"
#include "ui_simulatorxplaneconfigwindow.h"
#include "blackmisc/simulation/xplane/xswiftbusconfigwriter.h"
#include <QComboBox>
#include <QDialogButtonBox>
using namespace BlackGui;
using namespace BlackMisc;
using namespace BlackMisc::Simulation::XPlane;
namespace BlackSimPlugin
{
namespace XPlane
{
CSimulatorXPlaneConfigWindow::CSimulatorXPlaneConfigWindow(QWidget *parent) :
CPluginConfigWindow(parent),
ui(new Ui::CSimulatorXPlaneConfigWindow)
{
ui->setupUi(this);
ui->comp_SettingsXSwiftBus->setDefaultP2PAddress(m_xswiftbusServerSetting.getDefault());
ui->comp_SettingsXSwiftBus->set(m_xswiftbusServerSetting.getThreadLocal());
connect(ui->bb_OkCancel, &QDialogButtonBox::accepted, this, &CSimulatorXPlaneConfigWindow::onSettingsAccepted);
connect(ui->bb_OkCancel, &QDialogButtonBox::rejected, this, &CSimulatorXPlaneConfigWindow::close);
}
CSimulatorXPlaneConfigWindow::~CSimulatorXPlaneConfigWindow()
{ }
void CSimulatorXPlaneConfigWindow::onSettingsAccepted()
{
const QString currentAddress = m_xswiftbusServerSetting.getThreadLocal();
const QString updatedAddress = ui->comp_SettingsXSwiftBus->getDBusAddress();
if (currentAddress != ui->comp_SettingsXSwiftBus->getDBusAddress())
{
m_xswiftbusServerSetting.set(updatedAddress);
CXSwiftBusConfigWriter xswiftbusConfigWriter;
xswiftbusConfigWriter.setDBusAddress(updatedAddress);
xswiftbusConfigWriter.updateInAllXPlaneVersions();
}
close();
}
} // ns
} // ns

View File

@@ -0,0 +1,50 @@
/* Copyright (C) 2015
* swift project Community / Contributors
*
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
//! \file
#ifndef BLACKSIMPLUGIN_SIMULATOR_XPLANE_CONFIG_WINDOW_H
#define BLACKSIMPLUGIN_SIMULATOR_XPLANE_CONFIG_WINDOW_H
#include "blackgui/pluginconfigwindow.h"
#include "blackmisc/simulation/settings/mysettings.h"
#include "simulatorxplaneconfig.h"
#include <QObject>
#include <QScopedPointer>
namespace Ui { class CSimulatorXPlaneConfigWindow; }
namespace BlackSimPlugin
{
namespace XPlane
{
/**
* A window that shows all the X-Plane plugin options.
*/
class CSimulatorXPlaneConfigWindow : public BlackGui::CPluginConfigWindow
{
Q_OBJECT
public:
//! Ctor.
CSimulatorXPlaneConfigWindow(QWidget *parent);
//! Dtor.
virtual ~CSimulatorXPlaneConfigWindow();
private:
//! Settings have been accepted
void onSettingsAccepted();
QScopedPointer<Ui::CSimulatorXPlaneConfigWindow> ui;
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TXSwiftBusServer> m_xswiftbusServerSetting { this };
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CSimulatorXPlaneConfigWindow</class>
<widget class="QWidget" name="CSimulatorXPlaneConfigWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>275</width>
<height>175</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>250</width>
<height>150</height>
</size>
</property>
<property name="windowTitle">
<string>X-Plane plugin settings</string>
</property>
<layout class="QGridLayout" name="gl_ConfigWindow">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<property name="horizontalSpacing">
<number>2</number>
</property>
<item row="1" column="0">
<widget class="QDialogButtonBox" name="bb_OkCancel">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
<property name="centerButtons">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="0" alignment="Qt::AlignTop">
<widget class="BlackGui::Components::CDBusServerAddressSelector" name="comp_SettingsXSwiftBus">
<property name="minimumSize">
<size>
<width>0</width>
<height>100</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>BlackGui::Components::CDBusServerAddressSelector</class>
<extends>QFrame</extends>
<header>blackgui/components/dbusserveraddressselector.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -30,4 +30,8 @@ swiftConfig(sims.xplane) {
SUBDIRS += xplane
SUBDIRS += xplaneconfig
}
swiftConfig(sims.fg) {
SUBDIRS += flightgear
SUBDIRS += flightgearconfig
}
load(common_post)