mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-24 07:55:35 +08:00
refs #466 Resolved TODO items in xbus.
This commit is contained in:
@@ -97,6 +97,24 @@ namespace BlackSimPlugin
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getXPlanePreferencesPath"), setterCallback(o_prefsPath));
|
||||
}
|
||||
|
||||
bool CXBusServiceProxy::isPaused() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<bool>(QLatin1String("isPaused"));
|
||||
}
|
||||
void CXBusServiceProxy::isPausedAsync(bool *o_paused)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("isPaused"), setterCallback(o_paused));
|
||||
}
|
||||
|
||||
bool CXBusServiceProxy::isUsingRealTime() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<bool>(QLatin1String("isUsingRealTime"));
|
||||
}
|
||||
void CXBusServiceProxy::isUsingRealTimeAsync(bool *o_isRealTime)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("isUsingRealTime"), setterCallback(o_isRealTime));
|
||||
}
|
||||
|
||||
double CXBusServiceProxy::getLatitude() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<double>(QLatin1String("getLatitude"));
|
||||
|
||||
@@ -130,6 +130,18 @@ namespace BlackSimPlugin
|
||||
void getXPlanePreferencesPathAsync(QString *o_prefsPath);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XBus::CService::isPaused
|
||||
//! @{
|
||||
bool isPaused() const;
|
||||
void isPausedAsync(bool *o_paused);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XBus::CService::isUsingRealTime
|
||||
//! @{
|
||||
bool isUsingRealTime() const;
|
||||
void isUsingRealTimeAsync(bool *o_isRealTime);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XBus::CService::getLatitude
|
||||
//! @{
|
||||
double getLatitude() const;
|
||||
|
||||
@@ -55,6 +55,16 @@ namespace BlackSimPlugin
|
||||
m_dbusInterface->callDBus(QLatin1String("updateInstalledModels"));
|
||||
}
|
||||
|
||||
void CXBusTrafficProxy::setMaxPlanes(int planes)
|
||||
{
|
||||
m_dbusInterface->callDBus(QLatin1String("setMaxPlanes"), planes);
|
||||
}
|
||||
|
||||
void CXBusTrafficProxy::setDrawDistance(float nauticalMiles)
|
||||
{
|
||||
m_dbusInterface->callDBus(QLatin1String("setDrawDistance"), nauticalMiles);
|
||||
}
|
||||
|
||||
void CXBusTrafficProxy::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);
|
||||
|
||||
@@ -77,6 +77,12 @@ namespace BlackSimPlugin
|
||||
//! \copydoc XBus::CTraffic::updateInstalledModels
|
||||
void updateInstalledModels() const;
|
||||
|
||||
//! \copydoc XBus::CTraffic::setMaxPlanes
|
||||
void setMaxPlanes(int planes);
|
||||
|
||||
//! \copydoc XBus::CTraffic::setDrawDistance
|
||||
void setDrawDistance(float nauticalMiles);
|
||||
|
||||
//! \copydoc XBus::CTraffic::addPlane
|
||||
void addPlane(const QString &callsign, const QString &modelName, const QString &aircraftIcao, const QString &airlineIcao, const QString &livery);
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
//! \file
|
||||
|
||||
#include <XPLM/XPLMDataAccess.h>
|
||||
#include <XPLM/XPLMUtilities.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
@@ -24,7 +25,11 @@ namespace XBus
|
||||
public:
|
||||
DataRefImpl(char const* name) : m_ref(XPLMFindDataRef(name))
|
||||
{
|
||||
//TODO warn if m_ref is NULL
|
||||
if (! m_ref)
|
||||
{
|
||||
XPLMDebugString("Missing dataref:");
|
||||
XPLMDebugString(name);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -43,7 +48,11 @@ namespace XBus
|
||||
public:
|
||||
ArrayDataRefImpl(char const* name, size_t size) : m_ref(XPLMFindDataRef(name)), m_size(size)
|
||||
{
|
||||
//TODO warn if m_ref is NULL
|
||||
if (! m_ref)
|
||||
{
|
||||
XPLMDebugString("Missing dataref:");
|
||||
XPLMDebugString(name);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -131,7 +140,11 @@ namespace XBus
|
||||
//! Constructor
|
||||
StringDataRef() : m_ref(XPLMFindDataRef(DataRefTraits::name()))
|
||||
{
|
||||
//TODO warn if m_ref is NULL
|
||||
if (! m_ref)
|
||||
{
|
||||
XPLMDebugString("Missing dataref:");
|
||||
XPLMDebugString(DataRefTraits::name());
|
||||
}
|
||||
}
|
||||
|
||||
//! Set the value of the whole string (if it is writable)
|
||||
|
||||
@@ -98,6 +98,12 @@ namespace XBus
|
||||
//! Get full path to X-Plane preferences file
|
||||
QString getXPlanePreferencesPath() const;
|
||||
|
||||
//! True if sim is paused
|
||||
bool isPaused() const { return m_paused.get(); }
|
||||
|
||||
//! True if sim time is tracking operating system time
|
||||
bool isUsingRealTime() const { return m_useSystemTime.get(); }
|
||||
|
||||
//! Get aircraft latitude in degrees
|
||||
double getLatitude() const { return m_latitude.get(); }
|
||||
|
||||
@@ -217,6 +223,8 @@ namespace XBus
|
||||
|
||||
StringDataRef<xplane::data::sim::aircraft::view::acf_livery_path> m_liveryPath;
|
||||
StringDataRef<xplane::data::sim::aircraft::view::acf_ICAO> m_icao;
|
||||
DataRef<xplane::data::sim::time::paused> m_paused;
|
||||
DataRef<xplane::data::sim::time::use_system_time> m_useSystemTime;
|
||||
DataRef<xplane::data::sim::flightmodel::position::latitude> m_latitude;
|
||||
DataRef<xplane::data::sim::flightmodel::position::longitude> m_longitude;
|
||||
DataRef<xplane::data::sim::flightmodel::position::elevation> m_elevation;
|
||||
|
||||
@@ -101,19 +101,24 @@ namespace XBus
|
||||
}
|
||||
}
|
||||
|
||||
int g_maxPlanes = 100;
|
||||
float g_drawDistance = 50.0f;
|
||||
|
||||
int CTraffic::preferences(const char *section, const char *name, int def)
|
||||
{
|
||||
Q_UNUSED(name);
|
||||
Q_UNUSED(section);
|
||||
// TODO [planes] max_full_count
|
||||
if (strcmp(section, "planes") == 0 && strcmp(name, "max_full_count") == 0)
|
||||
{
|
||||
return g_maxPlanes;
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
float CTraffic::preferences(const char *section, const char *name, float def)
|
||||
{
|
||||
// TODO [planes] full_distance
|
||||
Q_UNUSED(name);
|
||||
Q_UNUSED(section);
|
||||
if (strcmp(section, "planes") == 0 && strcmp(name, "full_distance") == 0)
|
||||
{
|
||||
return g_drawDistance;
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
@@ -173,6 +178,16 @@ namespace XBus
|
||||
emit installedModelsUpdated(modelNames, icaos, airlines, liveries);
|
||||
}
|
||||
|
||||
void CTraffic::setMaxPlanes(int planes)
|
||||
{
|
||||
g_maxPlanes = planes;
|
||||
}
|
||||
|
||||
void CTraffic::setMaxDrawDistance(float nauticalMiles)
|
||||
{
|
||||
g_drawDistance = nauticalMiles;
|
||||
}
|
||||
|
||||
void CTraffic::addPlane(const QString &callsign, const QString &modelName, const QString &aircraftIcao, const QString &airlineIcao, const QString &livery)
|
||||
{
|
||||
XPMPPlaneID id = nullptr;
|
||||
|
||||
@@ -81,6 +81,12 @@ namespace XBus
|
||||
//! Called by newly connected client to cause installedModelsUpdated to be emitted.
|
||||
void updateInstalledModels();
|
||||
|
||||
//! Set the maximum number of aircraft.
|
||||
void setMaxPlanes(int planes);
|
||||
|
||||
//! Set the maximum distance at which to draw aircraft (nautical miles).
|
||||
void setMaxDrawDistance(float nauticalMiles);
|
||||
|
||||
//! Introduce a new traffic aircraft
|
||||
void addPlane(const QString &callsign, const QString &modelName, const QString &aircraftIcao, const QString &airlineIcao, const QString &livery);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user