mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 19:29:45 +08:00
Refactoring code of FG plugin
This commit is contained in:
committed by
Mat Sutcliffe
parent
9363bf3b1f
commit
1b273a36dc
@@ -14,416 +14,398 @@
|
||||
|
||||
class QDBusConnection;
|
||||
|
||||
#define XSWIFTBUS_SERVICE_SERVICENAME "org.swift-project.xswiftbus"
|
||||
#define FGSWIFTBUS_SERVICE_SERVICENAME "org.swift-project.fgswiftbus"
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace XPlane
|
||||
namespace Flightgear
|
||||
{
|
||||
CXSwiftBusServiceProxy::CXSwiftBusServiceProxy(QDBusConnection &connection, QObject *parent, bool dummy) : QObject(parent)
|
||||
CFGSwiftBusServiceProxy::CFGSwiftBusServiceProxy(QDBusConnection &connection, QObject *parent, bool dummy) : QObject(parent)
|
||||
{
|
||||
m_dbusInterface = new BlackMisc::CGenericDBusInterface(XSWIFTBUS_SERVICE_SERVICENAME, ObjectPath(), InterfaceName(), connection, this);
|
||||
m_dbusInterface = new BlackMisc::CGenericDBusInterface(FGSWIFTBUS_SERVICE_SERVICENAME, ObjectPath(), InterfaceName(), connection, this);
|
||||
if (!dummy)
|
||||
{
|
||||
bool s;
|
||||
s = connection.connect(QString(), "/xswiftbus/service", "org.swift_project.xswiftbus.service",
|
||||
s = connection.connect(QString(), "/fgswiftbus/service", "org.swift_project.fgswiftbus.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",
|
||||
s = connection.connect(QString(), "/fgswiftbus/service", "org.swift_project.fgswiftbus.service",
|
||||
"airportsInRangeUpdated", this,
|
||||
SIGNAL(airportsInRangeUpdated(QStringList, QStringList, QList<double>, QList<double>, QList<double>)));
|
||||
Q_ASSERT(s);
|
||||
}
|
||||
}
|
||||
|
||||
QString CXSwiftBusServiceProxy::getVersionNumber()
|
||||
QString CFGSwiftBusServiceProxy::getVersionNumber()
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<QString>(QLatin1String("getVersionNumber"));
|
||||
}
|
||||
|
||||
void CXSwiftBusServiceProxy::getOwnAircraftSituationData(XPlaneData *o_xplaneData)
|
||||
void CFGSwiftBusServiceProxy::getOwnAircraftSituationData(FlightgearData *o_flightgearData)
|
||||
{
|
||||
QPointer<CXSwiftBusServiceProxy> myself(this);
|
||||
QPointer<CFGSwiftBusServiceProxy> 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>();
|
||||
o_flightgearData->latitudeDeg = reply.argumentAt<0>();
|
||||
o_flightgearData->longitudeDeg = reply.argumentAt<1>();
|
||||
o_flightgearData->altitudeM = reply.argumentAt<2>();
|
||||
o_flightgearData->groundspeedMs = reply.argumentAt<3>();
|
||||
o_flightgearData->pitchDeg = reply.argumentAt<4>();
|
||||
o_flightgearData->rollDeg = reply.argumentAt<5>();
|
||||
o_flightgearData->trueHeadingDeg = reply.argumentAt<6>();
|
||||
o_flightgearData->seaLevelPressureInHg = reply.argumentAt<7>();
|
||||
}
|
||||
watcher->deleteLater();
|
||||
};
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getOwnAircraftSituationData"), callback);
|
||||
}
|
||||
|
||||
void CXSwiftBusServiceProxy::addTextMessage(const QString &text)
|
||||
void CFGSwiftBusServiceProxy::addTextMessage(const QString &text)
|
||||
{
|
||||
m_dbusInterface->callDBus(QLatin1String("addTextMessage"), text);
|
||||
}
|
||||
|
||||
QString CXSwiftBusServiceProxy::getAircraftModelPath() const
|
||||
QString CFGSwiftBusServiceProxy::getAircraftModelPath() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<QString>(QLatin1String("getAircraftModelPath"));
|
||||
}
|
||||
void CXSwiftBusServiceProxy::getAircraftModelPathAsync(QString *o_modelPath)
|
||||
void CFGSwiftBusServiceProxy::getAircraftModelPathAsync(QString *o_modelPath)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getAircraftModelPath"), setterCallback(o_modelPath));
|
||||
}
|
||||
|
||||
QString CXSwiftBusServiceProxy::getAircraftModelFilename() const
|
||||
QString CFGSwiftBusServiceProxy::getAircraftModelFilename() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<QString>(QLatin1String("getAircraftModelFilename"));
|
||||
}
|
||||
void CXSwiftBusServiceProxy::getAircraftModelFilenameAsync(QString *o_modelFilename)
|
||||
void CFGSwiftBusServiceProxy::getAircraftModelFilenameAsync(QString *o_modelFilename)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getAircraftModelFilename"), setterCallback(o_modelFilename));
|
||||
}
|
||||
|
||||
QString CXSwiftBusServiceProxy::getAircraftLivery() const
|
||||
QString CFGSwiftBusServiceProxy::getAircraftLivery() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<QString>(QLatin1String("getAircraftLivery"));
|
||||
}
|
||||
void CXSwiftBusServiceProxy::getAircraftLiveryAsync(QString *o_modelLivery)
|
||||
void CFGSwiftBusServiceProxy::getAircraftLiveryAsync(QString *o_modelLivery)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getAircraftLivery"), setterCallback(o_modelLivery));
|
||||
}
|
||||
|
||||
QString CXSwiftBusServiceProxy::getAircraftIcaoCode() const
|
||||
QString CFGSwiftBusServiceProxy::getAircraftIcaoCode() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<QString>(QLatin1String("getAircraftIcaoCode"));
|
||||
}
|
||||
void CXSwiftBusServiceProxy::getAircraftIcaoCodeAsync(QString *o_icaoCode)
|
||||
void CFGSwiftBusServiceProxy::getAircraftIcaoCodeAsync(QString *o_icaoCode)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getAircraftIcaoCode"), setterCallback(o_icaoCode));
|
||||
}
|
||||
|
||||
QString CXSwiftBusServiceProxy::getAircraftDescription() const
|
||||
QString CFGSwiftBusServiceProxy::getAircraftDescription() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<QString>(QLatin1String("getAircraftDescription"));
|
||||
}
|
||||
void CXSwiftBusServiceProxy::getAircraftDescriptionAsync(QString *o_description)
|
||||
void CFGSwiftBusServiceProxy::getAircraftDescriptionAsync(QString *o_description)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getAircraftDescription"), setterCallback(o_description));
|
||||
}
|
||||
|
||||
QString CXSwiftBusServiceProxy::getAircraftModelString() const
|
||||
QString CFGSwiftBusServiceProxy::getAircraftModelString() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<QString>(QLatin1String("getAircraftModelString"));
|
||||
}
|
||||
void CXSwiftBusServiceProxy::getAircraftModelStringAsync(QString *o_modelString)
|
||||
void CFGSwiftBusServiceProxy::getAircraftModelStringAsync(QString *o_modelString)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getAircraftModelString"), setterCallback(o_modelString));
|
||||
}
|
||||
|
||||
QString CXSwiftBusServiceProxy::getAircraftName() const
|
||||
QString CFGSwiftBusServiceProxy::getAircraftName() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<QString>(QLatin1String("getAircraftName"));
|
||||
}
|
||||
void CXSwiftBusServiceProxy::getAircraftNameAsync(QString *o_name)
|
||||
void CFGSwiftBusServiceProxy::getAircraftNameAsync(QString *o_name)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getAircraftName"), setterCallback(o_name));
|
||||
}
|
||||
|
||||
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
|
||||
bool CFGSwiftBusServiceProxy::isPaused() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<bool>(QLatin1String("isPaused"));
|
||||
}
|
||||
void CXSwiftBusServiceProxy::isPausedAsync(bool *o_paused)
|
||||
void CFGSwiftBusServiceProxy::isPausedAsync(bool *o_paused)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("isPaused"), setterCallback(o_paused));
|
||||
}
|
||||
|
||||
double CXSwiftBusServiceProxy::getLatitudeDeg() const
|
||||
double CFGSwiftBusServiceProxy::getLatitudeDeg() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<double>(QLatin1String("getLatitudeDeg"));
|
||||
}
|
||||
void CXSwiftBusServiceProxy::getLatitudeDegAsync(double *o_latitude)
|
||||
void CFGSwiftBusServiceProxy::getLatitudeDegAsync(double *o_latitude)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getLatitudeDeg"), setterCallback(o_latitude));
|
||||
}
|
||||
|
||||
double CXSwiftBusServiceProxy::getLongitudeDeg() const
|
||||
double CFGSwiftBusServiceProxy::getLongitudeDeg() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<double>(QLatin1String("getLongitudeDeg"));
|
||||
}
|
||||
void CXSwiftBusServiceProxy::getLongitudeDegAsync(double *o_longitude)
|
||||
void CFGSwiftBusServiceProxy::getLongitudeDegAsync(double *o_longitude)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getLongitudeDeg"), setterCallback(o_longitude));
|
||||
}
|
||||
|
||||
double CXSwiftBusServiceProxy::getAltitudeMslFt() const
|
||||
double CFGSwiftBusServiceProxy::getAltitudeMslFt() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<double>(QLatin1String("getAltitudeMslFt"));
|
||||
}
|
||||
void CXSwiftBusServiceProxy::getAltitudeMslFtAsync(double *o_altitude)
|
||||
void CFGSwiftBusServiceProxy::getAltitudeMslFtAsync(double *o_altitude)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getAltitudeMslFt"), setterCallback(o_altitude));
|
||||
}
|
||||
|
||||
double CXSwiftBusServiceProxy::getHeightAglFt() const
|
||||
double CFGSwiftBusServiceProxy::getHeightAglFt() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<double>(QLatin1String("getHeightAglFt"));
|
||||
}
|
||||
void CXSwiftBusServiceProxy::getHeightAglFtAsync(double *o_height)
|
||||
void CFGSwiftBusServiceProxy::getHeightAglFtAsync(double *o_height)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getHeightAglFt"), setterCallback(o_height));
|
||||
}
|
||||
|
||||
double CXSwiftBusServiceProxy::getGroundSpeedKts() const
|
||||
double CFGSwiftBusServiceProxy::getGroundSpeedKts() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<double>(QLatin1String("getGroundSpeedKts"));
|
||||
}
|
||||
void CXSwiftBusServiceProxy::getGroundSpeedKtsAsync(double *o_groundspeed)
|
||||
void CFGSwiftBusServiceProxy::getGroundSpeedKtsAsync(double *o_groundspeed)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getGroundSpeedKts"), setterCallback(o_groundspeed));
|
||||
}
|
||||
|
||||
double CXSwiftBusServiceProxy::getPitchDeg() const
|
||||
double CFGSwiftBusServiceProxy::getPitchDeg() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<double>(QLatin1String("getPitchDeg"));
|
||||
}
|
||||
void CXSwiftBusServiceProxy::getPitchDegAsync(double *o_pitch)
|
||||
void CFGSwiftBusServiceProxy::getPitchDegAsync(double *o_pitch)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getPitchDeg"), setterCallback(o_pitch));
|
||||
}
|
||||
|
||||
double CXSwiftBusServiceProxy::getRollDeg() const
|
||||
double CFGSwiftBusServiceProxy::getRollDeg() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<double>(QLatin1String("getRollDeg"));
|
||||
}
|
||||
void CXSwiftBusServiceProxy::getRollDegAsync(double *o_roll)
|
||||
void CFGSwiftBusServiceProxy::getRollDegAsync(double *o_roll)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getRollDeg"), setterCallback(o_roll));
|
||||
}
|
||||
|
||||
bool CXSwiftBusServiceProxy::getAllWheelsOnGround() const
|
||||
bool CFGSwiftBusServiceProxy::getAllWheelsOnGround() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<bool>(QLatin1String("getAllWheelsOnGround"));
|
||||
}
|
||||
void CXSwiftBusServiceProxy::getAllWheelsOnGroundAsync(bool *o_allWheels)
|
||||
void CFGSwiftBusServiceProxy::getAllWheelsOnGroundAsync(bool *o_allWheels)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getAllWheelsOnGround"), setterCallback(o_allWheels));
|
||||
}
|
||||
|
||||
int CXSwiftBusServiceProxy::getCom1ActiveKhz() const
|
||||
int CFGSwiftBusServiceProxy::getCom1ActiveKhz() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<int>(QLatin1String("getCom1ActiveKhz"));
|
||||
}
|
||||
void CXSwiftBusServiceProxy::getCom1ActiveKhzAsync(int *o_com1Active)
|
||||
void CFGSwiftBusServiceProxy::getCom1ActiveKhzAsync(int *o_com1Active)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getCom1ActiveKhz"), setterCallback(o_com1Active));
|
||||
}
|
||||
|
||||
int CXSwiftBusServiceProxy::getCom1StandbyKhz() const
|
||||
int CFGSwiftBusServiceProxy::getCom1StandbyKhz() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<int>(QLatin1String("getCom1StandbyKhz"));
|
||||
}
|
||||
void CXSwiftBusServiceProxy::getCom1StandbyKhzAsync(int *o_com1Standby)
|
||||
void CFGSwiftBusServiceProxy::getCom1StandbyKhzAsync(int *o_com1Standby)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getCom1StandbyKhz"), setterCallback(o_com1Standby));
|
||||
}
|
||||
|
||||
int CXSwiftBusServiceProxy::getCom2ActiveKhz() const
|
||||
int CFGSwiftBusServiceProxy::getCom2ActiveKhz() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<int>(QLatin1String("getCom2ActiveKhz"));
|
||||
}
|
||||
void CXSwiftBusServiceProxy::getCom2ActiveKhzAsync(int *o_com2Active)
|
||||
void CFGSwiftBusServiceProxy::getCom2ActiveKhzAsync(int *o_com2Active)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getCom2ActiveKhz"), setterCallback(o_com2Active));
|
||||
}
|
||||
|
||||
int CXSwiftBusServiceProxy::getCom2StandbyKhz() const
|
||||
int CFGSwiftBusServiceProxy::getCom2StandbyKhz() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<int>(QLatin1String("getCom2StandbyKhz"));
|
||||
}
|
||||
void CXSwiftBusServiceProxy::getCom2StandbyKhzAsync(int *o_com2Standby)
|
||||
void CFGSwiftBusServiceProxy::getCom2StandbyKhzAsync(int *o_com2Standby)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getCom2StandbyKhz"), setterCallback(o_com2Standby));
|
||||
}
|
||||
|
||||
int CXSwiftBusServiceProxy::getTransponderCode() const
|
||||
int CFGSwiftBusServiceProxy::getTransponderCode() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<int>(QLatin1String("getTransponderCode"));
|
||||
}
|
||||
void CXSwiftBusServiceProxy::getTransponderCodeAsync(int *o_xpdrCode)
|
||||
void CFGSwiftBusServiceProxy::getTransponderCodeAsync(int *o_xpdrCode)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getTransponderCode"), setterCallback(o_xpdrCode));
|
||||
}
|
||||
|
||||
int CXSwiftBusServiceProxy::getTransponderMode() const
|
||||
int CFGSwiftBusServiceProxy::getTransponderMode() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<int>(QLatin1String("getTransponderMode"));
|
||||
}
|
||||
void CXSwiftBusServiceProxy::getTransponderModeAsync(int *o_xpdrMode)
|
||||
void CFGSwiftBusServiceProxy::getTransponderModeAsync(int *o_xpdrMode)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getTransponderMode"), setterCallback(o_xpdrMode));
|
||||
}
|
||||
|
||||
bool CXSwiftBusServiceProxy::getTransponderIdent() const
|
||||
bool CFGSwiftBusServiceProxy::getTransponderIdent() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<bool>(QLatin1String("getTransponderIdent"));
|
||||
}
|
||||
void CXSwiftBusServiceProxy::getTransponderIdentAsync(bool *o_ident)
|
||||
void CFGSwiftBusServiceProxy::getTransponderIdentAsync(bool *o_ident)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getTransponderIdent"), setterCallback(o_ident));
|
||||
}
|
||||
|
||||
bool CXSwiftBusServiceProxy::getBeaconLightsOn() const
|
||||
bool CFGSwiftBusServiceProxy::getBeaconLightsOn() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<bool>(QLatin1String("getBeaconLightsOn"));
|
||||
}
|
||||
|
||||
void CXSwiftBusServiceProxy::getBeaconLightsOnAsync(bool *o_beaconLightsOn)
|
||||
void CFGSwiftBusServiceProxy::getBeaconLightsOnAsync(bool *o_beaconLightsOn)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getBeaconLightsOn"), setterCallback(o_beaconLightsOn));
|
||||
}
|
||||
|
||||
bool CXSwiftBusServiceProxy::getLandingLightsOn() const
|
||||
bool CFGSwiftBusServiceProxy::getLandingLightsOn() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<bool>(QLatin1String("getLandingLightsOn"));
|
||||
}
|
||||
|
||||
void CXSwiftBusServiceProxy::getLandingLightsOnAsync(bool *o_landingLightsOn)
|
||||
void CFGSwiftBusServiceProxy::getLandingLightsOnAsync(bool *o_landingLightsOn)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getLandingLightsOn"), setterCallback(o_landingLightsOn));
|
||||
}
|
||||
|
||||
bool CXSwiftBusServiceProxy::getNavLightsOn() const
|
||||
bool CFGSwiftBusServiceProxy::getNavLightsOn() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<bool>(QLatin1String("getNavLightsOn"));
|
||||
}
|
||||
|
||||
void CXSwiftBusServiceProxy::getNavLightsOnAsync(bool *o_navLightsOn)
|
||||
void CFGSwiftBusServiceProxy::getNavLightsOnAsync(bool *o_navLightsOn)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getNavLightsOn"), setterCallback(o_navLightsOn));
|
||||
}
|
||||
|
||||
bool CXSwiftBusServiceProxy::getStrobeLightsOn() const
|
||||
bool CFGSwiftBusServiceProxy::getStrobeLightsOn() const
|
||||
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<bool>(QLatin1String("getStrobeLightsOn"));
|
||||
}
|
||||
|
||||
void CXSwiftBusServiceProxy::getStrobeLightsOnAsync(bool *o_strobeLightsOn)
|
||||
void CFGSwiftBusServiceProxy::getStrobeLightsOnAsync(bool *o_strobeLightsOn)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getStrobeLightsOn"), setterCallback(o_strobeLightsOn));
|
||||
}
|
||||
|
||||
bool CXSwiftBusServiceProxy::getTaxiLightsOn() const
|
||||
bool CFGSwiftBusServiceProxy::getTaxiLightsOn() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<bool>(QLatin1String("getTaxiLightsOn"));
|
||||
}
|
||||
|
||||
void CXSwiftBusServiceProxy::getTaxiLightsOnAsync(bool *o_taxiLightsOn)
|
||||
void CFGSwiftBusServiceProxy::getTaxiLightsOnAsync(bool *o_taxiLightsOn)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getTaxiLightsOn"), setterCallback(o_taxiLightsOn));
|
||||
}
|
||||
|
||||
|
||||
double CXSwiftBusServiceProxy::getQNHInHg() const
|
||||
double CFGSwiftBusServiceProxy::getQNHInHg() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<double>(QLatin1String("getQNHInHg"));
|
||||
}
|
||||
|
||||
void CXSwiftBusServiceProxy::getQNHInHgAsync(double *o_qnh)
|
||||
void CFGSwiftBusServiceProxy::getQNHInHgAsync(double *o_qnh)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getQNHInHg"), setterCallback(o_qnh));
|
||||
}
|
||||
|
||||
|
||||
void CXSwiftBusServiceProxy::setCom1ActiveKhz(int freq)
|
||||
void CFGSwiftBusServiceProxy::setCom1ActiveKhz(int freq)
|
||||
{
|
||||
m_dbusInterface->callDBus(QLatin1String("setCom1ActiveKhz"), freq);
|
||||
}
|
||||
|
||||
void CXSwiftBusServiceProxy::setCom1StandbyKhz(int freq)
|
||||
void CFGSwiftBusServiceProxy::setCom1StandbyKhz(int freq)
|
||||
{
|
||||
m_dbusInterface->callDBus(QLatin1String("setCom1StandbyKhz"), freq);
|
||||
}
|
||||
|
||||
void CXSwiftBusServiceProxy::setCom2ActiveKhz(int freq)
|
||||
void CFGSwiftBusServiceProxy::setCom2ActiveKhz(int freq)
|
||||
{
|
||||
m_dbusInterface->callDBus(QLatin1String("setCom2ActiveKhz"), freq);
|
||||
}
|
||||
|
||||
void CXSwiftBusServiceProxy::setCom2StandbyKhz(int freq)
|
||||
void CFGSwiftBusServiceProxy::setCom2StandbyKhz(int freq)
|
||||
{
|
||||
m_dbusInterface->callDBus(QLatin1String("setCom2StandbyKhz"), freq);
|
||||
}
|
||||
|
||||
void CXSwiftBusServiceProxy::setTransponderCode(int code)
|
||||
void CFGSwiftBusServiceProxy::setTransponderCode(int code)
|
||||
{
|
||||
m_dbusInterface->callDBus(QLatin1String("setTransponderCode"), code);
|
||||
}
|
||||
|
||||
void CXSwiftBusServiceProxy::setTransponderMode(int mode)
|
||||
void CFGSwiftBusServiceProxy::setTransponderMode(int mode)
|
||||
{
|
||||
m_dbusInterface->callDBus(QLatin1String("setTransponderMode"), mode);
|
||||
}
|
||||
double CXSwiftBusServiceProxy::getFlapsDeployRatio() const
|
||||
double CFGSwiftBusServiceProxy::getFlapsDeployRatio() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<double>(QLatin1String("getFlapsDeployRatio"));
|
||||
}
|
||||
|
||||
void CXSwiftBusServiceProxy::getFlapsDeployRatioAsync(double *o_flapsDeployRatio)
|
||||
void CFGSwiftBusServiceProxy::getFlapsDeployRatioAsync(double *o_flapsDeployRatio)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getFlapsDeployRatio"), setterCallback(o_flapsDeployRatio));
|
||||
}
|
||||
|
||||
double CXSwiftBusServiceProxy::getGearDeployRatio() const
|
||||
double CFGSwiftBusServiceProxy::getGearDeployRatio() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<double>(QLatin1String("getGearDeployRatio"));
|
||||
}
|
||||
|
||||
void CXSwiftBusServiceProxy::getGearDeployRatioAsync(double *o_gearDeployRatio)
|
||||
void CFGSwiftBusServiceProxy::getGearDeployRatioAsync(double *o_gearDeployRatio)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getGearDeployRatio"), setterCallback(o_gearDeployRatio));
|
||||
}
|
||||
|
||||
QList<double> CXSwiftBusServiceProxy::getEngineN1Percentage() const
|
||||
QList<double> CFGSwiftBusServiceProxy::getEngineN1Percentage() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<QList<double>>(QLatin1String("getEngineN1Percentage"));
|
||||
}
|
||||
|
||||
void CXSwiftBusServiceProxy::getEngineN1PercentageAsync(QList<double> *o_engineN1Percentage)
|
||||
void CFGSwiftBusServiceProxy::getEngineN1PercentageAsync(QList<double> *o_engineN1Percentage)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getEngineN1Percentage"), setterCallback(o_engineN1Percentage));
|
||||
}
|
||||
|
||||
double CXSwiftBusServiceProxy::getSpeedBrakeRatio() const
|
||||
double CFGSwiftBusServiceProxy::getSpeedBrakeRatio() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<double>(QLatin1String("getSpeedBrakeRatio"));
|
||||
}
|
||||
|
||||
void CXSwiftBusServiceProxy::getSpeedBrakeRatioAsync(double *o_speedBrakeRatio)
|
||||
void CFGSwiftBusServiceProxy::getSpeedBrakeRatioAsync(double *o_speedBrakeRatio)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getSpeedBrakeRatio"), setterCallback(o_speedBrakeRatio));
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKSIMPLUGIN_XSWIFTBUS_SERVICE_PROXY_H
|
||||
#define BLACKSIMPLUGIN_XSWIFTBUS_SERVICE_PROXY_H
|
||||
#ifndef BLACKSIMPLUGIN_FGSWIFTBUS_SERVICE_PROXY_H
|
||||
#define BLACKSIMPLUGIN_FGSWIFTBUS_SERVICE_PROXY_H
|
||||
|
||||
#include "blackmisc/genericdbusinterface.h"
|
||||
|
||||
@@ -27,20 +27,20 @@ class QDBusConnection;
|
||||
class QDBusPendingCallWatcher;
|
||||
|
||||
//! \cond PRIVATE
|
||||
#define XSWIFTBUS_SERVICE_INTERFACENAME "org.swift_project.xswiftbus.service"
|
||||
#define XSWIFTBUS_SERVICE_OBJECTPATH "/xswiftbus/service"
|
||||
#define FGSWIFTBUS_SERVICE_INTERFACENAME "org.swift_project.fgswiftbus.service"
|
||||
#define FGSWIFTBUS_SERVICE_OBJECTPATH "/fgswiftbus/service"
|
||||
//! \endcond
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace XPlane
|
||||
namespace Flightgear
|
||||
{
|
||||
struct XPlaneData;
|
||||
struct FlightgearData;
|
||||
|
||||
/*!
|
||||
* Proxy object connected to a real XSwiftBus::CService object via DBus
|
||||
* Proxy object connected to a real FGSwiftBus::CService object via DBus
|
||||
*/
|
||||
class CXSwiftBusServiceProxy : public QObject
|
||||
class CFGSwiftBusServiceProxy : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -48,19 +48,19 @@ namespace BlackSimPlugin
|
||||
//! Service name
|
||||
static const QString &InterfaceName()
|
||||
{
|
||||
static const QString s(XSWIFTBUS_SERVICE_INTERFACENAME);
|
||||
static const QString s(FGSWIFTBUS_SERVICE_INTERFACENAME);
|
||||
return s;
|
||||
}
|
||||
|
||||
//! Service path
|
||||
static const QString &ObjectPath()
|
||||
{
|
||||
static const QString s(XSWIFTBUS_SERVICE_OBJECTPATH);
|
||||
static const QString s(FGSWIFTBUS_SERVICE_OBJECTPATH);
|
||||
return s;
|
||||
}
|
||||
|
||||
//! Constructor
|
||||
CXSwiftBusServiceProxy(QDBusConnection &connection, QObject *parent = nullptr, bool dummy = false);
|
||||
CFGSwiftBusServiceProxy(QDBusConnection &connection, QObject *parent = nullptr, bool dummy = false);
|
||||
|
||||
//! Does the remote object exist?
|
||||
bool isValid() const { return m_dbusInterface->isValid(); }
|
||||
@@ -97,112 +97,100 @@ namespace BlackSimPlugin
|
||||
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
|
||||
//! Get FGSwiftBus version number
|
||||
QString getVersionNumber();
|
||||
|
||||
//! Get own aircraft situation data
|
||||
void getOwnAircraftSituationData(BlackSimPlugin::XPlane::XPlaneData *o_xplaneData);
|
||||
void getOwnAircraftSituationData(BlackSimPlugin::Flightgear::FlightgearData *o_flightgearData);
|
||||
|
||||
//! \copydoc XSwiftBus::CService::addTextMessage
|
||||
//! \copydoc FGSwiftBus::CService::addTextMessage
|
||||
void addTextMessage(const QString &text);
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getAircraftModelPath
|
||||
//! \copydoc FGSwiftBus::CService::getAircraftModelPath
|
||||
//! @{
|
||||
QString getAircraftModelPath() const;
|
||||
void getAircraftModelPathAsync(QString *o_modelPath);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getAircraftModelFilename
|
||||
//! \copydoc FGSwiftBus::CService::getAircraftModelFilename
|
||||
//! @{
|
||||
QString getAircraftModelFilename() const;
|
||||
void getAircraftModelFilenameAsync(QString *o_modelFilename);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getAircraftLivery
|
||||
//! \copydoc FGSwiftBus::CService::getAircraftLivery
|
||||
//! @{
|
||||
QString getAircraftLivery() const;
|
||||
void getAircraftLiveryAsync(QString *o_modelLivery);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getAircraftIcaoCode
|
||||
//! \copydoc FGSwiftBus::CService::getAircraftIcaoCode
|
||||
//! @{
|
||||
QString getAircraftIcaoCode() const;
|
||||
void getAircraftIcaoCodeAsync(QString *o_icaoCode);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getAircraftDescription
|
||||
//! \copydoc FGSwiftBus::CService::getAircraftDescription
|
||||
//! @{
|
||||
QString getAircraftDescription() const;
|
||||
void getAircraftDescriptionAsync(QString *o_description);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getAircraftModelString
|
||||
//! \copydoc FGSwiftBus::CService::getAircraftModelString
|
||||
//! @{
|
||||
QString getAircraftModelString() const;
|
||||
void getAircraftModelStringAsync(QString *o_modelString);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getAircraftName
|
||||
//! \copydoc FGSwiftBus::CService::getAircraftName
|
||||
//! @{
|
||||
QString getAircraftName() const;
|
||||
void getAircraftNameAsync(QString *o_name);
|
||||
//! @}
|
||||
|
||||
//! \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
|
||||
//! \copydoc FGSwiftBus::CService::isPaused
|
||||
//! @{
|
||||
bool isPaused() const;
|
||||
void isPausedAsync(bool *o_paused);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getLatitudeDeg
|
||||
//! \copydoc FGSwiftBus::CService::getLatitudeDeg
|
||||
//! @{
|
||||
double getLatitudeDeg() const;
|
||||
void getLatitudeDegAsync(double *o_latitude);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getLongitudeDeg
|
||||
//! \copydoc FGSwiftBus::CService::getLongitudeDeg
|
||||
//! @{
|
||||
double getLongitudeDeg() const;
|
||||
void getLongitudeDegAsync(double *o_longitude);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getAltitudeMslFt
|
||||
//! \copydoc FGSwiftBus::CService::getAltitudeMslFt
|
||||
//! @{
|
||||
double getAltitudeMslFt() const;
|
||||
void getAltitudeMslFtAsync(double *o_altitude);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getHeightAglFt
|
||||
//! \copydoc FGSwiftBus::CService::getHeightAglFt
|
||||
//! @{
|
||||
double getHeightAglFt() const;
|
||||
void getHeightAglFtAsync(double *o_height);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getGroundSpeedKts
|
||||
//! \copydoc FGSwiftBus::CService::getGroundSpeedKts
|
||||
//! @{
|
||||
double getGroundSpeedKts() const;
|
||||
void getGroundSpeedKtsAsync(double *o_groundspeed);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getPitchDeg
|
||||
//! \copydoc FGSwiftBus::CService::getPitchDeg
|
||||
//! @{
|
||||
double getPitchDeg() const;
|
||||
void getPitchDegAsync(double *o_pitch);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getRollDeg
|
||||
//! \copydoc FGSwiftBus::CService::getRollDeg
|
||||
//! @{
|
||||
double getRollDeg() const;
|
||||
void getRollDegAsync(double *o_roll);
|
||||
@@ -214,122 +202,122 @@ namespace BlackSimPlugin
|
||||
void getAllWheelsOnGroundAsync(bool *o_allWheels);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getCom1ActiveKhz
|
||||
//! \copydoc FGSwiftBus::CService::getCom1ActiveKhz
|
||||
//! @{
|
||||
int getCom1ActiveKhz() const;
|
||||
void getCom1ActiveKhzAsync(int *o_com1Active);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getCom1StandbyKhz
|
||||
//! \copydoc FGSwiftBus::CService::getCom1StandbyKhz
|
||||
//! @{
|
||||
int getCom1StandbyKhz() const;
|
||||
void getCom1StandbyKhzAsync(int *o_com1Standby);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getCom2ActiveKhz
|
||||
//! \copydoc FGSwiftBus::CService::getCom2ActiveKhz
|
||||
//! @{
|
||||
int getCom2ActiveKhz() const;
|
||||
void getCom2ActiveKhzAsync(int *o_com2Active);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getCom2StandbyKhz
|
||||
//! \copydoc FGSwiftBus::CService::getCom2StandbyKhz
|
||||
//! @{
|
||||
int getCom2StandbyKhz() const;
|
||||
void getCom2StandbyKhzAsync(int *o_com2Standby);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getTransponderCode
|
||||
//! \copydoc FGSwiftBus::CService::getTransponderCode
|
||||
//! @{
|
||||
int getTransponderCode() const;
|
||||
void getTransponderCodeAsync(int *o_xpdrCode);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getTransponderMode
|
||||
//! \copydoc FGSwiftBus::CService::getTransponderMode
|
||||
//! @{
|
||||
int getTransponderMode() const;
|
||||
void getTransponderModeAsync(int *o_xpdrMode);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getTransponderIdent
|
||||
//! \copydoc FGSwiftBus::CService::getTransponderIdent
|
||||
//! @{
|
||||
bool getTransponderIdent() const;
|
||||
void getTransponderIdentAsync(bool *o_ident);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getLandingLightsOn
|
||||
//! \copydoc FGSwiftBus::CService::getLandingLightsOn
|
||||
//! @{
|
||||
bool getBeaconLightsOn() const;
|
||||
void getBeaconLightsOnAsync(bool *o_beaconLightsOn);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getLandingLightsOn
|
||||
//! \copydoc FGSwiftBus::CService::getLandingLightsOn
|
||||
//! @{
|
||||
bool getLandingLightsOn() const;
|
||||
void getLandingLightsOnAsync(bool *o_landingLightsOn);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getNavLightsOn
|
||||
//! \copydoc FGSwiftBus::CService::getNavLightsOn
|
||||
//! @{
|
||||
bool getNavLightsOn() const;
|
||||
void getNavLightsOnAsync(bool *o_navLightsOn);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getStrobeLightsOn
|
||||
//! \copydoc FGSwiftBus::CService::getStrobeLightsOn
|
||||
//! @{
|
||||
bool getStrobeLightsOn() const;
|
||||
void getStrobeLightsOnAsync(bool *o_strobeLightsOn);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getTaxiLightsOn
|
||||
//! \copydoc FGSwiftBus::CService::getTaxiLightsOn
|
||||
//! @{
|
||||
bool getTaxiLightsOn() const;
|
||||
void getTaxiLightsOnAsync(bool *o_taxiLightsOn);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getQNHInHg
|
||||
//! \copydoc FGSwiftBus::CService::getQNHInHg
|
||||
//! @{
|
||||
double getQNHInHg() const;
|
||||
void getQNHInHgAsync(double *o_qnh);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::setCom1ActiveKhz
|
||||
//! \copydoc FGSwiftBus::CService::setCom1ActiveKhz
|
||||
void setCom1ActiveKhz(int freq);
|
||||
|
||||
//! \copydoc XSwiftBus::CService::setCom1StandbyKhz
|
||||
//! \copydoc FGSwiftBus::CService::setCom1StandbyKhz
|
||||
void setCom1StandbyKhz(int freq);
|
||||
|
||||
//! \copydoc XSwiftBus::CService::setCom2ActiveKhz
|
||||
//! \copydoc FGSwiftBus::CService::setCom2ActiveKhz
|
||||
void setCom2ActiveKhz(int freq);
|
||||
|
||||
//! \copydoc XSwiftBus::CService::setCom2StandbyKhz
|
||||
//! \copydoc FGSwiftBus::CService::setCom2StandbyKhz
|
||||
void setCom2StandbyKhz(int freq);
|
||||
|
||||
//! \copydoc XSwiftBus::CService::setTransponderCode
|
||||
//! \copydoc FGSwiftBus::CService::setTransponderCode
|
||||
void setTransponderCode(int code);
|
||||
|
||||
//! \copydoc XSwiftBus::CService::setTransponderMode
|
||||
//! \copydoc FGSwiftBus::CService::setTransponderMode
|
||||
void setTransponderMode(int mode);
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getFlapsDeployRatio
|
||||
//! \copydoc FGSwiftBus::CService::getFlapsDeployRatio
|
||||
|
||||
//! @{
|
||||
double getFlapsDeployRatio() const;
|
||||
void getFlapsDeployRatioAsync(double *o_flapsDeployRatio);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getGearDeployRatio
|
||||
//! \copydoc FGSwiftBus::CService::getGearDeployRatio
|
||||
//! @{
|
||||
double getGearDeployRatio() const;
|
||||
void getGearDeployRatioAsync(double *o_gearDeployRatio);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getEngineN1Percentage
|
||||
//! \copydoc FGSwiftBus::CService::getEngineN1Percentage
|
||||
//! @{
|
||||
QList<double> getEngineN1Percentage() const;
|
||||
void getEngineN1PercentageAsync(QList<double> *o_engineN1Percentage);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getSpeedBrakeRatio
|
||||
//! \copydoc FGSwiftBus::CService::getSpeedBrakeRatio
|
||||
//! @{
|
||||
double getSpeedBrakeRatio() const;
|
||||
void getSpeedBrakeRatioAsync(double *o_speedBrakeRatio);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <QLatin1String>
|
||||
#include <QDBusConnection>
|
||||
|
||||
#define XSWIFTBUS_SERVICENAME "org.swift-project.xswiftbus"
|
||||
#define FGSWIFTBUS_SERVICENAME "org.swift-project.fgswiftbus"
|
||||
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Geo;
|
||||
@@ -18,35 +18,35 @@ using namespace BlackMisc::PhysicalQuantities;
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace XPlane
|
||||
namespace Flightgear
|
||||
{
|
||||
CXSwiftBusTrafficProxy::CXSwiftBusTrafficProxy(QDBusConnection &connection, QObject *parent, bool dummy) : QObject(parent)
|
||||
CFGSwiftBusTrafficProxy::CFGSwiftBusTrafficProxy(QDBusConnection &connection, QObject *parent, bool dummy) : QObject(parent)
|
||||
{
|
||||
m_dbusInterface = new BlackMisc::CGenericDBusInterface(XSWIFTBUS_SERVICENAME, ObjectPath(), InterfaceName(), connection, this);
|
||||
m_dbusInterface = new BlackMisc::CGenericDBusInterface(FGSWIFTBUS_SERVICENAME, ObjectPath(), InterfaceName(), connection, this);
|
||||
if (!dummy)
|
||||
{
|
||||
bool s;
|
||||
s = connection.connect(QString(), "/xswiftbus/traffic", "org.swift_project.xswiftbus.traffic",
|
||||
s = connection.connect(QString(), "/fgswiftbus/traffic", "org.swift_project.fgswiftbus.traffic",
|
||||
"simFrame", this, SIGNAL(simFrame()));
|
||||
Q_ASSERT(s);
|
||||
|
||||
s = connection.connect(QString(), "/xswiftbus/traffic", "org.swift_project.xswiftbus.traffic",
|
||||
s = connection.connect(QString(), "/fgswiftbus/traffic", "org.swift_project.fgswiftbus.traffic",
|
||||
"remoteAircraftAdded", this, SIGNAL(remoteAircraftAdded(QString)));
|
||||
Q_ASSERT(s);
|
||||
|
||||
s = connection.connect(QString(), "/xswiftbus/traffic", "org.swift_project.xswiftbus.traffic",
|
||||
s = connection.connect(QString(), "/fgswiftbus/traffic", "org.swift_project.fgswiftbus.traffic",
|
||||
"remoteAircraftAddingFailed", this, SIGNAL(remoteAircraftAddingFailed(QString)));
|
||||
Q_ASSERT(s);
|
||||
}
|
||||
}
|
||||
|
||||
MultiplayerAcquireInfo CXSwiftBusTrafficProxy::acquireMultiplayerPlanes()
|
||||
MultiplayerAcquireInfo CFGSwiftBusTrafficProxy::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();
|
||||
BlackMisc::CLogMessage(this).debug(u"CFGSwiftBusTrafficProxy::acquireMultiplayerPlanes returned: %1") << reply.error().message();
|
||||
}
|
||||
MultiplayerAcquireInfo info;
|
||||
info.hasAcquired = reply.argumentAt<0>();
|
||||
@@ -54,62 +54,62 @@ namespace BlackSimPlugin
|
||||
return info;
|
||||
}
|
||||
|
||||
bool CXSwiftBusTrafficProxy::initialize()
|
||||
bool CFGSwiftBusTrafficProxy::initialize()
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<bool>(QLatin1String("initialize"));
|
||||
}
|
||||
|
||||
void CXSwiftBusTrafficProxy::cleanup()
|
||||
void CFGSwiftBusTrafficProxy::cleanup()
|
||||
{
|
||||
m_dbusInterface->callDBus(QLatin1String("cleanup"));
|
||||
}
|
||||
|
||||
bool CXSwiftBusTrafficProxy::loadPlanesPackage(const QString &path)
|
||||
bool CFGSwiftBusTrafficProxy::loadPlanesPackage(const QString &path)
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<bool>(QLatin1String("loadPlanesPackage"), path);
|
||||
}
|
||||
|
||||
void CXSwiftBusTrafficProxy::setDefaultIcao(const QString &defaultIcao)
|
||||
void CFGSwiftBusTrafficProxy::setDefaultIcao(const QString &defaultIcao)
|
||||
{
|
||||
m_dbusInterface->callDBus(QLatin1String("setDefaultIcao"), defaultIcao);
|
||||
}
|
||||
|
||||
void CXSwiftBusTrafficProxy::setDrawingLabels(bool drawing)
|
||||
void CFGSwiftBusTrafficProxy::setDrawingLabels(bool drawing)
|
||||
{
|
||||
m_dbusInterface->callDBus(QLatin1String("setDrawingLabels"), drawing);
|
||||
}
|
||||
|
||||
bool CXSwiftBusTrafficProxy::isDrawingLabels() const
|
||||
bool CFGSwiftBusTrafficProxy::isDrawingLabels() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<bool>(QLatin1String("isDrawingLabels"));
|
||||
}
|
||||
|
||||
void CXSwiftBusTrafficProxy::setMaxPlanes(int planes)
|
||||
void CFGSwiftBusTrafficProxy::setMaxPlanes(int planes)
|
||||
{
|
||||
m_dbusInterface->callDBus(QLatin1String("setMaxPlanes"), planes);
|
||||
}
|
||||
|
||||
void CXSwiftBusTrafficProxy::setMaxDrawDistance(double nauticalMiles)
|
||||
void CFGSwiftBusTrafficProxy::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)
|
||||
void CFGSwiftBusTrafficProxy::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)
|
||||
void CFGSwiftBusTrafficProxy::removePlane(const QString &callsign)
|
||||
{
|
||||
m_dbusInterface->callDBus(QLatin1String("removePlane"), callsign);
|
||||
}
|
||||
|
||||
void CXSwiftBusTrafficProxy::removeAllPlanes()
|
||||
void CFGSwiftBusTrafficProxy::removeAllPlanes()
|
||||
{
|
||||
m_dbusInterface->callDBus(QLatin1String("removeAllPlanes"));
|
||||
}
|
||||
|
||||
void CXSwiftBusTrafficProxy::setPlanesPositions(const PlanesPositions &planesPositions)
|
||||
void CFGSwiftBusTrafficProxy::setPlanesPositions(const PlanesPositions &planesPositions)
|
||||
{
|
||||
m_dbusInterface->callDBus(QLatin1String("setPlanesPositions"),
|
||||
planesPositions.callsigns, planesPositions.latitudesDeg, planesPositions.longitudesDeg,
|
||||
@@ -117,19 +117,19 @@ namespace BlackSimPlugin
|
||||
planesPositions.headingsDeg, planesPositions.onGrounds);
|
||||
}
|
||||
|
||||
void CXSwiftBusTrafficProxy::setPlanesTransponders(const PlanesTransponders &planesTransponders)
|
||||
void CFGSwiftBusTrafficProxy::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)
|
||||
void CFGSwiftBusTrafficProxy::setInterpolatorMode(const QString &callsign, bool spline)
|
||||
{
|
||||
m_dbusInterface->callDBus(QLatin1String("setInterpolatorMode"), callsign, spline);
|
||||
}
|
||||
|
||||
void CXSwiftBusTrafficProxy::getRemoteAircraftData(const QStringList &callsigns, const RemoteAircraftDataCallback &setter) const
|
||||
void CFGSwiftBusTrafficProxy::getRemoteAircraftData(const QStringList &callsigns, const RemoteAircraftDataCallback &setter) const
|
||||
{
|
||||
std::function<void(QDBusPendingCallWatcher *)> callback = [ = ](QDBusPendingCallWatcher * watcher)
|
||||
{
|
||||
@@ -148,7 +148,7 @@ namespace BlackSimPlugin
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getRemoteAircraftData"), callback, callsigns);
|
||||
}
|
||||
|
||||
void CXSwiftBusTrafficProxy::getElevationAtPosition(const CCallsign &callsign, double latitudeDeg, double longitudeDeg, double altitudeMeters,
|
||||
void CFGSwiftBusTrafficProxy::getElevationAtPosition(const CCallsign &callsign, double latitudeDeg, double longitudeDeg, double altitudeMeters,
|
||||
const ElevationCallback &setter) const
|
||||
{
|
||||
std::function<void(QDBusPendingCallWatcher *)> callback = [ = ](QDBusPendingCallWatcher * watcher)
|
||||
@@ -169,7 +169,7 @@ namespace BlackSimPlugin
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getElevationAtPosition"), callback, callsign.asString(), latitudeDeg, longitudeDeg, altitudeMeters);
|
||||
}
|
||||
|
||||
void CXSwiftBusTrafficProxy::setFollowedAircraft(const QString &callsign)
|
||||
void CFGSwiftBusTrafficProxy::setFollowedAircraft(const QString &callsign)
|
||||
{
|
||||
m_dbusInterface->callDBus(QLatin1String("setFollowedAircraft"), callsign);
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKSIMPLUGIN_XSWIFTBUS_TRAFFIC_PROXY_H
|
||||
#define BLACKSIMPLUGIN_XSWIFTBUS_TRAFFIC_PROXY_H
|
||||
#ifndef BLACKSIMPLUGIN_FGSWIFTBUS_TRAFFIC_PROXY_H
|
||||
#define BLACKSIMPLUGIN_FGSWIFTBUS_TRAFFIC_PROXY_H
|
||||
|
||||
#include "blackmisc/genericdbusinterface.h"
|
||||
#include "blackmisc/aviation/callsign.h"
|
||||
@@ -24,13 +24,13 @@
|
||||
class QDBusConnection;
|
||||
|
||||
//! \cond PRIVATE
|
||||
#define XSWIFTBUS_TRAFFIC_INTERFACENAME "org.swift_project.xswiftbus.traffic"
|
||||
#define XSWIFTBUS_TRAFFIC_OBJECTPATH "/xswiftbus/traffic"
|
||||
#define FGSWIFTBUS_TRAFFIC_INTERFACENAME "org.swift_project.fgswiftbus.traffic"
|
||||
#define FGSWIFTBUS_TRAFFIC_OBJECTPATH "/fgswiftbus/traffic"
|
||||
//! \endcond
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace XPlane
|
||||
namespace Flightgear
|
||||
{
|
||||
//! List of doubles
|
||||
using QDoubleList = QList<double>;
|
||||
@@ -103,14 +103,14 @@ namespace BlackSimPlugin
|
||||
//! Multiplayer Acquire Info
|
||||
struct MultiplayerAcquireInfo
|
||||
{
|
||||
bool hasAcquired; //!< Has XSwiftBus acquired multiplayer planes?
|
||||
bool hasAcquired; //!< Has FGSwiftBus acquired multiplayer planes?
|
||||
QString owner; //!< Name of the plugin having multiplayer planes acquired
|
||||
};
|
||||
|
||||
/*!
|
||||
* Proxy object connected to a real XSwiftBus::CTraffic object via DBus
|
||||
* Proxy object connected to a real FGSwiftBus::CTraffic object via DBus
|
||||
*/
|
||||
class CXSwiftBusTrafficProxy : public QObject
|
||||
class CFGSwiftBusTrafficProxy : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -124,19 +124,19 @@ namespace BlackSimPlugin
|
||||
//! Service name
|
||||
static const QString &InterfaceName()
|
||||
{
|
||||
static QString s(XSWIFTBUS_TRAFFIC_INTERFACENAME);
|
||||
static QString s(FGSWIFTBUS_TRAFFIC_INTERFACENAME);
|
||||
return s;
|
||||
}
|
||||
|
||||
//! Service path
|
||||
static const QString &ObjectPath()
|
||||
{
|
||||
static QString s(XSWIFTBUS_TRAFFIC_OBJECTPATH);
|
||||
static QString s(FGSWIFTBUS_TRAFFIC_OBJECTPATH);
|
||||
return s;
|
||||
}
|
||||
|
||||
//! Constructor
|
||||
CXSwiftBusTrafficProxy(QDBusConnection &connection, QObject *parent = nullptr, bool dummy = false);
|
||||
CFGSwiftBusTrafficProxy(QDBusConnection &connection, QObject *parent = nullptr, bool dummy = false);
|
||||
|
||||
//! Does the remote object exist?
|
||||
bool isValid() const { return m_dbusInterface->isValid(); }
|
||||
@@ -153,59 +153,59 @@ namespace BlackSimPlugin
|
||||
void remoteAircraftAddingFailed(const QString &callsign);
|
||||
|
||||
public slots:
|
||||
//! \copydoc XSwiftBus::CTraffic::acquireMultiplayerPlanes
|
||||
//! \copydoc FGSwiftBus::CTraffic::acquireMultiplayerPlanes
|
||||
MultiplayerAcquireInfo acquireMultiplayerPlanes();
|
||||
|
||||
//! \copydoc XSwiftBus::CTraffic::initialize
|
||||
//! \copydoc FGSwiftBus::CTraffic::initialize
|
||||
bool initialize();
|
||||
|
||||
//! \copydoc XSwiftBus::CTraffic::cleanup
|
||||
//! \copydoc FGSwiftBus::CTraffic::cleanup
|
||||
void cleanup();
|
||||
|
||||
//! \copydoc XSwiftBus::CTraffic::loadPlanesPackage
|
||||
//! \copydoc FGSwiftBus::CTraffic::loadPlanesPackage
|
||||
bool loadPlanesPackage(const QString &path);
|
||||
|
||||
//! \copydoc XSwiftBus::CTraffic::setDefaultIcao
|
||||
//! \copydoc FGSwiftBus::CTraffic::setDefaultIcao
|
||||
void setDefaultIcao(const QString &defaultIcao);
|
||||
|
||||
//! \copydoc XSwiftBus::CTraffic::setDrawingLabels
|
||||
//! \copydoc FGSwiftBus::CTraffic::setDrawingLabels
|
||||
void setDrawingLabels(bool drawing);
|
||||
|
||||
//! \copydoc XSwiftBus::CTraffic::isDrawingLabels
|
||||
//! \copydoc FGSwiftBus::CTraffic::isDrawingLabels
|
||||
bool isDrawingLabels() const;
|
||||
|
||||
//! \copydoc XSwiftBus::CTraffic::setMaxPlanes
|
||||
//! \copydoc FGSwiftBus::CTraffic::setMaxPlanes
|
||||
void setMaxPlanes(int planes);
|
||||
|
||||
//! \copydoc XSwiftBus::CTraffic::setMaxDrawDistance
|
||||
//! \copydoc FGSwiftBus::CTraffic::setMaxDrawDistance
|
||||
void setMaxDrawDistance(double nauticalMiles);
|
||||
|
||||
//! \copydoc XSwiftBus::CTraffic::addPlane
|
||||
//! \copydoc FGSwiftBus::CTraffic::addPlane
|
||||
void addPlane(const QString &callsign, const QString &modelName, const QString &aircraftIcao, const QString &airlineIcao, const QString &livery);
|
||||
|
||||
//! \copydoc XSwiftBus::CTraffic::removePlane
|
||||
//! \copydoc FGSwiftBus::CTraffic::removePlane
|
||||
void removePlane(const QString &callsign);
|
||||
|
||||
//! \copydoc XSwiftBus::CTraffic::removeAllPlanes
|
||||
//! \copydoc FGSwiftBus::CTraffic::removeAllPlanes
|
||||
void removeAllPlanes();
|
||||
|
||||
//! \copydoc XSwiftBus::CTraffic::setPlanesPositions
|
||||
void setPlanesPositions(const BlackSimPlugin::XPlane::PlanesPositions &planesPositions);
|
||||
//! \copydoc FGSwiftBus::CTraffic::setPlanesPositions
|
||||
void setPlanesPositions(const BlackSimPlugin::Flightgear::PlanesPositions &planesPositions);
|
||||
|
||||
//! \copydoc XSwiftBus::CTraffic::setPlanesTransponders
|
||||
void setPlanesTransponders(const BlackSimPlugin::XPlane::PlanesTransponders &planesTransponders);
|
||||
//! \copydoc FGSwiftBus::CTraffic::setPlanesTransponders
|
||||
void setPlanesTransponders(const BlackSimPlugin::Flightgear::PlanesTransponders &planesTransponders);
|
||||
|
||||
//! \deprecated XSwiftBus::CTraffic::setInterpolatorMode
|
||||
//! \deprecated FGSwiftBus::CTraffic::setInterpolatorMode
|
||||
void setInterpolatorMode(const QString &callsign, bool spline);
|
||||
|
||||
//! \copydoc XSwiftBus::CTraffic::getRemoteAircraftData
|
||||
//! \copydoc FGSwiftBus::CTraffic::getRemoteAircraftData
|
||||
void getRemoteAircraftData(const QStringList &callsigns, const RemoteAircraftDataCallback &setter) const;
|
||||
|
||||
//! \copydoc XSwiftBus::CTraffic::getElevationAtPosition
|
||||
//! \copydoc FGSwiftBus::CTraffic::getElevationAtPosition
|
||||
void getElevationAtPosition(const BlackMisc::Aviation::CCallsign &callsign, double latitudeDeg, double longitudeDeg, double altitudeMeters,
|
||||
const ElevationCallback &setter) const;
|
||||
|
||||
//! \copydoc XSwiftBus::CTraffic::setFollowedAircraft
|
||||
//! \copydoc FGSwiftBus::CTraffic::setFollowedAircraft
|
||||
void setFollowedAircraft(const QString &callsign);
|
||||
|
||||
private:
|
||||
|
||||
@@ -17,12 +17,12 @@ using namespace BlackMisc::Simulation;
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace XPlane
|
||||
namespace Flightgear
|
||||
{
|
||||
CXPlaneMPAircraft::CXPlaneMPAircraft()
|
||||
CFlightgearMPAircraft::CFlightgearMPAircraft()
|
||||
{ }
|
||||
|
||||
CXPlaneMPAircraft::CXPlaneMPAircraft(
|
||||
CFlightgearMPAircraft::CFlightgearMPAircraft(
|
||||
const CSimulatedAircraft &aircraft, ISimulator *simulator, CInterpolationLogger *logger) :
|
||||
m_aircraft(aircraft),
|
||||
m_interpolator(QSharedPointer<CInterpolatorMulti>::create(aircraft.getCallsign(), simulator, simulator, simulator->getRemoteAircraftProvider(), logger))
|
||||
@@ -31,40 +31,40 @@ namespace BlackSimPlugin
|
||||
m_interpolator->initCorrespondingModel(aircraft.getModel());
|
||||
}
|
||||
|
||||
void CXPlaneMPAircraft::setSimulatedAircraft(const CSimulatedAircraft &simulatedAircraft)
|
||||
void CFlightgearMPAircraft::setSimulatedAircraft(const CSimulatedAircraft &simulatedAircraft)
|
||||
{
|
||||
m_aircraft = simulatedAircraft;
|
||||
}
|
||||
|
||||
QString CXPlaneMPAircraft::getInterpolatorInfo(CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const
|
||||
QString CFlightgearMPAircraft::getInterpolatorInfo(CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const
|
||||
{
|
||||
Q_ASSERT(m_interpolator);
|
||||
return m_interpolator->getInterpolatorInfo(mode);
|
||||
}
|
||||
|
||||
void CXPlaneMPAircraft::attachInterpolatorLogger(CInterpolationLogger *logger) const
|
||||
void CFlightgearMPAircraft::attachInterpolatorLogger(CInterpolationLogger *logger) const
|
||||
{
|
||||
Q_ASSERT(m_interpolator);
|
||||
m_interpolator->attachLogger(logger);
|
||||
}
|
||||
|
||||
CInterpolationResult CXPlaneMPAircraft::getInterpolation(qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetupPerCallsign &setup, int aircraftNumber) const
|
||||
CInterpolationResult CFlightgearMPAircraft::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
|
||||
CStatusMessageList CFlightgearMPAircraft::getInterpolationMessages(CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const
|
||||
{
|
||||
return this->getInterpolator() ? this->getInterpolator()->getInterpolationMessages(mode) : CStatusMessageList();
|
||||
}
|
||||
|
||||
CCallsignSet CXPlaneMPAircraftObjects::getAllCallsigns() const
|
||||
CCallsignSet CFlightgearMPAircraftObjects::getAllCallsigns() const
|
||||
{
|
||||
return CCallsignSet(this->keys());
|
||||
}
|
||||
|
||||
QStringList CXPlaneMPAircraftObjects::getAllCallsignStrings(bool sorted) const
|
||||
QStringList CFlightgearMPAircraftObjects::getAllCallsignStrings(bool sorted) const
|
||||
{
|
||||
return this->getAllCallsigns().getCallsignStrings(sorted);
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKSIMPLUGIN_XPLANE_XPLANEMPAIRCRAFT_H
|
||||
#define BLACKSIMPLUGIN_XPLANE_XPLANEMPAIRCRAFT_H
|
||||
#ifndef BLACKSIMPLUGIN_FLIGHTGEAR_FGPLANEMPAIRCRAFT_H
|
||||
#define BLACKSIMPLUGIN_FLIGHTGEAR_FGPLANEMPAIRCRAFT_H
|
||||
|
||||
#include "blackmisc/simulation/simulatedaircraft.h"
|
||||
#include "blackmisc/simulation/interpolatormulti.h"
|
||||
@@ -19,22 +19,22 @@
|
||||
namespace BlackCore { class ISimulator; }
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace XPlane
|
||||
namespace Flightgear
|
||||
{
|
||||
//! Class representing a X-Plane multiplayer aircraft
|
||||
class CXPlaneMPAircraft
|
||||
//! Class representing a Flightgear multiplayer aircraft
|
||||
class CFlightgearMPAircraft
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
CXPlaneMPAircraft();
|
||||
CFlightgearMPAircraft();
|
||||
|
||||
//! Constructor providing initial situation/parts
|
||||
CXPlaneMPAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraft,
|
||||
CFlightgearMPAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraft,
|
||||
BlackCore::ISimulator *simulator,
|
||||
BlackMisc::Simulation::CInterpolationLogger *logger);
|
||||
|
||||
//! Destructor
|
||||
~CXPlaneMPAircraft() {}
|
||||
~CFlightgearMPAircraft() {}
|
||||
|
||||
//! Set simulated aircraft
|
||||
void setSimulatedAircraft(const BlackMisc::Simulation::CSimulatedAircraft &simulatedAircraft);
|
||||
@@ -69,7 +69,7 @@ namespace BlackSimPlugin
|
||||
};
|
||||
|
||||
//! Simulator objects (aka AI aircraft)
|
||||
class CXPlaneMPAircraftObjects : public QHash<BlackMisc::Aviation::CCallsign, CXPlaneMPAircraft>
|
||||
class CFlightgearMPAircraftObjects : public QHash<BlackMisc::Aviation::CCallsign, CFlightgearMPAircraft>
|
||||
{
|
||||
public:
|
||||
//! Get all callsigns
|
||||
|
||||
@@ -75,18 +75,18 @@ using namespace BlackCore;
|
||||
|
||||
namespace
|
||||
{
|
||||
inline const QString &xswiftbusServiceName()
|
||||
inline const QString &fgswiftbusServiceName()
|
||||
{
|
||||
static const QString name("org.swift-project.xswiftbus");
|
||||
static const QString name("org.swift-project.fgswiftbus");
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace XPlane
|
||||
namespace Flightgear
|
||||
{
|
||||
CSimulatorXPlane::CSimulatorXPlane(const CSimulatorPluginInfo &info,
|
||||
CSimulatorFlightgear::CSimulatorFlightgear(const CSimulatorPluginInfo &info,
|
||||
IOwnAircraftProvider *ownAircraftProvider,
|
||||
IRemoteAircraftProvider *remoteAircraftProvider,
|
||||
IWeatherGridProvider *weatherGridProvider,
|
||||
@@ -96,16 +96,16 @@ namespace BlackSimPlugin
|
||||
{
|
||||
m_watcher = new QDBusServiceWatcher(this);
|
||||
m_watcher->setWatchMode(QDBusServiceWatcher::WatchForUnregistration);
|
||||
m_watcher->addWatchedService(xswiftbusServiceName());
|
||||
m_watcher->addWatchedService(fgswiftbusServiceName());
|
||||
m_watcher->setObjectName("QDBusServiceWatcher");
|
||||
connect(m_watcher, &QDBusServiceWatcher::serviceUnregistered, this, &CSimulatorXPlane::serviceUnregistered);
|
||||
connect(m_watcher, &QDBusServiceWatcher::serviceUnregistered, this, &CSimulatorFlightgear::serviceUnregistered);
|
||||
|
||||
m_fastTimer.setObjectName(this->objectName().append(":m_fastTimer"));
|
||||
m_slowTimer.setObjectName(this->objectName().append(":m_slowTimer"));
|
||||
m_pendingAddedTimer.setObjectName(this->objectName().append(":m_pendingAddedTimer"));
|
||||
connect(&m_fastTimer, &QTimer::timeout, this, &CSimulatorXPlane::fastTimerTimeout);
|
||||
connect(&m_slowTimer, &QTimer::timeout, this, &CSimulatorXPlane::slowTimerTimeout);
|
||||
connect(&m_pendingAddedTimer, &QTimer::timeout, this, &CSimulatorXPlane::addNextPendingAircraft);
|
||||
connect(&m_fastTimer, &QTimer::timeout, this, &CSimulatorFlightgear::fastTimerTimeout);
|
||||
connect(&m_slowTimer, &QTimer::timeout, this, &CSimulatorFlightgear::slowTimerTimeout);
|
||||
connect(&m_pendingAddedTimer, &QTimer::timeout, this, &CSimulatorFlightgear::addNextPendingAircraft);
|
||||
m_fastTimer.start(100);
|
||||
m_slowTimer.start(1000);
|
||||
m_airportUpdater.start(60 * 1000);
|
||||
@@ -113,15 +113,15 @@ namespace BlackSimPlugin
|
||||
|
||||
this->setDefaultModel({ "Jets A320_a A320_a_Austrian_Airlines A320_a_Austrian_Airlines", CAircraftModel::TypeModelMatchingDefaultModel,
|
||||
"A320 AUA", CAircraftIcaoCode("A320", "L2J")});
|
||||
this->resetXPlaneData();
|
||||
this->resetFlightgearData();
|
||||
}
|
||||
|
||||
CSimulatorXPlane::~CSimulatorXPlane()
|
||||
CSimulatorFlightgear::~CSimulatorFlightgear()
|
||||
{
|
||||
this->unload();
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::unload()
|
||||
void CSimulatorFlightgear::unload()
|
||||
{
|
||||
if (!this->isConnected()) { return; }
|
||||
|
||||
@@ -131,31 +131,31 @@ namespace BlackSimPlugin
|
||||
m_watcher = nullptr;
|
||||
}
|
||||
|
||||
QString CSimulatorXPlane::getStatisticsSimulatorSpecific() const
|
||||
QString CSimulatorFlightgear::getStatisticsSimulatorSpecific() const
|
||||
{
|
||||
return QStringLiteral("Add-time: %1ms/%2ms").arg(m_statsAddCurrentTimeMs).arg(m_statsAddMaxTimeMs);
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::resetAircraftStatistics()
|
||||
void CSimulatorFlightgear::resetAircraftStatistics()
|
||||
{
|
||||
m_statsAddMaxTimeMs = -1;
|
||||
m_statsAddCurrentTimeMs = -1;
|
||||
}
|
||||
|
||||
CStatusMessageList CSimulatorXPlane::getInterpolationMessages(const CCallsign &callsign) const
|
||||
CStatusMessageList CSimulatorFlightgear::getInterpolationMessages(const CCallsign &callsign) const
|
||||
{
|
||||
if (!m_xplaneAircraftObjects.contains(callsign)) { return CStatusMessageList(); }
|
||||
if (!m_flightgearAircraftObjects.contains(callsign)) { return CStatusMessageList(); }
|
||||
const CInterpolationAndRenderingSetupPerCallsign setup = this->getInterpolationSetupConsolidated(callsign, false);
|
||||
return m_xplaneAircraftObjects[callsign].getInterpolationMessages(setup.getInterpolatorMode());
|
||||
return m_flightgearAircraftObjects[callsign].getInterpolationMessages(setup.getInterpolatorMode());
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::clearAllRemoteAircraftData()
|
||||
void CSimulatorFlightgear::clearAllRemoteAircraftData()
|
||||
{
|
||||
m_aircraftAddedFailed.clear();
|
||||
CSimulatorPluginCommon::clearAllRemoteAircraftData();
|
||||
}
|
||||
|
||||
bool CSimulatorXPlane::requestElevation(const ICoordinateGeodetic &reference, const CCallsign &callsign)
|
||||
bool CSimulatorFlightgear::requestElevation(const ICoordinateGeodetic &reference, const CCallsign &callsign)
|
||||
{
|
||||
if (this->isShuttingDownOrDisconnected()) { return false; }
|
||||
if (reference.isNull()) { return false; }
|
||||
@@ -173,7 +173,7 @@ namespace BlackSimPlugin
|
||||
}
|
||||
|
||||
using namespace std::placeholders;
|
||||
auto callback = std::bind(&CSimulatorXPlane::callbackReceivedRequestedElevation, this, _1, _2);
|
||||
auto callback = std::bind(&CSimulatorFlightgear::callbackReceivedRequestedElevation, this, _1, _2);
|
||||
|
||||
// Request
|
||||
m_trafficProxy->getElevationAtPosition(callsign,
|
||||
@@ -185,7 +185,7 @@ namespace BlackSimPlugin
|
||||
return true;
|
||||
}
|
||||
|
||||
// convert xplane squawk mode to swift squawk mode
|
||||
// convert flightgear squawk mode to swift squawk mode
|
||||
CTransponder::TransponderMode xpdrMode(int xplaneMode, bool ident)
|
||||
{
|
||||
if (ident) { return CTransponder::StateIdent; }
|
||||
@@ -193,41 +193,41 @@ namespace BlackSimPlugin
|
||||
return CTransponder::ModeC;
|
||||
}
|
||||
|
||||
// convert swift squawk mode to xplane squawk mode
|
||||
// convert swift squawk mode to flightgear squawk mode
|
||||
int xpdrMode(CTransponder::TransponderMode mode)
|
||||
{
|
||||
return mode == CTransponder::StateStandby ? 1 : 2;
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::fastTimerTimeout()
|
||||
void CSimulatorFlightgear::fastTimerTimeout()
|
||||
{
|
||||
if (this->isConnected())
|
||||
{
|
||||
m_serviceProxy->getOwnAircraftSituationData(&m_xplaneData);
|
||||
m_serviceProxy->getCom1ActiveKhzAsync(&m_xplaneData.com1ActiveKhz);
|
||||
m_serviceProxy->getCom1StandbyKhzAsync(&m_xplaneData.com1StandbyKhz);
|
||||
m_serviceProxy->getCom2ActiveKhzAsync(&m_xplaneData.com2ActiveKhz);
|
||||
m_serviceProxy->getCom2StandbyKhzAsync(&m_xplaneData.com2StandbyKhz);
|
||||
m_serviceProxy->getTransponderCodeAsync(&m_xplaneData.xpdrCode);
|
||||
m_serviceProxy->getTransponderModeAsync(&m_xplaneData.xpdrMode);
|
||||
m_serviceProxy->getTransponderIdentAsync(&m_xplaneData.xpdrIdent);
|
||||
m_serviceProxy->getAllWheelsOnGroundAsync(&m_xplaneData.onGroundAll);
|
||||
m_serviceProxy->getOwnAircraftSituationData(&m_flightgearData);
|
||||
m_serviceProxy->getCom1ActiveKhzAsync(&m_flightgearData.com1ActiveKhz);
|
||||
m_serviceProxy->getCom1StandbyKhzAsync(&m_flightgearData.com1StandbyKhz);
|
||||
m_serviceProxy->getCom2ActiveKhzAsync(&m_flightgearData.com2ActiveKhz);
|
||||
m_serviceProxy->getCom2StandbyKhzAsync(&m_flightgearData.com2StandbyKhz);
|
||||
m_serviceProxy->getTransponderCodeAsync(&m_flightgearData.xpdrCode);
|
||||
m_serviceProxy->getTransponderModeAsync(&m_flightgearData.xpdrMode);
|
||||
m_serviceProxy->getTransponderIdentAsync(&m_flightgearData.xpdrIdent);
|
||||
m_serviceProxy->getAllWheelsOnGroundAsync(&m_flightgearData.onGroundAll);
|
||||
|
||||
CAircraftSituation situation;
|
||||
situation.setPosition({ m_xplaneData.latitudeDeg, m_xplaneData.longitudeDeg, 0 });
|
||||
CAltitude altitude { m_xplaneData.altitudeM, CAltitude::MeanSeaLevel, CLengthUnit::ft() };
|
||||
situation.setAltitude({ m_xplaneData.altitudeM, CAltitude::MeanSeaLevel, CLengthUnit::ft() });
|
||||
CPressure seaLevelPressure({ m_xplaneData.seaLevelPressureInHg, CPressureUnit::inHg() });
|
||||
situation.setPosition({ m_flightgearData.latitudeDeg, m_flightgearData.longitudeDeg, 0 });
|
||||
CAltitude altitude { m_flightgearData.altitudeM, CAltitude::MeanSeaLevel, CLengthUnit::ft() };
|
||||
situation.setAltitude({ m_flightgearData.altitudeM, CAltitude::MeanSeaLevel, CLengthUnit::ft() });
|
||||
CPressure seaLevelPressure({ m_flightgearData.seaLevelPressureInHg, CPressureUnit::inHg() });
|
||||
CAltitude pressureAltitude(altitude.toPressureAltitude(seaLevelPressure));
|
||||
situation.setPressureAltitude(pressureAltitude);
|
||||
situation.setHeading({ m_xplaneData.trueHeadingDeg, CHeading::True, CAngleUnit::deg() });
|
||||
situation.setPitch({ m_xplaneData.pitchDeg, CAngleUnit::deg() });
|
||||
situation.setBank({ m_xplaneData.rollDeg, CAngleUnit::deg() });
|
||||
situation.setGroundSpeed({ m_xplaneData.groundspeedMs, CSpeedUnit::kts() });
|
||||
situation.setHeading({ m_flightgearData.trueHeadingDeg, CHeading::True, CAngleUnit::deg() });
|
||||
situation.setPitch({ m_flightgearData.pitchDeg, CAngleUnit::deg() });
|
||||
situation.setBank({ m_flightgearData.rollDeg, CAngleUnit::deg() });
|
||||
situation.setGroundSpeed({ m_flightgearData.groundspeedMs, CSpeedUnit::kts() });
|
||||
|
||||
// Updates
|
||||
// Do not update ICAO codes, as this overrides reverse lookups
|
||||
// updateOwnIcaoCodes(m_xplaneData.aircraftIcaoCode, CAirlineIcaoCode());
|
||||
// updateOwnIcaoCodes(m_flightgearData.aircraftIcaoCode, CAirlineIcaoCode());
|
||||
updateOwnSituation(situation);
|
||||
|
||||
// defaults
|
||||
@@ -237,15 +237,15 @@ namespace BlackSimPlugin
|
||||
CTransponder transponder(myAircraft.getTransponder());
|
||||
|
||||
// updates
|
||||
com1.setFrequencyActive(CFrequency(m_xplaneData.com1ActiveKhz, CFrequencyUnit::kHz()));
|
||||
com1.setFrequencyStandby(CFrequency(m_xplaneData.com1StandbyKhz, CFrequencyUnit::kHz()));
|
||||
com1.setFrequencyActive(CFrequency(m_flightgearData.com1ActiveKhz, CFrequencyUnit::kHz()));
|
||||
com1.setFrequencyStandby(CFrequency(m_flightgearData.com1StandbyKhz, CFrequencyUnit::kHz()));
|
||||
const bool changedCom1 = myAircraft.getCom1System() != com1;
|
||||
|
||||
com2.setFrequencyActive(CFrequency(m_xplaneData.com2ActiveKhz, CFrequencyUnit::kHz()));
|
||||
com2.setFrequencyStandby(CFrequency(m_xplaneData.com2StandbyKhz, CFrequencyUnit::kHz()));
|
||||
com2.setFrequencyActive(CFrequency(m_flightgearData.com2ActiveKhz, CFrequencyUnit::kHz()));
|
||||
com2.setFrequencyStandby(CFrequency(m_flightgearData.com2StandbyKhz, CFrequencyUnit::kHz()));
|
||||
const bool changedCom2 = myAircraft.getCom2System() != com2;
|
||||
|
||||
transponder = CTransponder::getStandardTransponder(m_xplaneData.xpdrCode, xpdrMode(m_xplaneData.xpdrMode, m_xplaneData.xpdrIdent));
|
||||
transponder = CTransponder::getStandardTransponder(m_flightgearData.xpdrCode, xpdrMode(m_flightgearData.xpdrMode, m_flightgearData.xpdrIdent));
|
||||
const bool changedXpr = (myAircraft.getTransponder() != transponder);
|
||||
|
||||
if (changedCom1 || changedCom2 || changedXpr)
|
||||
@@ -255,60 +255,60 @@ namespace BlackSimPlugin
|
||||
}
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::slowTimerTimeout()
|
||||
void CSimulatorFlightgear::slowTimerTimeout()
|
||||
{
|
||||
if (isConnected())
|
||||
{
|
||||
m_serviceProxy->getAircraftModelPathAsync(&m_xplaneData.aircraftModelPath); // this is NOT the model string
|
||||
m_serviceProxy->getAircraftIcaoCodeAsync(&m_xplaneData.aircraftIcaoCode);
|
||||
m_serviceProxy->getBeaconLightsOnAsync(&m_xplaneData.beaconLightsOn);
|
||||
m_serviceProxy->getLandingLightsOnAsync(&m_xplaneData.landingLightsOn);
|
||||
m_serviceProxy->getNavLightsOnAsync(&m_xplaneData.navLightsOn);
|
||||
m_serviceProxy->getStrobeLightsOnAsync(&m_xplaneData.strobeLightsOn);
|
||||
m_serviceProxy->getTaxiLightsOnAsync(&m_xplaneData.taxiLightsOn);
|
||||
m_serviceProxy->getFlapsDeployRatioAsync(&m_xplaneData.flapsReployRatio);
|
||||
m_serviceProxy->getGearDeployRatioAsync(&m_xplaneData.gearReployRatio);
|
||||
m_serviceProxy->getEngineN1PercentageAsync(&m_xplaneData.enginesN1Percentage);
|
||||
m_serviceProxy->getSpeedBrakeRatioAsync(&m_xplaneData.speedBrakeRatio);
|
||||
m_serviceProxy->getAircraftModelPathAsync(&m_flightgearData.aircraftModelPath); // this is NOT the model string
|
||||
m_serviceProxy->getAircraftIcaoCodeAsync(&m_flightgearData.aircraftIcaoCode);
|
||||
m_serviceProxy->getBeaconLightsOnAsync(&m_flightgearData.beaconLightsOn);
|
||||
m_serviceProxy->getLandingLightsOnAsync(&m_flightgearData.landingLightsOn);
|
||||
m_serviceProxy->getNavLightsOnAsync(&m_flightgearData.navLightsOn);
|
||||
m_serviceProxy->getStrobeLightsOnAsync(&m_flightgearData.strobeLightsOn);
|
||||
m_serviceProxy->getTaxiLightsOnAsync(&m_flightgearData.taxiLightsOn);
|
||||
m_serviceProxy->getFlapsDeployRatioAsync(&m_flightgearData.flapsReployRatio);
|
||||
m_serviceProxy->getGearDeployRatioAsync(&m_flightgearData.gearReployRatio);
|
||||
m_serviceProxy->getEngineN1PercentageAsync(&m_flightgearData.enginesN1Percentage);
|
||||
m_serviceProxy->getSpeedBrakeRatioAsync(&m_flightgearData.speedBrakeRatio);
|
||||
|
||||
CAircraftEngineList engines;
|
||||
for (int engineNumber = 0; engineNumber < m_xplaneData.enginesN1Percentage.size(); ++engineNumber)
|
||||
for (int engineNumber = 0; engineNumber < m_flightgearData.enginesN1Percentage.size(); ++engineNumber)
|
||||
{
|
||||
// Engine number start counting at 1
|
||||
// We consider the engine running when N1 is bigger than 5 %
|
||||
CAircraftEngine engine {engineNumber + 1, m_xplaneData.enginesN1Percentage.at(engineNumber) > 5.0};
|
||||
CAircraftEngine engine {engineNumber + 1, m_flightgearData.enginesN1Percentage.at(engineNumber) > 5.0};
|
||||
engines.push_back(engine);
|
||||
}
|
||||
|
||||
CAircraftParts parts { {
|
||||
m_xplaneData.strobeLightsOn, m_xplaneData.landingLightsOn, m_xplaneData.taxiLightsOn,
|
||||
m_xplaneData.beaconLightsOn, m_xplaneData.navLightsOn, false
|
||||
m_flightgearData.strobeLightsOn, m_flightgearData.landingLightsOn, m_flightgearData.taxiLightsOn,
|
||||
m_flightgearData.beaconLightsOn, m_flightgearData.navLightsOn, false
|
||||
},
|
||||
m_xplaneData.gearReployRatio > 0, static_cast<int>(m_xplaneData.flapsReployRatio * 100),
|
||||
m_xplaneData.speedBrakeRatio > 0.5, engines, m_xplaneData.onGroundAll
|
||||
m_flightgearData.gearReployRatio > 0, static_cast<int>(m_flightgearData.flapsReployRatio * 100),
|
||||
m_flightgearData.speedBrakeRatio > 0.5, engines, m_flightgearData.onGroundAll
|
||||
};
|
||||
|
||||
this->updateOwnParts(parts);
|
||||
this->requestRemoteAircraftDataFromXPlane();
|
||||
this->requestRemoteAircraftDataFromFlightgear();
|
||||
|
||||
for (CXPlaneMPAircraft &xplaneAircraft : m_xplaneAircraftObjects)
|
||||
for (CFlightgearMPAircraft &flightgearAircraft : m_flightgearAircraftObjects)
|
||||
{
|
||||
// Update remote aircraft to have the latest transponder modes, codes etc.
|
||||
CSimulatedAircraft simulatedAircraft = this->getAircraftInRangeForCallsign(xplaneAircraft.getCallsign());
|
||||
xplaneAircraft.setSimulatedAircraft(simulatedAircraft);
|
||||
CSimulatedAircraft simulatedAircraft = this->getAircraftInRangeForCallsign(flightgearAircraft.getCallsign());
|
||||
flightgearAircraft.setSimulatedAircraft(simulatedAircraft);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CSimulatorXPlane::isConnected() const
|
||||
bool CSimulatorFlightgear::isConnected() const
|
||||
{
|
||||
return m_serviceProxy && m_trafficProxy;
|
||||
}
|
||||
|
||||
bool CSimulatorXPlane::connectTo()
|
||||
bool CSimulatorFlightgear::connectTo()
|
||||
{
|
||||
if (isConnected()) { return true; }
|
||||
QString dbusAddress = m_xswiftbusServerSetting.getThreadLocal();
|
||||
QString dbusAddress = m_fgswiftbusServerSetting.getThreadLocal();
|
||||
|
||||
if (BlackMisc::CDBusServer::isSessionOrSystemAddress(dbusAddress))
|
||||
{
|
||||
@@ -317,13 +317,13 @@ namespace BlackSimPlugin
|
||||
}
|
||||
else if (BlackMisc::CDBusServer::isQtDBusAddress(dbusAddress))
|
||||
{
|
||||
m_dBusConnection = QDBusConnection::connectToPeer(dbusAddress, "xswiftbus");
|
||||
m_dBusConnection = QDBusConnection::connectToPeer(dbusAddress, "fgswiftbus");
|
||||
if (! m_dBusConnection.isConnected()) { return false; }
|
||||
m_dbusMode = P2P;
|
||||
}
|
||||
|
||||
m_serviceProxy = new CXSwiftBusServiceProxy(m_dBusConnection, this);
|
||||
m_trafficProxy = new CXSwiftBusTrafficProxy(m_dBusConnection, this);
|
||||
m_serviceProxy = new CFGSwiftBusServiceProxy(m_dBusConnection, this);
|
||||
m_trafficProxy = new CFGSwiftBusTrafficProxy(m_dBusConnection, this);
|
||||
|
||||
bool s = m_dBusConnection.connect(QString(), DBUS_PATH_LOCAL, DBUS_INTERFACE_LOCAL,
|
||||
"Disconnected", this, SLOT(serviceUnregistered()));
|
||||
@@ -336,22 +336,21 @@ namespace BlackSimPlugin
|
||||
|
||||
emitOwnAircraftModelChanged(m_serviceProxy->getAircraftModelPath(), m_serviceProxy->getAircraftModelFilename(), m_serviceProxy->getAircraftLivery(),
|
||||
m_serviceProxy->getAircraftIcaoCode(), m_serviceProxy->getAircraftModelString(), m_serviceProxy->getAircraftName(), m_serviceProxy->getAircraftDescription());
|
||||
setSimulatorDetails("X-Plane", {}, "");
|
||||
connect(m_serviceProxy, &CXSwiftBusServiceProxy::aircraftModelChanged, this, &CSimulatorXPlane::emitOwnAircraftModelChanged);
|
||||
connect(m_serviceProxy, &CXSwiftBusServiceProxy::airportsInRangeUpdated, this, &CSimulatorXPlane::setAirportsInRange);
|
||||
connect(m_trafficProxy, &CXSwiftBusTrafficProxy::simFrame, this, &CSimulatorXPlane::updateRemoteAircraft);
|
||||
connect(m_trafficProxy, &CXSwiftBusTrafficProxy::remoteAircraftAdded, this, &CSimulatorXPlane::onRemoteAircraftAdded);
|
||||
connect(m_trafficProxy, &CXSwiftBusTrafficProxy::remoteAircraftAddingFailed, this, &CSimulatorXPlane::onRemoteAircraftAddingFailed);
|
||||
setSimulatorDetails("Flightgear", {}, "");
|
||||
connect(m_serviceProxy, &CFGSwiftBusServiceProxy::aircraftModelChanged, this, &CSimulatorFlightgear::emitOwnAircraftModelChanged);
|
||||
connect(m_serviceProxy, &CFGSwiftBusServiceProxy::airportsInRangeUpdated, this, &CSimulatorFlightgear::setAirportsInRange);
|
||||
connect(m_trafficProxy, &CFGSwiftBusTrafficProxy::simFrame, this, &CSimulatorFlightgear::updateRemoteAircraft);
|
||||
connect(m_trafficProxy, &CFGSwiftBusTrafficProxy::remoteAircraftAdded, this, &CSimulatorFlightgear::onRemoteAircraftAdded);
|
||||
connect(m_trafficProxy, &CFGSwiftBusTrafficProxy::remoteAircraftAddingFailed, this, &CSimulatorFlightgear::onRemoteAircraftAddingFailed);
|
||||
if (m_watcher) { m_watcher->setConnection(m_dBusConnection); }
|
||||
m_trafficProxy->removeAllPlanes();
|
||||
this->loadCslPackages();
|
||||
this->emitSimulatorCombinedStatus();
|
||||
|
||||
this->initSimulatorInternals();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CSimulatorXPlane::disconnectFrom()
|
||||
bool CSimulatorFlightgear::disconnectFrom()
|
||||
{
|
||||
if (!this->isConnected()) { return true; } // avoid emit if already disconnected
|
||||
this->disconnectFromDBus();
|
||||
@@ -364,7 +363,7 @@ namespace BlackSimPlugin
|
||||
return true;
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::serviceUnregistered()
|
||||
void CSimulatorFlightgear::serviceUnregistered()
|
||||
{
|
||||
if (m_dbusMode == P2P) { m_dBusConnection.disconnectFromPeer(m_dBusConnection.name()); }
|
||||
m_dBusConnection = QDBusConnection { "default" };
|
||||
@@ -376,7 +375,7 @@ namespace BlackSimPlugin
|
||||
this->emitSimulatorCombinedStatus();
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::emitOwnAircraftModelChanged(const QString &path, const QString &filename, const QString &livery,
|
||||
void CSimulatorFlightgear::emitOwnAircraftModelChanged(const QString &path, const QString &filename, const QString &livery,
|
||||
const QString &icao, const QString &modelString, const QString &name, const QString &description)
|
||||
{
|
||||
CAircraftModel model(modelString, CAircraftModel::TypeOwnSimulatorModel, CSimulatorInfo::XPLANE, name, description, icao);
|
||||
@@ -386,7 +385,7 @@ namespace BlackSimPlugin
|
||||
this->reverseLookupAndUpdateOwnAircraftModel(model);
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::displayStatusMessage(const CStatusMessage &message) const
|
||||
void CSimulatorFlightgear::displayStatusMessage(const CStatusMessage &message) const
|
||||
{
|
||||
// No assert here as status message may come because of network problems
|
||||
if (!isConnected()) { return; }
|
||||
@@ -400,14 +399,14 @@ namespace BlackSimPlugin
|
||||
isInFunction = false;
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::displayTextMessage(const Network::CTextMessage &message) const
|
||||
void CSimulatorFlightgear::displayTextMessage(const Network::CTextMessage &message) const
|
||||
{
|
||||
Q_ASSERT(isConnected());
|
||||
|
||||
m_serviceProxy->addTextMessage(message.getSenderCallsign().toQString() + ": " + message.getMessage());
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::setAirportsInRange(const QStringList &icaos, const QStringList &names, const CSequence<double> &lats, const CSequence<double> &lons, const CSequence<double> &alts)
|
||||
void CSimulatorFlightgear::setAirportsInRange(const QStringList &icaos, const QStringList &names, const CSequence<double> &lats, const CSequence<double> &lons, const CSequence<double> &alts)
|
||||
{
|
||||
//! \todo restrict to maxAirportsInRange()
|
||||
m_airportsInRange.clear();
|
||||
@@ -422,7 +421,7 @@ namespace BlackSimPlugin
|
||||
}
|
||||
}
|
||||
|
||||
CAirportList CSimulatorXPlane::getAirportsInRange(bool recalculateDistance) const
|
||||
CAirportList CSimulatorFlightgear::getAirportsInRange(bool recalculateDistance) const
|
||||
{
|
||||
if (!recalculateDistance) { return m_airportsInRange; }
|
||||
CAirportList airports(m_airportsInRange);
|
||||
@@ -430,49 +429,49 @@ namespace BlackSimPlugin
|
||||
return airports;
|
||||
}
|
||||
|
||||
bool CSimulatorXPlane::setTimeSynchronization(bool enable, const PhysicalQuantities::CTime &offset)
|
||||
bool CSimulatorFlightgear::setTimeSynchronization(bool enable, const PhysicalQuantities::CTime &offset)
|
||||
{
|
||||
Q_UNUSED(offset);
|
||||
if (enable)
|
||||
{
|
||||
CLogMessage(this).info(u"X-Plane provides real time synchronization, use this one");
|
||||
CLogMessage(this).info(u"Flightgear provides real time synchronization, use this one");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QDBusConnection CSimulatorXPlane::connectionFromString(const QString &str)
|
||||
QDBusConnection CSimulatorFlightgear::connectionFromString(const QString &str)
|
||||
{
|
||||
if (str == CDBusServer::sessionBusAddress()) { return QDBusConnection::sessionBus(); }
|
||||
Q_UNREACHABLE();
|
||||
return QDBusConnection("NO CONNECTION");
|
||||
}
|
||||
|
||||
bool CSimulatorXPlane::isPhysicallyRenderedAircraft(const CCallsign &callsign) const
|
||||
bool CSimulatorFlightgear::isPhysicallyRenderedAircraft(const CCallsign &callsign) const
|
||||
{
|
||||
return m_xplaneAircraftObjects.contains(callsign);
|
||||
return m_flightgearAircraftObjects.contains(callsign);
|
||||
}
|
||||
|
||||
bool CSimulatorXPlane::updateOwnSimulatorCockpit(const Simulation::CSimulatedAircraft &aircraft, const CIdentifier &originator)
|
||||
bool CSimulatorFlightgear::updateOwnSimulatorCockpit(const Simulation::CSimulatedAircraft &aircraft, const CIdentifier &originator)
|
||||
{
|
||||
Q_ASSERT(this->isConnected());
|
||||
if (originator == this->identifier()) { return false; }
|
||||
auto com1 = CComSystem::getCom1System({ m_xplaneData.com1ActiveKhz, CFrequencyUnit::kHz() }, { m_xplaneData.com1StandbyKhz, CFrequencyUnit::kHz() });
|
||||
auto com2 = CComSystem::getCom2System({ m_xplaneData.com2ActiveKhz, CFrequencyUnit::kHz() }, { m_xplaneData.com2StandbyKhz, CFrequencyUnit::kHz() });
|
||||
auto xpdr = CTransponder::getStandardTransponder(m_xplaneData.xpdrCode, xpdrMode(m_xplaneData.xpdrMode, m_xplaneData.xpdrIdent));
|
||||
auto com1 = CComSystem::getCom1System({ m_flightgearData.com1ActiveKhz, CFrequencyUnit::kHz() }, { m_flightgearData.com1StandbyKhz, CFrequencyUnit::kHz() });
|
||||
auto com2 = CComSystem::getCom2System({ m_flightgearData.com2ActiveKhz, CFrequencyUnit::kHz() }, { m_flightgearData.com2StandbyKhz, CFrequencyUnit::kHz() });
|
||||
auto xpdr = CTransponder::getStandardTransponder(m_flightgearData.xpdrCode, xpdrMode(m_flightgearData.xpdrMode, m_flightgearData.xpdrIdent));
|
||||
if (aircraft.hasChangedCockpitData(com1, com2, xpdr))
|
||||
{
|
||||
m_xplaneData.com1ActiveKhz = aircraft.getCom1System().getFrequencyActive().valueInteger(CFrequencyUnit::kHz());
|
||||
m_xplaneData.com1StandbyKhz = aircraft.getCom1System().getFrequencyStandby().valueInteger(CFrequencyUnit::kHz());
|
||||
m_xplaneData.com2ActiveKhz = aircraft.getCom2System().getFrequencyActive().valueInteger(CFrequencyUnit::kHz());
|
||||
m_xplaneData.com2StandbyKhz = aircraft.getCom2System().getFrequencyStandby().valueInteger(CFrequencyUnit::kHz());
|
||||
m_xplaneData.xpdrCode = aircraft.getTransponderCode();
|
||||
m_xplaneData.xpdrMode = xpdrMode(aircraft.getTransponderMode());
|
||||
m_serviceProxy->setCom1ActiveKhz(m_xplaneData.com1ActiveKhz);
|
||||
m_serviceProxy->setCom1StandbyKhz(m_xplaneData.com1StandbyKhz);
|
||||
m_serviceProxy->setCom2ActiveKhz(m_xplaneData.com2ActiveKhz);
|
||||
m_serviceProxy->setCom2StandbyKhz(m_xplaneData.com2StandbyKhz);
|
||||
m_serviceProxy->setTransponderCode(m_xplaneData.xpdrCode);
|
||||
m_serviceProxy->setTransponderMode(m_xplaneData.xpdrMode);
|
||||
m_flightgearData.com1ActiveKhz = aircraft.getCom1System().getFrequencyActive().valueInteger(CFrequencyUnit::kHz());
|
||||
m_flightgearData.com1StandbyKhz = aircraft.getCom1System().getFrequencyStandby().valueInteger(CFrequencyUnit::kHz());
|
||||
m_flightgearData.com2ActiveKhz = aircraft.getCom2System().getFrequencyActive().valueInteger(CFrequencyUnit::kHz());
|
||||
m_flightgearData.com2StandbyKhz = aircraft.getCom2System().getFrequencyStandby().valueInteger(CFrequencyUnit::kHz());
|
||||
m_flightgearData.xpdrCode = aircraft.getTransponderCode();
|
||||
m_flightgearData.xpdrMode = xpdrMode(aircraft.getTransponderMode());
|
||||
m_serviceProxy->setCom1ActiveKhz(m_flightgearData.com1ActiveKhz);
|
||||
m_serviceProxy->setCom1StandbyKhz(m_flightgearData.com1StandbyKhz);
|
||||
m_serviceProxy->setCom2ActiveKhz(m_flightgearData.com2ActiveKhz);
|
||||
m_serviceProxy->setCom2StandbyKhz(m_flightgearData.com2StandbyKhz);
|
||||
m_serviceProxy->setTransponderCode(m_flightgearData.xpdrCode);
|
||||
m_serviceProxy->setTransponderMode(m_flightgearData.xpdrMode);
|
||||
|
||||
m_serviceProxy->cancelAllPendingAsyncCalls(); // in case there is already a reply with some old data incoming
|
||||
return true;
|
||||
@@ -480,7 +479,7 @@ namespace BlackSimPlugin
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CSimulatorXPlane::updateOwnSimulatorSelcal(const CSelcal &selcal, const CIdentifier &originator)
|
||||
bool CSimulatorFlightgear::updateOwnSimulatorSelcal(const CSelcal &selcal, const CIdentifier &originator)
|
||||
{
|
||||
Q_ASSERT(this->isConnected());
|
||||
if (originator == this->identifier()) { return false; }
|
||||
@@ -490,54 +489,7 @@ namespace BlackSimPlugin
|
||||
return false;
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::loadCslPackages()
|
||||
{
|
||||
struct Prefix { QString s; };
|
||||
struct PrefixComparator
|
||||
{
|
||||
bool operator()(const Prefix &a, const QString &b) const { return QStringRef(&a.s) < b.leftRef(a.s.size()); }
|
||||
bool operator()(const QString &a, const Prefix &b) const { return a.leftRef(b.s.size()) < QStringRef(&b.s); }
|
||||
};
|
||||
QList<Prefix> packages;
|
||||
|
||||
Q_ASSERT(isConnected());
|
||||
const CAircraftModelList models = m_modelSet.getThreadLocal();
|
||||
for (const auto &model : models)
|
||||
{
|
||||
const QString &modelFile = model.getFileName();
|
||||
if (modelFile.isEmpty() || ! QFile::exists(modelFile)) { continue; }
|
||||
auto it = std::lower_bound(packages.begin(), packages.end(), modelFile, PrefixComparator());
|
||||
if (it != packages.end() && modelFile.startsWith(it->s)) { continue; }
|
||||
QString package = findCslPackage(modelFile);
|
||||
if (package.isEmpty()) { continue; }
|
||||
packages.insert(it, { package.append('/') });
|
||||
}
|
||||
for (auto &package : packages)
|
||||
{
|
||||
Q_ASSERT(package.s.endsWith('/'));
|
||||
package.s.chop(1);
|
||||
m_trafficProxy->loadPlanesPackage(package.s);
|
||||
}
|
||||
}
|
||||
|
||||
QString CSimulatorXPlane::findCslPackage(const QString &modelFile)
|
||||
{
|
||||
//! \todo KB 2018-02 KB when I have removed the CSL dir (acciedently) there was no warning here
|
||||
const QFileInfo info(modelFile);
|
||||
QDir dir = info.isDir() ? QDir(modelFile) : info.dir();
|
||||
do
|
||||
{
|
||||
if (dir.exists(QStringLiteral("xsb_aircraft.txt")))
|
||||
{
|
||||
if (dir.cdUp()) { return dir.path(); }
|
||||
}
|
||||
}
|
||||
while (dir.cdUp());
|
||||
CLogMessage(this).warning(u"Failed to find CSL package for %1") << modelFile;
|
||||
return {};
|
||||
}
|
||||
|
||||
bool CSimulatorXPlane::physicallyAddRemoteAircraft(const CSimulatedAircraft &newRemoteAircraft)
|
||||
bool CSimulatorFlightgear::physicallyAddRemoteAircraft(const CSimulatedAircraft &newRemoteAircraft)
|
||||
{
|
||||
Q_ASSERT(isConnected());
|
||||
// entry checks
|
||||
@@ -557,7 +509,7 @@ namespace BlackSimPlugin
|
||||
if (this->canAddAircraft())
|
||||
{
|
||||
// no aircraft pending, add
|
||||
CLogMessage(this).info(u"Adding '%1' to XPlane") << newRemoteAircraft.getCallsign();
|
||||
CLogMessage(this).info(u"Adding '%1' to Flightgear") << newRemoteAircraft.getCallsign();
|
||||
const qint64 now = QDateTime::currentMSecsSinceEpoch();
|
||||
m_addingInProgressAircraft.insert(newRemoteAircraft.getCallsign(), now);
|
||||
const QString callsign = newRemoteAircraft.getCallsign().asString();
|
||||
@@ -576,7 +528,7 @@ namespace BlackSimPlugin
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CSimulatorXPlane::physicallyRemoveRemoteAircraft(const CCallsign &callsign)
|
||||
bool CSimulatorFlightgear::physicallyRemoveRemoteAircraft(const CCallsign &callsign)
|
||||
{
|
||||
Q_ASSERT(isConnected());
|
||||
|
||||
@@ -585,7 +537,7 @@ namespace BlackSimPlugin
|
||||
if (callsign.isEmpty()) { return false; } // can happen if an object is not an aircraft
|
||||
|
||||
// really remove from simulator
|
||||
if (!m_xplaneAircraftObjects.contains(callsign) && !m_pendingToBeAddedAircraft.containsCallsign(callsign) && !m_addingInProgressAircraft.contains(callsign))
|
||||
if (!m_flightgearAircraftObjects.contains(callsign) && !m_pendingToBeAddedAircraft.containsCallsign(callsign) && !m_addingInProgressAircraft.contains(callsign))
|
||||
{
|
||||
// not existing aircraft
|
||||
return false;
|
||||
@@ -595,10 +547,10 @@ namespace BlackSimPlugin
|
||||
const bool updated = this->updateAircraftRendered(callsign, false);
|
||||
if (updated)
|
||||
{
|
||||
if (m_xplaneAircraftObjects.contains(callsign))
|
||||
if (m_flightgearAircraftObjects.contains(callsign))
|
||||
{
|
||||
const CXPlaneMPAircraft &xplaneAircraft = m_xplaneAircraftObjects[callsign];
|
||||
CSimulatedAircraft aircraft(xplaneAircraft.getAircraft());
|
||||
const CFlightgearMPAircraft &flightgearAircraft = m_flightgearAircraftObjects[callsign];
|
||||
CSimulatedAircraft aircraft(flightgearAircraft.getAircraft());
|
||||
aircraft.setRendered(false);
|
||||
emit this->aircraftRenderingChanged(aircraft);
|
||||
}
|
||||
@@ -611,7 +563,7 @@ namespace BlackSimPlugin
|
||||
else if (m_addingInProgressAircraft.contains(callsign))
|
||||
{
|
||||
// we are just about to add that aircraft
|
||||
QPointer<CSimulatorXPlane> myself(this);
|
||||
QPointer<CSimulatorFlightgear> myself(this);
|
||||
QTimer::singleShot(TimeoutAdding, this, [ = ]
|
||||
{
|
||||
if (!myself) { return; }
|
||||
@@ -622,14 +574,14 @@ namespace BlackSimPlugin
|
||||
}
|
||||
|
||||
m_trafficProxy->removePlane(callsign.asString());
|
||||
m_xplaneAircraftObjects.remove(callsign);
|
||||
m_flightgearAircraftObjects.remove(callsign);
|
||||
m_pendingToBeAddedAircraft.removeByCallsign(callsign);
|
||||
|
||||
// bye
|
||||
return true;
|
||||
}
|
||||
|
||||
int CSimulatorXPlane::physicallyRemoveAllRemoteAircraft()
|
||||
int CSimulatorFlightgear::physicallyRemoveAllRemoteAircraft()
|
||||
{
|
||||
if (!this->isConnected()) { return 0; }
|
||||
m_pendingToBeAddedAircraft.clear();
|
||||
@@ -637,20 +589,19 @@ namespace BlackSimPlugin
|
||||
return CSimulatorPluginCommon::physicallyRemoveAllRemoteAircraft();
|
||||
}
|
||||
|
||||
CCallsignSet CSimulatorXPlane::physicallyRenderedAircraft() const
|
||||
CCallsignSet CSimulatorFlightgear::physicallyRenderedAircraft() const
|
||||
{
|
||||
//! \todo XP driver, return list of callsigns really present in the simulator
|
||||
return this->getAircraftInRange().findByRendered(true).getCallsigns(); // just a poor workaround
|
||||
}
|
||||
|
||||
bool CSimulatorXPlane::followAircraft(const CCallsign &callsign)
|
||||
bool CSimulatorFlightgear::followAircraft(const CCallsign &callsign)
|
||||
{
|
||||
if (! m_trafficProxy || ! m_trafficProxy->isValid()) { return false; }
|
||||
m_trafficProxy->setFollowedAircraft(callsign.toQString());
|
||||
return true;
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::updateRemoteAircraft()
|
||||
void CSimulatorFlightgear::updateRemoteAircraft()
|
||||
{
|
||||
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "thread");
|
||||
|
||||
@@ -667,14 +618,14 @@ namespace BlackSimPlugin
|
||||
|
||||
int aircraftNumber = 0;
|
||||
const bool updateAllAircraft = this->isUpdateAllRemoteAircraft(currentTimestamp);
|
||||
for (const CXPlaneMPAircraft &xplaneAircraft : m_xplaneAircraftObjects)
|
||||
for (const CFlightgearMPAircraft &flightgearAircraft : m_flightgearAircraftObjects)
|
||||
{
|
||||
const CCallsign callsign(xplaneAircraft.getCallsign());
|
||||
const CCallsign callsign(flightgearAircraft.getCallsign());
|
||||
Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "missing callsign");
|
||||
|
||||
planesTransponders.callsigns.push_back(callsign.asString());
|
||||
planesTransponders.codes.push_back(xplaneAircraft.getAircraft().getTransponderCode());
|
||||
CTransponder::TransponderMode transponderMode = xplaneAircraft.getAircraft().getTransponderMode();
|
||||
planesTransponders.codes.push_back(flightgearAircraft.getAircraft().getTransponderCode());
|
||||
CTransponder::TransponderMode transponderMode = flightgearAircraft.getAircraft().getTransponderMode();
|
||||
planesTransponders.idents.push_back(transponderMode == CTransponder::StateIdent);
|
||||
planesTransponders.modeCs.push_back(transponderMode == CTransponder::ModeC);
|
||||
|
||||
@@ -682,7 +633,7 @@ namespace BlackSimPlugin
|
||||
const CInterpolationAndRenderingSetupPerCallsign setup = this->getInterpolationSetupConsolidated(callsign, updateAllAircraft);
|
||||
|
||||
// interpolated situation/parts
|
||||
const CInterpolationResult result = xplaneAircraft.getInterpolation(currentTimestamp, setup, aircraftNumber++);
|
||||
const CInterpolationResult result = flightgearAircraft.getInterpolation(currentTimestamp, setup, aircraftNumber++);
|
||||
if (result.getInterpolationStatus().hasValidSituation())
|
||||
{
|
||||
const CAircraftSituation interpolatedSituation(result);
|
||||
@@ -726,20 +677,20 @@ namespace BlackSimPlugin
|
||||
this->finishUpdateRemoteAircraftAndSetStatistics(currentTimestamp);
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::requestRemoteAircraftDataFromXPlane()
|
||||
void CSimulatorFlightgear::requestRemoteAircraftDataFromFlightgear()
|
||||
{
|
||||
if (!isConnected()) { return; }
|
||||
|
||||
// It is not required to request all elevations and CGs, but only for aircraft "near ground relevant"
|
||||
// - we could use the elevation cache and CG cache to decide if we need to request
|
||||
// - if an aircraft is on ground but not moving, we do not need to request elevation if we already have it (it will not change
|
||||
CCallsignSet callsigns = m_xplaneAircraftObjects.getAllCallsigns();
|
||||
CCallsignSet callsigns = m_flightgearAircraftObjects.getAllCallsigns();
|
||||
const CCallsignSet remove = this->getLastSentCanLikelySkipNearGroundInterpolation().getCallsigns();
|
||||
callsigns.remove(remove);
|
||||
if (!callsigns.isEmpty()) { this->requestRemoteAircraftDataFromXPlane(callsigns); }
|
||||
if (!callsigns.isEmpty()) { this->requestRemoteAircraftDataFromFlightgear(callsigns); }
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::requestRemoteAircraftDataFromXPlane(const CCallsignSet &callsigns)
|
||||
void CSimulatorFlightgear::requestRemoteAircraftDataFromFlightgear(const CCallsignSet &callsigns)
|
||||
{
|
||||
if (callsigns.isEmpty()) { return; }
|
||||
if (this->isShuttingDown()) { return; }
|
||||
@@ -750,18 +701,18 @@ namespace BlackSimPlugin
|
||||
});
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::triggerRequestRemoteAircraftDataFromXPlane(const CCallsignSet &callsigns)
|
||||
void CSimulatorFlightgear::triggerRequestRemoteAircraftDataFromFlightgear(const CCallsignSet &callsigns)
|
||||
{
|
||||
if (callsigns.isEmpty()) { return; }
|
||||
QPointer<CSimulatorXPlane> myself(this);
|
||||
QPointer<CSimulatorFlightgear> myself(this);
|
||||
QTimer::singleShot(0, this, [ = ]
|
||||
{
|
||||
if (!myself) { return; }
|
||||
this->requestRemoteAircraftDataFromXPlane(callsigns);
|
||||
this->requestRemoteAircraftDataFromFlightgear(callsigns);
|
||||
});
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::updateRemoteAircraftFromSimulator(
|
||||
void CSimulatorFlightgear::updateRemoteAircraftFromSimulator(
|
||||
const QStringList &callsigns, const QDoubleList &latitudesDeg, const QDoubleList &longitudesDeg,
|
||||
const QDoubleList &elevationsMeters, const QDoubleList &verticalOffsetsMeters)
|
||||
{
|
||||
@@ -780,16 +731,16 @@ namespace BlackSimPlugin
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
const CCallsign cs(callsigns[i]);
|
||||
if (!m_xplaneAircraftObjects.contains(cs)) { continue; }
|
||||
const CXPlaneMPAircraft xpAircraft = m_xplaneAircraftObjects[cs];
|
||||
if (!m_flightgearAircraftObjects.contains(cs)) { continue; }
|
||||
const CFlightgearMPAircraft fgAircraft = m_flightgearAircraftObjects[cs];
|
||||
|
||||
const double cgValue = verticalOffsetsMeters[i]; // XP offset is swift CG
|
||||
const double cgValue = verticalOffsetsMeters[i]; // FG offset is swift CG
|
||||
const CAltitude elevationAlt(elevationsMeters[i], CLengthUnit::m(), CLengthUnit::ft());
|
||||
const CElevationPlane elevation(CLatitude(latitudesDeg[i], CAngleUnit::deg()), CLongitude(longitudesDeg[i], CAngleUnit::deg()), elevationAlt, CElevationPlane::singlePointRadius());
|
||||
const CLength cg = std::isnan(cgValue) ?
|
||||
CLength::null() :
|
||||
CLength(cgValue, CLengthUnit::m(), CLengthUnit::ft());
|
||||
//this->rememberElevationAndCG(cs, xpAircraft.getAircraftModelString(), elevation, cg);
|
||||
//this->rememberElevationAndCG(cs, fgAircraft.getAircraftModelString(), elevation, cg);
|
||||
|
||||
// loopback
|
||||
if (logCallsigns.contains(cs))
|
||||
@@ -799,7 +750,7 @@ namespace BlackSimPlugin
|
||||
}
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::disconnectFromDBus()
|
||||
void CSimulatorFlightgear::disconnectFromDBus()
|
||||
{
|
||||
if (m_dBusConnection.isConnected())
|
||||
{
|
||||
@@ -811,7 +762,7 @@ namespace BlackSimPlugin
|
||||
m_dBusConnection = QDBusConnection { "default" };
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::onRemoteAircraftAdded(const QString &callsign)
|
||||
void CSimulatorFlightgear::onRemoteAircraftAdded(const QString &callsign)
|
||||
{
|
||||
const CCallsign cs(callsign);
|
||||
CSimulatedAircraft addedRemoteAircraft = this->getAircraftInRangeForCallsign(cs);
|
||||
@@ -846,14 +797,14 @@ namespace BlackSimPlugin
|
||||
const bool rendered = true;
|
||||
addedRemoteAircraft.setRendered(rendered);
|
||||
this->updateAircraftRendered(cs, rendered);
|
||||
this->triggerRequestRemoteAircraftDataFromXPlane(cs);
|
||||
this->triggerRequestRemoteAircraftDataFromFlightgear(cs);
|
||||
this->triggerAddNextPendingAircraft();
|
||||
|
||||
m_xplaneAircraftObjects.insert(addedRemoteAircraft.getCallsign(), CXPlaneMPAircraft(addedRemoteAircraft, this, &m_interpolationLogger));
|
||||
m_flightgearAircraftObjects.insert(addedRemoteAircraft.getCallsign(), CFlightgearMPAircraft(addedRemoteAircraft, this, &m_interpolationLogger));
|
||||
emit this->aircraftRenderingChanged(addedRemoteAircraft);
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::onRemoteAircraftAddingFailed(const QString &callsign)
|
||||
void CSimulatorFlightgear::onRemoteAircraftAddingFailed(const QString &callsign)
|
||||
{
|
||||
|
||||
const CCallsign cs(callsign);
|
||||
@@ -880,7 +831,7 @@ namespace BlackSimPlugin
|
||||
this->triggerAddNextPendingAircraft();
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::addNextPendingAircraft()
|
||||
void CSimulatorFlightgear::addNextPendingAircraft()
|
||||
{
|
||||
if (m_pendingToBeAddedAircraft.isEmpty()) { return; } // no more pending
|
||||
|
||||
@@ -897,9 +848,9 @@ namespace BlackSimPlugin
|
||||
this->physicallyAddRemoteAircraft(newRemoteAircraft);
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::triggerAddNextPendingAircraft()
|
||||
void CSimulatorFlightgear::triggerAddNextPendingAircraft()
|
||||
{
|
||||
QPointer<CSimulatorXPlane> myself(this);
|
||||
QPointer<CSimulatorFlightgear> myself(this);
|
||||
QTimer::singleShot(100, this, [ = ]
|
||||
{
|
||||
if (!myself) { return; }
|
||||
@@ -907,7 +858,7 @@ namespace BlackSimPlugin
|
||||
});
|
||||
}
|
||||
|
||||
int CSimulatorXPlane::detectTimeoutAdding()
|
||||
int CSimulatorFlightgear::detectTimeoutAdding()
|
||||
{
|
||||
if (m_addingInProgressAircraft.isEmpty()) { return 0; }
|
||||
const qint64 timeout = QDateTime::currentMSecsSinceEpoch() + TimeoutAdding;
|
||||
@@ -928,9 +879,9 @@ namespace BlackSimPlugin
|
||||
return timeoutCallsigns.size();
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::triggerRemoveAircraft(const CCallsign &callsign, qint64 deferMs)
|
||||
void CSimulatorFlightgear::triggerRemoveAircraft(const CCallsign &callsign, qint64 deferMs)
|
||||
{
|
||||
QPointer<CSimulatorXPlane> myself(this);
|
||||
QPointer<CSimulatorFlightgear> myself(this);
|
||||
QTimer::singleShot(deferMs, this, [ = ]
|
||||
{
|
||||
if (!myself) { return; }
|
||||
@@ -938,7 +889,7 @@ namespace BlackSimPlugin
|
||||
});
|
||||
}
|
||||
|
||||
QPair<qint64, qint64> CSimulatorXPlane::minMaxTimestampsAddInProgress() const
|
||||
QPair<qint64, qint64> CSimulatorFlightgear::minMaxTimestampsAddInProgress() const
|
||||
{
|
||||
static const QPair<qint64, qint64> empty(-1, -1);
|
||||
if (m_addingInProgressAircraft.isEmpty()) { return empty; }
|
||||
@@ -947,7 +898,7 @@ namespace BlackSimPlugin
|
||||
return QPair<qint64, qint64>(*mm.first, *mm.second);
|
||||
}
|
||||
|
||||
bool CSimulatorXPlane::canAddAircraft() const
|
||||
bool CSimulatorFlightgear::canAddAircraft() const
|
||||
{
|
||||
if (m_addingInProgressAircraft.isEmpty()) { return true; }
|
||||
|
||||
@@ -959,40 +910,40 @@ namespace BlackSimPlugin
|
||||
return canAdd;
|
||||
}
|
||||
|
||||
ISimulator *CSimulatorXPlaneFactory::create(const CSimulatorPluginInfo &info,
|
||||
ISimulator *CSimulatorFlightgearFactory::create(const CSimulatorPluginInfo &info,
|
||||
IOwnAircraftProvider *ownAircraftProvider,
|
||||
IRemoteAircraftProvider *remoteAircraftProvider,
|
||||
IWeatherGridProvider *weatherGridProvider,
|
||||
IClientProvider *clientProvider)
|
||||
{
|
||||
return new CSimulatorXPlane(info, ownAircraftProvider, remoteAircraftProvider, weatherGridProvider, clientProvider, this);
|
||||
return new CSimulatorFlightgear(info, ownAircraftProvider, remoteAircraftProvider, weatherGridProvider, clientProvider, this);
|
||||
}
|
||||
|
||||
CSimulatorXPlaneListener::CSimulatorXPlaneListener(const CSimulatorPluginInfo &info): ISimulatorListener(info)
|
||||
CSimulatorFlightgearListener::CSimulatorFlightgearListener(const CSimulatorPluginInfo &info): ISimulatorListener(info)
|
||||
{
|
||||
constexpr int QueryInterval = 5 * 1000; // 5 seconds
|
||||
m_timer.setInterval(QueryInterval);
|
||||
m_timer.setObjectName(this->objectName().append(":m_timer"));
|
||||
connect(&m_timer, &QTimer::timeout, this, &CSimulatorXPlaneListener::checkConnection);
|
||||
connect(&m_timer, &QTimer::timeout, this, &CSimulatorFlightgearListener::checkConnection);
|
||||
}
|
||||
|
||||
void CSimulatorXPlaneListener::startImpl()
|
||||
void CSimulatorFlightgearListener::startImpl()
|
||||
{
|
||||
m_timer.start();
|
||||
}
|
||||
|
||||
void CSimulatorXPlaneListener::stopImpl()
|
||||
void CSimulatorFlightgearListener::stopImpl()
|
||||
{
|
||||
m_timer.stop();
|
||||
}
|
||||
|
||||
void CSimulatorXPlaneListener::checkImpl()
|
||||
void CSimulatorFlightgearListener::checkImpl()
|
||||
{
|
||||
if (!m_timer.isActive()) { return; }
|
||||
if (this->isShuttingDown()) { return; }
|
||||
|
||||
m_timer.start(); // restart because we will check just now
|
||||
QPointer<CSimulatorXPlaneListener> myself(this);
|
||||
QPointer<CSimulatorFlightgearListener> myself(this);
|
||||
QTimer::singleShot(0, this, [ = ]
|
||||
{
|
||||
if (!myself) { return; }
|
||||
@@ -1000,12 +951,12 @@ namespace BlackSimPlugin
|
||||
});
|
||||
}
|
||||
|
||||
void CSimulatorXPlaneListener::checkConnection()
|
||||
void CSimulatorFlightgearListener::checkConnection()
|
||||
{
|
||||
if (this->isShuttingDown()) { return; }
|
||||
Q_ASSERT_X(!CThreadUtils::isCurrentThreadApplicationThread(), Q_FUNC_INFO, "Expect to run in background");
|
||||
|
||||
QString dbusAddress = m_xswiftbusServerSetting.getThreadLocal();
|
||||
QString dbusAddress = m_fgswiftbusServerSetting.getThreadLocal();
|
||||
if (CDBusServer::isSessionOrSystemAddress(dbusAddress))
|
||||
{
|
||||
checkConnectionViaBus(dbusAddress);
|
||||
@@ -1016,9 +967,9 @@ namespace BlackSimPlugin
|
||||
}
|
||||
}
|
||||
|
||||
void CSimulatorXPlaneListener::checkConnectionViaBus(const QString &address)
|
||||
void CSimulatorFlightgearListener::checkConnectionViaBus(const QString &address)
|
||||
{
|
||||
m_conn = CSimulatorXPlane::connectionFromString(address);
|
||||
m_conn = CSimulatorFlightgear::connectionFromString(address);
|
||||
if (!m_conn.isConnected())
|
||||
{
|
||||
m_conn.disconnectFromBus(m_conn.name());
|
||||
@@ -1028,9 +979,9 @@ namespace BlackSimPlugin
|
||||
m_conn.disconnectFromBus(m_conn.name());
|
||||
}
|
||||
|
||||
void CSimulatorXPlaneListener::checkConnectionViaPeer(const QString &address)
|
||||
void CSimulatorFlightgearListener::checkConnectionViaPeer(const QString &address)
|
||||
{
|
||||
m_conn = QDBusConnection::connectToPeer(address, "xswiftbus");
|
||||
m_conn = QDBusConnection::connectToPeer(address, "fgswiftbus");
|
||||
if (!m_conn.isConnected())
|
||||
{
|
||||
// This is required to cleanup the connection in QtDBus
|
||||
@@ -1041,40 +992,40 @@ namespace BlackSimPlugin
|
||||
m_conn.disconnectFromPeer(m_conn.name());
|
||||
}
|
||||
|
||||
void CSimulatorXPlaneListener::checkConnectionCommon()
|
||||
void CSimulatorFlightgearListener::checkConnectionCommon()
|
||||
{
|
||||
CXSwiftBusServiceProxy service(m_conn);
|
||||
CXSwiftBusTrafficProxy traffic(m_conn);
|
||||
CFGSwiftBusServiceProxy service(m_conn);
|
||||
CFGSwiftBusTrafficProxy traffic(m_conn);
|
||||
|
||||
bool result = service.isValid() && traffic.isValid();
|
||||
if (! result) { return; }
|
||||
|
||||
if (!traffic.initialize())
|
||||
{
|
||||
CLogMessage(this).error(u"Connection to XSwiftBus successful, but could not initialize XSwiftBus. Check X-Plane Log.txt.");
|
||||
CLogMessage(this).error(u"Connection to FGSwiftBus successful, but could not initialize FGSwiftBus.");
|
||||
return;
|
||||
}
|
||||
|
||||
MultiplayerAcquireInfo info = traffic.acquireMultiplayerPlanes();
|
||||
if (! info.hasAcquired)
|
||||
{
|
||||
CLogMessage(this).error(u"Connection to XSwiftBus successful, but could not acquire multiplayer planes. %1 has acquired them already. Disable %2 or remove it if not required and reload XSwiftBus.") << info.owner << info.owner;
|
||||
CLogMessage(this).error(u"Connection to FGSwiftBus successful, but could not acquire multiplayer planes. %1 has acquired them already. Disable %2 or remove it if not required and reload FGSwiftBus.") << info.owner << info.owner;
|
||||
return;
|
||||
}
|
||||
|
||||
emit simulatorStarted(getPluginInfo());
|
||||
}
|
||||
|
||||
void CSimulatorXPlaneListener::serviceRegistered(const QString &serviceName)
|
||||
void CSimulatorFlightgearListener::serviceRegistered(const QString &serviceName)
|
||||
{
|
||||
if (serviceName == xswiftbusServiceName())
|
||||
if (serviceName == fgswiftbusServiceName())
|
||||
{
|
||||
emit simulatorStarted(getPluginInfo());
|
||||
}
|
||||
m_conn.disconnectFromBus(m_conn.name());
|
||||
}
|
||||
|
||||
void CSimulatorXPlaneListener::xSwiftBusServerSettingChanged()
|
||||
void CSimulatorFlightgearListener::fgSwiftBusServerSettingChanged()
|
||||
{
|
||||
this->stop();
|
||||
this->start();
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKSIMPLUGIN_SIMULATOR_XPLANE_H
|
||||
#define BLACKSIMPLUGIN_SIMULATOR_XPLANE_H
|
||||
#ifndef BLACKSIMPLUGIN_SIMULATOR_FLIGHTGEAR_H
|
||||
#define BLACKSIMPLUGIN_SIMULATOR_FLIGHTGEAR_H
|
||||
|
||||
#include "flightgearmpaircraft.h"
|
||||
#include "plugins/simulator/flightgearconfig/simulatorflightgearconfig.h"
|
||||
@@ -63,13 +63,13 @@ namespace BlackMisc
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace XPlane
|
||||
namespace Flightgear
|
||||
{
|
||||
class CXSwiftBusServiceProxy;
|
||||
class CXSwiftBusTrafficProxy;
|
||||
class CFGSwiftBusServiceProxy;
|
||||
class CFGSwiftBusTrafficProxy;
|
||||
|
||||
//! X-Plane data
|
||||
struct XPlaneData
|
||||
//! Flightgear data
|
||||
struct FlightgearData
|
||||
{
|
||||
QString aircraftModelPath; //!< Aircraft model path
|
||||
QString aircraftIcaoCode; //!< Aircraft ICAO code
|
||||
@@ -100,14 +100,14 @@ namespace BlackSimPlugin
|
||||
double seaLevelPressureInHg; //!< Sea level pressure [inhg]
|
||||
};
|
||||
|
||||
//! X-Plane ISimulator implementation
|
||||
class CSimulatorXPlane : public Common::CSimulatorPluginCommon
|
||||
//! Flightgear ISimulator implementation
|
||||
class CSimulatorFlightgear : public Common::CSimulatorPluginCommon
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
CSimulatorXPlane(const BlackMisc::Simulation::CSimulatorPluginInfo &info,
|
||||
CSimulatorFlightgear(const BlackMisc::Simulation::CSimulatorPluginInfo &info,
|
||||
BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider,
|
||||
BlackMisc::Simulation::IRemoteAircraftProvider *remoteAircraftProvider,
|
||||
BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider,
|
||||
@@ -115,11 +115,11 @@ namespace BlackSimPlugin
|
||||
QObject *parent = nullptr);
|
||||
|
||||
//! Dtor
|
||||
virtual ~CSimulatorXPlane() override;
|
||||
virtual ~CSimulatorFlightgear() override;
|
||||
|
||||
//! \name ISimulator implementations
|
||||
//! @{
|
||||
virtual bool isTimeSynchronized() const override { return false; } // TODO: Can we query the XP intrinisc feature?
|
||||
virtual bool isTimeSynchronized() const override { return false; }
|
||||
virtual bool connectTo() override;
|
||||
virtual bool disconnectFrom() override;
|
||||
virtual bool updateOwnSimulatorCockpit(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const BlackMisc::CIdentifier &originator) override;
|
||||
@@ -154,7 +154,6 @@ namespace BlackSimPlugin
|
||||
virtual void clearAllRemoteAircraftData() override;
|
||||
virtual bool isPaused() const override
|
||||
{
|
||||
//! \todo XP: provide correct pause state
|
||||
return false;
|
||||
}
|
||||
//! @}
|
||||
@@ -177,17 +176,14 @@ namespace BlackSimPlugin
|
||||
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();
|
||||
|
||||
//! Request elevation and CG from XPlane @{
|
||||
void requestRemoteAircraftDataFromXPlane();
|
||||
void requestRemoteAircraftDataFromXPlane(const BlackMisc::Aviation::CCallsignSet &callsigns);
|
||||
void triggerRequestRemoteAircraftDataFromXPlane(const BlackMisc::Aviation::CCallsignSet &callsigns);
|
||||
//! Request elevation and CG from Flightgear @{
|
||||
void requestRemoteAircraftDataFromFlightgear();
|
||||
void requestRemoteAircraftDataFromFlightgear(const BlackMisc::Aviation::CCallsignSet &callsigns);
|
||||
void triggerRequestRemoteAircraftDataFromFlightgear(const BlackMisc::Aviation::CCallsignSet &callsigns);
|
||||
//! @}
|
||||
|
||||
//! Adding new aircraft @{
|
||||
@@ -218,46 +214,46 @@ namespace BlackSimPlugin
|
||||
void disconnectFromDBus();
|
||||
|
||||
DBusMode m_dbusMode;
|
||||
BlackMisc::CSettingReadOnly<BlackMisc::Simulation::Settings::TXSwiftBusServer> m_xswiftbusServerSetting { this };
|
||||
BlackMisc::CSettingReadOnly<BlackMisc::Simulation::Settings::TFGSwiftBusServer> m_fgswiftbusServerSetting { this };
|
||||
static constexpr qint64 TimeoutAdding = 10000;
|
||||
QDBusConnection m_dBusConnection { "default" };
|
||||
QDBusServiceWatcher *m_watcher { nullptr };
|
||||
CXSwiftBusServiceProxy *m_serviceProxy { nullptr };
|
||||
CXSwiftBusTrafficProxy *m_trafficProxy { nullptr };
|
||||
CFGSwiftBusServiceProxy *m_serviceProxy { nullptr };
|
||||
CFGSwiftBusTrafficProxy *m_trafficProxy { 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::CData<BlackMisc::Simulation::Data::TModelSetCacheFG> m_modelSet { this }; //!< Flightgear 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
|
||||
CFlightgearMPAircraftObjects m_flightgearAircraftObjects; //!< Flightgear multiplayer aircraft
|
||||
FlightgearData m_flightgearData; //!< Flightgear data
|
||||
|
||||
// statistics
|
||||
qint64 m_statsAddMaxTimeMs = -1;
|
||||
qint64 m_statsAddCurrentTimeMs = -1;
|
||||
|
||||
//! Reset the XPlane data
|
||||
void resetXPlaneData()
|
||||
//! Reset the Flightgear data
|
||||
void resetFlightgearData()
|
||||
{
|
||||
m_xplaneData = { "", "", 0, 0, 0, 0, 0, 0, 0, false, 122800, 122800, 122800, 122800, 2000, 0, false, false, false, false,
|
||||
m_flightgearData = { "", "", 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
|
||||
//! Listener waits for fgswiftbus service to show up
|
||||
class CSimulatorFlightgearListener : public BlackCore::ISimulatorListener
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
CSimulatorXPlaneListener(const BlackMisc::Simulation::CSimulatorPluginInfo &info);
|
||||
CSimulatorFlightgearListener(const BlackMisc::Simulation::CSimulatorPluginInfo &info);
|
||||
|
||||
protected:
|
||||
//! \copydoc BlackCore::ISimulatorListener::startImpl
|
||||
@@ -276,15 +272,15 @@ namespace BlackSimPlugin
|
||||
void checkConnectionCommon();
|
||||
|
||||
void serviceRegistered(const QString &serviceName);
|
||||
void xSwiftBusServerSettingChanged();
|
||||
void fgSwiftBusServerSettingChanged();
|
||||
|
||||
QTimer m_timer { this };
|
||||
QDBusConnection m_conn { "default" };
|
||||
BlackMisc::CSettingReadOnly<BlackMisc::Simulation::Settings::TXSwiftBusServer> m_xswiftbusServerSetting { this, &CSimulatorXPlaneListener::xSwiftBusServerSettingChanged };
|
||||
BlackMisc::CSettingReadOnly<BlackMisc::Simulation::Settings::TFGSwiftBusServer> m_fgswiftbusServerSetting { this, &CSimulatorFlightgearListener::fgSwiftBusServerSettingChanged };
|
||||
};
|
||||
|
||||
//! Factory for creating CSimulatorXPlane instance
|
||||
class CSimulatorXPlaneFactory : public QObject, public BlackCore::ISimulatorFactory
|
||||
//! Factory for creating CSimulatorFlightgear instance
|
||||
class CSimulatorFlightgearFactory : public QObject, public BlackCore::ISimulatorFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.swift-project.blackcore.simulatorinterface" FILE "simulatorflightgear.json")
|
||||
@@ -299,7 +295,7 @@ namespace BlackSimPlugin
|
||||
BlackMisc::Network::IClientProvider *clientProvider) override;
|
||||
|
||||
//! \copydoc BlackCore::ISimulatorFactory::createListener
|
||||
virtual BlackCore::ISimulatorListener *createListener(const BlackMisc::Simulation::CSimulatorPluginInfo &info) override { return new CSimulatorXPlaneListener(info); }
|
||||
virtual BlackCore::ISimulatorListener *createListener(const BlackMisc::Simulation::CSimulatorPluginInfo &info) override { return new CSimulatorFlightgearListener(info); }
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
"identifier" : "org.swift-project.plugins.simulator.flightgear",
|
||||
"name" : "Flightgear",
|
||||
"simulator" : "flightgear",
|
||||
"description" : "Support for the Flightgear simulator via the xswiftbus plugin.",
|
||||
"description" : "Support for the Flightgear simulator via the fgswiftbus plugin.",
|
||||
"config" : "org.swift-project.plugins.simulator.flightgear.config"
|
||||
}
|
||||
|
||||
@@ -13,16 +13,16 @@ class QWidget;
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace XPlane
|
||||
namespace Flightgear
|
||||
{
|
||||
CSimulatorXPlaneConfig::CSimulatorXPlaneConfig(QObject *parent) : QObject(parent)
|
||||
CSimulatorFlightgearConfig::CSimulatorFlightgearConfig(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
BlackGui::CPluginConfigWindow *CSimulatorXPlaneConfig::createConfigWindow(QWidget *parent)
|
||||
BlackGui::CPluginConfigWindow *CSimulatorFlightgearConfig::createConfigWindow(QWidget *parent)
|
||||
{
|
||||
CSimulatorXPlaneConfigWindow* w = new CSimulatorXPlaneConfigWindow(parent);
|
||||
CSimulatorFlightgearConfigWindow* w = new CSimulatorFlightgearConfigWindow(parent);
|
||||
return w;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKSIMPLUGIN_SIMULATOR_XPLANE_CONFIG_H
|
||||
#define BLACKSIMPLUGIN_SIMULATOR_XPLANE_CONFIG_H
|
||||
#ifndef BLACKSIMPLUGIN_SIMULATOR_FLIGHTGEAR_CONFIG_H
|
||||
#define BLACKSIMPLUGIN_SIMULATOR_FLIGHTGEAR_CONFIG_H
|
||||
|
||||
#include "blackgui/pluginconfig.h"
|
||||
#include "blackmisc/settingscache.h"
|
||||
@@ -22,12 +22,12 @@ class QWidget;
|
||||
namespace BlackGui { class CPluginConfigWindow; }
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace XPlane
|
||||
namespace Flightgear
|
||||
{
|
||||
/*!
|
||||
* Config plugin for the X-Plane plugin.
|
||||
* Config plugin for the Flightgear plugin.
|
||||
*/
|
||||
class CSimulatorXPlaneConfig : public QObject, public BlackGui::IPluginConfig
|
||||
class CSimulatorFlightgearConfig : public QObject, public BlackGui::IPluginConfig
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.swift-project.blackgui.pluginconfiginterface" FILE "simulatorflightgearconfig.json")
|
||||
@@ -35,10 +35,10 @@ namespace BlackSimPlugin
|
||||
|
||||
public:
|
||||
//! Ctor
|
||||
CSimulatorXPlaneConfig(QObject *parent = nullptr);
|
||||
CSimulatorFlightgearConfig(QObject *parent = nullptr);
|
||||
|
||||
//! Dtor
|
||||
virtual ~CSimulatorXPlaneConfig() {}
|
||||
virtual ~CSimulatorFlightgearConfig() {}
|
||||
|
||||
//! \copydoc BlackGui::IPluginConfig::createConfigWindow()
|
||||
BlackGui::CPluginConfigWindow *createConfigWindow(QWidget *parent) override;
|
||||
|
||||
@@ -9,44 +9,44 @@
|
||||
#include "simulatorflightgearconfigwindow.h"
|
||||
#include "blackcore/application.h"
|
||||
#include "ui_simulatorflightgearconfigwindow.h"
|
||||
#include "blackmisc/simulation/xplane/xswiftbusconfigwriter.h"
|
||||
#include "blackmisc/simulation/flightgear/fgswiftbusconfigwriter.h"
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QDialogButtonBox>
|
||||
|
||||
using namespace BlackGui;
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation::XPlane;
|
||||
using namespace BlackMisc::Simulation::Flightgear;
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace XPlane
|
||||
namespace Flightgear
|
||||
{
|
||||
CSimulatorXPlaneConfigWindow::CSimulatorXPlaneConfigWindow(QWidget *parent) :
|
||||
CSimulatorFlightgearConfigWindow::CSimulatorFlightgearConfigWindow(QWidget *parent) :
|
||||
CPluginConfigWindow(parent),
|
||||
ui(new Ui::CSimulatorXPlaneConfigWindow)
|
||||
ui(new Ui::CSimulatorFlightgearConfigWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->comp_SettingsXSwiftBus->setDefaultP2PAddress(m_xswiftbusServerSetting.getDefault());
|
||||
ui->comp_SettingsXSwiftBus->set(m_xswiftbusServerSetting.getThreadLocal());
|
||||
ui->comp_SettingsFGSwiftBus->setDefaultP2PAddress(m_fgswiftbusServerSetting.getDefault());
|
||||
ui->comp_SettingsFGSwiftBus->set(m_fgswiftbusServerSetting.getThreadLocal());
|
||||
|
||||
connect(ui->bb_OkCancel, &QDialogButtonBox::accepted, this, &CSimulatorXPlaneConfigWindow::onSettingsAccepted);
|
||||
connect(ui->bb_OkCancel, &QDialogButtonBox::rejected, this, &CSimulatorXPlaneConfigWindow::close);
|
||||
connect(ui->bb_OkCancel, &QDialogButtonBox::accepted, this, &CSimulatorFlightgearConfigWindow::onSettingsAccepted);
|
||||
connect(ui->bb_OkCancel, &QDialogButtonBox::rejected, this, &CSimulatorFlightgearConfigWindow::close);
|
||||
}
|
||||
|
||||
CSimulatorXPlaneConfigWindow::~CSimulatorXPlaneConfigWindow()
|
||||
CSimulatorFlightgearConfigWindow::~CSimulatorFlightgearConfigWindow()
|
||||
{ }
|
||||
|
||||
void CSimulatorXPlaneConfigWindow::onSettingsAccepted()
|
||||
void CSimulatorFlightgearConfigWindow::onSettingsAccepted()
|
||||
{
|
||||
const QString currentAddress = m_xswiftbusServerSetting.getThreadLocal();
|
||||
const QString updatedAddress = ui->comp_SettingsXSwiftBus->getDBusAddress();
|
||||
if (currentAddress != ui->comp_SettingsXSwiftBus->getDBusAddress())
|
||||
const QString currentAddress = m_fgswiftbusServerSetting.getThreadLocal();
|
||||
const QString updatedAddress = ui->comp_SettingsFGSwiftBus->getDBusAddress();
|
||||
if (currentAddress != ui->comp_SettingsFGSwiftBus->getDBusAddress())
|
||||
{
|
||||
m_xswiftbusServerSetting.set(updatedAddress);
|
||||
CXSwiftBusConfigWriter xswiftbusConfigWriter;
|
||||
xswiftbusConfigWriter.setDBusAddress(updatedAddress);
|
||||
xswiftbusConfigWriter.updateInAllXPlaneVersions();
|
||||
m_fgswiftbusServerSetting.set(updatedAddress);
|
||||
CFGSwiftBusConfigWriter fgswiftbusConfigWriter;
|
||||
fgswiftbusConfigWriter.setDBusAddress(updatedAddress);
|
||||
fgswiftbusConfigWriter.updateInAllXPlaneVersions();
|
||||
}
|
||||
close();
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKSIMPLUGIN_SIMULATOR_XPLANE_CONFIG_WINDOW_H
|
||||
#define BLACKSIMPLUGIN_SIMULATOR_XPLANE_CONFIG_WINDOW_H
|
||||
#ifndef BLACKSIMPLUGIN_SIMULATOR_FLIGHTGEAR_CONFIG_WINDOW_H
|
||||
#define BLACKSIMPLUGIN_SIMULATOR_FLIGHTGEAR_CONFIG_WINDOW_H
|
||||
|
||||
#include "blackgui/pluginconfigwindow.h"
|
||||
#include "blackmisc/simulation/settings/fgsettings.h"
|
||||
@@ -17,31 +17,31 @@
|
||||
#include <QObject>
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace Ui { class CSimulatorXPlaneConfigWindow; }
|
||||
namespace Ui { class CSimulatorFlightgearConfigWindow; }
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace XPlane
|
||||
namespace Flightgear
|
||||
{
|
||||
/**
|
||||
* A window that shows all the X-Plane plugin options.
|
||||
* A window that shows all the Flightgear plugin options.
|
||||
*/
|
||||
class CSimulatorXPlaneConfigWindow : public BlackGui::CPluginConfigWindow
|
||||
class CSimulatorFlightgearConfigWindow : public BlackGui::CPluginConfigWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Ctor.
|
||||
CSimulatorXPlaneConfigWindow(QWidget *parent);
|
||||
CSimulatorFlightgearConfigWindow(QWidget *parent);
|
||||
|
||||
//! Dtor.
|
||||
virtual ~CSimulatorXPlaneConfigWindow();
|
||||
virtual ~CSimulatorFlightgearConfigWindow();
|
||||
|
||||
private:
|
||||
//! Settings have been accepted
|
||||
void onSettingsAccepted();
|
||||
|
||||
QScopedPointer<Ui::CSimulatorXPlaneConfigWindow> ui;
|
||||
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TXSwiftBusServer> m_xswiftbusServerSetting { this };
|
||||
QScopedPointer<Ui::CSimulatorFlightgearConfigWindow> ui;
|
||||
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TFGSwiftBusServer> m_fgswiftbusServerSetting { this };
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CSimulatorXPlaneConfigWindow</class>
|
||||
<widget class="QWidget" name="CSimulatorXPlaneConfigWindow">
|
||||
<class>CSimulatorFlightgearConfigWindow</class>
|
||||
<widget class="QWidget" name="CSimulatorFlightgearConfigWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@@ -17,7 +17,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>X-Plane plugin settings</string>
|
||||
<string>Flightgear plugin settings</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gl_ConfigWindow">
|
||||
<property name="leftMargin">
|
||||
@@ -46,7 +46,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" alignment="Qt::AlignTop">
|
||||
<widget class="BlackGui::Components::CDBusServerAddressSelector" name="comp_SettingsXSwiftBus">
|
||||
<widget class="BlackGui::Components::CDBusServerAddressSelector" name="comp_SettingsFGSwiftBus">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
|
||||
Reference in New Issue
Block a user