mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +08:00
Issue #96 [Flightgear] Get velocity data from Flightgear in fast update timer timeout
This commit is contained in:
committed by
Mat Sutcliffe
parent
1d9fcabebf
commit
23eb283c19
@@ -43,6 +43,7 @@ namespace BlackSimPlugin::Flightgear
|
||||
|
||||
void CFGSwiftBusServiceProxy::getOwnAircraftSituationData(FlightgearData *o_flightgearData)
|
||||
{
|
||||
if (!o_flightgearData) { return; }
|
||||
QPointer<CFGSwiftBusServiceProxy> myself(this);
|
||||
std::function<void(QDBusPendingCallWatcher *)> callback = [ = ](QDBusPendingCallWatcher * watcher)
|
||||
{
|
||||
@@ -64,6 +65,28 @@ namespace BlackSimPlugin::Flightgear
|
||||
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)
|
||||
{
|
||||
m_dbusInterface->callDBus(QLatin1String("addTextMessage"), text);
|
||||
|
||||
@@ -120,6 +120,9 @@ namespace BlackSimPlugin::Flightgear
|
||||
//! Get own aircraft situation data
|
||||
void getOwnAircraftSituationData(FlightgearData *o_flightgearData);
|
||||
|
||||
//! Get own aircraft velocity data
|
||||
void getOwnAircraftVelocityData(FlightgearData *o_flightgearData);
|
||||
|
||||
//! Add a text message to the on-screen display
|
||||
void addTextMessage(const QString &text);
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace
|
||||
namespace BlackSimPlugin::Flightgear
|
||||
{
|
||||
int FGSWIFTBUS_API_VERSION = -1;
|
||||
QList<int> incompatibleVersions = {};
|
||||
QList<int> incompatibleVersions = {1,2};
|
||||
CSimulatorFlightgear::CSimulatorFlightgear(const CSimulatorPluginInfo &info,
|
||||
IOwnAircraftProvider *ownAircraftProvider,
|
||||
IRemoteAircraftProvider *remoteAircraftProvider,
|
||||
@@ -199,6 +199,7 @@ namespace BlackSimPlugin::Flightgear
|
||||
if (!this->isShuttingDownOrDisconnected())
|
||||
{
|
||||
m_serviceProxy->getOwnAircraftSituationData(&m_flightgearData);
|
||||
m_serviceProxy->getOwnAircraftVelocityData(&m_flightgearData);
|
||||
m_serviceProxy->getCom1ActiveKhzAsync(&m_flightgearData.com1ActiveKhz);
|
||||
m_serviceProxy->getCom1StandbyKhzAsync(&m_flightgearData.com1StandbyKhz);
|
||||
m_serviceProxy->getCom2ActiveKhzAsync(&m_flightgearData.com2ActiveKhz);
|
||||
@@ -220,6 +221,9 @@ namespace BlackSimPlugin::Flightgear
|
||||
situation.setBank({ m_flightgearData.rollDeg, CAngleUnit::deg() });
|
||||
situation.setGroundSpeed({ m_flightgearData.groundspeedKts, CSpeedUnit::kts() });
|
||||
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
|
||||
// Do not update ICAO codes, as this overrides reverse lookups
|
||||
|
||||
@@ -73,34 +73,40 @@ namespace BlackSimPlugin::Flightgear
|
||||
{
|
||||
QString aircraftModelPath; //!< Aircraft model path
|
||||
QString aircraftIcaoCode; //!< Aircraft ICAO code
|
||||
double latitudeDeg; //!< Longitude [deg]
|
||||
double longitudeDeg; //!< Latitude [deg]
|
||||
double altitudeFt; //!< Altitude [ft]
|
||||
double groundspeedKts; //!< Ground speed [kts]
|
||||
double pitchDeg; //!< Pitch [deg]
|
||||
double rollDeg; //!< Roll [deg]
|
||||
double trueHeadingDeg; //!< True heading [deg]
|
||||
bool onGroundAll; //!< All wheels on ground?
|
||||
int com1ActiveKhz; //!< COM1 active [kHz]
|
||||
int com1StandbyKhz; //!< COM1 standby [kHz]
|
||||
int com2ActiveKhz; //!< COM2 active [kHz]
|
||||
int com2StandbyKhz; //!< COM2 standby [kHz]
|
||||
int xpdrCode; //!< Transpondder code
|
||||
int xpdrMode; //!< Transponder mode (off=0,stdby=1-2, >2 on)
|
||||
bool xpdrIdent; //!< Is transponder in ident?
|
||||
bool beaconLightsOn; //!< Beacon lights on?
|
||||
bool landingLightsOn; //!< Landing lights on?
|
||||
bool navLightsOn; //!< NAV lights on?
|
||||
bool strobeLightsOn; //!< Strobe lights on?
|
||||
bool taxiLightsOn; //!< Taxi lights on?
|
||||
double flapsReployRatio; //!< Flaps deployment ratio [%]
|
||||
double gearReployRatio; //!< Gear deployment ratio [%]
|
||||
double latitudeDeg = 0; //!< Longitude [deg]
|
||||
double longitudeDeg = 0; //!< Latitude [deg]
|
||||
double altitudeFt = 0; //!< Altitude [ft]
|
||||
double groundspeedKts = 0; //!< Ground speed [kts]
|
||||
double pitchDeg = 0; //!< Pitch [deg]
|
||||
double rollDeg = 0; //!< Roll [deg]
|
||||
double trueHeadingDeg = 0; //!< True heading [deg]
|
||||
double velocityXMs = 0; //!< x velocity [m/s]
|
||||
double velocityYMs = 0; //!< y velocity [m/s]
|
||||
double velocityZMs = 0; //!< z velocity [m/s]
|
||||
double pitchRateRadPerSec = 0; //!< Pitch angular velocity [rad/s]
|
||||
double rollRateRadPerSec = 0; //!< Roll angular velocity [rad/s]
|
||||
double yawRateRadPerSec = 0; //!< Yaw angular velocity [rad/s]
|
||||
bool onGroundAll = false; //!< All wheels on ground?
|
||||
int com1ActiveKhz = 122800; //!< COM1 active [kHz]
|
||||
int com1StandbyKhz = 122800; //!< COM1 standby [kHz]
|
||||
int com2ActiveKhz = 122800; //!< COM2 active [kHz]
|
||||
int com2StandbyKhz = 122800; //!< COM2 standby [kHz]
|
||||
int xpdrCode = 2000; //!< Transpondder code
|
||||
int xpdrMode = 0; //!< Transponder mode (off=0,stdby=1-2, >2 on)
|
||||
bool xpdrIdent = false; //!< Is transponder in ident?
|
||||
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 [%]
|
||||
double speedBrakeRatio; //!< Speed break ratio [%]
|
||||
double pressureAltitudeFt; //!< Pressure altitude [inhg]
|
||||
double groundElevation; //!< Ground Elevation [m]
|
||||
double volumeCom1; //!< Volume com1 [0..1]
|
||||
double volumeCom2; //!< Volume com2 [0..1]
|
||||
double speedBrakeRatio = 0; //!< Speed break ratio [%]
|
||||
double pressureAltitudeFt = 0; //!< Pressure altitude [inhg]
|
||||
double groundElevation = 0; //!< Ground Elevation [m]
|
||||
double volumeCom1 = 1; //!< Volume com1 [0..1]
|
||||
double volumeCom2 = 1; //!< Volume com2 [0..1]
|
||||
};
|
||||
|
||||
//! Flightgear ISimulator implementation
|
||||
@@ -241,10 +247,7 @@ namespace BlackSimPlugin::Flightgear
|
||||
//! Reset the Flightgear data
|
||||
void resetFlightgearData()
|
||||
{
|
||||
m_flightgearData = { "", "", 0, 0, 0, 0, 0, 0, 0, false, 122800, 122800, 122800, 122800, 2000, 0, false, false, false, false,
|
||||
false, false, 0, 0, {}, 0.0, 0.0, 0.0, 1.0, 1.0
|
||||
};
|
||||
|
||||
m_flightgearData = {};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user