Issue #96 [Flightgear] Get velocity data from Flightgear in fast update timer timeout

This commit is contained in:
Lars Toenning
2021-10-11 19:17:46 +01:00
committed by Mat Sutcliffe
parent 1d9fcabebf
commit 23eb283c19
4 changed files with 65 additions and 32 deletions

View File

@@ -43,6 +43,7 @@ namespace BlackSimPlugin::Flightgear
void CFGSwiftBusServiceProxy::getOwnAircraftSituationData(FlightgearData *o_flightgearData) void CFGSwiftBusServiceProxy::getOwnAircraftSituationData(FlightgearData *o_flightgearData)
{ {
if (!o_flightgearData) { return; }
QPointer<CFGSwiftBusServiceProxy> myself(this); QPointer<CFGSwiftBusServiceProxy> myself(this);
std::function<void(QDBusPendingCallWatcher *)> callback = [ = ](QDBusPendingCallWatcher * watcher) std::function<void(QDBusPendingCallWatcher *)> callback = [ = ](QDBusPendingCallWatcher * watcher)
{ {
@@ -64,6 +65,28 @@ namespace BlackSimPlugin::Flightgear
m_dbusInterface->callDBusAsync(QLatin1String("getOwnAircraftSituationData"), callback); m_dbusInterface->callDBusAsync(QLatin1String("getOwnAircraftSituationData"), callback);
} }
void CFGSwiftBusServiceProxy::getOwnAircraftVelocityData(FlightgearData *o_flightgearData)
{
if (!o_flightgearData) { return; }
QPointer<CFGSwiftBusServiceProxy> myself(this);
std::function<void(QDBusPendingCallWatcher *)> callback = [ = ](QDBusPendingCallWatcher * watcher)
{
if (!myself) { return; }
QDBusPendingReply<double, double, double, double, double, double> reply = *watcher;
if (!reply.isError())
{
o_flightgearData->velocityXMs = reply.argumentAt<0>();
o_flightgearData->velocityYMs = reply.argumentAt<1>();
o_flightgearData->velocityZMs = reply.argumentAt<2>();
o_flightgearData->pitchRateRadPerSec = reply.argumentAt<3>();
o_flightgearData->rollRateRadPerSec = reply.argumentAt<4>();
o_flightgearData->yawRateRadPerSec = reply.argumentAt<5>();
}
watcher->deleteLater();
};
m_dbusInterface->callDBusAsync(QLatin1String("getOwnAircraftVelocityData"), callback);
}
void CFGSwiftBusServiceProxy::addTextMessage(const QString &text) void CFGSwiftBusServiceProxy::addTextMessage(const QString &text)
{ {
m_dbusInterface->callDBus(QLatin1String("addTextMessage"), text); m_dbusInterface->callDBus(QLatin1String("addTextMessage"), text);

View File

@@ -120,6 +120,9 @@ namespace BlackSimPlugin::Flightgear
//! Get own aircraft situation data //! Get own aircraft situation data
void getOwnAircraftSituationData(FlightgearData *o_flightgearData); void getOwnAircraftSituationData(FlightgearData *o_flightgearData);
//! Get own aircraft velocity data
void getOwnAircraftVelocityData(FlightgearData *o_flightgearData);
//! Add a text message to the on-screen display //! Add a text message to the on-screen display
void addTextMessage(const QString &text); void addTextMessage(const QString &text);

View File

@@ -85,7 +85,7 @@ namespace
namespace BlackSimPlugin::Flightgear namespace BlackSimPlugin::Flightgear
{ {
int FGSWIFTBUS_API_VERSION = -1; int FGSWIFTBUS_API_VERSION = -1;
QList<int> incompatibleVersions = {}; QList<int> incompatibleVersions = {1,2};
CSimulatorFlightgear::CSimulatorFlightgear(const CSimulatorPluginInfo &info, CSimulatorFlightgear::CSimulatorFlightgear(const CSimulatorPluginInfo &info,
IOwnAircraftProvider *ownAircraftProvider, IOwnAircraftProvider *ownAircraftProvider,
IRemoteAircraftProvider *remoteAircraftProvider, IRemoteAircraftProvider *remoteAircraftProvider,
@@ -199,6 +199,7 @@ namespace BlackSimPlugin::Flightgear
if (!this->isShuttingDownOrDisconnected()) if (!this->isShuttingDownOrDisconnected())
{ {
m_serviceProxy->getOwnAircraftSituationData(&m_flightgearData); m_serviceProxy->getOwnAircraftSituationData(&m_flightgearData);
m_serviceProxy->getOwnAircraftVelocityData(&m_flightgearData);
m_serviceProxy->getCom1ActiveKhzAsync(&m_flightgearData.com1ActiveKhz); m_serviceProxy->getCom1ActiveKhzAsync(&m_flightgearData.com1ActiveKhz);
m_serviceProxy->getCom1StandbyKhzAsync(&m_flightgearData.com1StandbyKhz); m_serviceProxy->getCom1StandbyKhzAsync(&m_flightgearData.com1StandbyKhz);
m_serviceProxy->getCom2ActiveKhzAsync(&m_flightgearData.com2ActiveKhz); m_serviceProxy->getCom2ActiveKhzAsync(&m_flightgearData.com2ActiveKhz);
@@ -220,6 +221,9 @@ namespace BlackSimPlugin::Flightgear
situation.setBank({ m_flightgearData.rollDeg, CAngleUnit::deg() }); situation.setBank({ m_flightgearData.rollDeg, CAngleUnit::deg() });
situation.setGroundSpeed({ m_flightgearData.groundspeedKts, CSpeedUnit::kts() }); situation.setGroundSpeed({ m_flightgearData.groundspeedKts, CSpeedUnit::kts() });
situation.setGroundElevation(CAltitude(m_flightgearData.groundElevation, CAltitude::MeanSeaLevel, CLengthUnit::m()), CAircraftSituation::FromProvider); situation.setGroundElevation(CAltitude(m_flightgearData.groundElevation, CAltitude::MeanSeaLevel, CLengthUnit::m()), CAircraftSituation::FromProvider);
situation.setVelocity({ m_flightgearData.velocityXMs, m_flightgearData.velocityYMs, m_flightgearData.velocityZMs,
CSpeedUnit::m_s(), m_flightgearData.pitchRateRadPerSec, m_flightgearData.rollRateRadPerSec, m_flightgearData.yawRateRadPerSec,
CAngleUnit::rad(), CTimeUnit::s()});
// Updates // Updates
// Do not update ICAO codes, as this overrides reverse lookups // Do not update ICAO codes, as this overrides reverse lookups

View File

@@ -73,34 +73,40 @@ namespace BlackSimPlugin::Flightgear
{ {
QString aircraftModelPath; //!< Aircraft model path QString aircraftModelPath; //!< Aircraft model path
QString aircraftIcaoCode; //!< Aircraft ICAO code QString aircraftIcaoCode; //!< Aircraft ICAO code
double latitudeDeg; //!< Longitude [deg] double latitudeDeg = 0; //!< Longitude [deg]
double longitudeDeg; //!< Latitude [deg] double longitudeDeg = 0; //!< Latitude [deg]
double altitudeFt; //!< Altitude [ft] double altitudeFt = 0; //!< Altitude [ft]
double groundspeedKts; //!< Ground speed [kts] double groundspeedKts = 0; //!< Ground speed [kts]
double pitchDeg; //!< Pitch [deg] double pitchDeg = 0; //!< Pitch [deg]
double rollDeg; //!< Roll [deg] double rollDeg = 0; //!< Roll [deg]
double trueHeadingDeg; //!< True heading [deg] double trueHeadingDeg = 0; //!< True heading [deg]
bool onGroundAll; //!< All wheels on ground? double velocityXMs = 0; //!< x velocity [m/s]
int com1ActiveKhz; //!< COM1 active [kHz] double velocityYMs = 0; //!< y velocity [m/s]
int com1StandbyKhz; //!< COM1 standby [kHz] double velocityZMs = 0; //!< z velocity [m/s]
int com2ActiveKhz; //!< COM2 active [kHz] double pitchRateRadPerSec = 0; //!< Pitch angular velocity [rad/s]
int com2StandbyKhz; //!< COM2 standby [kHz] double rollRateRadPerSec = 0; //!< Roll angular velocity [rad/s]
int xpdrCode; //!< Transpondder code double yawRateRadPerSec = 0; //!< Yaw angular velocity [rad/s]
int xpdrMode; //!< Transponder mode (off=0,stdby=1-2, >2 on) bool onGroundAll = false; //!< All wheels on ground?
bool xpdrIdent; //!< Is transponder in ident? int com1ActiveKhz = 122800; //!< COM1 active [kHz]
bool beaconLightsOn; //!< Beacon lights on? int com1StandbyKhz = 122800; //!< COM1 standby [kHz]
bool landingLightsOn; //!< Landing lights on? int com2ActiveKhz = 122800; //!< COM2 active [kHz]
bool navLightsOn; //!< NAV lights on? int com2StandbyKhz = 122800; //!< COM2 standby [kHz]
bool strobeLightsOn; //!< Strobe lights on? int xpdrCode = 2000; //!< Transpondder code
bool taxiLightsOn; //!< Taxi lights on? int xpdrMode = 0; //!< Transponder mode (off=0,stdby=1-2, >2 on)
double flapsReployRatio; //!< Flaps deployment ratio [%] bool xpdrIdent = false; //!< Is transponder in ident?
double gearReployRatio; //!< Gear deployment ratio [%] bool beaconLightsOn = false; //!< Beacon lights on?
bool landingLightsOn = false; //!< Landing lights on?
bool navLightsOn = false; //!< NAV lights on?
bool strobeLightsOn = false; //!< Strobe lights on?
bool taxiLightsOn = false; //!< Taxi lights on?
double flapsReployRatio = false; //!< Flaps deployment ratio [%]
double gearReployRatio = false; //!< Gear deployment ratio [%]
QList<double> enginesN1Percentage; //!< N1 per engine [%] QList<double> enginesN1Percentage; //!< N1 per engine [%]
double speedBrakeRatio; //!< Speed break ratio [%] double speedBrakeRatio = 0; //!< Speed break ratio [%]
double pressureAltitudeFt; //!< Pressure altitude [inhg] double pressureAltitudeFt = 0; //!< Pressure altitude [inhg]
double groundElevation; //!< Ground Elevation [m] double groundElevation = 0; //!< Ground Elevation [m]
double volumeCom1; //!< Volume com1 [0..1] double volumeCom1 = 1; //!< Volume com1 [0..1]
double volumeCom2; //!< Volume com2 [0..1] double volumeCom2 = 1; //!< Volume com2 [0..1]
}; };
//! Flightgear ISimulator implementation //! Flightgear ISimulator implementation
@@ -241,10 +247,7 @@ namespace BlackSimPlugin::Flightgear
//! Reset the Flightgear data //! Reset the Flightgear data
void resetFlightgearData() void resetFlightgearData()
{ {
m_flightgearData = { "", "", 0, 0, 0, 0, 0, 0, 0, false, 122800, 122800, 122800, 122800, 2000, 0, false, false, false, false, m_flightgearData = {};
false, false, 0, 0, {}, 0.0, 0.0, 0.0, 1.0, 1.0
};
} }
}; };