From bf859a91c37b838183ff52fdc9d2266e076c7c63 Mon Sep 17 00:00:00 2001 From: ehofman Date: Sun, 19 Oct 2003 09:48:44 +0000 Subject: [PATCH] Update to the latest version of JSBSim --- src/FDM/JSBSim/FGAerodynamics.h | 29 +++++--- src/FDM/JSBSim/FGAtmosphere.cpp | 6 +- src/FDM/JSBSim/FGJSBBase.h | 3 +- src/FDM/JSBSim/FGLGear.cpp | 27 ++++--- src/FDM/JSBSim/FGLGear.h | 7 ++ src/FDM/JSBSim/FGPiston.cpp | 2 +- src/FDM/JSBSim/FGSimTurbine.cpp | 26 ++++--- src/FDM/JSBSim/FGSimTurbine.h | 102 ++++++++++++++++++-------- src/FDM/JSBSim/JSBSim.cxx | 9 +-- src/FDM/JSBSim/filtersjb/FGGain.cpp | 48 ++++++++---- src/FDM/JSBSim/filtersjb/FGSummer.cpp | 10 ++- src/FDM/JSBSim/filtersjb/FGSwitch.cpp | 11 ++- src/FDM/JSBSim/filtersjb/FGSwitch.h | 4 +- 13 files changed, 188 insertions(+), 96 deletions(-) diff --git a/src/FDM/JSBSim/FGAerodynamics.h b/src/FDM/JSBSim/FGAerodynamics.h index c58356480..bd641f3b9 100644 --- a/src/FDM/JSBSim/FGAerodynamics.h +++ b/src/FDM/JSBSim/FGAerodynamics.h @@ -66,17 +66,12 @@ DEFINITIONS #define ID_AERODYNAMICS "$Id$" - /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FORWARD DECLARATIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ namespace JSBSim { -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs] -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CLASS DOCUMENTATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ @@ -86,11 +81,8 @@ CLASS DOCUMENTATION aerodynamic properties of this aircraft. Here also, such unique phenomena as ground effect and maximum lift curve tailoff are handled. @author Jon S. Berndt + @author Tony Peden @version $Id$ - @see - Header File - @see - Source File */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -102,7 +94,7 @@ class FGAerodynamics : public FGModel { public: /** Constructor @param Executive a pointer to the parent executive object */ - FGAerodynamics(FGFDMExec*); + FGAerodynamics(FGFDMExec* Executive); /// Destructor ~FGAerodynamics(); @@ -110,18 +102,31 @@ public: @return false if no error */ bool Run(void); - /** Loads the Aerodynamics model + /** Loads the Aerodynamics model. + The Load function for this class expects the configuration file to + have found the AERODYNAMICS keyword in the configution file and to + have set that line to the current line. + @param AC_cfg pointer to the current configuration file. @return true if successful */ bool Load(FGConfigFile* AC_cfg); /** Gets the total aerodynamic force vector. @return a force vector reference. */ FGColumnVector3& GetForces(void) {return vForces;} + + /** Gets the aerodynamic force for an axis. + @param n Axis index. This could be 0, 1, or 2, or one of the + axis enums: eX, eY, eZ. + @return the force acting on an axis */ double GetForces(int n) const {return vForces(n);} /** Gets the total aerodynamic moment vector. @return a moment vector reference. */ FGColumnVector3& GetMoments(void) {return vMoments;} + + /** Gets the aerodynamic moment for an axis. + @return the moment about a single axis (as described also in the + similar call to GetForces(int n).*/ double GetMoments(int n) const {return vMoments(n);} FGColumnVector3& GetvLastFs(void) { return vLastFs; } @@ -145,7 +150,7 @@ public: inline void SetAlphaCLMax(double tt) { alphaclmax=tt; } inline void SetAlphaCLMin(double tt) { alphaclmin=tt; } - /** Gets the strings for the current set of coefficients. + /** Gets the strings for the current set of coefficients. @return a string containing the descriptive names for all coefficients */ string GetCoefficientStrings(void); diff --git a/src/FDM/JSBSim/FGAtmosphere.cpp b/src/FDM/JSBSim/FGAtmosphere.cpp index 4de422d19..bf02c1bc0 100644 --- a/src/FDM/JSBSim/FGAtmosphere.cpp +++ b/src/FDM/JSBSim/FGAtmosphere.cpp @@ -93,7 +93,7 @@ FGAtmosphere::FGAtmosphere(FGFDMExec* fdmex) : FGModel(fdmex) // turbType = ttBerndt; TurbGain = 0.0; TurbRate = 1.0; - + bind(); Debug(0); } @@ -141,7 +141,7 @@ bool FGAtmosphere::Run(void) Calculate(h); } - if (turbType != ttNone && TurbGain > 0.0) { + if (turbType != ttNone) { Turbulence(); vWindNED += vTurbulence; } @@ -278,7 +278,7 @@ void FGAtmosphere::Turbulence(void) vDirectiondAccelDt(eY) = 1 - 2.0*(double(rand())/double(RAND_MAX)); vDirectiondAccelDt(eZ) = 1 - 2.0*(double(rand())/double(RAND_MAX)); - MagnitudedAccelDt = 1 - 2.0*(double(rand())/double(RAND_MAX)); + MagnitudedAccelDt = 1 - 2.0*(double(rand())/double(RAND_MAX)) - Magnitude; // Scale the magnitude so that it moves // away from the peaks MagnitudedAccelDt = ((MagnitudedAccelDt - Magnitude) / diff --git a/src/FDM/JSBSim/FGJSBBase.h b/src/FDM/JSBSim/FGJSBBase.h index 7515b9219..b25573838 100644 --- a/src/FDM/JSBSim/FGJSBBase.h +++ b/src/FDM/JSBSim/FGJSBBase.h @@ -94,6 +94,7 @@ DEFINITIONS FORWARD DECLARATIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ +namespace JSBSim { /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs] @@ -112,8 +113,6 @@ CLASS DOCUMENTATION CLASS DECLARATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -namespace JSBSim { - class FGJSBBase { public: /// Constructor for FGJSBBase. diff --git a/src/FDM/JSBSim/FGLGear.cpp b/src/FDM/JSBSim/FGLGear.cpp index 3a9c4b86a..49d29ed0a 100644 --- a/src/FDM/JSBSim/FGLGear.cpp +++ b/src/FDM/JSBSim/FGLGear.cpp @@ -94,6 +94,7 @@ FGLGear::FGLGear(FGConfigFile* AC_cfg, FGFDMExec* fdmex) : Exec(fdmex) GearUp = false; GearDown = true; + Servicable = true; // Add some AI here to determine if gear is located properly according to its // brake group type ?? @@ -132,6 +133,8 @@ FGLGear::FGLGear(FGConfigFile* AC_cfg, FGFDMExec* fdmex) : Exec(fdmex) brakePct = 0.0; maxCompLen = 0.0; + TirePressureNorm = 1.0; + Debug(0); } @@ -188,6 +191,8 @@ FGLGear::FGLGear(const FGLGear& lgear) GearDown = lgear.GearDown; WheelSlip = lgear.WheelSlip; lastWheelSlip = lgear.lastWheelSlip; + TirePressureNorm = lgear.TirePressureNorm; + Servicable = lgear.Servicable; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -296,30 +301,30 @@ FGColumnVector3& FGLGear::Force(void) switch (eBrakeGrp) { case bgLeft: SteerGain = 0.10; - BrakeFCoeff = rollingFCoeff*(1.0 - FCS->GetBrake(bgLeft)) + - staticFCoeff*FCS->GetBrake(bgLeft); + BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgLeft)) + + staticFCoeff*FCS->GetBrake(bgLeft) ); break; case bgRight: SteerGain = 0.10; - BrakeFCoeff = rollingFCoeff*(1.0 - FCS->GetBrake(bgRight)) + - staticFCoeff*FCS->GetBrake(bgRight); + BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgRight)) + + staticFCoeff*FCS->GetBrake(bgRight) ); break; case bgCenter: SteerGain = 0.10; - BrakeFCoeff = rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) + - staticFCoeff*FCS->GetBrake(bgCenter); + BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) + + staticFCoeff*FCS->GetBrake(bgCenter) ); break; case bgNose: SteerGain = -0.50; - BrakeFCoeff = rollingFCoeff; + BrakeFCoeff = rollingFCoeff; break; case bgTail: SteerGain = -0.10; - BrakeFCoeff = rollingFCoeff; + BrakeFCoeff = rollingFCoeff; break; case bgNone: SteerGain = 0.0; - BrakeFCoeff = rollingFCoeff; + BrakeFCoeff = rollingFCoeff; break; default: cerr << "Improper brake group membership detected for this gear." << endl; @@ -400,7 +405,9 @@ FGColumnVector3& FGLGear::Force(void) RollingForce = 0; if (fabs(RollingWhlVel) > 1E-3) { - RollingForce = vLocalForce(eZ) * BrakeFCoeff * fabs(RollingWhlVel)/RollingWhlVel; + RollingForce = (1.0 - TirePressureNorm) * 30 + + vLocalForce(eZ) * BrakeFCoeff + * fabs(RollingWhlVel)/RollingWhlVel; } SideForce = vLocalForce(eZ) * FCoeff; diff --git a/src/FDM/JSBSim/FGLGear.h b/src/FDM/JSBSim/FGLGear.h index e849d229e..5e746a804 100644 --- a/src/FDM/JSBSim/FGLGear.h +++ b/src/FDM/JSBSim/FGLGear.h @@ -224,6 +224,11 @@ public: /// Gets the gear compression force in pounds inline double GetCompForce(void) {return Force()(3); } inline double GetBrakeFCoeff(void) {return BrakeFCoeff;} + + /// Gets the current normalized tire pressure + inline double GetTirePressure(void) { return TirePressureNorm; } + /// Sets the new normalized tire pressure + inline void SetTirePressure(double p) { TirePressureNorm = p; } /// Sets the brake value in percent (0 - 100) inline void SetBrake(double bp) {brakePct = bp;} @@ -278,6 +283,7 @@ private: double RollingForce, SideForce, FCoeff; double WheelSlip; double lastWheelSlip; + double TirePressureNorm; bool WOW; bool lastWOW; bool FirstContact; @@ -287,6 +293,7 @@ private: bool ReportEnable; bool isRetractable; bool GearUp, GearDown; + bool Servicable; string name; string sSteerType; string sBrakeGroup; diff --git a/src/FDM/JSBSim/FGPiston.cpp b/src/FDM/JSBSim/FGPiston.cpp index dbbc88588..e0907230a 100644 --- a/src/FDM/JSBSim/FGPiston.cpp +++ b/src/FDM/JSBSim/FGPiston.cpp @@ -137,7 +137,7 @@ FGPiston::~FGPiston() double FGPiston::Calculate(double PowerRequired) { - ConsumeFuel(); + if (FuelFlow_gph > 0.0) ConsumeFuel(); Throttle = FCS->GetThrottlePos(EngineNumber); Mixture = FCS->GetMixturePos(EngineNumber); diff --git a/src/FDM/JSBSim/FGSimTurbine.cpp b/src/FDM/JSBSim/FGSimTurbine.cpp index 83901c093..864e17b59 100644 --- a/src/FDM/JSBSim/FGSimTurbine.cpp +++ b/src/FDM/JSBSim/FGSimTurbine.cpp @@ -139,8 +139,8 @@ double FGSimTurbine::Run(void) { double idlethrust, milthrust, thrust; double N2norm; // 0.0 = idle N2, 1.0 = maximum N2 - idlethrust = MaxMilThrust * ThrustTables[0]->TotalValue(); - milthrust = (MaxMilThrust - idlethrust) * ThrustTables[1]->TotalValue(); + idlethrust = MilThrust * ThrustTables[0]->TotalValue(); + milthrust = (MilThrust - idlethrust) * ThrustTables[1]->TotalValue(); Running = true; Starter = false; @@ -149,13 +149,13 @@ double FGSimTurbine::Run(void) N1 = Seek(&N1, IdleN1 + ThrottleCmd * N1_factor, delay, delay * 2.4); N2norm = (N2 - IdleN2) / N2_factor; thrust = idlethrust + (milthrust * N2norm * N2norm); - FuelFlow_pph = thrust * TSFC; thrust = thrust * (1.0 - BleedDemand); + FuelFlow_pph = thrust * TSFC; if (FuelFlow_pph < IdleFF) FuelFlow_pph = IdleFF; EGT_degC = TAT + 363.1 + ThrottleCmd * 357.1; OilPressure_psi = N2 * 0.62; OilTemp_degK = Seek(&OilTemp_degK, 366.0, 1.2, 0); - EPR = 1.0 + thrust/MaxMilThrust; + EPR = 1.0 + thrust/MilThrust; NozzlePosition = Seek(&NozzlePosition, 1.0 - N2norm, 0.8, 0.8); if (Reversed) thrust = thrust * -0.2; @@ -165,9 +165,9 @@ double FGSimTurbine::Run(void) } if ((Augmented == 1) && Augmentation) { - thrust = thrust * ThrustTables[2]->TotalValue(); + thrust = MaxThrust * ThrustTables[2]->TotalValue(); FuelFlow_pph = thrust * ATSFC; - NozzlePosition = Seek(&NozzlePosition, 1.0, 0.8, 0); + NozzlePosition = Seek(&NozzlePosition, 1.0, 0.8, 0.8); } if ((Injected == 1) && Injection) @@ -200,7 +200,7 @@ double FGSimTurbine::SpinUp(void) double FGSimTurbine::Start(void) { if ((N2 > 15.0) && !Starved) { // minimum 15% N2 needed for start - Cranking = true; + Cranking = true; // provided for sound effects signal if (N2 < IdleN2) { N2 = Seek(&N2, IdleN2, 2.0, N2/2.0); N1 = Seek(&N1, IdleN1, 1.4, N1/2.0); @@ -254,8 +254,8 @@ double FGSimTurbine::Seize(void) double FGSimTurbine::Trim(void) { double idlethrust, milthrust, thrust; - idlethrust = MaxMilThrust * ThrustTables[0]->TotalValue(); - milthrust = (MaxMilThrust - idlethrust) * ThrustTables[1]->TotalValue(); + idlethrust = MilThrust * ThrustTables[0]->TotalValue(); + milthrust = (MilThrust - idlethrust) * ThrustTables[1]->TotalValue(); thrust = idlethrust + (milthrust * ThrottleCmd * ThrottleCmd); return thrust; } @@ -295,7 +295,8 @@ double FGSimTurbine::Seek(double *var, double target, double accel, double decel void FGSimTurbine::SetDefaults(void) { Name = "None_Defined"; - MaxMilThrust = 10000.0; + MilThrust = 10000.0; + MaxThrust = 10000.0; BypassRatio = 0.0; TSFC = 0.8; ATSFC = 1.7; @@ -329,7 +330,8 @@ bool FGSimTurbine::Load(FGConfigFile *Eng_cfg) Name = Eng_cfg->GetValue("NAME"); cout << Name << endl; Eng_cfg->GetNextConfigLine(); - *Eng_cfg >> token >> MaxMilThrust; + *Eng_cfg >> token >> MilThrust; + *Eng_cfg >> token >> MaxThrust; *Eng_cfg >> token >> BypassRatio; *Eng_cfg >> token >> TSFC; *Eng_cfg >> token >> ATSFC; @@ -352,7 +354,7 @@ bool FGSimTurbine::Load(FGConfigFile *Eng_cfg) N1_factor = MaxN1 - IdleN1; N2_factor = MaxN2 - IdleN2; OilTemp_degK = (Auxiliary->GetTotalTemperature() - 491.69) * 0.5555556 + 273.0; - IdleFF = pow(MaxMilThrust, 0.2) * 107.0; // just an estimate + IdleFF = pow(MilThrust, 0.2) * 107.0; // just an estimate return true; } diff --git a/src/FDM/JSBSim/FGSimTurbine.h b/src/FDM/JSBSim/FGSimTurbine.h index 573948fae..eca4e680a 100644 --- a/src/FDM/JSBSim/FGSimTurbine.h +++ b/src/FDM/JSBSim/FGSimTurbine.h @@ -25,14 +25,14 @@ HISTORY -------------------------------------------------------------------------------- -03/11/2003 DPC Created -09/22/2003 DPC Added starting, stopping +03/11/2003 DPC Created, based on FGTurbine +09/22/2003 DPC Added starting, stopping, new framework %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% COMMENTS, REFERENCES, and NOTES -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SENTRY %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ @@ -51,15 +51,56 @@ INCLUDES #define ID_SIMTURBINE "$Id$" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -CLASS DECLARATION +FORWARD DECLARATIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ namespace JSBSim { +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +CLASS DOCUMENTATION +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ + +/** This class models a turbine engine. Based on Jon Berndt's FGTurbine module. + Here the term "phase" signifies the engine's mode of operation. At any given + time the engine is in only one phase. At simulator startup the engine will be + placed in the Trim phase in order to provide a simplified thrust value without + throttle lag. When trimming is complete the engine will go to the Off phase, + unless the value FGEngine::Running has been previously set to true, in which + case the engine will go to the Run phase. Once an engine is in the Off phase + the full starting procedure (or airstart) must be used to get it running. +

+ -STARTING (on ground): + -# Set the control FGEngine::Starter to true. The engine will spin up to + a maximum of about %25 N2 (%5.2 N1). This simulates the action of a + pneumatic starter. + -# After reaching %15 N2 set the control FGEngine::Cutoff to false. If fuel + is available the engine will now accelerate to idle. The starter will + automatically be set to false after the start cycle. +

+ -STARTING (in air): + -# Increase speed to obtain a minimum of %15 N2. If this is not possible, + the starter may be used to assist. + -# Place the control FGEngine::Cutoff to false. +

+ Ignition is assumed to be on anytime the Cutoff control is set to false, + therefore a seperate ignition system is not modeled. + + @author David P. Culp + @version $Id$ +*/ + +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +CLASS DECLARATION +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ + class FGSimTurbine : public FGEngine { public: + /** Constructor + @param exec pointer to executive structure + @param Eng_Cfg pointer to engine config file instance */ FGSimTurbine(FGFDMExec* exec, FGConfigFile* Eng_cfg); + /// Destructor ~FGSimTurbine(); enum phaseType { tpOff, tpRun, tpSpinUp, tpStart, tpStall, tpSeize, tpTrim }; @@ -80,32 +121,31 @@ private: typedef vector CoeffArray; CoeffArray ThrustTables; - phaseType phase; // Operating mode, or "phase" - double MaxMilThrust; // Maximum Rated Thrust, static @ S.L. (lbf) - double BypassRatio; // Bypass Ratio - double TSFC; // Thrust Specific Fuel Consumption (lbm/hr/lbf) - double ATSFC; // Augmented TSFC (lbm/hr/lbf) - double IdleN1; // Idle N1 - double IdleN2; // Idle N2 - double MaxN1; // N1 at 100% throttle - double MaxN2; // N2 at 100% throttle - double IdleFF; // Idle Fuel Flow (lbm/hr) - double delay; // Inverse spool-up time from idle to 100% (seconds) - double dt; // Simulator time slice - double N1_factor; // factor to tie N1 and throttle - double N2_factor; // factor to tie N2 and throttle - double ThrottleCmd; // FCS-supplied throttle position - double throttle; // virtual throttle position - double TAT; // total air temperature (deg C) - bool Stalled; // true if engine is compressor-stalled - bool Seized; // true if inner spool is seized - bool Overtemp; // true if EGT exceeds limits - bool Fire; // true if engine fire detected - bool start_running; // true if user wants engine running at start - int Augmented; // = 1 if augmentation installed - int Injected; // = 1 if water injection installed - int AugMethod; // = 0 if using property /engine[n]/augmentation - // = 1 if using last 1% of throttle movement + phaseType phase; ///< Operating mode, or "phase" + double MilThrust; ///< Maximum Unaugmented Thrust, static @ S.L. (lbf) + double MaxThrust; ///< Maximum Augmented Thrust, static @ S.L. (lbf) + double BypassRatio; ///< Bypass Ratio + double TSFC; ///< Thrust Specific Fuel Consumption (lbm/hr/lbf) + double ATSFC; ///< Augmented TSFC (lbm/hr/lbf) + double IdleN1; ///< Idle N1 + double IdleN2; ///< Idle N2 + double MaxN1; ///< N1 at 100% throttle + double MaxN2; ///< N2 at 100% throttle + double IdleFF; ///< Idle Fuel Flow (lbm/hr) + double delay; ///< Inverse spool-up time from idle to 100% (seconds) + double dt; ///< Simulator time slice + double N1_factor; ///< factor to tie N1 and throttle + double N2_factor; ///< factor to tie N2 and throttle + double ThrottleCmd; ///< FCS-supplied throttle position + double TAT; ///< total air temperature (deg C) + bool Stalled; ///< true if engine is compressor-stalled + bool Seized; ///< true if inner spool is seized + bool Overtemp; ///< true if EGT exceeds limits + bool Fire; ///< true if engine fire detected + int Augmented; ///< = 1 if augmentation installed + int Injected; ///< = 1 if water injection installed + int AugMethod; ///< = 0 if using property /engine[n]/augmentation + ///< = 1 if using last 1% of throttle movement double Off(void); double Run(void); diff --git a/src/FDM/JSBSim/JSBSim.cxx b/src/FDM/JSBSim/JSBSim.cxx index 49a4abc18..936f1108e 100644 --- a/src/FDM/JSBSim/JSBSim.cxx +++ b/src/FDM/JSBSim/JSBSim.cxx @@ -224,8 +224,6 @@ void FGJSBsim::init() { Atmosphere->SetTurbGain(tmp * tmp * 100.0); tmp = turbulence_rate->getDoubleValue(); - if (tmp <= 0) - tmp = 1.0; Atmosphere->SetTurbRate(tmp); } else { @@ -427,10 +425,7 @@ bool FGJSBsim::copy_to_JSBsim() { tmp = turbulence_gain->getDoubleValue(); Atmosphere->SetTurbGain(tmp * tmp * 100.0); - if (turbulence_rate->hasValue()) - tmp = turbulence_rate->getDoubleValue(); - else - tmp = 1.0; + tmp = turbulence_rate->getDoubleValue(); Atmosphere->SetTurbRate(tmp); Atmosphere->SetWindNED( wind_from_north->getDoubleValue(), @@ -819,6 +814,7 @@ void FGJSBsim::init_gear(void ) { node->setBoolValue("wow", gr->GetGearUnit(i)->GetWOW()); node->setBoolValue("has-brake", gr->GetGearUnit(i)->GetBrakeGroup() > 0); node->setDoubleValue("position-norm", FCS->GetGearPos()); + node->setDoubleValue("tire-pressure-norm", gr->GetGearUnit(i)->GetTirePressure()); } } @@ -832,6 +828,7 @@ void FGJSBsim::update_gear(void) { ->setBoolValue(gr->GetGearUnit(i)->GetWOW()); node->getChild("position-norm", 0, true) ->setDoubleValue(FCS->GetGearPos()); + gr->GetGearUnit(i)->SetTirePressure(node->getDoubleValue("tire-pressure-norm")); } } diff --git a/src/FDM/JSBSim/filtersjb/FGGain.cpp b/src/FDM/JSBSim/filtersjb/FGGain.cpp index 1c7117996..e62a07c95 100644 --- a/src/FDM/JSBSim/filtersjb/FGGain.cpp +++ b/src/FDM/JSBSim/filtersjb/FGGain.cpp @@ -61,8 +61,8 @@ FGGain::FGGain(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), Gain = 1.000; Rows = 0; Min = Max = 0.0; - OutputPct=0; - invert=false; + OutputPct = 0; + invert = false; ScheduledBy = 0; Type = AC_cfg->GetValue("TYPE"); @@ -73,6 +73,12 @@ FGGain::FGGain(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), *AC_cfg >> token; if (token == "INPUT") { token = AC_cfg->GetValue("INPUT"); + + if (token[0] == '-') { + invert = true; + token.erase(0,1); + } + if (InputNodes.size() > 0) { cerr << "Gains can only accept one input" << endl; } else { @@ -86,7 +92,10 @@ FGGain::FGGain(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), } else if (token == "MAX") { *AC_cfg >> Max; } else if (token == "INVERT") { - invert=true; + invert = true; + cerr << endl << "The INVERT keyword is being deprecated and will not be " + "supported in the future. Please use a minus sign in front " + "of an input property in the future." << endl << endl; } else if (token == "ROWS") { *AC_cfg >> Rows; Table = new FGTable(Rows); @@ -128,23 +137,26 @@ bool FGGain::Run(void ) FGFCSComponent::Run(); // call the base class for initialization of Input Input = InputNodes[0]->getDoubleValue(); - if (Type == "PURE_GAIN") { + + if (invert) Input = -Input; + + if (Type == "PURE_GAIN") { // PURE_GAIN + Output = Gain * Input; - } else if (Type == "SCHEDULED_GAIN") { + + } else if (Type == "SCHEDULED_GAIN") { // SCHEDULED_GAIN + LookupVal = ScheduledBy->getDoubleValue(); SchedGain = Table->GetValue(LookupVal); Output = Gain * SchedGain * Input; - } else if (Type == "AEROSURFACE_SCALE") { - if (!invert) { - OutputPct = Input; - if (Input >= 0.0) Output = Input * Max; - else Output = Input * -Min; - } else { - OutputPct=-1*Input; - if (Input <= 0.0) Output = Input * -Max; - else Output = Input * Min; - } + + } else if (Type == "AEROSURFACE_SCALE") { // AEROSURFACE_SCALE + + OutputPct = Input; + if (Input >= 0.0) Output = Input * Max; + else Output = Input * -Min; Output *= Gain; + } if (IsOutput) SetOutput(); @@ -177,7 +189,11 @@ void FGGain::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor - cout << " INPUT: " << InputNodes[0]->getName() << endl; + if (invert) + cout << " INPUT: -" << InputNodes[0]->getName() << endl; + else + cout << " INPUT: " << InputNodes[0]->getName() << endl; + cout << " GAIN: " << Gain << endl; if (IsOutput) cout << " OUTPUT: " << OutputNode->getName() << endl; cout << " MIN: " << Min << endl; diff --git a/src/FDM/JSBSim/filtersjb/FGSummer.cpp b/src/FDM/JSBSim/filtersjb/FGSummer.cpp index 5ae13a358..71f7b0a23 100644 --- a/src/FDM/JSBSim/filtersjb/FGSummer.cpp +++ b/src/FDM/JSBSim/filtersjb/FGSummer.cpp @@ -77,6 +77,8 @@ FGSummer::FGSummer(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), } InputNodes.push_back( resolveSymbol(token) ); + } else if (token == "BIAS") { + *AC_cfg >> Bias; } else if (token == "CLIPTO") { *AC_cfg >> clipmin >> clipmax; if (clipmax > clipmin) { @@ -116,6 +118,8 @@ bool FGSummer::Run(void ) Output += InputNodes[idx]->getDoubleValue()*InputSigns[idx]; } + Output += Bias; + if (clip) { if (Output > clipmax) Output = clipmax; else if (Output < clipmin) Output = clipmin; @@ -153,8 +157,12 @@ void FGSummer::Debug(int from) if (from == 0) { // Constructor cout << " INPUTS: " << endl; for (unsigned i=0;igetName() << endl; + if (InputSigns[i] < 0) + cout << " -" << InputNodes[i]->getName() << endl; + else + cout << " " << InputNodes[i]->getName() << endl; } + if (Bias != 0.0) cout << " Bias: " << Bias << endl; if (clip) cout << " CLIPTO: " << clipmin << ", " << clipmax << endl; if (IsOutput) cout << " OUTPUT: " <getName() << endl; diff --git a/src/FDM/JSBSim/filtersjb/FGSwitch.cpp b/src/FDM/JSBSim/filtersjb/FGSwitch.cpp index 30b633e15..e38b2064b 100644 --- a/src/FDM/JSBSim/filtersjb/FGSwitch.cpp +++ b/src/FDM/JSBSim/filtersjb/FGSwitch.cpp @@ -110,6 +110,12 @@ FGSwitch::FGSwitch(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), current_test->OutputVal = atof(value.c_str()); } else { // "value" must be a property if execution passes to here. + if (value[0] == '-') { + current_test->sign = -1.0; + value.erase(0,1); + } else { + current_test->sign = 1.0; + } current_test->OutputProp = PropertyManager->GetNode(value); } } @@ -230,7 +236,10 @@ void FGSwitch::Debug(int from) } if (iTests->OutputProp != 0L) - cout << indent << "Switch VALUE is " << iTests->OutputProp->GetName() << scratch << endl; + if (iTests->sign < 0) + cout << indent << "Switch VALUE is - " << iTests->OutputProp->GetName() << scratch << endl; + else + cout << indent << "Switch VALUE is " << iTests->OutputProp->GetName() << scratch << endl; else cout << indent << "Switch VALUE is " << iTests->OutputVal << scratch << endl; diff --git a/src/FDM/JSBSim/filtersjb/FGSwitch.h b/src/FDM/JSBSim/filtersjb/FGSwitch.h index 2a68b7475..cf1ea4c90 100644 --- a/src/FDM/JSBSim/filtersjb/FGSwitch.h +++ b/src/FDM/JSBSim/filtersjb/FGSwitch.h @@ -127,16 +127,18 @@ private: eLogic Logic; double OutputVal; FGPropertyManager *OutputProp; + float sign; double GetValue(void) { if (OutputProp == 0L) return OutputVal; - else return OutputProp->getDoubleValue(); + else return OutputProp->getDoubleValue()*sign; } test(void) { // constructor for the test structure Logic = elUndef; OutputVal = 0.0; OutputProp = 0L; + sign = 1.0; } }; -- 2.39.5