refactor: Remove weather support

This commit is contained in:
Lars Toenning
2024-08-05 23:05:09 +02:00
parent 5b6abbefaf
commit de7b820112
172 changed files with 28 additions and 17332 deletions

View File

@@ -8,7 +8,6 @@ endif()
add_library(xswiftbus SHARED
org.swift_project.xswiftbus.service.xml
org.swift_project.xswiftbus.traffic.xml
org.swift_project.xswiftbus.weather.xml
xswiftbus.conf
command.h
config.cpp
@@ -47,8 +46,6 @@ add_library(xswiftbus SHARED
traffic.h
utils.cpp
utils.h
weather.cpp
weather.h
xplanemp2/src/CSL.cpp
xplanemp2/src/CSL.h

View File

@@ -1,50 +0,0 @@
R"XML(<node>
<interface name="org.swift_project.xswiftbus.weather">
<method name="isUsingRealWeather">
<arg type="b" direction="out"/>
</method>
<method name="setUseRealWeather">
<arg name="enable" type="b" direction="in"/>
</method>
<method name="setVisibility">
<arg name="visibilityM" type="d" direction="in"/>
</method>
<method name="setTemperature">
<arg name="degreesC" type="i" direction="in"/>
</method>
<method name="setDewPoint">
<arg name="degreesC" type="i" direction="in"/>
</method>
<method name="setQNH">
<arg name="inHg" type="d" direction="in"/>
</method>
<method name="setPrecipitationRatio">
<arg name="precipRatio" type="d" direction="in"/>
</method>
<method name="setThunderstormRatio">
<arg name="cbRatio" type="d" direction="in"/>
</method>
<method name="setTurbulenceRatio">
<arg name="turbulenceRatio" type="d" direction="in"/>
</method>
<method name="setRunwayFriction">
<arg name="friction" type="i" direction="in"/>
</method>
<method name="setCloudLayer">
<arg name="layer" type="i" direction="in"/>
<arg name="base" type="i" direction="in"/>
<arg name="tops" type="i" direction="in"/>
<arg name="type" type="i" direction="in"/>
<arg name="coverage" type="i" direction="in"/>
</method>
<method name="setWindLayer">
<arg name="layer" type="i" direction="in"/>
<arg name="altitude" type="i" direction="in"/>
<arg name="direction" type="d" direction="in"/>
<arg name="speed" type="i" direction="in"/>
<arg name="shearDirection" type="i" direction="in"/>
<arg name="shearSpeed" type="i" direction="in"/>
<arg name="turbulence" type="i" direction="in"/>
</method>
</interface>
</node>)XML"

View File

@@ -4,7 +4,6 @@
#include "plugin.h"
#include "service.h"
#include "traffic.h"
#include "weather.h"
#include "utils.h"
#include "XPLM/XPLMProcessing.h"
#include <cmath>
@@ -90,7 +89,6 @@ namespace XSwiftBus
m_service = std::make_unique<CService>(this);
m_traffic = std::make_unique<CTraffic>(this);
m_weather = std::make_unique<CWeather>(this);
m_traffic->setPlaneViewMenu(m_planeViewSubMenu);
@@ -114,8 +112,6 @@ namespace XSwiftBus
m_service->registerDBusObjectPath(m_service->InterfaceName(), m_service->ObjectPath());
m_traffic->setDBusConnection(m_dbusConnection);
m_traffic->registerDBusObjectPath(m_traffic->InterfaceName(), m_traffic->ObjectPath());
m_weather->setDBusConnection(m_dbusConnection);
m_weather->registerDBusObjectPath(m_weather->InterfaceName(), m_weather->ObjectPath());
});
}
else
@@ -136,8 +132,6 @@ namespace XSwiftBus
m_service->registerDBusObjectPath(m_service->InterfaceName(), m_service->ObjectPath());
m_traffic->setDBusConnection(m_dbusConnection);
m_traffic->registerDBusObjectPath(m_traffic->InterfaceName(), m_traffic->ObjectPath());
m_weather->setDBusConnection(m_dbusConnection);
m_weather->registerDBusObjectPath(m_weather->InterfaceName(), m_weather->ObjectPath());
}
//! todo RR: Send all logs to the the message window.
@@ -190,7 +184,6 @@ namespace XSwiftBus
plugin->m_dbusDispatcher.runOnce();
if (plugin->m_service) { plugin->m_service->process(); }
if (plugin->m_weather) { plugin->m_weather->process(); }
if (plugin->m_traffic) { plugin->m_traffic->process(); }
return -1;
}

View File

@@ -31,7 +31,6 @@ namespace XSwiftBus
{
class CService;
class CTraffic;
class CWeather;
/*!
* Main plugin class
@@ -73,7 +72,6 @@ namespace XSwiftBus
std::shared_ptr<CDBusConnection> m_dbusConnection;
std::unique_ptr<CService> m_service;
std::unique_ptr<CTraffic> m_traffic;
std::unique_ptr<CWeather> m_weather;
CMenu m_menu;
CMenuItem m_showHideLabelsMenuItem;
CMenuItem m_enableDisableXPlaneAtisMenuItem;

View File

@@ -1,233 +0,0 @@
// SPDX-FileCopyrightText: Copyright (C) 2015 swift Project Community / Contributors
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
//! \cond PRIVATE
#include "weather.h"
#include "utils.h"
namespace XSwiftBus
{
CWeather::CWeather(CSettingsProvider *settingsProvider) : CDBusObject(settingsProvider)
{
// void
}
//! Set cloud layer
template <class T>
void setCloudLayerImpl(T &layer, int base, int tops, int type, int coverage)
{
layer.base.setAsInt(base);
layer.tops.setAsInt(tops);
layer.type.set(type);
layer.coverage.setAsInt(coverage);
}
void CWeather::setCloudLayer(int layer, int baseM, int topsM, int type, int coverage)
{
switch (layer)
{
case 0: setCloudLayerImpl(m_cloudLayer0, baseM, topsM, type, coverage); break;
case 1: setCloudLayerImpl(m_cloudLayer1, baseM, topsM, type, coverage); break;
case 2: setCloudLayerImpl(m_cloudLayer2, baseM, topsM, type, coverage); break;
default: DEBUG_LOG("Invalid cloud layer"); break;
}
}
//! Set wind layer
template <class T>
void setWindLayerImpl(T &layer, int altitude, double direction, int speed, int shearDirection, int shearSpeed, int turbulence)
{
layer.altitude.setAsInt(altitude);
layer.direction.set(static_cast<float>(direction));
layer.speed.setAsInt(speed);
layer.shearDirection.setAsInt(shearDirection);
layer.shearSpeed.setAsInt(shearSpeed);
layer.turbulence.setAsInt(turbulence);
}
void CWeather::setWindLayer(int layer, int altitudeM, double directionDeg, int speedKt, int shearDirectionDeg, int shearSpeedKt, int turbulence)
{
switch (layer)
{
case 0: setWindLayerImpl(m_windLayer0, altitudeM, directionDeg, speedKt, shearDirectionDeg, shearSpeedKt, turbulence); break;
case 1: setWindLayerImpl(m_windLayer1, altitudeM, directionDeg, speedKt, shearDirectionDeg, shearSpeedKt, turbulence); break;
case 2: setWindLayerImpl(m_windLayer2, altitudeM, directionDeg, speedKt, shearDirectionDeg, shearSpeedKt, turbulence); break;
default: DEBUG_LOG("Invalid wind layer"); break;
}
}
static const char *introspection_weather =
DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE
#include "org.swift_project.xswiftbus.weather.xml"
;
DBusHandlerResult CWeather::dbusMessageHandler(const CDBusMessage &message_)
{
CDBusMessage message(message_);
const std::string sender = message.getSender();
const dbus_uint32_t serial = message.getSerial();
const bool wantsReply = message.wantsReply();
if (message.getInterfaceName() == DBUS_INTERFACE_INTROSPECTABLE)
{
if (message.getMethodName() == "Introspect")
{
sendDBusReply(sender, serial, introspection_weather);
}
}
else if (message.getInterfaceName() == XSWIFTBUS_WEATHER_INTERFACENAME)
{
if (message.getMethodName() == "isUsingRealWeather")
{
queueDBusCall([=]() {
sendDBusReply(sender, serial, isUsingRealWeather());
});
}
else if (message.getMethodName() == "setUseRealWeather")
{
maybeSendEmptyDBusReply(wantsReply, sender, serial);
bool enable = false;
message.beginArgumentRead();
message.getArgument(enable);
queueDBusCall([=]() {
setUseRealWeather(enable);
});
}
else if (message.getMethodName() == "setVisibility")
{
maybeSendEmptyDBusReply(wantsReply, sender, serial);
double visibilityM = 10.0;
message.beginArgumentRead();
message.getArgument(visibilityM);
queueDBusCall([=]() {
setVisibility(visibilityM);
});
}
else if (message.getMethodName() == "setTemperature")
{
maybeSendEmptyDBusReply(wantsReply, sender, serial);
int degreesC = 10;
message.beginArgumentRead();
message.getArgument(degreesC);
queueDBusCall([=]() {
setTemperature(degreesC);
});
}
else if (message.getMethodName() == "setDewPoint")
{
maybeSendEmptyDBusReply(wantsReply, sender, serial);
int degreesC = 10;
message.beginArgumentRead();
message.getArgument(degreesC);
queueDBusCall([=]() {
setDewPoint(degreesC);
});
}
else if (message.getMethodName() == "setQNH")
{
maybeSendEmptyDBusReply(wantsReply, sender, serial);
double inHg = 29.92;
message.beginArgumentRead();
message.getArgument(inHg);
queueDBusCall([=]() {
setQNH(inHg);
});
}
else if (message.getMethodName() == "setPrecipitationRatio")
{
maybeSendEmptyDBusReply(wantsReply, sender, serial);
double precipRatio = 0.0;
message.beginArgumentRead();
message.getArgument(precipRatio);
queueDBusCall([=]() {
setPrecipitationRatio(precipRatio);
});
}
else if (message.getMethodName() == "setThunderstormRatio")
{
maybeSendEmptyDBusReply(wantsReply, sender, serial);
double cbRatio = 0.0;
message.beginArgumentRead();
message.getArgument(cbRatio);
queueDBusCall([=]() {
setThunderstormRatio(cbRatio);
});
}
else if (message.getMethodName() == "setTurbulenceRatio")
{
maybeSendEmptyDBusReply(wantsReply, sender, serial);
double turbulenceRatio = 0.0;
message.beginArgumentRead();
message.getArgument(turbulenceRatio);
queueDBusCall([=]() {
setTurbulenceRatio(turbulenceRatio);
});
}
else if (message.getMethodName() == "setRunwayFriction")
{
maybeSendEmptyDBusReply(wantsReply, sender, serial);
int friction = 10;
message.beginArgumentRead();
message.getArgument(friction);
queueDBusCall([=]() {
setRunwayFriction(friction);
});
}
else if (message.getMethodName() == "setCloudLayer")
{
maybeSendEmptyDBusReply(wantsReply, sender, serial);
int layer = 0;
int base = 0;
int tops = 0;
int type = 0;
int coverage = 0;
message.beginArgumentRead();
message.getArgument(layer);
message.getArgument(base);
message.getArgument(tops);
message.getArgument(type);
message.getArgument(coverage);
queueDBusCall([=]() {
setCloudLayer(layer, base, tops, type, coverage);
});
}
else if (message.getMethodName() == "setWindLayer")
{
maybeSendEmptyDBusReply(wantsReply, sender, serial);
int layer = 0;
int altitudeM = 0;
double directionDeg = 0;
int speedKt = 0;
int shearDirectionDeg = 0;
int shearSpeedKt = 0;
int turbulence = 0;
message.beginArgumentRead();
message.getArgument(layer);
message.getArgument(altitudeM);
message.getArgument(directionDeg);
message.getArgument(speedKt);
message.getArgument(shearDirectionDeg);
message.getArgument(shearSpeedKt);
message.getArgument(turbulence);
queueDBusCall([=]() {
setWindLayer(layer, altitudeM, directionDeg, speedKt, shearDirectionDeg, shearSpeedKt, turbulence);
});
}
else
{
// Unknown message. Tell DBus that we cannot handle it
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
}
return DBUS_HANDLER_RESULT_HANDLED;
}
int CWeather::process()
{
invokeQueuedDBusCalls();
return 1;
}
}
//! \endcond

View File

@@ -1,161 +0,0 @@
// SPDX-FileCopyrightText: Copyright (C) 2015 swift Project Community / Contributors
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
#ifndef BLACKSIM_XSWIFTBUS_WEATHER_H
#define BLACKSIM_XSWIFTBUS_WEATHER_H
//! \file
#ifndef NOMINMAX
# define NOMINMAX
#endif
#include "dbusobject.h"
#include "datarefs.h"
//! \cond PRIVATE
#define XSWIFTBUS_WEATHER_INTERFACENAME "org.swift_project.xswiftbus.weather"
#define XSWIFTBUS_WEATHER_OBJECTPATH "/xswiftbus/weather"
//! \endcond
namespace XSwiftBus
{
/*!
* xswiftbus weather object which is accessible through DBus
*/
class CWeather : public CDBusObject
{
public:
//! Constructor
CWeather(CSettingsProvider *settingsProvider);
//! DBus interface name
static const std::string &InterfaceName()
{
static std::string s(XSWIFTBUS_WEATHER_INTERFACENAME);
return s;
}
//! DBus object path
static const std::string &ObjectPath()
{
static std::string s(XSWIFTBUS_WEATHER_OBJECTPATH);
return s;
}
//! True if the sim is using X-Plane built-in real weather source.
bool isUsingRealWeather() const { return m_useRealWeather.get(); }
//! Set whether or not to use X-Plane built-in real weather source.
void setUseRealWeather(bool enable) { m_useRealWeather.set(enable ? 1 : 0); }
//! Set reported visibility in meters.
void setVisibility(double visibilityM) { m_visibilityM.set(static_cast<float>(visibilityM)); }
//! Set temperature at sea level in degrees C.
void setTemperature(int degreesC) { m_temperatureC.setAsInt(degreesC); }
//! Set dew point at sea level in degrees C.
void setDewPoint(int degreesC) { m_dewPointC.setAsInt(degreesC); }
//! Set barometric pressure at sea level in inches of mercury.
void setQNH(double inHg) { m_qnhInhg.set(static_cast<float>(inHg)); }
//! Set amount of precipitation between 0 and 1.
void setPrecipitationRatio(double precipRatio) { m_precipRatio.set(static_cast<float>(precipRatio)); }
//! Set amount of thunderstorms between 0 and 1.
void setThunderstormRatio(double cbRatio) { m_cbRatio.set(static_cast<float>(cbRatio)); }
//! Set amount of turbulence between 0 and 1.
void setTurbulenceRatio(double turbulenceRatio) { m_turbulenceRatio.set(static_cast<float>(turbulenceRatio)); }
//! Set runway friction, 0=dry, 1=damp, 2=wet.
void setRunwayFriction(int friction) { m_runwayFriction.setAsInt(friction); }
//! Set a cloud layer.
//! \param layer Layer 0, 1, or 2.
//! \param baseM Cloud base in meters above mean sea level.
//! \param topsM Cloud tops in meters above mean sea level.
//! \param type Type of cloud: 0=clear, 1=cirrus, 2=scattered, 3=broken, 4=overcast, 5=stratus.
//! \param coverage Amount of sky covered [0,6].
void setCloudLayer(int layer, int baseM, int topsM, int type, int coverage);
//! Set a wind layer.
//! \param layer Layer 0, 1, or 2.
//! \param altitudeM Altitude in middle of layer in meters above mean sea level.
//! \param directionDeg Direction from which wind is blowing in degrees true.
//! \param speedKt Wind speed in knots.
//! \param shearDirectionDeg Direction from which wind shears blow in degrees true.
//! \param shearSpeedKt Wind speed gain in knots (e.g. speed=10 and shearSpeed=5 means speed varies between 10 and 15).
//! \param turbulence Amount of turbulence [0,10].
void setWindLayer(int layer, int altitudeM, double directionDeg, int speedKt, int shearDirectionDeg, int shearSpeedKt, int turbulence);
//! Perform generic processing
int process();
protected:
virtual DBusHandlerResult dbusMessageHandler(const CDBusMessage &message) override;
private:
DataRef<xplane::data::sim::weather::use_real_weather_bool> m_useRealWeather;
DataRef<xplane::data::sim::weather::visibility_reported_m> m_visibilityM;
DataRef<xplane::data::sim::weather::rain_percent> m_precipRatio;
DataRef<xplane::data::sim::weather::thunderstorm_percent> m_cbRatio;
DataRef<xplane::data::sim::weather::wind_turbulence_percent> m_turbulenceRatio;
DataRef<xplane::data::sim::weather::temperature_sealevel_c> m_temperatureC;
DataRef<xplane::data::sim::weather::dewpoi_sealevel_c> m_dewPointC;
DataRef<xplane::data::sim::weather::barometer_sealevel_inhg> m_qnhInhg;
DataRef<xplane::data::sim::weather::runway_friction> m_runwayFriction;
struct
{
DataRef<xplane::data::sim::weather::cloud_base_msl_m_0> base;
DataRef<xplane::data::sim::weather::cloud_tops_msl_m_0> tops;
DataRef<xplane::data::sim::weather::cloud_type_0> type;
DataRef<xplane::data::sim::weather::cloud_coverage_0> coverage;
} m_cloudLayer0;
struct
{
DataRef<xplane::data::sim::weather::cloud_base_msl_m_1> base;
DataRef<xplane::data::sim::weather::cloud_tops_msl_m_1> tops;
DataRef<xplane::data::sim::weather::cloud_type_1> type;
DataRef<xplane::data::sim::weather::cloud_coverage_1> coverage;
} m_cloudLayer1;
struct
{
DataRef<xplane::data::sim::weather::cloud_base_msl_m_2> base;
DataRef<xplane::data::sim::weather::cloud_tops_msl_m_2> tops;
DataRef<xplane::data::sim::weather::cloud_type_2> type;
DataRef<xplane::data::sim::weather::cloud_coverage_2> coverage;
} m_cloudLayer2;
struct
{
DataRef<xplane::data::sim::weather::wind_altitude_msl_m_0> altitude;
DataRef<xplane::data::sim::weather::wind_direction_degt_0> direction;
DataRef<xplane::data::sim::weather::wind_speed_kt_0> speed;
DataRef<xplane::data::sim::weather::shear_direction_degt_0> shearDirection;
DataRef<xplane::data::sim::weather::shear_speed_kt_0> shearSpeed;
DataRef<xplane::data::sim::weather::turbulence_0> turbulence;
} m_windLayer0;
struct
{
DataRef<xplane::data::sim::weather::wind_altitude_msl_m_1> altitude;
DataRef<xplane::data::sim::weather::wind_direction_degt_1> direction;
DataRef<xplane::data::sim::weather::wind_speed_kt_1> speed;
DataRef<xplane::data::sim::weather::shear_direction_degt_1> shearDirection;
DataRef<xplane::data::sim::weather::shear_speed_kt_1> shearSpeed;
DataRef<xplane::data::sim::weather::turbulence_1> turbulence;
} m_windLayer1;
struct
{
DataRef<xplane::data::sim::weather::wind_altitude_msl_m_2> altitude;
DataRef<xplane::data::sim::weather::wind_direction_degt_2> direction;
DataRef<xplane::data::sim::weather::wind_speed_kt_2> speed;
DataRef<xplane::data::sim::weather::shear_direction_degt_2> shearDirection;
DataRef<xplane::data::sim::weather::shear_speed_kt_2> shearSpeed;
DataRef<xplane::data::sim::weather::turbulence_2> turbulence;
} m_windLayer2;
};
}
#endif // guard