Issue #95 [XPlane] Get velocity data from xswiftbus in fast update timer timeout

This commit is contained in:
Mat Sutcliffe
2021-10-11 18:26:05 +01:00
parent 0faa7ed8fc
commit 3f57c66784
7 changed files with 233 additions and 0 deletions

View File

@@ -316,6 +316,7 @@ namespace BlackSimPlugin::XPlane
m_fastTimerCalls++;
m_serviceProxy->getOwnAircraftSituationDataAsync(&m_xplaneData);
m_serviceProxy->getOwnAircraftVelocityDataAsync(&m_xplaneData);
m_serviceProxy->getOwnAircraftCom1DataAsync(&m_xplaneData);
m_serviceProxy->getOwnAircraftCom2DataAsync(&m_xplaneData);
m_serviceProxy->getOwnAircraftXpdrAsync(&m_xplaneData);
@@ -332,6 +333,9 @@ namespace BlackSimPlugin::XPlane
situation.setPitch({ m_xplaneData.pitchDeg, CAngleUnit::deg() });
situation.setBank({ m_xplaneData.rollDeg, CAngleUnit::deg() });
situation.setGroundSpeed({ m_xplaneData.groundspeedMs, CSpeedUnit::m_s() });
situation.setVelocity({ m_xplaneData.localXVelocityMs, m_xplaneData.localYVelocityMs, m_xplaneData.localZVelocityMs,
CSpeedUnit::m_s(), m_xplaneData.pitchRadPerSec, m_xplaneData.rollRadPerSec, m_xplaneData.headingRadPerSec,
CAngleUnit::rad(), CTimeUnit::s()});
// Updates
// Do not update ICAO codes, as this overrides reverse lookups

View File

@@ -79,6 +79,12 @@ namespace BlackSimPlugin::XPlane
double pitchDeg = 0; //!< Pitch [deg]
double rollDeg = 0; //!< Roll [deg]
double trueHeadingDeg = 0; //!< True heading [deg]
double localXVelocityMs = 0; //!< Local x velocity [m/s]
double localYVelocityMs = 0; //!< Local y velocity [m/s]
double localZVelocityMs = 0; //!< Local z velocity [m/s]
double pitchRadPerSec = 0; //!< Pitch angular velocity [rad/s]
double rollRadPerSec = 0; //!< Roll angular velocity [rad/s]
double headingRadPerSec = 0; //!< Heading angular velocity [rad/s]
bool onGroundAll = false; //!< All wheels on ground?
int com1ActiveKhz = 122800; //!< COM1 active [kHz]
int com1StandbyKhz = 122800; //!< COM1 standby [kHz]

View File

@@ -75,6 +75,27 @@ namespace BlackSimPlugin::XPlane
m_dbusInterface->callDBusAsync(QLatin1String("getOwnAircraftSituationData"), callback);
}
void CXSwiftBusServiceProxy::getOwnAircraftVelocityDataAsync(XPlaneData *o_xplaneData)
{
if (!o_xplaneData) { return; }
QPointer<CXSwiftBusServiceProxy> 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_xplaneData->localXVelocityMs = reply.argumentAt<0>();
o_xplaneData->localYVelocityMs = reply.argumentAt<1>();
o_xplaneData->localZVelocityMs = reply.argumentAt<2>();
o_xplaneData->pitchRadPerSec = reply.argumentAt<3>();
o_xplaneData->rollRadPerSec = reply.argumentAt<4>();
o_xplaneData->headingRadPerSec = reply.argumentAt<5>();
}
};
m_dbusInterface->callDBusAsync(QLatin1String("getOwnAircraftVelocityData"), callback);
}
void CXSwiftBusServiceProxy::getOwnAircraftCom1DataAsync(XPlaneData *o_xplaneData)
{
if (!o_xplaneData) { return; }
@@ -451,6 +472,60 @@ namespace BlackSimPlugin::XPlane
m_dbusInterface->callDBusAsync(QLatin1String("getTrueHeadingDeg"), setterCallback(o_heading));
}
double CXSwiftBusServiceProxy::getLocalXVelocityMps() const
{
return m_dbusInterface->callDBusRet<double>(QLatin1String("getLocalXVelocityMps"));
}
void CXSwiftBusServiceProxy::getLocalXVelocityMpsAsync(double *o_velocity)
{
m_dbusInterface->callDBusAsync(QLatin1String("getLocalXVelocityMps"), setterCallback(o_velocity));
}
double CXSwiftBusServiceProxy::getLocalYVelocityMps() const
{
return m_dbusInterface->callDBusRet<double>(QLatin1String("getLocalYVelocityMps"));
}
void CXSwiftBusServiceProxy::getLocalYVelocityMpsAsync(double *o_velocity)
{
m_dbusInterface->callDBusAsync(QLatin1String("getLocalYVelocityMps"), setterCallback(o_velocity));
}
double CXSwiftBusServiceProxy::getLocalZVelocityMps() const
{
return m_dbusInterface->callDBusRet<double>(QLatin1String("getLocalZVelocityMps"));
}
void CXSwiftBusServiceProxy::getLocalZVelocityMpsAsync(double *o_velocity)
{
m_dbusInterface->callDBusAsync(QLatin1String("getLocalZVelocityMps"), setterCallback(o_velocity));
}
double CXSwiftBusServiceProxy::getPitchRadPerSec() const
{
return m_dbusInterface->callDBusRet<double>(QLatin1String("getPitchRadPerSec"));
}
void CXSwiftBusServiceProxy::getPitchRadPerSecAsync(double *o_radPerSec)
{
m_dbusInterface->callDBusAsync(QLatin1String("getPitchRadPerSec"), setterCallback(o_radPerSec));
}
double CXSwiftBusServiceProxy::getRollRadPerSec() const
{
return m_dbusInterface->callDBusRet<double>(QLatin1String("getRollRadPerSec"));
}
void CXSwiftBusServiceProxy::getRollRadPerSecAsync(double *o_radPerSec)
{
m_dbusInterface->callDBusAsync(QLatin1String("getRollRadPerSec"), setterCallback(o_radPerSec));
}
double CXSwiftBusServiceProxy::getHeadingRadPerSec() const
{
return m_dbusInterface->callDBusRet<double>(QLatin1String("getHeadingRadPerSec"));
}
void CXSwiftBusServiceProxy::getHeadingRadPerSecAsync(double *o_radPerSec)
{
m_dbusInterface->callDBusAsync(QLatin1String("getHeadingRadPerSec"), setterCallback(o_radPerSec));
}
bool CXSwiftBusServiceProxy::getAnyWheelOnGround() const
{
return m_dbusInterface->callDBusRet<bool>(QLatin1String("getAnyWheelOnGround"));

View File

@@ -107,6 +107,9 @@ namespace BlackSimPlugin::XPlane
//! Get own aircraft situation data
void getOwnAircraftSituationDataAsync(BlackSimPlugin::XPlane::XPlaneData *o_xplaneData);
//! Get own aircraft velocity data
void getOwnAircraftVelocityDataAsync(BlackSimPlugin::XPlane::XPlaneData *o_xplaneData);
//! Get own aircraft COM1 data
void getOwnAircraftCom1DataAsync(BlackSimPlugin::XPlane::XPlaneData *o_xplaneData);
@@ -278,6 +281,42 @@ namespace BlackSimPlugin::XPlane
void getTrueHeadingDegAsync(double *o_heading);
//! @}
//! \copydoc XSwiftBus::CService::getLocalXVelocityMps
//! @{
double getLocalXVelocityMps() const;
void getLocalXVelocityMpsAsync(double *o_velocity);
//! @}
//! \copydoc XSwiftBus::CService::getLocalYVelocityMps
//! @{
double getLocalYVelocityMps() const;
void getLocalYVelocityMpsAsync(double *o_velocity);
//! @}
//! \copydoc XSwiftBus::CService::getLocalZVelocityMps
//! @{
double getLocalZVelocityMps() const;
void getLocalZVelocityMpsAsync(double *o_velocity);
//! @}
//! \copydoc XSwiftBus::CService::getPitchRadPerSec
//! @{
double getPitchRadPerSec() const;
void getPitchRadPerSecAsync(double *o_radPerSec);
//! @}
//! \copydoc XSwiftBus::CService::getRollRadPerSec
//! @{
double getRollRadPerSec() const;
void getRollRadPerSecAsync(double *o_radPerSec);
//! @}
//! \copydoc XSwiftBus::CService::getHeadingRadPerSec
//! @{
double getHeadingRadPerSec() const;
void getHeadingRadPerSecAsync(double *o_radPerSec);
//! @}
//! Get whether any wheel is on the ground
//! @{
bool getAnyWheelOnGround() const;