refs #466 Added a weather service class for XBus.

This commit is contained in:
Mathew Sutcliffe
2015-09-22 20:12:21 +01:00
parent f757adbf5a
commit b489b888a3
8 changed files with 418 additions and 0 deletions

View File

@@ -10,6 +10,7 @@
#include "simulator_xplane.h"
#include "xbus_service_proxy.h"
#include "xbus_traffic_proxy.h"
#include "xbus_weather_proxy.h"
#include "blackmisc/logmessage.h"
#include "blackmisc/blackmiscfreefunctions.h"
#include "blackmisc/simulation/modelmappingsprovider.h"

View File

@@ -27,6 +27,7 @@ namespace BlackSimPlugin
{
class CXBusServiceProxy;
class CXBusTrafficProxy;
class CXBusWeatherProxy;
//! X-Plane ISimulator implementation
class CSimulatorXPlane : public BlackCore::CSimulatorCommon
@@ -135,6 +136,7 @@ namespace BlackSimPlugin
QDBusServiceWatcher *m_watcher { nullptr };
CXBusServiceProxy *m_service { nullptr };
CXBusTrafficProxy *m_traffic { nullptr };
CXBusWeatherProxy *m_weather { nullptr };
QTimer *m_fastTimer { nullptr };
QTimer *m_slowTimer { nullptr };
BlackMisc::Aviation::CAirportList m_airportsInRange; //!< aiports in range of own aircraft

View File

@@ -0,0 +1,86 @@
/* Copyright (C) 2015
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
#include "xbus_weather_proxy.h"
#include "blackcore/dbus_server.h"
#define XBUS_SERVICENAME "org.swift-project.xbus"
namespace BlackSimPlugin
{
namespace XPlane
{
CXBusWeatherProxy::CXBusWeatherProxy(QDBusConnection &connection, QObject *parent) : QObject(parent)
{
m_dbusInterface = new BlackMisc::CGenericDBusInterface(XBUS_SERVICENAME, ObjectPath(), InterfaceName(), connection, this);
}
bool CXBusWeatherProxy::isUsingRealWeather() const
{
return m_dbusInterface->callDBusRet<bool>(QLatin1String("isUsingRealWeather"));
}
void CXBusWeatherProxy::setUseRealWeather(bool enable)
{
m_dbusInterface->callDBus(QLatin1String("setUseRealWeather"), enable);
}
void CXBusWeatherProxy::setVisibility(float visibilityM)
{
m_dbusInterface->callDBus(QLatin1String("setVisibility"), visibilityM);
}
void CXBusWeatherProxy::setTemperature(int degreesC)
{
m_dbusInterface->callDBus(QLatin1String("setTemperature"), degreesC);
}
void CXBusWeatherProxy::setDewPoint(int degreesC)
{
m_dbusInterface->callDBus(QLatin1String("setDewPoint"), degreesC);
}
void CXBusWeatherProxy::setQNH(float inHg)
{
m_dbusInterface->callDBus(QLatin1String("setQNH"), inHg);
}
void CXBusWeatherProxy::setPrecipitationRatio(float precipRatio)
{
m_dbusInterface->callDBus(QLatin1String("setPrecipitationRatio"), precipRatio);
}
void CXBusWeatherProxy::setThunderstormRatio(float cbRatio)
{
m_dbusInterface->callDBus(QLatin1String("setThunderstormRatio"), cbRatio);
}
void CXBusWeatherProxy::setTurbulenceRatio(float turbulenceRatio)
{
m_dbusInterface->callDBus(QLatin1String("setTurbulenceRatio"), turbulenceRatio);
}
void CXBusWeatherProxy::setRunwayFriction(int friction)
{
m_dbusInterface->callDBus(QLatin1String("setRunwayFriction"), friction);
}
void CXBusWeatherProxy::setCloudLayer(int layer, int base, int tops, int type, int coverage)
{
m_dbusInterface->callDBus(QLatin1String("setCloudLayer"), layer, base, tops, type, coverage);
}
void CXBusWeatherProxy::setWindLayer(int layer, int altitude, float direction, int speed, int shearDirection, int shearSpeed, int turbulence)
{
m_dbusInterface->callDBus(QLatin1String("setWindLayer"), layer, altitude, direction, speed, shearDirection, shearSpeed, turbulence);
}
}
}

View File

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