From b82a5ad06271a3b0748e4b8020cfd8e9464853be Mon Sep 17 00:00:00 2001 From: curt Date: Tue, 30 Oct 2001 02:51:13 +0000 Subject: [PATCH] Latest updates from the JSBSim project. --- src/FDM/JSBSim/FGDefs.h | 2 ++ src/FDM/JSBSim/FGEngine.cpp | 4 ++-- src/FDM/JSBSim/FGEngine.h | 2 ++ src/FDM/JSBSim/FGFDMExec.cpp | 4 ++-- src/FDM/JSBSim/FGOutput.cpp | 2 ++ src/FDM/JSBSim/FGState.cpp | 40 ++++++++++++++++++++++++++++++++++-- src/FDM/JSBSim/FGState.h | 3 +++ 7 files changed, 51 insertions(+), 6 deletions(-) diff --git a/src/FDM/JSBSim/FGDefs.h b/src/FDM/JSBSim/FGDefs.h index 5344ef525..f12512687 100644 --- a/src/FDM/JSBSim/FGDefs.h +++ b/src/FDM/JSBSim/FGDefs.h @@ -95,6 +95,8 @@ enum eParam { FG_THROTTLE_POS, FG_MIXTURE_CMD, FG_MIXTURE_POS, + FG_MAGNETO_CMD, + FG_STARTER_CMD, FG_ACTIVE_ENGINE, FG_HOVERB, FG_PITCH_TRIM_CMD, diff --git a/src/FDM/JSBSim/FGEngine.cpp b/src/FDM/JSBSim/FGEngine.cpp index 8488c4fbf..6b0fc8b7a 100644 --- a/src/FDM/JSBSim/FGEngine.cpp +++ b/src/FDM/JSBSim/FGEngine.cpp @@ -77,12 +77,12 @@ FGEngine::FGEngine(FGFDMExec* exec) { Auxiliary = FDMExec->GetAuxiliary(); Output = FDMExec->GetOutput(); - Mixture = 1.0; // FIXME: get actual value + Mixture = 1.0; // FIXME: get actual value Thrust = PctPower = 0.0; Starved = Flameout = false; Running = false; - Cranking = false; + Cranking = Starter = false; if (debug_lvl & 2) cout << "Instantiated: FGEngine" << endl; TrimMode = false; diff --git a/src/FDM/JSBSim/FGEngine.h b/src/FDM/JSBSim/FGEngine.h index d042d192b..62a1c9c0c 100644 --- a/src/FDM/JSBSim/FGEngine.h +++ b/src/FDM/JSBSim/FGEngine.h @@ -117,6 +117,8 @@ public: virtual float GetThrottleMax(void) { return MaxThrottle; } float GetThrottle(void) { return Throttle; } float GetMixture(void) { return Mixture; } + int GetMagnetos(void) { return Magnetos; } + bool GetStarter(void) { return Starter; } float GetThrust(void) { return Thrust; } bool GetStarved(void) { return Starved; } bool GetFlameout(void) { return Flameout; } diff --git a/src/FDM/JSBSim/FGFDMExec.cpp b/src/FDM/JSBSim/FGFDMExec.cpp index 30a274675..33adae95c 100644 --- a/src/FDM/JSBSim/FGFDMExec.cpp +++ b/src/FDM/JSBSim/FGFDMExec.cpp @@ -520,10 +520,10 @@ bool FGFDMExec::LoadScript(string script) << iterConditions->Comparison[i] << " " << iterConditions->TestValue[i] << ")"; } - cout << ") then {" << endl; + cout << ") then {"; for (i=0; iSetValue.size(); i++) { - cout << " set" << State->paramdef[iterConditions->SetParam[i]] + cout << endl << " set" << State->paramdef[iterConditions->SetParam[i]] << "to " << iterConditions->SetValue[i]; switch (iterConditions->Type[i]) { diff --git a/src/FDM/JSBSim/FGOutput.cpp b/src/FDM/JSBSim/FGOutput.cpp index b5fd9e57a..b5e1df665 100644 --- a/src/FDM/JSBSim/FGOutput.cpp +++ b/src/FDM/JSBSim/FGOutput.cpp @@ -151,6 +151,7 @@ void FGOutput::DelimitedOutput(string fname) if (SubSystems & FGAircraft::ssAerosurfaces) { outstream << ", "; outstream << "Throttle, "; + outstream << "Mixture, "; outstream << "Aileron Cmd, "; outstream << "Elevator Cmd, "; outstream << "Rudder Cmd, "; @@ -226,6 +227,7 @@ void FGOutput::DelimitedOutput(string fname) if (SubSystems & FGAircraft::ssAerosurfaces) { outstream << ", "; outstream << FCS->GetThrottlePos(0) << ", "; + outstream << FCS->GetMixturePos(0) << ", "; outstream << FCS->GetDaCmd() << ", "; outstream << FCS->GetDeCmd() << ", "; outstream << FCS->GetDrCmd() << ", "; diff --git a/src/FDM/JSBSim/FGState.cpp b/src/FDM/JSBSim/FGState.cpp index dc05a21bf..19bb8edc7 100644 --- a/src/FDM/JSBSim/FGState.cpp +++ b/src/FDM/JSBSim/FGState.cpp @@ -97,6 +97,7 @@ FGState::FGState(FGFDMExec* fdex) : mTb2l(3,3), Atmosphere = FDMExec->GetAtmosphere(); Aerodynamics = FDMExec->GetAerodynamics(); GroundReactions = FDMExec->GetGroundReactions(); + Propulsion = FDMExec->GetPropulsion(); RegisterVariable(FG_TIME, " time " ); RegisterVariable(FG_QBAR, " qbar " ); @@ -132,6 +133,10 @@ FGState::FGState(FGFDMExec* fdex) : mTb2l(3,3), RegisterVariable(FG_FLAPS_CMD, " flaps_cmd " ); RegisterVariable(FG_THROTTLE_CMD, " throttle_cmd " ); RegisterVariable(FG_THROTTLE_POS, " throttle_pos " ); + RegisterVariable(FG_MIXTURE_CMD, " mixture_cmd " ); + RegisterVariable(FG_MIXTURE_POS, " mixture_pos " ); + RegisterVariable(FG_MAGNETO_CMD, " magneto_cmd " ); + RegisterVariable(FG_STARTER_CMD, " starter_cmd " ); RegisterVariable(FG_ACTIVE_ENGINE, " active_engine " ); RegisterVariable(FG_HOVERB, " height/span " ); RegisterVariable(FG_PITCH_TRIM_CMD, " pitch_trim_cmd " ); @@ -258,12 +263,29 @@ float FGState::GetParameter(eParam val_idx) { case FG_THROTTLE_POS: if (ActiveEngine < 0) return FCS->GetThrottlePos(0); else return FCS->GetThrottlePos(ActiveEngine); + case FG_MAGNETO_CMD: + if (ActiveEngine < 0) return Propulsion->GetEngine(0)->GetMagnetos(); + else return Propulsion->GetEngine(ActiveEngine)->GetMagnetos(); + case FG_STARTER_CMD: + if (ActiveEngine < 0) { + if (Propulsion->GetEngine(0)->GetStarter()) return 1.0; + else return 0.0; + } else { + if (Propulsion->GetEngine(ActiveEngine)->GetStarter()) return 1.0; + else return 0.0; + } + case FG_MIXTURE_CMD: + if (ActiveEngine < 0) return FCS->GetMixtureCmd(0); + else return FCS->GetMixtureCmd(ActiveEngine); + case FG_MIXTURE_POS: + if (ActiveEngine < 0) return FCS->GetMixturePos(0); + else return FCS->GetMixturePos(ActiveEngine); case FG_HOVERB: return Position->GetHOverB(); case FG_PITCH_TRIM_CMD: return FCS->GetPitchTrimCmd(); default: - cerr << "FGState::GetParameter() - No handler for parameter " << val_idx << endl; + cerr << "FGState::GetParameter() - No handler for parameter " << paramdef[val_idx] << endl; return 0.0; } return 0; @@ -306,6 +328,9 @@ void FGState::SetParameter(eParam val_idx, float val) { case FG_THROTTLE_POS: FCS->SetThrottlePos(ActiveEngine,val); break; + case FG_MIXTURE_POS: + FCS->SetMixturePos(ActiveEngine,val); + break; case FG_ELEVATOR_CMD: FCS->SetDeCmd(val); @@ -328,7 +353,18 @@ void FGState::SetParameter(eParam val_idx, float val) { case FG_THROTTLE_CMD: FCS->SetThrottleCmd(ActiveEngine,val); break; - + case FG_MIXTURE_CMD: + FCS->SetMixtureCmd(ActiveEngine,val); + break; + case FG_MAGNETO_CMD: + Propulsion->GetEngine(ActiveEngine)->SetMagnetos(val); // need to account for -1 + break; + case FG_STARTER_CMD: + if (val < 0.001) + Propulsion->GetEngine(ActiveEngine)->SetStarter(false); // need to account for -1 + else if (val >= 0.001) + Propulsion->GetEngine(ActiveEngine)->SetStarter(true); // need to account for -1 + break; case FG_ACTIVE_ENGINE: ActiveEngine = (int)val; break; diff --git a/src/FDM/JSBSim/FGState.h b/src/FDM/JSBSim/FGState.h index 6e24822b1..c9ab9d48c 100644 --- a/src/FDM/JSBSim/FGState.h +++ b/src/FDM/JSBSim/FGState.h @@ -83,6 +83,7 @@ class FGOutput; class FGPosition; class FGFDMExec; class FGGroundReactions; +class FGPropulsion; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs] @@ -331,6 +332,7 @@ private: FGFCS* FCS; FGAerodynamics* Aerodynamics; FGGroundReactions* GroundReactions; + FGPropulsion* Propulsion; typedef map CoeffMap; CoeffMap coeffdef; @@ -350,6 +352,7 @@ private: #include "FGOutput.h" #include "FGAircraft.h" #include "FGGroundReactions.h" +#include "FGPropulsion.h" #endif