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;

View File

@@ -22,6 +22,14 @@ R"XML(<node>
<arg name="trueHeading" type="d" direction="out"/>
<arg name="qnh" type="d" direction="out"/>
</method>
<method name="getOwnAircraftVelocityData">
<arg name="x" type="d" direction="out"/>
<arg name="y" type="d" direction="out"/>
<arg name="z" type="d" direction="out"/>
<arg name="pitch" type="d" direction="out"/>
<arg name="roll" type="d" direction="out"/>
<arg name="heading" type="d" direction="out"/>
</method>
<method name="getOwnAircraftCom1Data">
<arg name="actv" type="i" direction="out"/>
<arg name="stby" type="i" direction="out"/>
@@ -137,6 +145,24 @@ R"XML(<node>
<method name="getTrueHeadingDeg">
<arg type="d" direction="out"/>
</method>
<method name="getLocalXVelocityMps">
<arg type="d" direction="out"/>
</method>
<method name="getLocalYVelocityMps">
<arg type="d" direction="out"/>
</method>
<method name="getLocalZVelocityMps">
<arg type="d" direction="out"/>
</method>
<method name="getPitchRadPerSec">
<arg type="d" direction="out"/>
</method>
<method name="getRollRadPerSec">
<arg type="d" direction="out"/>
</method>
<method name="getHeadingRadPerSec">
<arg type="d" direction="out"/>
</method>
<method name="getAnyWheelOnGround">
<arg type="b" direction="out"/>
</method>

View File

@@ -396,6 +396,27 @@ namespace XSwiftBus
sendDBusMessage(reply);
});
}
else if (message.getMethodName() == "getOwnAircraftVelocityData")
{
queueDBusCall([ = ]()
{
const double velocityX = m_velocityX.get();
const double velocityY = m_velocityY.get();
const double velocityZ = m_velocityZ.get();
const double pitchVelocity = m_pitchVelocity.get();
const double rollVelocity = m_rollVelocity.get();
const double headingVelocity = m_headingVelocity.get();
CDBusMessage reply = CDBusMessage::createReply(sender, serial);
reply.beginArgumentWrite();
reply.appendArgument(velocityX);
reply.appendArgument(velocityY);
reply.appendArgument(velocityZ);
reply.appendArgument(pitchVelocity);
reply.appendArgument(rollVelocity);
reply.appendArgument(headingVelocity);
sendDBusMessage(reply);
});
}
else if (message.getMethodName() == "getOwnAircraftCom1Data")
{
queueDBusCall([ = ]()
@@ -689,6 +710,48 @@ namespace XSwiftBus
sendDBusReply(sender, serial, getTrueHeadingDeg());
});
}
else if (message.getMethodName() == "getLocalXVelocityXMps")
{
queueDBusCall([ = ]()
{
sendDBusReply(sender, serial, getLocalXVelocityMps());
});
}
else if (message.getMethodName() == "getLocalYVelocityYMps")
{
queueDBusCall([ = ]()
{
sendDBusReply(sender, serial, getLocalYVelocityMps());
});
}
else if (message.getMethodName() == "getLocalZVelocityZMps")
{
queueDBusCall([ = ]()
{
sendDBusReply(sender, serial, getLocalZVelocityMps());
});
}
else if (message.getMethodName() == "getPitchRadPerSec")
{
queueDBusCall([ = ]()
{
sendDBusReply(sender, serial, getPitchRadPerSec());
});
}
else if (message.getMethodName() == "getRollRadPerSec")
{
queueDBusCall([ = ]()
{
sendDBusReply(sender, serial, getRollRadPerSec());
});
}
else if (message.getMethodName() == "getHeadingRadPerSec")
{
queueDBusCall([ = ]()
{
sendDBusReply(sender, serial, getHeadingRadPerSec());
});
}
else if (message.getMethodName() == "getAnyWheelOnGround")
{
queueDBusCall([ = ]()

View File

@@ -154,6 +154,20 @@ namespace XSwiftBus
//! Get aircraft true heading in degrees
double getTrueHeadingDeg() const { return m_heading.get(); }
//! Get aircraft local velocity in world coordinates meters per second
//! @{
double getLocalXVelocityMps() const { return m_velocityX.get(); }
double getLocalYVelocityMps() const { return m_velocityY.get(); }
double getLocalZVelocityMps() const { return m_velocityZ.get(); }
//! @}
//! Get aircraft angular velocity in radians per second
//! @{
double getPitchRadPerSec() const { return m_pitchVelocity.get(); }
double getRollRadPerSec() const { return m_rollVelocity.get(); }
double getHeadingRadPerSec() const { return m_headingVelocity.get(); }
//! @}
//! Get whether any wheel is on the ground
bool getAnyWheelOnGround() const { return m_onGroundAny.get(); }
@@ -347,6 +361,12 @@ namespace XSwiftBus
DataRef<xplane::data::sim::flightmodel::position::theta> m_pitch;
DataRef<xplane::data::sim::flightmodel::position::phi> m_roll;
DataRef<xplane::data::sim::flightmodel::position::psi> m_heading;
DataRef<xplane::data::sim::flightmodel::position::local_vx> m_velocityX;
DataRef<xplane::data::sim::flightmodel::position::local_vy> m_velocityY;
DataRef<xplane::data::sim::flightmodel::position::local_vz> m_velocityZ;
DataRef<xplane::data::sim::flightmodel::position::Prad> m_rollVelocity;
DataRef<xplane::data::sim::flightmodel::position::Qrad> m_pitchVelocity;
DataRef<xplane::data::sim::flightmodel::position::Rrad> m_headingVelocity;
DataRef<xplane::data::sim::flightmodel::failures::onground_any> m_onGroundAny;
DataRef<xplane::data::sim::flightmodel::failures::onground_all> m_onGroundAll;
DataRef<xplane::data::sim::cockpit2::radios::actuators::com1_frequency_hz_833> m_com1Active;