1
0
Fork 0

[JSBSim] An improvement and 2 bug fixes

- Electric engines RPM is now exported in UDP sockets.
- The sign of the XZ inertia has been fixed in the property inertia/ixz-slug_ft2 (was just an output error, the correct XZ inertia was used internally). Thanks to Nikolai Verner Christensen for reporting the bug.
- The parameter <ignitionn2> was wrongly affected to N1. Bug reported by Nikolai Verner Christensen and fixed by Jonathan Redpath. Thanks to them.
This commit is contained in:
Bertrand Coconnier 2019-11-17 12:33:28 +01:00
parent b4bb24f10e
commit 88ca381e83
3 changed files with 24 additions and 14 deletions

View file

@ -47,6 +47,7 @@ INCLUDES
#include "models/FGPropulsion.h" #include "models/FGPropulsion.h"
#include "models/FGFCS.h" #include "models/FGFCS.h"
#include "models/propulsion/FGPiston.h" #include "models/propulsion/FGPiston.h"
#include "models/propulsion/FGElectric.h"
#include "models/propulsion/FGTank.h" #include "models/propulsion/FGTank.h"
#if defined(WIN32) && !defined(__CYGWIN__) #if defined(WIN32) && !defined(__CYGWIN__)
@ -216,32 +217,37 @@ void FGOutputFG::SocketDataFill(FGNetFDM* net)
net->num_engines = min(FGNetFDM::FG_MAX_ENGINES,Propulsion->GetNumEngines()); // Number of valid engines net->num_engines = min(FGNetFDM::FG_MAX_ENGINES,Propulsion->GetNumEngines()); // Number of valid engines
for (i=0; i<net->num_engines; i++) { for (i=0; i<net->num_engines; i++) {
if (Propulsion->GetEngine(i)->GetRunning()) FGEngine* engine = Propulsion->GetEngine(i);
if (engine->GetRunning())
net->eng_state[i] = 2; // Engine state running net->eng_state[i] = 2; // Engine state running
else if (Propulsion->GetEngine(i)->GetCranking()) else if (engine->GetCranking())
net->eng_state[i] = 1; // Engine state cranking net->eng_state[i] = 1; // Engine state cranking
else else
net->eng_state[i] = 0; // Engine state off net->eng_state[i] = 0; // Engine state off
switch (Propulsion->GetEngine(i)->GetType()) { switch (engine->GetType()) {
case (FGEngine::etRocket): case (FGEngine::etRocket):
break; break;
case (FGEngine::etPiston): case (FGEngine::etPiston):
net->rpm[i] = (float)(((FGPiston *)Propulsion->GetEngine(i))->getRPM()); {
net->fuel_flow[i] = (float)(((FGPiston *)Propulsion->GetEngine(i))->getFuelFlow_gph()); FGPiston* piston_engine = static_cast<FGPiston*>(engine);
net->fuel_px[i] = 0; // Fuel pressure, psi (N/A in current model) net->rpm[i] = (float)(piston_engine->getRPM());
net->egt[i] = (float)(((FGPiston *)Propulsion->GetEngine(i))->GetEGT()); net->fuel_flow[i] = (float)(piston_engine->getFuelFlow_gph());
net->cht[i] = (float)(((FGPiston *)Propulsion->GetEngine(i))->getCylinderHeadTemp_degF()); net->fuel_px[i] = 0; // Fuel pressure, psi (N/A in current model)
net->mp_osi[i] = (float)(((FGPiston *)Propulsion->GetEngine(i))->getManifoldPressure_inHg()); net->egt[i] = (float)(piston_engine->GetEGT());
net->oil_temp[i] = (float)(((FGPiston *)Propulsion->GetEngine(i))->getOilTemp_degF()); net->cht[i] = (float)(piston_engine->getCylinderHeadTemp_degF());
net->oil_px[i] = (float)(((FGPiston *)Propulsion->GetEngine(i))->getOilPressure_psi()); net->mp_osi[i] = (float)(piston_engine->getManifoldPressure_inHg());
net->tit[i] = 0; // Turbine Inlet Temperature (N/A for piston) net->oil_temp[i] = (float)(piston_engine->getOilTemp_degF());
net->oil_px[i] = (float)(piston_engine->getOilPressure_psi());
net->tit[i] = 0; // Turbine Inlet Temperature (N/A for piston)
}
break; break;
case (FGEngine::etTurbine): case (FGEngine::etTurbine):
break; break;
case (FGEngine::etTurboprop): case (FGEngine::etTurboprop):
break; break;
case (FGEngine::etElectric): case (FGEngine::etElectric):
net->rpm[i] = static_cast<float>(static_cast<FGElectric*>(engine)->getRPM());
break; break;
case (FGEngine::etUnknown): case (FGEngine::etUnknown):
break; break;

View file

@ -126,6 +126,8 @@ public:
double GetMass(void) const {return Mass;} double GetMass(void) const {return Mass;}
double GetWeight(void) const {return Weight;} double GetWeight(void) const {return Weight;}
double GetEmptyWeight(void) const {return EmptyWeight;} double GetEmptyWeight(void) const {return EmptyWeight;}
/** Returns the coordinates of the center of gravity expressed in the
structural frame. */
const FGColumnVector3& GetXYZcg(void) const {return vXYZcg;} const FGColumnVector3& GetXYZcg(void) const {return vXYZcg;}
double GetXYZcg(int axis) const {return vXYZcg(axis);} double GetXYZcg(int axis) const {return vXYZcg(axis);}
const FGColumnVector3& GetDeltaXYZcg(void) const {return vDeltaXYZcg;} const FGColumnVector3& GetDeltaXYZcg(void) const {return vDeltaXYZcg;}
@ -172,7 +174,9 @@ public:
double GetTotalPointMassWeight(void) const; double GetTotalPointMassWeight(void) const;
const FGColumnVector3& GetPointMassMoment(void); const FGColumnVector3& GetPointMassMoment(void);
/// Returns the inertia matrix expressed in the body frame.
const FGMatrix33& GetJ(void) const {return mJ;} const FGMatrix33& GetJ(void) const {return mJ;}
/// Returns the inverse of the inertia matrix expressed in the body frame.
const FGMatrix33& GetJinv(void) const {return mJinv;} const FGMatrix33& GetJinv(void) const {return mJinv;}
void SetAircraftBaseInertias(const FGMatrix33& BaseJ) {baseJ = BaseJ;} void SetAircraftBaseInertias(const FGMatrix33& BaseJ) {baseJ = BaseJ;}
void GetMassPropertiesReport(int i); void GetMassPropertiesReport(int i);
@ -209,7 +213,7 @@ private:
double GetIyy(void) const { return mJ(2,2); } double GetIyy(void) const { return mJ(2,2); }
double GetIzz(void) const { return mJ(3,3); } double GetIzz(void) const { return mJ(3,3); }
double GetIxy(void) const { return -mJ(1,2); } double GetIxy(void) const { return -mJ(1,2); }
double GetIxz(void) const { return -mJ(1,3); } double GetIxz(void) const { return mJ(1,3); }
double GetIyz(void) const { return -mJ(2,3); } double GetIyz(void) const { return -mJ(2,3); }
/** The PointMass structure encapsulates a point mass object, moments of inertia /** The PointMass structure encapsulates a point mass object, moments of inertia

View file

@ -459,7 +459,7 @@ bool FGTurbine::Load(FGFDMExec* exec, Element *el)
if (el->FindElement("ignitionn1")) if (el->FindElement("ignitionn1"))
IgnitionN1 = el->FindElementValueAsNumber("ignitionn1"); IgnitionN1 = el->FindElementValueAsNumber("ignitionn1");
if (el->FindElement("ignitionn2")) if (el->FindElement("ignitionn2"))
IgnitionN1 = el->FindElementValueAsNumber("ignitionn2"); IgnitionN2 = el->FindElementValueAsNumber("ignitionn2");
if (el->FindElement("idlen1")) if (el->FindElement("idlen1"))
IdleN1 = el->FindElementValueAsNumber("idlen1"); IdleN1 = el->FindElementValueAsNumber("idlen1");
if (el->FindElement("idlen2")) if (el->FindElement("idlen2"))