mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-13 15:45:42 +08:00
Inject global weather grid to Flight Simulators via FSUIPC
In the short term FSUIPC is used for all MSFS simulators, but in the mid term this will be superceded by the Simconnect Weather API. refs #579
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#define BLACKSIMPLUGIN_FSUIPC_H
|
||||
|
||||
#include "blackmisc/simulation/simulatedaircraft.h"
|
||||
#include "blackmisc/weather/weathergrid.h"
|
||||
#include <QStringList>
|
||||
|
||||
namespace BlackSimPlugin
|
||||
@@ -20,8 +21,10 @@ namespace BlackSimPlugin
|
||||
namespace FsCommon
|
||||
{
|
||||
//! Class representing a FSUIPC "interface"
|
||||
class CFsuipc
|
||||
class CFsuipc : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
@@ -45,6 +48,9 @@ namespace BlackSimPlugin
|
||||
//! Write variables
|
||||
bool write(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
|
||||
|
||||
//! Write weather grid to simulator
|
||||
bool write(const BlackMisc::Weather::CWeatherGrid &weatherGrid);
|
||||
|
||||
//! Read data from FSUIPC
|
||||
//! \param aircraft object to be updated
|
||||
//! \param cockpit update cockpit data
|
||||
@@ -97,11 +103,30 @@ namespace BlackSimPlugin
|
||||
//! Log message category
|
||||
static QString getMessageCategory() { return "swift.fscommon.fsuipc"; }
|
||||
|
||||
protected:
|
||||
//! \copydoc QObject::timerEvent
|
||||
void timerEvent(QTimerEvent *event);
|
||||
|
||||
private:
|
||||
struct FsuipcWeatherMessage
|
||||
{
|
||||
FsuipcWeatherMessage() = default;
|
||||
FsuipcWeatherMessage(unsigned int offset, const QByteArray &data, int leftTrials);
|
||||
int m_offset = 0;
|
||||
QByteArray m_messageData;
|
||||
int m_leftTrials = 0;
|
||||
};
|
||||
|
||||
void clearAllWeather();
|
||||
void processWeatherMessages();
|
||||
|
||||
bool m_connected = false;
|
||||
QString m_lastErrorMessage;
|
||||
QString m_fsuipcVersion;
|
||||
|
||||
QVector<FsuipcWeatherMessage> m_weatherMessageQueue;
|
||||
unsigned int m_lastTimestamp = 0;
|
||||
|
||||
//! Integer representing fractional
|
||||
static double intToFractional(double fractional);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user