From ad51a9bde2995605984161af1b4273b28ce4fddc Mon Sep 17 00:00:00 2001 From: Erik Hofman Date: Sun, 28 Nov 2010 10:58:47 +0100 Subject: [PATCH] Sync JSBSim again --- src/FDM/JSBSim/FGFDMExec.cpp | 31 ++--- src/FDM/JSBSim/FGFDMExec.h | 75 +++++++----- src/FDM/JSBSim/JSBSim.cxx | 15 ++- .../initialization/FGInitialCondition.cpp | 89 +++++++------- .../initialization/FGInitialCondition.h | 7 +- src/FDM/JSBSim/input_output/FGScript.cpp | 12 +- src/FDM/JSBSim/math/FGModelFunctions.h | 17 ++- src/FDM/JSBSim/models/FGAerodynamics.cpp | 38 +++--- src/FDM/JSBSim/models/FGAerodynamics.h | 26 ++-- src/FDM/JSBSim/models/FGAircraft.cpp | 37 +++--- src/FDM/JSBSim/models/FGAircraft.h | 60 +++++----- src/FDM/JSBSim/models/FGAtmosphere.cpp | 54 +++++---- src/FDM/JSBSim/models/FGAtmosphere.h | 14 +-- src/FDM/JSBSim/models/FGAuxiliary.cpp | 111 ++++++++++-------- src/FDM/JSBSim/models/FGAuxiliary.h | 7 +- src/FDM/JSBSim/models/FGBuoyantForces.cpp | 4 +- src/FDM/JSBSim/models/FGExternalForce.h | 4 +- src/FDM/JSBSim/models/FGExternalReactions.h | 8 +- src/FDM/JSBSim/models/FGFCS.cpp | 10 +- src/FDM/JSBSim/models/FGFCS.h | 4 +- src/FDM/JSBSim/models/FGGroundReactions.cpp | 8 +- src/FDM/JSBSim/models/FGGroundReactions.h | 12 +- src/FDM/JSBSim/models/FGInertial.cpp | 6 +- src/FDM/JSBSim/models/FGInput.cpp | 2 +- src/FDM/JSBSim/models/FGMassBalance.cpp | 24 ++-- src/FDM/JSBSim/models/FGMassBalance.h | 10 +- src/FDM/JSBSim/models/FGModel.cpp | 40 +------ src/FDM/JSBSim/models/FGModel.h | 26 +--- src/FDM/JSBSim/models/FGOutput.cpp | 32 ++++- src/FDM/JSBSim/models/FGOutput.h | 5 +- src/FDM/JSBSim/models/FGPropagate.cpp | 44 ++++--- src/FDM/JSBSim/models/FGPropagate.h | 5 +- src/FDM/JSBSim/models/FGPropulsion.cpp | 45 ++++--- src/FDM/JSBSim/models/FGPropulsion.h | 36 +++--- src/FDM/JSBSim/models/atmosphere/FGMSIS.cpp | 20 ++-- 35 files changed, 477 insertions(+), 461 deletions(-) diff --git a/src/FDM/JSBSim/FGFDMExec.cpp b/src/FDM/JSBSim/FGFDMExec.cpp index 616dd6ea6..ab0bf8a9a 100644 --- a/src/FDM/JSBSim/FGFDMExec.cpp +++ b/src/FDM/JSBSim/FGFDMExec.cpp @@ -71,7 +71,7 @@ using namespace std; namespace JSBSim { -static const char *IdSrc = "$Id: FGFDMExec.cpp,v 1.82 2010/10/07 03:17:29 jberndt Exp $"; +static const char *IdSrc = "$Id: FGFDMExec.cpp,v 1.83 2010/11/07 13:30:54 jberndt Exp $"; static const char *IdHdr = ID_FDMEXEC; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -95,23 +95,11 @@ void checkTied ( FGPropertyManager *node ) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -// Constructors -FGFDMExec::FGFDMExec(FGPropertyManager* root) : Root(root), delete_root(false) -{ - FDMctr = new unsigned int; - *FDMctr = 0; - Initialize(); - root_overload = (root != NULL); -} +// Constructor -FGFDMExec::FGFDMExec(FGPropertyManager* root, unsigned int* fdmctr) : Root(root), delete_root(false), FDMctr(fdmctr) +FGFDMExec::FGFDMExec(FGPropertyManager* root, unsigned int* fdmctr) : Root(root), FDMctr(fdmctr) { - Initialize(); - root_overload = (root != NULL); -} -void FGFDMExec::Initialize() -{ Frame = 0; Error = 0; GroundCallback = 0; @@ -138,6 +126,7 @@ void FGFDMExec::Initialize() IsChild = false; holding = false; Terminate = false; + StandAlone = false; sim_time = 0.0; dT = 1.0/120.0; // a default timestep size. This is needed for when JSBSim is @@ -152,8 +141,10 @@ void FGFDMExec::Initialize() if (Root == 0) { // Then this is the root FDM Root = new FGPropertyManager; // Create the property manager - delete_root = true; - + StandAlone = true; + } + + if (FDMctr == 0) { FDMctr = new unsigned int; // Create and initialize the child FDM counter (*FDMctr) = 0; } @@ -197,13 +188,13 @@ FGFDMExec::~FGFDMExec() checkTied( instance ); DeAllocate(); - if(FDMctr != 0 && !root_overload) { + if (IdFDM == 0) { // Meaning this is no child FDM if(Root != 0) { - if (delete_root) + if(StandAlone) delete Root; Root = 0; } - if (IdFDM == 0) { // Meaning this is no child FDM + if(FDMctr != 0) { delete FDMctr; FDMctr = 0; } diff --git a/src/FDM/JSBSim/FGFDMExec.h b/src/FDM/JSBSim/FGFDMExec.h index 38921ac7c..10736f4a4 100644 --- a/src/FDM/JSBSim/FGFDMExec.h +++ b/src/FDM/JSBSim/FGFDMExec.h @@ -41,7 +41,10 @@ SENTRY INCLUDES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#include "models/FGModel.h" +#include +#include + +//#include "models/FGModel.h" #include "models/FGOutput.h" #include "models/FGInput.h" #include "initialization/FGTrim.h" @@ -53,14 +56,11 @@ INCLUDES #include "models/FGPropagate.h" #include "math/FGColumnVector3.h" -#include -#include - /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#define ID_FDMEXEC "$Id: FGFDMExec.h,v 1.54 2010/10/07 03:17:29 jberndt Exp $" +#define ID_FDMEXEC "$Id: FGFDMExec.h,v 1.56 2010/11/18 20:37:10 jberndt Exp $" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FORWARD DECLARATIONS @@ -70,6 +70,20 @@ namespace JSBSim { class FGScript; class FGTrim; +class FGAerodynamics; +class FGAircraft; +class FGAtmosphere; +class FGAuxiliary; +class FGBuoyantForces; +class FGExternalReactions; +class FGGroundReactions; +class FGFCS; +class FGInertial; +class FGInput; +class FGOutput; +class FGPropagate; +class FGPropulsion; +class FGMassBalance; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CLASS DOCUMENTATION @@ -169,7 +183,7 @@ CLASS DOCUMENTATION property actually maps toa function call of DoTrim(). @author Jon S. Berndt - @version $Revision: 1.54 $ + @version $Revision: 1.56 $ */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -206,9 +220,8 @@ class FGFDMExec : public FGJSBBase, public FGXMLFileRead public: - /// Default constructors - FGFDMExec(FGPropertyManager* root = 0); - FGFDMExec(FGPropertyManager* root, unsigned int* fdmctr); + /// Default constructor + FGFDMExec(FGPropertyManager* root = 0, unsigned int* fdmctr = 0); /// Default destructor ~FGFDMExec(); @@ -292,49 +305,49 @@ public: /// @name Top-level executive State and Model retrieval mechanism //@{ /// Returns the FGAtmosphere pointer. - inline FGAtmosphere* GetAtmosphere(void) {return Atmosphere;} + FGAtmosphere* GetAtmosphere(void) {return Atmosphere;} /// Returns the FGFCS pointer. - inline FGFCS* GetFCS(void) {return FCS;} + FGFCS* GetFCS(void) {return FCS;} /// Returns the FGPropulsion pointer. - inline FGPropulsion* GetPropulsion(void) {return Propulsion;} + FGPropulsion* GetPropulsion(void) {return Propulsion;} /// Returns the FGAircraft pointer. - inline FGMassBalance* GetMassBalance(void) {return MassBalance;} + FGMassBalance* GetMassBalance(void) {return MassBalance;} /// Returns the FGAerodynamics pointer - inline FGAerodynamics* GetAerodynamics(void){return Aerodynamics;} + FGAerodynamics* GetAerodynamics(void){return Aerodynamics;} /// Returns the FGInertial pointer. - inline FGInertial* GetInertial(void) {return Inertial;} + FGInertial* GetInertial(void) {return Inertial;} /// Returns the FGGroundReactions pointer. - inline FGGroundReactions* GetGroundReactions(void) {return GroundReactions;} + FGGroundReactions* GetGroundReactions(void) {return GroundReactions;} /// Returns the FGExternalReactions pointer. - inline FGExternalReactions* GetExternalReactions(void) {return ExternalReactions;} + FGExternalReactions* GetExternalReactions(void) {return ExternalReactions;} /// Returns the FGBuoyantForces pointer. - inline FGBuoyantForces* GetBuoyantForces(void) {return BuoyantForces;} + FGBuoyantForces* GetBuoyantForces(void) {return BuoyantForces;} /// Returns the FGAircraft pointer. - inline FGAircraft* GetAircraft(void) {return Aircraft;} + FGAircraft* GetAircraft(void) {return Aircraft;} /// Returns the FGPropagate pointer. - inline FGPropagate* GetPropagate(void) {return Propagate;} + FGPropagate* GetPropagate(void) {return Propagate;} /// Returns the FGAuxiliary pointer. - inline FGAuxiliary* GetAuxiliary(void) {return Auxiliary;} + FGAuxiliary* GetAuxiliary(void) {return Auxiliary;} /// Returns the FGInput pointer. - inline FGInput* GetInput(void) {return Input;} + FGInput* GetInput(void) {return Input;} /// Returns the FGGroundCallback pointer. - inline FGGroundCallback* GetGroundCallback(void) {return GroundCallback;} + FGGroundCallback* GetGroundCallback(void) {return GroundCallback;} /// Retrieves the script object - inline FGScript* GetScript(void) {return Script;} + FGScript* GetScript(void) {return Script;} // Returns a pointer to the FGInitialCondition object - inline FGInitialCondition* GetIC(void) {return IC;} + FGInitialCondition* GetIC(void) {return IC;} // Returns a pointer to the FGTrim object FGTrim* GetTrim(void); //@} /// Retrieves the engine path. - inline const string& GetEnginePath(void) {return EnginePath;} + const string& GetEnginePath(void) {return EnginePath;} /// Retrieves the aircraft path. - inline const string& GetAircraftPath(void) {return AircraftPath;} + const string& GetAircraftPath(void) {return AircraftPath;} /// Retrieves the systems path. - inline const string& GetSystemsPath(void) {return SystemsPath;} + const string& GetSystemsPath(void) {return SystemsPath;} /// Retrieves the full aircraft path name. - inline const string& GetFullAircraftPath(void) {return FullAircraftPath;} + const string& GetFullAircraftPath(void) {return FullAircraftPath;} /** Retrieves the value of a property. @param property the name of the property @@ -524,7 +537,6 @@ private: bool Constructing; bool modelLoaded; bool IsChild; - bool root_overload; string modelName; string AircraftPath; string FullAircraftPath; @@ -556,7 +568,7 @@ private: FGTrim* Trim; FGPropertyManager* Root; - bool delete_root; + bool StandAlone; FGPropertyManager* instance; // The FDM counter is used to give each child FDM an unique ID. The root FDM has the ID 0 @@ -567,7 +579,6 @@ private: vector ChildFDMList; vector Models; - void Initialize(); bool ReadFileHeader(Element*); bool ReadChild(Element*); bool ReadPrologue(Element*); diff --git a/src/FDM/JSBSim/JSBSim.cxx b/src/FDM/JSBSim/JSBSim.cxx index 612424629..e8a96c018 100644 --- a/src/FDM/JSBSim/JSBSim.cxx +++ b/src/FDM/JSBSim/JSBSim.cxx @@ -18,7 +18,7 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -// $Id: JSBSim.cxx,v 1.63 2010/10/07 03:45:40 jberndt Exp $ +// $Id: JSBSim.cxx,v 1.64 2010/10/31 04:49:25 jberndt Exp $ #ifdef HAVE_CONFIG_H @@ -452,7 +452,7 @@ void FGJSBsim::update( double dt ) // ground in this area. double groundCacheRadius = acrad + 2*dt*Propagate->GetUVW().Magnitude(); double alt, slr, lat, lon; - FGColumnVector3 cart = Auxiliary->GetLocationVRP(); + FGLocation cart = Auxiliary->GetLocationVRP(); if ( needTrim && startup_trim->getBoolValue() ) { alt = fgic->GetAltitudeASLFtIC(); slr = fgic->GetSeaLevelRadiusFtIC(); @@ -488,9 +488,9 @@ void FGJSBsim::update( double dt ) if ( needTrim ) { if ( startup_trim->getBoolValue() ) { - double contact[3], d[3], agl; + double contact[3], d[3], vel[3], agl; get_agl_ft(fdmex->GetSimTime(), cart_pos, SG_METER_TO_FEET*2, contact, - d, d, d, &agl); + d, vel, d, &agl); double terrain_alt = sqrt(contact[0]*contact[0] + contact[1]*contact[1] + contact[2]*contact[2]) - fgic->GetSeaLevelRadiusFtIC(); @@ -498,6 +498,13 @@ void FGJSBsim::update( double dt ) "Ready to trim, terrain elevation is: " << terrain_alt * SG_METER_TO_FEET ); + if (fgGetBool("/sim/presets/onground")) { + FGColumnVector3 gndVelNED = cart.GetTec2l() + * FGColumnVector3(vel[0], vel[1], vel[2]); + fgic->SetVNorthFpsIC(gndVelNED(1)); + fgic->SetVEastFpsIC(gndVelNED(2)); + fgic->SetVDownFpsIC(gndVelNED(3)); + } fgic->SetTerrainElevationFtIC( terrain_alt ); do_trim(); } else { diff --git a/src/FDM/JSBSim/initialization/FGInitialCondition.cpp b/src/FDM/JSBSim/initialization/FGInitialCondition.cpp index d8452c77b..cb1fe5710 100644 --- a/src/FDM/JSBSim/initialization/FGInitialCondition.cpp +++ b/src/FDM/JSBSim/initialization/FGInitialCondition.cpp @@ -62,7 +62,7 @@ using namespace std; namespace JSBSim { -static const char *IdSrc = "$Id: FGInitialCondition.cpp,v 1.46 2010/09/29 02:19:05 jberndt Exp $"; +static const char *IdSrc = "$Id: FGInitialCondition.cpp,v 1.50 2010/11/20 16:38:43 bcoconni Exp $"; static const char *IdHdr = ID_INITIALCONDITION; //****************************************************************************** @@ -187,7 +187,7 @@ void FGInitialCondition::WriteStateFile(int num) outfile << " " << Propagate->GetEuler(ePsi) << " " << endl; outfile << " " << Propagate->GetLongitudeDeg() << " " << endl; outfile << " " << Propagate->GetLatitudeDeg() << " " << endl; - outfile << " " << Propagate->GetAltitudeASL() << " " << endl; + outfile << " " << Propagate->GetDistanceAGL() << " " << endl; outfile << "" << endl; outfile.close(); } else { @@ -225,20 +225,37 @@ void FGInitialCondition::SetVequivalentKtsIC(double tt) { //****************************************************************************** -void FGInitialCondition::SetVgroundFpsIC(double tt) { - double ua,va,wa; - double vxz; +void FGInitialCondition::calcAeroEuler(void) +{ + double ua = u + uw; + double va = v + vw; + double wa = w + ww; + vt = sqrt( ua*ua + va*va + wa*wa ); + alpha = beta = 0.0; + calpha = cbeta = 1.0; + salpha = sbeta = 0.0; + double vxz = sqrt( u*u + w*w ); + if( w != 0 ) alpha = atan2( w, u ); + if( vxz != 0 ) { + beta = atan2( v, vxz ); + calpha = u / vxz; + salpha = w / vxz; + } + double vn = sqrt(vxz*vxz + v*v); + if (vn != 0) { + cbeta = vxz / vn; + sbeta = v / vn; + } +} +//****************************************************************************** + +void FGInitialCondition::SetVgroundFpsIC(double tt) { vg=tt; lastSpeedSet=setvg; vnorth = vg*cos(psi); veast = vg*sin(psi); vdown = 0; calcUVWfromNED(); - ua = u + uw; va = v + vw; wa = w + ww; - vt = sqrt( ua*ua + va*va + wa*wa ); - alpha = beta = 0; - vxz = sqrt( u*u + w*w ); - if( w != 0 ) alpha = atan2( w, u ); - if( vxz != 0 ) beta = atan2( v, vxz ); + calcAeroEuler(); mach=vt/fdmex->GetAtmosphere()->GetSoundSpeed(); vc=calcVcas(mach); ve=vt*sqrt(fdmex->GetAtmosphere()->GetDensityRatio()); @@ -336,7 +353,7 @@ void FGInitialCondition::SetPsiRadIC(double tt) { void FGInitialCondition::SetUBodyFpsIC(double tt) { u=tt; - vt=sqrt(u*u + v*v + w*w); + calcAeroEuler(); lastSpeedSet=setuvw; } @@ -344,7 +361,7 @@ void FGInitialCondition::SetUBodyFpsIC(double tt) { void FGInitialCondition::SetVBodyFpsIC(double tt) { v=tt; - vt=sqrt(u*u + v*v + w*w); + calcAeroEuler(); lastSpeedSet=setuvw; } @@ -352,7 +369,7 @@ void FGInitialCondition::SetVBodyFpsIC(double tt) { void FGInitialCondition::SetWBodyFpsIC(double tt) { w=tt; - vt=sqrt( u*u + v*v + w*w ); + calcAeroEuler(); lastSpeedSet=setuvw; } @@ -360,16 +377,9 @@ void FGInitialCondition::SetWBodyFpsIC(double tt) { //****************************************************************************** void FGInitialCondition::SetVNorthFpsIC(double tt) { - double ua,va,wa; - double vxz; vnorth = tt; calcUVWfromNED(); - ua = u + uw; va = v + vw; wa = w + ww; - vt = sqrt( ua*ua + va*va + wa*wa ); - alpha = beta = 0; - vxz = sqrt( u*u + w*w ); - if( w != 0 ) alpha = atan2( w, u ); - if( vxz != 0 ) beta = atan2( v, vxz ); + calcAeroEuler(); mach=vt/fdmex->GetAtmosphere()->GetSoundSpeed(); vc=calcVcas(mach); ve=vt*sqrt(fdmex->GetAtmosphere()->GetDensityRatio()); @@ -379,16 +389,9 @@ void FGInitialCondition::SetVNorthFpsIC(double tt) { //****************************************************************************** void FGInitialCondition::SetVEastFpsIC(double tt) { - double ua,va,wa; - double vxz; veast = tt; calcUVWfromNED(); - ua = u + uw; va = v + vw; wa = w + ww; - vt = sqrt( ua*ua + va*va + wa*wa ); - alpha = beta = 0; - vxz = sqrt( u*u + w*w ); - if( w != 0 ) alpha = atan2( w, u ); - if( vxz != 0 ) beta = atan2( v, vxz ); + calcAeroEuler(); mach=vt/fdmex->GetAtmosphere()->GetSoundSpeed(); vc=calcVcas(mach); ve=vt*sqrt(fdmex->GetAtmosphere()->GetDensityRatio()); @@ -398,16 +401,9 @@ void FGInitialCondition::SetVEastFpsIC(double tt) { //****************************************************************************** void FGInitialCondition::SetVDownFpsIC(double tt) { - double ua,va,wa; - double vxz; vdown = tt; calcUVWfromNED(); - ua = u + uw; va = v + vw; wa = w + ww; - vt = sqrt( ua*ua + va*va + wa*wa ); - alpha = beta = 0; - vxz = sqrt( u*u + w*w ); - if( w != 0 ) alpha = atan2( w, u ); - if( vxz != 0 ) beta = atan2( v, vxz ); + calcAeroEuler(); mach=vt/fdmex->GetAtmosphere()->GetSoundSpeed(); vc=calcVcas(mach); ve=vt*sqrt(fdmex->GetAtmosphere()->GetDensityRatio()); @@ -885,6 +881,7 @@ bool FGInitialCondition::Load(string rstfile, bool useStoredPath) bool FGInitialCondition::Load_v1(void) { + bool result = true; int n; if (document->FindElement("latitude")) @@ -953,13 +950,18 @@ bool FGInitialCondition::Load_v1(void) Element* running_elements = document->FindElement("running"); while (running_elements) { n = int(running_elements->GetDataAsNumber()); - propulsion->InitRunning(n); + try { + propulsion->InitRunning(n); + } catch (string str) { + cerr << str << endl; + result = false; + } running_elements = document->FindNextElement("running"); } fdmex->RunIC(); - return true; + return result; } //****************************************************************************** @@ -1213,7 +1215,12 @@ bool FGInitialCondition::Load_v2(void) Element* running_elements = document->FindElement("running"); while (running_elements) { n = int(running_elements->GetDataAsNumber()); - propulsion->InitRunning(n); + try { + propulsion->InitRunning(n); + } catch (string str) { + cerr << str << endl; + result = false; + } running_elements = document->FindNextElement("running"); } diff --git a/src/FDM/JSBSim/initialization/FGInitialCondition.h b/src/FDM/JSBSim/initialization/FGInitialCondition.h index b5c8c2819..ebd65bda9 100644 --- a/src/FDM/JSBSim/initialization/FGInitialCondition.h +++ b/src/FDM/JSBSim/initialization/FGInitialCondition.h @@ -56,7 +56,7 @@ INCLUDES DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#define ID_INITIALCONDITION "$Id: FGInitialCondition.h,v 1.20 2010/02/15 03:22:57 jberndt Exp $" +#define ID_INITIALCONDITION "$Id: FGInitialCondition.h,v 1.22 2010/11/20 16:38:43 bcoconni Exp $" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FORWARD DECLARATIONS @@ -151,7 +151,7 @@ CLASS DOCUMENTATION - vc (calibrated airspeed, ft/sec) - mach (mach) - vground (ground speed, ft/sec) - - running (0 or 1) + - running (-1 for all engines, 0 for no engines, 1 ... n for specific engines)

Properties

@property ic/vc-kts (read/write) Calibrated airspeed initial condition in knots @@ -202,7 +202,7 @@ CLASS DOCUMENTATION @property ic/r-rad_sec (read/write) Yaw rate initial condition in radians/second @author Tony Peden - @version "$Id: FGInitialCondition.h,v 1.20 2010/02/15 03:22:57 jberndt Exp $" + @version "$Id: FGInitialCondition.h,v 1.22 2010/11/20 16:38:43 bcoconni Exp $" */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -661,6 +661,7 @@ private: double calcVcas(double Mach); void calcUVWfromNED(void); void calcWindUVW(void); + void calcAeroEuler(void); bool findInterval(double x,double guess); bool solve(double *y, double x); diff --git a/src/FDM/JSBSim/input_output/FGScript.cpp b/src/FDM/JSBSim/input_output/FGScript.cpp index bd940bb4c..1697e7ce7 100755 --- a/src/FDM/JSBSim/input_output/FGScript.cpp +++ b/src/FDM/JSBSim/input_output/FGScript.cpp @@ -54,7 +54,7 @@ using namespace std; namespace JSBSim { -static const char *IdSrc = "$Id: FGScript.cpp,v 1.41 2010/07/08 11:36:28 jberndt Exp $"; +static const char *IdSrc = "$Id: FGScript.cpp,v 1.42 2010/11/24 12:58:39 jberndt Exp $"; static const char *IdHdr = ID_FGSCRIPT; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -376,7 +376,9 @@ bool FGScript::RunScript(void) Events[ev_ctr].Triggered = true; } else if (Events[ev_ctr].Persistent) { // If the event is persistent, reset the trigger. - + Events[ev_ctr].Triggered = false; // Reset the trigger for persistent events + Events[ev_ctr].Notified = false; // Also reset the notification flag + } else if (Events[ev_ctr].Continuous) { // If the event is continuous, reset the trigger. Events[ev_ctr].Triggered = false; // Reset the trigger for persistent events Events[ev_ctr].Notified = false; // Also reset the notification flag } @@ -486,9 +488,11 @@ void FGScript::Debug(int from) cout << ":" << endl; if (Events[i].Persistent) - cout << " " << "Always executes"; + cout << " " << "Whenever triggered, executes once"; + else if (Events[i].Continuous) + cout << " " << "While true, always executes"; else - cout << " " << "Executes once"; + cout << " " << "When first triggered, executes once"; Events[i].Condition->PrintCondition(); diff --git a/src/FDM/JSBSim/math/FGModelFunctions.h b/src/FDM/JSBSim/math/FGModelFunctions.h index f98f2b4bf..2b3f94e17 100755 --- a/src/FDM/JSBSim/math/FGModelFunctions.h +++ b/src/FDM/JSBSim/math/FGModelFunctions.h @@ -44,7 +44,7 @@ INCLUDES DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#define ID_MODELFUNCTIONS "$Id: FGModelFunctions.h,v 1.2 2010/08/24 10:30:14 jberndt Exp $" +#define ID_MODELFUNCTIONS "$Id: FGModelFunctions.h,v 1.3 2010/11/17 03:18:37 jberndt Exp $" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FORWARD DECLARATIONS @@ -56,15 +56,24 @@ namespace JSBSim { CLASS DOCUMENTATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -/** -@author Jon Berndt +/** The model functions class provides the capability for loading, storing, and + executing arbitrary functions. + For certain classes, such as the engine, aerodynamics, ground reactions, + mass balance, etc., it can be useful to incorporate special functions that + can operate on the local model parameters before and/or after the model + executes. For example, there is no inherent chamber pressure calculation + done in the rocket engine model. However, an arbitrary function can be added + to a specific rocket engine XML configuration file. It would be tagged with + a "pre" or "post" type attribute to denote whether the function is to be + executed before or after the standard model algorithm. + @author Jon Berndt */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DECLARATION: FGModelFunctions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - class FGModelFunctions : public FGJSBBase +class FGModelFunctions : public FGJSBBase { public: ~FGModelFunctions(); diff --git a/src/FDM/JSBSim/models/FGAerodynamics.cpp b/src/FDM/JSBSim/models/FGAerodynamics.cpp index 0a384447d..07e639860 100644 --- a/src/FDM/JSBSim/models/FGAerodynamics.cpp +++ b/src/FDM/JSBSim/models/FGAerodynamics.cpp @@ -52,7 +52,7 @@ using namespace std; namespace JSBSim { -static const char *IdSrc = "$Id: FGAerodynamics.cpp,v 1.34 2010/10/15 11:32:41 jberndt Exp $"; +static const char *IdSrc = "$Id: FGAerodynamics.cpp,v 1.35 2010/11/18 12:38:06 jberndt Exp $"; static const char *IdHdr = ID_AERODYNAMICS; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -134,24 +134,28 @@ bool FGAerodynamics::InitModel(void) bool FGAerodynamics::Run(void) { - unsigned int axis_ctr, ctr; - double alpha, twovel; if (FGModel::Run()) return true; if (FDMExec->Holding()) return false; // if paused don't execute + unsigned int axis_ctr, ctr; + const double alpha=FDMExec->GetAuxiliary()->Getalpha(); + const double twovel=2*FDMExec->GetAuxiliary()->GetVt(); + const double qbar = FDMExec->GetAuxiliary()->Getqbar(); + const double wingarea = FDMExec->GetAircraft()->GetWingArea(); + const double wingspan = FDMExec->GetAircraft()->GetWingSpan(); + const double wingchord = FDMExec->GetAircraft()->Getcbar(); + const double wingincidence = FDMExec->GetAircraft()->GetWingIncidence(); RunPreFunctions(); // calculate some oft-used quantities for speed - twovel = 2*Auxiliary->GetVt(); if (twovel != 0) { - bi2vel = Aircraft->GetWingSpan() / twovel; - ci2vel = Aircraft->Getcbar() / twovel; + bi2vel = wingspan / twovel; + ci2vel = wingchord / twovel; } - alphaw = Auxiliary->Getalpha() + Aircraft->GetWingIncidence(); - alpha = Auxiliary->Getalpha(); - qbar_area = Aircraft->GetWingArea() * Auxiliary->Getqbar(); + alphaw = alpha + wingincidence; + qbar_area = wingarea * qbar; if (alphaclmax != 0) { if (alpha > 0.85*alphaclmax) { @@ -204,18 +208,18 @@ bool FGAerodynamics::Run(void) } // Calculate aerodynamic reference point shift, if any - if (AeroRPShift) vDeltaRP(eX) = AeroRPShift->GetValue()*Aircraft->Getcbar()*12.0; + if (AeroRPShift) vDeltaRP(eX) = AeroRPShift->GetValue()*wingchord*12.0; // Calculate lift coefficient squared - if ( Auxiliary->Getqbar() > 0) { - clsq = vFw(eLift) / (Aircraft->GetWingArea()*Auxiliary->Getqbar()); + if ( qbar > 0) { + clsq = vFw(eLift) / (wingarea*qbar); clsq *= clsq; } // Calculate lift Lift over Drag if ( fabs(vFw(eDrag)) > 0.0) lod = fabs( vFw(eLift) / vFw(eDrag) ); - vDXYZcg = MassBalance->StructuralToBody(Aircraft->GetXYZrp() + vDeltaRP); + vDXYZcg = FDMExec->GetMassBalance()->StructuralToBody(FDMExec->GetAircraft()->GetXYZrp() + vDeltaRP); vMoments = vDXYZcg*vForces; // M = r X F @@ -250,8 +254,8 @@ FGMatrix33& FGAerodynamics::GetTw2b(void) { double ca, cb, sa, sb; - double alpha = Auxiliary->Getalpha(); - double beta = Auxiliary->Getbeta(); + double alpha = FDMExec->GetAuxiliary()->Getalpha(); + double beta = FDMExec->GetAuxiliary()->Getbeta(); ca = cos(alpha); sa = sin(alpha); @@ -278,8 +282,8 @@ FGMatrix33& FGAerodynamics::GetTb2w(void) double alpha,beta; double ca, cb, sa, sb; - alpha = Auxiliary->Getalpha(); - beta = Auxiliary->Getbeta(); + alpha = FDMExec->GetAuxiliary()->Getalpha(); + beta = FDMExec->GetAuxiliary()->Getbeta(); ca = cos(alpha); sa = sin(alpha); diff --git a/src/FDM/JSBSim/models/FGAerodynamics.h b/src/FDM/JSBSim/models/FGAerodynamics.h index 0f966d845..a5e278195 100644 --- a/src/FDM/JSBSim/models/FGAerodynamics.h +++ b/src/FDM/JSBSim/models/FGAerodynamics.h @@ -52,7 +52,7 @@ INCLUDES DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#define ID_AERODYNAMICS "$Id: FGAerodynamics.h,v 1.20 2009/11/12 13:08:11 jberndt Exp $" +#define ID_AERODYNAMICS "$Id: FGAerodynamics.h,v 1.21 2010/11/18 12:38:06 jberndt Exp $" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FORWARD DECLARATIONS @@ -109,7 +109,7 @@ CLASS DOCUMENTATION Systems may NOT be combined, or a load error will occur. @author Jon S. Berndt, Tony Peden - @version $Revision: 1.20 $ + @version $Revision: 1.21 $ */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -141,7 +141,7 @@ public: /** Gets the total aerodynamic force vector. @return a force vector reference. */ - FGColumnVector3& GetForces(void) {return vForces;} + const FGColumnVector3& GetForces(void) const {return vForces;} /** Gets the aerodynamic force for an axis. @param n Axis index. This could be 0, 1, or 2, or one of the @@ -151,7 +151,7 @@ public: /** Gets the total aerodynamic moment vector. @return a moment vector reference. */ - FGColumnVector3& GetMoments(void) {return vMoments;} + const FGColumnVector3& GetMoments(void) const {return vMoments;} /** Gets the aerodynamic moment for an axis. @return the moment about a single axis (as described also in the @@ -160,7 +160,7 @@ public: /** Retrieves the aerodynamic forces in the wind axes. @return a reference to a column vector containing the wind axis forces. */ - FGColumnVector3& GetvFw(void) { return vFw; } + const FGColumnVector3& GetvFw(void) const { return vFw; } /** Retrieves the aerodynamic forces in the wind axes, given an axis. @param axis the axis to return the force for (eX, eY, eZ). @@ -169,22 +169,22 @@ public: double GetvFw(int axis) const { return vFw(axis); } /** Retrieves the lift over drag ratio */ - inline double GetLoD(void) const { return lod; } + double GetLoD(void) const { return lod; } /** Retrieves the square of the lift coefficient. */ - inline double GetClSquared(void) const { return clsq; } - inline double GetAlphaCLMax(void) const { return alphaclmax; } - inline double GetAlphaCLMin(void) const { return alphaclmin; } + double GetClSquared(void) const { return clsq; } + double GetAlphaCLMax(void) const { return alphaclmax; } + double GetAlphaCLMin(void) const { return alphaclmin; } - inline double GetHysteresisParm(void) const { return stall_hyst; } - inline double GetStallWarn(void) const { return impending_stall; } + double GetHysteresisParm(void) const { return stall_hyst; } + double GetStallWarn(void) const { return impending_stall; } double GetAlphaW(void) const { return alphaw; } double GetBI2Vel(void) const { return bi2vel; } double GetCI2Vel(void) const { return ci2vel; } - inline void SetAlphaCLMax(double tt) { alphaclmax=tt; } - inline void SetAlphaCLMin(double tt) { alphaclmin=tt; } + void SetAlphaCLMax(double tt) { alphaclmax=tt; } + void SetAlphaCLMin(double tt) { alphaclmin=tt; } /** Gets the strings for the current set of coefficients. @param delimeter either a tab or comma string depending on output type diff --git a/src/FDM/JSBSim/models/FGAircraft.cpp b/src/FDM/JSBSim/models/FGAircraft.cpp index 0ed6ac74f..079748274 100644 --- a/src/FDM/JSBSim/models/FGAircraft.cpp +++ b/src/FDM/JSBSim/models/FGAircraft.cpp @@ -40,7 +40,7 @@ INCLUDES #include #include - +#include #include #include "FGAircraft.h" @@ -54,7 +54,6 @@ INCLUDES #include "FGPropagate.h" #include "FGPropulsion.h" #include "input_output/FGPropertyManager.h" -#include using namespace std; @@ -68,7 +67,7 @@ DEFINITIONS GLOBAL DATA %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -static const char *IdSrc = "$Id: FGAircraft.cpp,v 1.28 2010/09/07 00:40:03 jberndt Exp $"; +static const char *IdSrc = "$Id: FGAircraft.cpp,v 1.29 2010/11/18 12:38:06 jberndt Exp $"; static const char *IdHdr = ID_AIRCRAFT; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -118,30 +117,30 @@ bool FGAircraft::Run(void) vForces.InitMatrix(); if (!HoldDown) { - vForces += Aerodynamics->GetForces(); - vForces += Propulsion->GetForces(); - vForces += GroundReactions->GetForces(); - vForces += ExternalReactions->GetForces(); - vForces += BuoyantForces->GetForces(); + vForces += FDMExec->GetAerodynamics()->GetForces(); + vForces += FDMExec->GetPropulsion()->GetForces(); + vForces += FDMExec->GetGroundReactions()->GetForces(); + vForces += FDMExec->GetExternalReactions()->GetForces(); + vForces += FDMExec->GetBuoyantForces()->GetForces(); } else { - const FGMatrix33& mTl2b = Propagate->GetTl2b(); - vForces = mTl2b * FGColumnVector3(0,0,-MassBalance->GetWeight()); + const FGMatrix33& mTl2b = FDMExec->GetPropagate()->GetTl2b(); + vForces = mTl2b * FGColumnVector3(0,0,-FDMExec->GetMassBalance()->GetWeight()); } vMoments.InitMatrix(); if (!HoldDown) { - vMoments += Aerodynamics->GetMoments(); - vMoments += Propulsion->GetMoments(); - vMoments += GroundReactions->GetMoments(); - vMoments += ExternalReactions->GetMoments(); - vMoments += BuoyantForces->GetMoments(); + vMoments += FDMExec->GetAerodynamics()->GetMoments(); + vMoments += FDMExec->GetPropulsion()->GetMoments(); + vMoments += FDMExec->GetGroundReactions()->GetMoments(); + vMoments += FDMExec->GetExternalReactions()->GetMoments(); + vMoments += FDMExec->GetBuoyantForces()->GetMoments(); } - vBodyAccel = vForces/MassBalance->GetMass(); + vBodyAccel = vForces/FDMExec->GetMassBalance()->GetMass(); - vNcg = vBodyAccel/Inertial->SLgravity(); + vNcg = vBodyAccel/FDMExec->GetInertial()->SLgravity(); - vNwcg = Aerodynamics->GetTb2w() * vNcg; + vNwcg = FDMExec->GetAerodynamics()->GetTb2w() * vNcg; vNwcg(3) = 1.0 - vNwcg(3); RunPostFunctions(); @@ -153,7 +152,7 @@ bool FGAircraft::Run(void) double FGAircraft::GetNlf(void) const { - return -1*Aerodynamics->GetvFw(3)/MassBalance->GetWeight(); + return (-FDMExec->GetAerodynamics()->GetvFw(3))/FDMExec->GetMassBalance()->GetWeight(); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/models/FGAircraft.h b/src/FDM/JSBSim/models/FGAircraft.h index a03656895..c3060db37 100644 --- a/src/FDM/JSBSim/models/FGAircraft.h +++ b/src/FDM/JSBSim/models/FGAircraft.h @@ -49,7 +49,7 @@ INCLUDES DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#define ID_AIRCRAFT "$Id: FGAircraft.h,v 1.15 2009/10/24 22:59:30 jberndt Exp $" +#define ID_AIRCRAFT "$Id: FGAircraft.h,v 1.16 2010/11/18 12:38:06 jberndt Exp $" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FORWARD DECLARATIONS @@ -90,7 +90,7 @@ CLASS DOCUMENTATION @endcode @author Jon S. Berndt - @version $Id: FGAircraft.h,v 1.15 2009/10/24 22:59:30 jberndt Exp $ + @version $Id: FGAircraft.h,v 1.16 2010/11/18 12:38:06 jberndt Exp $ @see Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate School, January 1994 @@ -140,33 +140,33 @@ public: double GetWingSpan(void) const { return WingSpan; } /// Gets the average wing chord double Getcbar(void) const { return cbar; } - inline double GetWingIncidence(void) const { return WingIncidence; } - inline double GetWingIncidenceDeg(void) const { return WingIncidence*radtodeg; } - inline double GetHTailArea(void) const { return HTailArea; } - inline double GetHTailArm(void) const { return HTailArm; } - inline double GetVTailArea(void) const { return VTailArea; } - inline double GetVTailArm(void) const { return VTailArm; } - inline double Getlbarh(void) const { return lbarh; } // HTailArm / cbar - inline double Getlbarv(void) const { return lbarv; } // VTailArm / cbar - inline double Getvbarh(void) const { return vbarh; } // H. Tail Volume - inline double Getvbarv(void) const { return vbarv; } // V. Tail Volume - inline FGColumnVector3& GetMoments(void) { return vMoments; } - inline double GetMoments(int idx) const { return vMoments(idx); } - inline FGColumnVector3& GetForces(void) { return vForces; } - inline double GetForces(int idx) const { return vForces(idx); } - inline FGColumnVector3& GetBodyAccel(void) { return vBodyAccel; } - inline double GetBodyAccel(int idx) { return vBodyAccel(idx); } - inline FGColumnVector3& GetNcg (void) { return vNcg; } - inline double GetNcg(int idx) { return vNcg(idx); } - inline FGColumnVector3& GetXYZrp(void) { return vXYZrp; } - inline FGColumnVector3& GetXYZvrp(void) { return vXYZvrp; } - inline FGColumnVector3& GetXYZep(void) { return vXYZep; } - inline double GetXYZrp(int idx) const { return vXYZrp(idx); } - inline double GetXYZvrp(int idx) const { return vXYZvrp(idx); } - inline double GetXYZep(int idx) const { return vXYZep(idx); } - inline void SetAircraftName(const std::string& name) {AircraftName = name;} - inline void SetHoldDown(int hd) {HoldDown = hd;} - inline int GetHoldDown(void) const {return HoldDown;} + double GetWingIncidence(void) const { return WingIncidence; } + double GetWingIncidenceDeg(void) const { return WingIncidence*radtodeg; } + double GetHTailArea(void) const { return HTailArea; } + double GetHTailArm(void) const { return HTailArm; } + double GetVTailArea(void) const { return VTailArea; } + double GetVTailArm(void) const { return VTailArm; } + double Getlbarh(void) const { return lbarh; } // HTailArm / cbar + double Getlbarv(void) const { return lbarv; } // VTailArm / cbar + double Getvbarh(void) const { return vbarh; } // H. Tail Volume + double Getvbarv(void) const { return vbarv; } // V. Tail Volume + const FGColumnVector3& GetMoments(void) const { return vMoments; } + double GetMoments(int idx) const { return vMoments(idx); } + const FGColumnVector3& GetForces(void) const { return vForces; } + double GetForces(int idx) const { return vForces(idx); } + FGColumnVector3& GetBodyAccel(void) { return vBodyAccel; } + double GetBodyAccel(int idx) const { return vBodyAccel(idx); } + const FGColumnVector3& GetNcg(void) const { return vNcg; } + double GetNcg(int idx) const { return vNcg(idx); } + const FGColumnVector3& GetXYZrp(void) const { return vXYZrp; } + const FGColumnVector3& GetXYZvrp(void) const { return vXYZvrp; } + const FGColumnVector3& GetXYZep(void) const { return vXYZep; } + double GetXYZrp(int idx) const { return vXYZrp(idx); } + double GetXYZvrp(int idx) const { return vXYZvrp(idx); } + double GetXYZep(int idx) const { return vXYZep(idx); } + void SetAircraftName(const std::string& name) {AircraftName = name;} + void SetHoldDown(int hd) {HoldDown = hd;} + int GetHoldDown(void) const {return HoldDown;} void SetXYZrp(int idx, double value) {vXYZrp(idx) = value;} @@ -174,7 +174,7 @@ public: double GetNlf(void) const; - inline FGColumnVector3& GetNwcg(void) { return vNwcg; } + FGColumnVector3& GetNwcg(void) { return vNwcg; } void bind(void); void unbind(void); diff --git a/src/FDM/JSBSim/models/FGAtmosphere.cpp b/src/FDM/JSBSim/models/FGAtmosphere.cpp index 12fb084a7..d2c6a3dac 100644 --- a/src/FDM/JSBSim/models/FGAtmosphere.cpp +++ b/src/FDM/JSBSim/models/FGAtmosphere.cpp @@ -61,7 +61,7 @@ using namespace std; namespace JSBSim { -static const char *IdSrc = "$Id: FGAtmosphere.cpp,v 1.38 2010/09/16 11:01:24 jberndt Exp $"; +static const char *IdSrc = "$Id: FGAtmosphere.cpp,v 1.40 2010/11/18 12:38:06 jberndt Exp $"; static const char *IdHdr = ID_ATMOSPHERE; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -158,7 +158,7 @@ bool FGAtmosphere::Run(void) RunPreFunctions(); T_dev = 0.0; - h = Propagate->GetAltitudeASL(); + h = FDMExec->GetPropagate()->GetAltitudeASL(); if (!useExternal) { Calculate(h); @@ -275,11 +275,11 @@ void FGAtmosphere::Calculate(double altitude) if (slope == 0) { intTemperature = reftemp; - intPressure = refpress*exp(-Inertial->SLgravity()/(reftemp*Reng)*(altitude-htab[i])); + intPressure = refpress*exp(-FDMExec->GetInertial()->SLgravity()/(reftemp*Reng)*(altitude-htab[i])); intDensity = intPressure/(Reng*intTemperature); } else { intTemperature = reftemp+slope*(altitude-htab[i]); - intPressure = refpress*pow(intTemperature/reftemp,-Inertial->SLgravity()/(slope*Reng)); + intPressure = refpress*pow(intTemperature/reftemp,-FDMExec->GetInertial()->SLgravity()/(slope*Reng)); intDensity = intPressure/(Reng*intTemperature); } @@ -404,7 +404,12 @@ void FGAtmosphere::SetWindPsi(double dir) void FGAtmosphere::Turbulence(void) { - double DeltaT = rate*FDMExec->GetDeltaT(); + const double DeltaT = rate*FDMExec->GetDeltaT(); + const double wingspan = FDMExec->GetAircraft()->GetWingSpan(); + const double HOverBMAC = FDMExec->GetAuxiliary()->GetHOverBMAC(); + const FGMatrix33& Tl2b = FDMExec->GetPropagate()->GetTl2b(); + const double HTailArm = FDMExec->GetAircraft()->GetHTailArm(); + const double VTailArm = FDMExec->GetAircraft()->GetVTailArm(); switch (turbType) { case ttStandard: { @@ -438,7 +443,6 @@ void FGAtmosphere::Turbulence(void) // Diminish turbulence within three wingspans // of the ground vTurbulenceNED = TurbGain * Magnitude * vDirection; - double HOverBMAC = Auxiliary->GetHOverBMAC(); if (HOverBMAC < 3.0) vTurbulenceNED *= (HOverBMAC / 3.0) * (HOverBMAC / 3.0); @@ -451,20 +455,20 @@ void FGAtmosphere::Turbulence(void) // Need to determine the turbulence change in body axes between two time points. vTurbulenceGrad = TurbGain*MagnitudeAccel * vDirection; - vBodyTurbGrad = Propagate->GetTl2b()*vTurbulenceGrad; + vBodyTurbGrad = Tl2b*vTurbulenceGrad; - if (Aircraft->GetWingSpan() > 0) { - vTurbPQR(eP) = vBodyTurbGrad(eY)/Aircraft->GetWingSpan(); + if (wingspan > 0) { + vTurbPQR(eP) = vBodyTurbGrad(eY)/wingspan; } else { vTurbPQR(eP) = vBodyTurbGrad(eY)/30.0; } -// if (Aircraft->GetHTailArm() != 0.0) -// vTurbPQR(eQ) = vBodyTurbGrad(eZ)/Aircraft->GetHTailArm(); +// if (HTailArm != 0.0) +// vTurbPQR(eQ) = vBodyTurbGrad(eZ)/HTailArm; // else // vTurbPQR(eQ) = vBodyTurbGrad(eZ)/10.0; - if (Aircraft->GetVTailArm() > 0) - vTurbPQR(eR) = vBodyTurbGrad(eX)/Aircraft->GetVTailArm(); + if (VTailArm > 0) + vTurbPQR(eR) = vBodyTurbGrad(eX)/VTailArm; else vTurbPQR(eR) = vBodyTurbGrad(eX)/10.0; @@ -496,7 +500,6 @@ void FGAtmosphere::Turbulence(void) vDirection += vDirectionAccel*DeltaT; // Diminish z-vector within two wingspans of the ground - double HOverBMAC = Auxiliary->GetHOverBMAC(); if (HOverBMAC < 2.0) vDirection(eZ) *= HOverBMAC / 2.0; vDirection.Normalize(); @@ -504,15 +507,15 @@ void FGAtmosphere::Turbulence(void) vTurbulenceNED = TurbGain*Magnitude * vDirection; vTurbulenceGrad = TurbGain*MagnitudeAccel * vDirection; - vBodyTurbGrad = Propagate->GetTl2b() * vTurbulenceGrad; - vTurbPQR(eP) = vBodyTurbGrad(eY) / Aircraft->GetWingSpan(); - if (Aircraft->GetHTailArm() > 0) - vTurbPQR(eQ) = vBodyTurbGrad(eZ) / Aircraft->GetHTailArm(); + vBodyTurbGrad = Tl2b * vTurbulenceGrad; + vTurbPQR(eP) = vBodyTurbGrad(eY) / wingspan; + if (HTailArm > 0) + vTurbPQR(eQ) = vBodyTurbGrad(eZ) / HTailArm; else vTurbPQR(eQ) = vBodyTurbGrad(eZ) / 10.0; - if (Aircraft->GetVTailArm() > 0) - vTurbPQR(eR) = vBodyTurbGrad(eX) / Aircraft->GetVTailArm(); + if (VTailArm > 0) + vTurbPQR(eR) = vBodyTurbGrad(eX) / VTailArm; else vTurbPQR(eR) = vBodyTurbGrad(eX)/10.0; @@ -554,7 +557,6 @@ void FGAtmosphere::Turbulence(void) // Vertical component of turbulence. vTurbulenceNED(3) = sinewave * max_vs * TurbGain * Rhythmicity; vTurbulenceNED(3)+= delta; - double HOverBMAC = Auxiliary->GetHOverBMAC(); if (HOverBMAC < 3.0) vTurbulenceNED(3) *= HOverBMAC * 0.3333; @@ -579,9 +581,9 @@ void FGAtmosphere::Turbulence(void) // Turbulence model according to MIL-F-8785C (Flying Qualities of Piloted Aircraft) double - h = Propagate->GetDistanceAGL(), - V = Auxiliary->GetVt(), // true airspeed in ft/s - b_w = Aircraft->GetWingSpan(), + h = FDMExec->GetPropagate()->GetDistanceAGL(), + V = FDMExec->GetAuxiliary()->GetVt(), // true airspeed in ft/s + b_w = wingspan, L_u, L_w, sig_u, sig_w; // clip height functions at 10 ft @@ -628,7 +630,7 @@ void FGAtmosphere::Turbulence(void) nu_v = GaussianRandomNumber(), nu_w = GaussianRandomNumber(), nu_p = GaussianRandomNumber(), - xi_u, xi_v, xi_w, xi_p, xi_q, xi_r; + xi_u=0, xi_v=0, xi_w=0, xi_p=0, xi_q=0, xi_r=0; // values of turbulence NED velocities @@ -685,7 +687,7 @@ void FGAtmosphere::Turbulence(void) vTurbPQR(3) = xi_r; // vTurbPQR is in the body fixed frame, not NED - vTurbPQR = Propagate->GetTl2b()*vTurbPQR; + vTurbPQR = Tl2b*vTurbPQR; // hand on the values for the next timestep xi_u_km1 = xi_u; nu_u_km1 = nu_u; diff --git a/src/FDM/JSBSim/models/FGAtmosphere.h b/src/FDM/JSBSim/models/FGAtmosphere.h index d6561fa86..3dd6fa322 100644 --- a/src/FDM/JSBSim/models/FGAtmosphere.h +++ b/src/FDM/JSBSim/models/FGAtmosphere.h @@ -35,8 +35,8 @@ HISTORY SENTRY %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#ifndef FGAtmosphere_H -#define FGAtmosphere_H +#ifndef FGATMOSPHERE_H +#define FGATMOSPHERE_H /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% INCLUDES @@ -50,7 +50,7 @@ INCLUDES DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#define ID_ATMOSPHERE "$Id: FGAtmosphere.h,v 1.23 2010/09/16 11:01:24 jberndt Exp $" +#define ID_ATMOSPHERE "$Id: FGAtmosphere.h,v 1.24 2010/11/18 12:38:06 jberndt Exp $" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FORWARD DECLARATIONS @@ -64,7 +64,7 @@ CLASS DOCUMENTATION /** Models the 1976 Standard Atmosphere. @author Tony Peden, Jon Berndt - @version $Id: FGAtmosphere.h,v 1.23 2010/09/16 11:01:24 jberndt Exp $ + @version $Id: FGAtmosphere.h,v 1.24 2010/11/18 12:38:06 jberndt Exp $ @see Anderson, John D. "Introduction to Flight, Third Edition", McGraw-Hill, 1989, ISBN 0-07-001641-0 @@ -205,7 +205,7 @@ public: // TOTAL WIND access functions (wind + gust + turbulence) /// Retrieves the total wind components in NED frame. - FGColumnVector3& GetTotalWindNED(void) { return vTotalWindNED; } + const FGColumnVector3& GetTotalWindNED(void) const { return vTotalWindNED; } /// Retrieves a total wind component in NED frame. double GetTotalWindNED(int idx) const {return vTotalWindNED(idx);} @@ -276,8 +276,8 @@ public: double GetTurbPQR(int idx) const {return vTurbPQR(idx);} double GetTurbMagnitude(void) const {return Magnitude;} - FGColumnVector3& GetTurbDirection(void) {return vDirection;} - FGColumnVector3& GetTurbPQR(void) {return vTurbPQR;} + const FGColumnVector3& GetTurbDirection(void) const {return vDirection;} + const FGColumnVector3& GetTurbPQR(void) const {return vTurbPQR;} void SetWindspeed20ft(double ws) { windspeed_at_20ft = ws;} double GetWindspeed20ft() const { return windspeed_at_20ft;} diff --git a/src/FDM/JSBSim/models/FGAuxiliary.cpp b/src/FDM/JSBSim/models/FGAuxiliary.cpp index 630a9712a..1dd3e2207 100755 --- a/src/FDM/JSBSim/models/FGAuxiliary.cpp +++ b/src/FDM/JSBSim/models/FGAuxiliary.cpp @@ -59,7 +59,7 @@ using namespace std; namespace JSBSim { -static const char *IdSrc = "$Id: FGAuxiliary.cpp,v 1.44 2010/10/10 15:10:15 jberndt Exp $"; +static const char *IdSrc = "$Id: FGAuxiliary.cpp,v 1.45 2010/11/18 12:38:06 jberndt Exp $"; static const char *IdHdr = ID_AUXILIARY; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -144,22 +144,29 @@ bool FGAuxiliary::Run() RunPreFunctions(); - const FGColumnVector3& vPQR = Propagate->GetPQR(); - const FGColumnVector3& vUVW = Propagate->GetUVW(); - const FGColumnVector3& vUVWdot = Propagate->GetUVWdot(); - const FGColumnVector3& vVel = Propagate->GetVel(); + const double density = FDMExec->GetAtmosphere()->GetDensity(); + const double soundspeed = FDMExec->GetAtmosphere()->GetSoundSpeed(); + const double DistanceAGL = FDMExec->GetPropagate()->GetDistanceAGL(); + const double wingspan = FDMExec->GetAircraft()->GetWingSpan(); + const FGMatrix33& Tl2b = FDMExec->GetPropagate()->GetTl2b(); + const FGMatrix33& Tb2l = FDMExec->GetPropagate()->GetTb2l(); - p = Atmosphere->GetPressure(); - rhosl = Atmosphere->GetDensitySL(); - psl = Atmosphere->GetPressureSL(); - sat = Atmosphere->GetTemperature(); + const FGColumnVector3& vPQR = FDMExec->GetPropagate()->GetPQR(); + const FGColumnVector3& vUVW = FDMExec->GetPropagate()->GetUVW(); + const FGColumnVector3& vUVWdot = FDMExec->GetPropagate()->GetUVWdot(); + const FGColumnVector3& vVel = FDMExec->GetPropagate()->GetVel(); + + p = FDMExec->GetAtmosphere()->GetPressure(); + rhosl = FDMExec->GetAtmosphere()->GetDensitySL(); + psl = FDMExec->GetAtmosphere()->GetPressureSL(); + sat = FDMExec->GetAtmosphere()->GetTemperature(); // Rotation - double cTht = Propagate->GetCosEuler(eTht); - double sTht = Propagate->GetSinEuler(eTht); - double cPhi = Propagate->GetCosEuler(ePhi); - double sPhi = Propagate->GetSinEuler(ePhi); + double cTht = FDMExec->GetPropagate()->GetCosEuler(eTht); + double sTht = FDMExec->GetPropagate()->GetSinEuler(eTht); + double cPhi = FDMExec->GetPropagate()->GetCosEuler(ePhi); + double sPhi = FDMExec->GetPropagate()->GetSinEuler(ePhi); vEulerRates(eTht) = vPQR(eQ)*cPhi - vPQR(eR)*sPhi; if (cTht != 0.0) { @@ -168,8 +175,8 @@ bool FGAuxiliary::Run() } // Combine the wind speed with aircraft speed to obtain wind relative speed - FGColumnVector3 wind = Propagate->GetTl2b()*Atmosphere->GetTotalWindNED(); - vAeroPQR = vPQR - Atmosphere->GetTurbPQR(); + FGColumnVector3 wind = Tl2b*FDMExec->GetAtmosphere()->GetTotalWindNED(); + vAeroPQR = vPQR - FDMExec->GetAtmosphere()->GetTurbPQR(); vAeroUVW = vUVW - wind; Vt = vAeroUVW.Magnitude(); @@ -196,15 +203,15 @@ bool FGAuxiliary::Run() alpha = beta = adot = bdot = 0; } - Re = Vt * Aircraft->Getcbar() / Atmosphere->GetKinematicViscosity(); + Re = Vt * FDMExec->GetAircraft()->Getcbar() / FDMExec->GetAtmosphere()->GetKinematicViscosity(); - qbar = 0.5*Atmosphere->GetDensity()*Vt*Vt; - qbarUW = 0.5*Atmosphere->GetDensity()*(vAeroUVW(eU)*vAeroUVW(eU) + vAeroUVW(eW)*vAeroUVW(eW)); - qbarUV = 0.5*Atmosphere->GetDensity()*(vAeroUVW(eU)*vAeroUVW(eU) + vAeroUVW(eV)*vAeroUVW(eV)); - Mach = Vt / Atmosphere->GetSoundSpeed(); - MachU = vMachUVW(eU) = vAeroUVW(eU) / Atmosphere->GetSoundSpeed(); - vMachUVW(eV) = vAeroUVW(eV) / Atmosphere->GetSoundSpeed(); - vMachUVW(eW) = vAeroUVW(eW) / Atmosphere->GetSoundSpeed(); + qbar = 0.5*density*Vt*Vt; + qbarUW = 0.5*density*(vAeroUVW(eU)*vAeroUVW(eU) + vAeroUVW(eW)*vAeroUVW(eW)); + qbarUV = 0.5*density*(vAeroUVW(eU)*vAeroUVW(eU) + vAeroUVW(eV)*vAeroUVW(eV)); + Mach = Vt / soundspeed; + MachU = vMachUVW(eU) = vAeroUVW(eU) / soundspeed; + vMachUVW(eV) = vAeroUVW(eV) / soundspeed; + vMachUVW(eW) = vAeroUVW(eW) / soundspeed; // Position @@ -234,20 +241,15 @@ bool FGAuxiliary::Run() vcas = veas = 0.0; } + const double SLgravity = FDMExec->GetInertial()->SLgravity(); + vPilotAccel.InitMatrix(); if ( Vt > 1.0 ) { - // Use the "+=" operator to avoid the creation of temporary objects. - vAircraftAccel = Aerodynamics->GetForces(); - vAircraftAccel += Propulsion->GetForces(); - vAircraftAccel += GroundReactions->GetForces(); - vAircraftAccel += ExternalReactions->GetForces(); - vAircraftAccel += BuoyantForces->GetForces(); - - vAircraftAccel /= MassBalance->GetMass(); + vAircraftAccel = FDMExec->GetAircraft()->GetBodyAccel(); // Nz is Acceleration in "g's", along normal axis (-Z body axis) - Nz = -vAircraftAccel(eZ)/Inertial->SLgravity(); - vToEyePt = MassBalance->StructuralToBody(Aircraft->GetXYZep()); - vPilotAccel = vAircraftAccel + Propagate->GetPQRdot() * vToEyePt; + Nz = -vAircraftAccel(eZ)/SLgravity; + vToEyePt = FDMExec->GetMassBalance()->StructuralToBody(FDMExec->GetAircraft()->GetXYZep()); + vPilotAccel = vAircraftAccel + FDMExec->GetPropagate()->GetPQRdot() * vToEyePt; vPilotAccel += vPQR * (vPQR * vToEyePt); } else { // The line below handles low velocity (and on-ground) cases, basically @@ -256,24 +258,24 @@ bool FGAuxiliary::Run() // any jitter that could be introduced by the landing gear. Theoretically, // this branch could be eliminated, with a penalty of having a short // transient at startup (lasting only a fraction of a second). - vPilotAccel = Propagate->GetTl2b() * FGColumnVector3( 0.0, 0.0, -Inertial->SLgravity() ); - Nz = -vPilotAccel(eZ)/Inertial->SLgravity(); + vPilotAccel = Tl2b * FGColumnVector3( 0.0, 0.0, -SLgravity ); + Nz = -vPilotAccel(eZ)/SLgravity; } - vPilotAccelN = vPilotAccel/Inertial->SLgravity(); + vPilotAccelN = vPilotAccel/SLgravity; // VRP computation - const FGLocation& vLocation = Propagate->GetLocation(); - FGColumnVector3& vrpStructural = Aircraft->GetXYZvrp(); - FGColumnVector3 vrpBody = MassBalance->StructuralToBody( vrpStructural ); - FGColumnVector3 vrpLocal = Propagate->GetTb2l() * vrpBody; + const FGLocation& vLocation = FDMExec->GetPropagate()->GetLocation(); + const FGColumnVector3& vrpStructural = FDMExec->GetAircraft()->GetXYZvrp(); + const FGColumnVector3 vrpBody = FDMExec->GetMassBalance()->StructuralToBody( vrpStructural ); + const FGColumnVector3 vrpLocal = Tb2l * vrpBody; vLocationVRP = vLocation.LocalToLocation( vrpLocal ); // Recompute some derived values now that we know the dependent parameters values ... - hoverbcg = Propagate->GetDistanceAGL() / Aircraft->GetWingSpan(); + hoverbcg = DistanceAGL / wingspan; - FGColumnVector3 vMac = Propagate->GetTb2l()*MassBalance->StructuralToBody(Aircraft->GetXYZrp()); - hoverbmac = (Propagate->GetDistanceAGL() + vMac(3)) / Aircraft->GetWingSpan(); + FGColumnVector3 vMac = Tb2l*FDMExec->GetMassBalance()->StructuralToBody(FDMExec->GetAircraft()->GetXYZrp()); + hoverbmac = (DistanceAGL + vMac(3)) / wingspan; // when all model are executed, // please calculate the distance from the initial point @@ -294,10 +296,10 @@ double FGAuxiliary::GetHeadWind(void) const { double psiw,vw; - psiw = Atmosphere->GetWindPsi(); - vw = Atmosphere->GetTotalWindNED().Magnitude(); + psiw = FDMExec->GetAtmosphere()->GetWindPsi(); + vw = FDMExec->GetAtmosphere()->GetTotalWindNED().Magnitude(); - return vw*cos(psiw - Propagate->GetEuler(ePsi)); + return vw*cos(psiw - FDMExec->GetPropagate()->GetEuler(ePsi)); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -310,10 +312,17 @@ double FGAuxiliary::GetCrossWind(void) const { double psiw,vw; - psiw = Atmosphere->GetWindPsi(); - vw = Atmosphere->GetTotalWindNED().Magnitude(); + psiw = FDMExec->GetAtmosphere()->GetWindPsi(); + vw = FDMExec->GetAtmosphere()->GetTotalWindNED().Magnitude(); - return vw*sin(psiw - Propagate->GetEuler(ePsi)); + return vw*sin(psiw - FDMExec->GetPropagate()->GetEuler(ePsi)); +} + +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +double FGAuxiliary::GethVRP(void) const +{ + return vLocationVRP.GetRadius() - FDMExec->GetPropagate()->GetSeaLevelRadius(); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -382,7 +391,7 @@ void FGAuxiliary::bind(void) void FGAuxiliary::CalculateRelativePosition(void) { - const double earth_radius_mt = Inertial->GetRefRadius()*fttom; + const double earth_radius_mt = FDMExec->GetInertial()->GetRefRadius()*fttom; lat_relative_position=(FDMExec->GetPropagate()->GetLatitude() - FDMExec->GetIC()->GetLatitudeDegIC() *degtorad)*earth_radius_mt; lon_relative_position=(FDMExec->GetPropagate()->GetLongitude() - FDMExec->GetIC()->GetLongitudeDegIC()*degtorad)*earth_radius_mt; relative_position = sqrt(lat_relative_position*lat_relative_position + lon_relative_position*lon_relative_position); diff --git a/src/FDM/JSBSim/models/FGAuxiliary.h b/src/FDM/JSBSim/models/FGAuxiliary.h index d86cc5f11..8f7821245 100644 --- a/src/FDM/JSBSim/models/FGAuxiliary.h +++ b/src/FDM/JSBSim/models/FGAuxiliary.h @@ -42,13 +42,12 @@ INCLUDES #include "FGModel.h" #include "math/FGColumnVector3.h" #include "math/FGLocation.h" -#include "FGPropagate.h" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#define ID_AUXILIARY "$Id: FGAuxiliary.h,v 1.17 2009/10/24 22:59:30 jberndt Exp $" +#define ID_AUXILIARY "$Id: FGAuxiliary.h,v 1.19 2010/11/18 12:38:06 jberndt Exp $" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FORWARD DECLARATIONS @@ -100,7 +99,7 @@ CLASS DOCUMENTATION The radius R is calculated below in the vector vToEyePt. @author Tony Peden, Jon Berndt - @version $Id: FGAuxiliary.h,v 1.17 2009/10/24 22:59:30 jberndt Exp $ + @version $Id: FGAuxiliary.h,v 1.19 2010/11/18 12:38:06 jberndt Exp $ */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -162,7 +161,7 @@ public: const FGColumnVector3& GetAeroUVW (void) const { return vAeroUVW; } const FGLocation& GetLocationVRP(void) const { return vLocationVRP; } - double GethVRP(void) const { return vLocationVRP.GetRadius() - Propagate->GetSeaLevelRadius(); } + double GethVRP(void) const; double GetAeroUVW (int idx) const { return vAeroUVW(idx); } double Getalpha (void) const { return alpha; } double Getbeta (void) const { return beta; } diff --git a/src/FDM/JSBSim/models/FGBuoyantForces.cpp b/src/FDM/JSBSim/models/FGBuoyantForces.cpp index 1b9a63b74..b3808d70f 100644 --- a/src/FDM/JSBSim/models/FGBuoyantForces.cpp +++ b/src/FDM/JSBSim/models/FGBuoyantForces.cpp @@ -45,7 +45,7 @@ using namespace std; namespace JSBSim { -static const char *IdSrc = "$Id: FGBuoyantForces.cpp,v 1.13 2010/09/07 00:40:03 jberndt Exp $"; +static const char *IdSrc = "$Id: FGBuoyantForces.cpp,v 1.14 2010/11/18 12:38:06 jberndt Exp $"; static const char *IdHdr = ID_BUOYANTFORCES; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -181,7 +181,7 @@ const FGMatrix33& FGBuoyantForces::GetGasMassInertia(void) gasCellJ = FGMatrix33(); for (unsigned int i=0; i < size; i++) { - FGColumnVector3 v = MassBalance->StructuralToBody( Cells[i]->GetXYZ() ); + FGColumnVector3 v = FDMExec->GetMassBalance()->StructuralToBody( Cells[i]->GetXYZ() ); // Body basis is in FT. const double mass = Cells[i]->GetMass(); diff --git a/src/FDM/JSBSim/models/FGExternalForce.h b/src/FDM/JSBSim/models/FGExternalForce.h index f1a6a41ac..5ece2bf22 100755 --- a/src/FDM/JSBSim/models/FGExternalForce.h +++ b/src/FDM/JSBSim/models/FGExternalForce.h @@ -39,10 +39,10 @@ SENTRY INCLUDES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ +#include #include "FGFDMExec.h" #include "FGJSBBase.h" #include "models/propulsion/FGForce.h" -#include #include "input_output/FGPropertyManager.h" #include "math/FGColumnVector3.h" #include "math/FGFunction.h" @@ -51,7 +51,7 @@ INCLUDES DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#define ID_EXTERNALFORCE "$Id: FGExternalForce.h,v 1.8 2009/10/02 10:30:09 jberndt Exp $" +#define ID_EXTERNALFORCE "$Id: FGExternalForce.h,v 1.9 2010/11/18 12:38:06 jberndt Exp $" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FORWARD DECLARATIONS diff --git a/src/FDM/JSBSim/models/FGExternalReactions.h b/src/FDM/JSBSim/models/FGExternalReactions.h index 10ad35d07..4b7df2d85 100755 --- a/src/FDM/JSBSim/models/FGExternalReactions.h +++ b/src/FDM/JSBSim/models/FGExternalReactions.h @@ -38,15 +38,15 @@ SENTRY INCLUDES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ +#include #include "FGModel.h" #include "FGExternalForce.h" -#include /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#define ID_EXTERNALREACTIONS "$Id: FGExternalReactions.h,v 1.9 2009/10/24 22:59:30 jberndt Exp $" +#define ID_EXTERNALREACTIONS "$Id: FGExternalReactions.h,v 1.10 2010/11/18 12:38:06 jberndt Exp $" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FORWARD DECLARATIONS @@ -147,12 +147,12 @@ public: /** Retrieves the total forces defined in the external reactions. @return the total force in pounds. */ - FGColumnVector3 GetForces(void) {return vTotalForces;} + FGColumnVector3 GetForces(void) const {return vTotalForces;} /** Retrieves the total moment resulting from the forces defined in the external reactions. @return the total moment in foot-pounds. */ - FGColumnVector3 GetMoments(void) {return vTotalMoments;} + FGColumnVector3 GetMoments(void) const {return vTotalMoments;} private: diff --git a/src/FDM/JSBSim/models/FGFCS.cpp b/src/FDM/JSBSim/models/FGFCS.cpp index 3de0c7135..f0b77007d 100644 --- a/src/FDM/JSBSim/models/FGFCS.cpp +++ b/src/FDM/JSBSim/models/FGFCS.cpp @@ -63,7 +63,7 @@ using namespace std; namespace JSBSim { -static const char *IdSrc = "$Id: FGFCS.cpp,v 1.71 2010/09/28 02:54:03 jberndt Exp $"; +static const char *IdSrc = "$Id: FGFCS.cpp,v 1.72 2010/11/18 12:38:06 jberndt Exp $"; static const char *IdHdr = ID_FCS; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -218,7 +218,7 @@ bool FGFCS::Run(void) // Set the default steering angle for (i=0; iGetGearUnit(i); + FGLGear* gear = FDMExec->GetGroundReactions()->GetGearUnit(i); SteerPosDeg[i] = gear->GetDefaultSteerAngle( GetDsCmd() ); } @@ -760,7 +760,7 @@ ifstream* FGFCS::FindSystemFile(const string& sysfilename) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGFCS::GetComponentStrings(const string& delimiter) +string FGFCS::GetComponentStrings(const string& delimiter) const { unsigned int comp; string CompStrings = ""; @@ -797,7 +797,7 @@ string FGFCS::GetComponentStrings(const string& delimiter) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGFCS::GetComponentValues(const string& delimiter) +string FGFCS::GetComponentValues(const string& delimiter) const { std::ostringstream buf; @@ -964,7 +964,7 @@ void FGFCS::bindModel(void) string tmp; for (i=0; iGetGearUnit(i)->GetSteerable()) { + if (FDMExec->GetGroundReactions()->GetGearUnit(i)->GetSteerable()) { tmp = CreateIndexedPropertyName("fcs/steer-pos-deg", i); PropertyManager->Tie( tmp.c_str(), this, i, &FGFCS::GetSteerPosDeg, &FGFCS::SetSteerPosDeg); } diff --git a/src/FDM/JSBSim/models/FGFCS.h b/src/FDM/JSBSim/models/FGFCS.h index 1a57835f9..a17509212 100644 --- a/src/FDM/JSBSim/models/FGFCS.h +++ b/src/FDM/JSBSim/models/FGFCS.h @@ -348,13 +348,13 @@ public: /** Retrieves all component names for inclusion in output stream @param delimiter either a tab or comma string depending on output type @return a string containing the descriptive names for all components */ - std::string GetComponentStrings(const std::string& delimiter); + std::string GetComponentStrings(const std::string& delimiter) const; /** Retrieves all component outputs for inclusion in output stream @param delimiter either a tab or comma string depending on output type @return a string containing the numeric values for the current set of component outputs */ - std::string GetComponentValues(const std::string& delimiter); + std::string GetComponentValues(const std::string& delimiter) const; /// @name Pilot input command setting //@{ diff --git a/src/FDM/JSBSim/models/FGGroundReactions.cpp b/src/FDM/JSBSim/models/FGGroundReactions.cpp index 246cefe8c..9126c9f81 100644 --- a/src/FDM/JSBSim/models/FGGroundReactions.cpp +++ b/src/FDM/JSBSim/models/FGGroundReactions.cpp @@ -46,7 +46,7 @@ using namespace std; namespace JSBSim { -static const char *IdSrc = "$Id: FGGroundReactions.cpp,v 1.30 2010/09/07 00:40:03 jberndt Exp $"; +static const char *IdSrc = "$Id: FGGroundReactions.cpp,v 1.31 2010/11/18 12:38:06 jberndt Exp $"; static const char *IdHdr = ID_GROUNDREACTIONS; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -187,7 +187,7 @@ bool FGGroundReactions::Load(Element* el) Element* contact_element = el->FindElement("contact"); while (contact_element) { lGear.push_back(new FGLGear(contact_element, FDMExec, num++)); - FCS->AddGear(); // make the FCS aware of the landing gear + FDMExec->GetFCS()->AddGear(); // make the FCS aware of the landing gear contact_element = el->FindNextElement("contact"); } @@ -202,7 +202,7 @@ bool FGGroundReactions::Load(Element* el) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGGroundReactions::GetGroundReactionStrings(string delimeter) +string FGGroundReactions::GetGroundReactionStrings(string delimeter) const { std::ostringstream buf; @@ -237,7 +237,7 @@ string FGGroundReactions::GetGroundReactionStrings(string delimeter) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGGroundReactions::GetGroundReactionValues(string delimeter) +string FGGroundReactions::GetGroundReactionValues(string delimeter) const { std::ostringstream buf; diff --git a/src/FDM/JSBSim/models/FGGroundReactions.h b/src/FDM/JSBSim/models/FGGroundReactions.h index a10ff0bb1..30792225d 100644 --- a/src/FDM/JSBSim/models/FGGroundReactions.h +++ b/src/FDM/JSBSim/models/FGGroundReactions.h @@ -45,7 +45,7 @@ INCLUDES #include "math/FGColumnVector3.h" #include "input_output/FGXMLElement.h" -#define ID_GROUNDREACTIONS "$Id: FGGroundReactions.h,v 1.18 2010/09/07 00:40:03 jberndt Exp $" +#define ID_GROUNDREACTIONS "$Id: FGGroundReactions.h,v 1.19 2010/11/18 12:38:06 jberndt Exp $" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FORWARD DECLARATIONS @@ -100,12 +100,12 @@ public: bool InitModel(void); bool Run(void); bool Load(Element* el); - FGColumnVector3& GetForces(void) {return vForces;} + const FGColumnVector3& GetForces(void) const {return vForces;} double GetForces(int idx) const {return vForces(idx);} - FGColumnVector3& GetMoments(void) {return vMoments;} + const FGColumnVector3& GetMoments(void) const {return vMoments;} double GetMoments(int idx) const {return vMoments(idx);} - string GetGroundReactionStrings(string delimeter); - string GetGroundReactionValues(string delimeter); + string GetGroundReactionStrings(string delimeter) const; + string GetGroundReactionValues(string delimeter) const; bool GetWOW(void) const; void UpdateForcesAndMoments(void); @@ -114,7 +114,7 @@ public: /** Gets a gear instance @param gear index of gear instance @return a pointer to the FGLGear instance of the gear unit requested */ - inline FGLGear* GetGearUnit(int gear) { return lGear[gear]; } + FGLGear* GetGearUnit(int gear) const { return lGear[gear]; } private: vector lGear; diff --git a/src/FDM/JSBSim/models/FGInertial.cpp b/src/FDM/JSBSim/models/FGInertial.cpp index 0779c6954..94aa291c3 100644 --- a/src/FDM/JSBSim/models/FGInertial.cpp +++ b/src/FDM/JSBSim/models/FGInertial.cpp @@ -45,7 +45,7 @@ using namespace std; namespace JSBSim { -static const char *IdSrc = "$Id: FGInertial.cpp,v 1.19 2010/10/10 15:06:38 jberndt Exp $"; +static const char *IdSrc = "$Id: FGInertial.cpp,v 1.20 2010/11/18 12:38:06 jberndt Exp $"; static const char *IdHdr = ID_INERTIAL; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -116,7 +116,7 @@ bool FGInertial::Run(void) RunPreFunctions(); // Gravitation accel - double r = Propagate->GetRadius(); + double r = FDMExec->GetPropagate()->GetRadius(); gAccel = GetGAccel(r); earthPosAngle += FDMExec->GetDeltaT()*RotationRate; @@ -145,7 +145,7 @@ FGColumnVector3 FGInertial::GetGravityJ2(FGColumnVector3 position) const // Gravitation accel double r = position.Magnitude(); - double lat = Propagate->GetLatitude(); + double lat = FDMExec->GetPropagate()->GetLatitude(); double sinLat = sin(lat); double adivr = a/r; diff --git a/src/FDM/JSBSim/models/FGInput.cpp b/src/FDM/JSBSim/models/FGInput.cpp index c8cc13b83..65ab24db2 100755 --- a/src/FDM/JSBSim/models/FGInput.cpp +++ b/src/FDM/JSBSim/models/FGInput.cpp @@ -191,7 +191,7 @@ bool FGInput::Run(void) ostringstream info; info << "JSBSim version: " << JSBSim_version << endl; info << "Config File version: " << needed_cfg_version << endl; - info << "Aircraft simulated: " << Aircraft->GetAircraftName() << endl; +// info << "Aircraft simulated: " << Aircraft->GetAircraftName() << endl; info << "Simulation time: " << setw(8) << setprecision(3) << FDMExec->GetSimTime() << endl; socket->Reply(info.str()); diff --git a/src/FDM/JSBSim/models/FGMassBalance.cpp b/src/FDM/JSBSim/models/FGMassBalance.cpp index 95608f6bf..fd067ab51 100644 --- a/src/FDM/JSBSim/models/FGMassBalance.cpp +++ b/src/FDM/JSBSim/models/FGMassBalance.cpp @@ -51,7 +51,7 @@ using namespace std; namespace JSBSim { -static const char *IdSrc = "$Id: FGMassBalance.cpp,v 1.33 2010/09/07 00:40:03 jberndt Exp $"; +static const char *IdSrc = "$Id: FGMassBalance.cpp,v 1.34 2010/11/18 12:38:06 jberndt Exp $"; static const char *IdHdr = ID_MASSBALANCE; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -151,8 +151,8 @@ bool FGMassBalance::Load(Element* el) if (FDMExec->GetChildFDM(fdm)->mated) ChildFDMWeight += FDMExec->GetChildFDM(fdm)->exec->GetMassBalance()->GetWeight(); } - Weight = EmptyWeight + Propulsion->GetTanksWeight() + GetTotalPointMassWeight() - + BuoyantForces->GetGasMass()*slugtolb + ChildFDMWeight; + Weight = EmptyWeight + FDMExec->GetPropulsion()->GetTanksWeight() + GetTotalPointMassWeight() + + FDMExec->GetBuoyantForces()->GetGasMass()*slugtolb + ChildFDMWeight; Mass = lbtoslug*Weight; @@ -179,16 +179,16 @@ bool FGMassBalance::Run(void) if (FDMExec->GetChildFDM(fdm)->mated) ChildFDMWeight += FDMExec->GetChildFDM(fdm)->exec->GetMassBalance()->GetWeight(); } - Weight = EmptyWeight + Propulsion->GetTanksWeight() + GetTotalPointMassWeight() - + BuoyantForces->GetGasMass()*slugtolb + ChildFDMWeight; + Weight = EmptyWeight + FDMExec->GetPropulsion()->GetTanksWeight() + GetTotalPointMassWeight() + + FDMExec->GetBuoyantForces()->GetGasMass()*slugtolb + ChildFDMWeight; Mass = lbtoslug*Weight; // Calculate new CG - vXYZcg = (Propulsion->GetTanksMoment() + EmptyWeight*vbaseXYZcg + vXYZcg = (FDMExec->GetPropulsion()->GetTanksMoment() + EmptyWeight*vbaseXYZcg + GetPointMassMoment() - + BuoyantForces->GetGasMassMoment()) / Weight; + + FDMExec->GetBuoyantForces()->GetGasMassMoment()) / Weight; // Track frame-by-frame delta CG, and move the EOM-tracked location // by this amount. @@ -196,7 +196,7 @@ bool FGMassBalance::Run(void) vDeltaXYZcg = vXYZcg - vLastXYZcg; vDeltaXYZcgBody = StructuralToBody(vLastXYZcg) - StructuralToBody(vXYZcg); vLastXYZcg = vXYZcg; - Propagate->NudgeBodyLocation(vDeltaXYZcgBody); + FDMExec->GetPropagate()->NudgeBodyLocation(vDeltaXYZcgBody); // Calculate new total moments of inertia @@ -206,8 +206,8 @@ bool FGMassBalance::Run(void) mJ += GetPointmassInertia( lbtoslug * EmptyWeight, vbaseXYZcg ); // Then add the contributions from the additional pointmasses. mJ += CalculatePMInertias(); - mJ += Propulsion->CalculateTankInertias(); - mJ += BuoyantForces->GetGasMassInertia(); + mJ += FDMExec->GetPropulsion()->CalculateTankInertias(); + mJ += FDMExec->GetBuoyantForces()->GetGasMassInertia(); Ixx = mJ(1,1); Iyy = mJ(2,2); @@ -432,8 +432,8 @@ void FGMassBalance::GetMassPropertiesReport(void) const << setw(12) << pm->GetPointMassMoI(3,3) << endl; } - for (unsigned int i=0;iGetNumTanks() ;i++) { - FGTank* tank = Propulsion->GetTank(i); + for (unsigned int i=0;iGetPropulsion()->GetNumTanks() ;i++) { + FGTank* tank = FDMExec->GetPropulsion()->GetTank(i); string tankname=""; if (tank->GetType() == FGTank::ttFUEL && tank->GetGrainType() != FGTank::gtUNKNOWN) { tankname = "Solid Fuel"; diff --git a/src/FDM/JSBSim/models/FGMassBalance.h b/src/FDM/JSBSim/models/FGMassBalance.h index be461a1e8..c7468c5db 100644 --- a/src/FDM/JSBSim/models/FGMassBalance.h +++ b/src/FDM/JSBSim/models/FGMassBalance.h @@ -49,7 +49,7 @@ INCLUDES DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#define ID_MASSBALANCE "$Id: FGMassBalance.h,v 1.21 2010/08/12 04:07:11 jberndt Exp $" +#define ID_MASSBALANCE "$Id: FGMassBalance.h,v 1.22 2010/11/18 12:38:06 jberndt Exp $" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FORWARD DECLARATIONSS @@ -160,15 +160,15 @@ public: */ FGColumnVector3 StructuralToBody(const FGColumnVector3& r) const; - inline void SetEmptyWeight(double EW) { EmptyWeight = EW;} - inline void SetBaseCG(const FGColumnVector3& CG) {vbaseXYZcg = vXYZcg = CG;} + void SetEmptyWeight(double EW) { EmptyWeight = EW;} + void SetBaseCG(const FGColumnVector3& CG) {vbaseXYZcg = vXYZcg = CG;} void AddPointMass(Element* el); double GetTotalPointMassWeight(void); FGColumnVector3& GetPointMassMoment(void); - FGMatrix33& GetJ(void) {return mJ;} - FGMatrix33& GetJinv(void) {return mJinv;} + const FGMatrix33& GetJ(void) const {return mJ;} + const FGMatrix33& GetJinv(void) const {return mJinv;} void SetAircraftBaseInertias(FGMatrix33 BaseJ) {baseJ = BaseJ;} void GetMassPropertiesReport(void) const; diff --git a/src/FDM/JSBSim/models/FGModel.cpp b/src/FDM/JSBSim/models/FGModel.cpp index fe8039919..71f6cb3ed 100644 --- a/src/FDM/JSBSim/models/FGModel.cpp +++ b/src/FDM/JSBSim/models/FGModel.cpp @@ -57,7 +57,7 @@ using namespace std; namespace JSBSim { -static const char *IdSrc = "$Id: FGModel.cpp,v 1.15 2010/09/07 00:19:38 jberndt Exp $"; +static const char *IdSrc = "$Id: FGModel.cpp,v 1.16 2010/11/18 12:38:06 jberndt Exp $"; static const char *IdHdr = ID_MODEL; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -72,18 +72,6 @@ FGModel::FGModel(FGFDMExec* fdmex) { FDMExec = fdmex; - Atmosphere = 0; - FCS = 0; - Propulsion = 0; - MassBalance = 0; - Aerodynamics = 0; - Inertial = 0; - GroundReactions = 0; - ExternalReactions = 0; - Aircraft = 0; - Propagate = 0; - Auxiliary = 0; - //in order for FGModel derived classes to self-bind (that is, call //their bind function in the constructor, the PropertyManager pointer //must be brought up now. @@ -106,31 +94,7 @@ FGModel::~FGModel() bool FGModel::InitModel(void) { - Atmosphere = FDMExec->GetAtmosphere(); - FCS = FDMExec->GetFCS(); - Propulsion = FDMExec->GetPropulsion(); - MassBalance = FDMExec->GetMassBalance(); - Aerodynamics = FDMExec->GetAerodynamics(); - Inertial = FDMExec->GetInertial(); - GroundReactions = FDMExec->GetGroundReactions(); - ExternalReactions = FDMExec->GetExternalReactions(); - BuoyantForces = FDMExec->GetBuoyantForces(); - Aircraft = FDMExec->GetAircraft(); - Propagate = FDMExec->GetPropagate(); - Auxiliary = FDMExec->GetAuxiliary(); - - if (!Atmosphere || - !FCS || - !Propulsion || - !MassBalance || - !Aerodynamics || - !Inertial || - !GroundReactions || - !ExternalReactions || - !Aircraft || - !Propagate || - !Auxiliary) return(false); - else return(true); + return true; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/models/FGModel.h b/src/FDM/JSBSim/models/FGModel.h index 775ea9f29..470dc731a 100644 --- a/src/FDM/JSBSim/models/FGModel.h +++ b/src/FDM/JSBSim/models/FGModel.h @@ -48,7 +48,7 @@ INCLUDES DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#define ID_MODEL "$Id: FGModel.h,v 1.16 2010/09/22 11:33:40 jberndt Exp $" +#define ID_MODEL "$Id: FGModel.h,v 1.18 2010/11/18 12:38:06 jberndt Exp $" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FORWARD DECLARATIONS @@ -57,18 +57,6 @@ FORWARD DECLARATIONS namespace JSBSim { class FGFDMExec; -class FGAtmosphere; -class FGFCS; -class FGPropulsion; -class FGMassBalance; -class FGAerodynamics; -class FGInertial; -class FGGroundReactions; -class FGExternalReactions; -class FGBuoyantForces; -class FGAircraft; -class FGPropagate; -class FGAuxiliary; class Element; class FGPropertyManager; @@ -118,18 +106,6 @@ protected: virtual void Debug(int from); FGFDMExec* FDMExec; - FGAtmosphere* Atmosphere; - FGFCS* FCS; - FGPropulsion* Propulsion; - FGMassBalance* MassBalance; - FGAerodynamics* Aerodynamics; - FGInertial* Inertial; - FGGroundReactions* GroundReactions; - FGExternalReactions* ExternalReactions; - FGBuoyantForces* BuoyantForces; - FGAircraft* Aircraft; - FGPropagate* Propagate; - FGAuxiliary* Auxiliary; FGPropertyManager* PropertyManager; }; } diff --git a/src/FDM/JSBSim/models/FGOutput.cpp b/src/FDM/JSBSim/models/FGOutput.cpp index c074d9813..3e5c986c6 100644 --- a/src/FDM/JSBSim/models/FGOutput.cpp +++ b/src/FDM/JSBSim/models/FGOutput.cpp @@ -74,7 +74,7 @@ using namespace std; namespace JSBSim { -static const char *IdSrc = "$Id: FGOutput.cpp,v 1.49 2010/10/15 11:30:29 jberndt Exp $"; +static const char *IdSrc = "$Id: FGOutput.cpp,v 1.50 2010/11/18 12:38:06 jberndt Exp $"; static const char *IdHdr = ID_OUTPUT; // (stolen from FGFS native_fdm.cxx) @@ -237,6 +237,19 @@ void FGOutput::SetProtocol(const string& protocol) void FGOutput::DelimitedOutput(const string& fname) { + const FGAerodynamics* Aerodynamics = FDMExec->GetAerodynamics(); + const FGAuxiliary* Auxiliary = FDMExec->GetAuxiliary(); + const FGAircraft* Aircraft = FDMExec->GetAircraft(); + const FGAtmosphere* Atmosphere = FDMExec->GetAtmosphere(); + const FGPropulsion* Propulsion = FDMExec->GetPropulsion(); + const FGMassBalance* MassBalance = FDMExec->GetMassBalance(); + const FGPropagate* Propagate = FDMExec->GetPropagate(); + const FGFCS* FCS = FDMExec->GetFCS(); + const FGInertial* Inertial = FDMExec->GetInertial(); + const FGGroundReactions* GroundReactions = FDMExec->GetGroundReactions(); + const FGExternalReactions* ExternalReactions = FDMExec->GetExternalReactions(); + const FGBuoyantForces* BuoyantForces = FDMExec->GetBuoyantForces(); + streambuf* buffer; string scratch = ""; @@ -493,6 +506,13 @@ void FGOutput::DelimitedOutput(const string& fname) void FGOutput::SocketDataFill(FGNetFDM* net) { + const FGAerodynamics* Aerodynamics = FDMExec->GetAerodynamics(); + const FGAuxiliary* Auxiliary = FDMExec->GetAuxiliary(); + const FGPropulsion* Propulsion = FDMExec->GetPropulsion(); + const FGMassBalance* MassBalance = FDMExec->GetMassBalance(); + const FGPropagate* Propagate = FDMExec->GetPropagate(); + const FGFCS* FCS = FDMExec->GetFCS(); + const FGGroundReactions* GroundReactions = FDMExec->GetGroundReactions(); unsigned int i; // Version @@ -701,6 +721,16 @@ void FGOutput::FlightGearSocketOutput(void) void FGOutput::SocketOutput(void) { + const FGAerodynamics* Aerodynamics = FDMExec->GetAerodynamics(); + const FGAuxiliary* Auxiliary = FDMExec->GetAuxiliary(); + const FGPropulsion* Propulsion = FDMExec->GetPropulsion(); + const FGMassBalance* MassBalance = FDMExec->GetMassBalance(); + const FGPropagate* Propagate = FDMExec->GetPropagate(); + const FGFCS* FCS = FDMExec->GetFCS(); + const FGAtmosphere* Atmosphere = FDMExec->GetAtmosphere(); + const FGAircraft* Aircraft = FDMExec->GetAircraft(); + const FGGroundReactions* GroundReactions = FDMExec->GetGroundReactions(); + string asciiData, scratch; if (socket == NULL) return; diff --git a/src/FDM/JSBSim/models/FGOutput.h b/src/FDM/JSBSim/models/FGOutput.h index c4ef388d5..d03ac5981 100644 --- a/src/FDM/JSBSim/models/FGOutput.h +++ b/src/FDM/JSBSim/models/FGOutput.h @@ -51,7 +51,7 @@ INCLUDES DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#define ID_OUTPUT "$Id: FGOutput.h,v 1.18 2010/10/15 11:30:29 jberndt Exp $" +#define ID_OUTPUT "$Id: FGOutput.h,v 1.19 2010/10/31 04:48:46 jberndt Exp $" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FORWARD DECLARATIONS @@ -124,7 +124,7 @@ CLASS DOCUMENTATION propulsion ON|OFF NOTE that Time is always output with the data. - @version $Id: FGOutput.h,v 1.18 2010/10/15 11:30:29 jberndt Exp $ + @version $Id: FGOutput.h,v 1.19 2010/10/31 04:48:46 jberndt Exp $ */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -178,7 +178,6 @@ public: /** Subsystem: Propulsion (= 4096) */ ssPropulsion = 4096 } subsystems; - FGNetFDM fgSockBuf; private: diff --git a/src/FDM/JSBSim/models/FGPropagate.cpp b/src/FDM/JSBSim/models/FGPropagate.cpp index 0fec89b0c..066010405 100644 --- a/src/FDM/JSBSim/models/FGPropagate.cpp +++ b/src/FDM/JSBSim/models/FGPropagate.cpp @@ -71,7 +71,7 @@ using namespace std; namespace JSBSim { -static const char *IdSrc = "$Id: FGPropagate.cpp,v 1.71 2010/10/15 11:34:09 jberndt Exp $"; +static const char *IdSrc = "$Id: FGPropagate.cpp,v 1.73 2010/11/18 12:38:06 jberndt Exp $"; static const char *IdHdr = ID_PROPAGATE; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -94,7 +94,6 @@ FGPropagate::FGPropagate(FGFDMExec* fdmex) : FGModel(fdmex) integrator_rotational_position = eAdamsBashforth2; integrator_translational_position = eTrapezoidal; - VState.dqPQRdot.resize(4, FGColumnVector3(0.0,0.0,0.0)); VState.dqPQRidot.resize(4, FGColumnVector3(0.0,0.0,0.0)); VState.dqUVWidot.resize(4, FGColumnVector3(0.0,0.0,0.0)); VState.dqInertialVelocity.resize(4, FGColumnVector3(0.0,0.0,0.0)); @@ -118,18 +117,17 @@ bool FGPropagate::InitModel(void) if (!FGModel::InitModel()) return false; // For initialization ONLY: - SeaLevelRadius = LocalTerrainRadius = Inertial->GetRefRadius(); + SeaLevelRadius = LocalTerrainRadius = FDMExec->GetInertial()->GetRefRadius(); VState.vLocation.SetRadius( LocalTerrainRadius + 4.0 ); - VState.vLocation.SetEllipse(Inertial->GetSemimajor(), Inertial->GetSemiminor()); - vOmegaEarth = FGColumnVector3( 0.0, 0.0, Inertial->omega() ); // Earth rotation vector + VState.vLocation.SetEllipse(FDMExec->GetInertial()->GetSemimajor(), FDMExec->GetInertial()->GetSemiminor()); + vOmegaEarth = FGColumnVector3( 0.0, 0.0, FDMExec->GetInertial()->omega() ); // Earth rotation vector vPQRdot.InitMatrix(); vQtrndot = FGQuaternion(0,0,0); vUVWdot.InitMatrix(); vInertialVelocity.InitMatrix(); - VState.dqPQRdot.resize(4, FGColumnVector3(0.0,0.0,0.0)); VState.dqPQRidot.resize(4, FGColumnVector3(0.0,0.0,0.0)); VState.dqUVWidot.resize(4, FGColumnVector3(0.0,0.0,0.0)); VState.dqInertialVelocity.resize(4, FGColumnVector3(0.0,0.0,0.0)); @@ -157,7 +155,7 @@ void FGPropagate::SetInitialState(const FGInitialCondition *FGIC) FGIC->GetLatitudeRadIC(), FGIC->GetAltitudeASLFtIC() + FGIC->GetSeaLevelRadiusFtIC() ); - VState.vLocation.SetEarthPositionAngle(Inertial->GetEarthPositionAngle()); + VState.vLocation.SetEarthPositionAngle(FDMExec->GetInertial()->GetEarthPositionAngle()); Ti2ec = GetTi2ec(); // ECI to ECEF transform Tec2i = Ti2ec.Transposed(); // ECEF to ECI frame transform @@ -259,7 +257,7 @@ bool FGPropagate::Run(void) // matrices that are consistent with the new state of the vehicle // 1. Update the Earth position angle (EPA) - VState.vLocation.SetEarthPositionAngle(Inertial->GetEarthPositionAngle()); + VState.vLocation.SetEarthPositionAngle(FDMExec->GetInertial()->GetEarthPositionAngle()); // 2. Update the Ti2ec and Tec2i transforms from the updated EPA Ti2ec = GetTi2ec(); // ECI to ECEF transform @@ -314,9 +312,9 @@ bool FGPropagate::Run(void) void FGPropagate::CalculatePQRdot(void) { - const FGColumnVector3& vMoments = Aircraft->GetMoments(); // current moments - const FGMatrix33& J = MassBalance->GetJ(); // inertia matrix - const FGMatrix33& Jinv = MassBalance->GetJinv(); // inertia matrix inverse + const FGColumnVector3& vMoments = FDMExec->GetAircraft()->GetMoments(); // current moments + const FGMatrix33& J = FDMExec->GetMassBalance()->GetJ(); // inertia matrix + const FGMatrix33& Jinv = FDMExec->GetMassBalance()->GetJinv(); // inertia matrix inverse // Compute body frame rotational accelerations based on the current body // moments and the total inertial angular velocity expressed in the body @@ -358,8 +356,8 @@ void FGPropagate::CalculateQuatdot(void) void FGPropagate::CalculateUVWdot(void) { - double mass = MassBalance->GetMass(); // mass - const FGColumnVector3& vForces = Aircraft->GetForces(); // current forces + double mass = FDMExec->GetMassBalance()->GetMass(); // mass + const FGColumnVector3& vForces = FDMExec->GetAircraft()->GetForces(); // current forces vUVWdot = vForces/mass - (VState.vPQR + 2.0*(Ti2b *vOmegaEarth)) * VState.vUVW; @@ -369,10 +367,10 @@ void FGPropagate::CalculateUVWdot(void) // Include Gravitation accel switch (gravType) { case gtStandard: - vGravAccel = Tl2b * FGColumnVector3( 0.0, 0.0, Inertial->GetGAccel(VehicleRadius) ); + vGravAccel = Tl2b * FGColumnVector3( 0.0, 0.0, FDMExec->GetInertial()->GetGAccel(VehicleRadius) ); break; case gtWGS84: - vGravAccel = Tec2b * Inertial->GetGravityJ2(VState.vLocation); + vGravAccel = Tec2b * FDMExec->GetInertial()->GetGravityJ2(VState.vLocation); break; } @@ -471,15 +469,15 @@ void FGPropagate::Integrate( FGQuaternion& Integrand, void FGPropagate::ResolveFrictionForces(double dt) { - const double invMass = 1.0 / MassBalance->GetMass(); - const FGMatrix33& Jinv = MassBalance->GetJinv(); + const double invMass = 1.0 / FDMExec->GetMassBalance()->GetMass(); + const FGMatrix33& Jinv = FDMExec->GetMassBalance()->GetJinv(); vector JacF, JacM; FGColumnVector3 vdot, wdot; FGColumnVector3 Fc, Mc; int n = 0, i; // Compiles data from the ground reactions to build up the jacobian matrix - for (MultiplierIterator it=MultiplierIterator(GroundReactions); *it; ++it, n++) { + for (MultiplierIterator it=MultiplierIterator(FDMExec->GetGroundReactions()); *it; ++it, n++) { JacF.push_back((*it)->ForceJacobian); JacM.push_back((*it)->MomentJacobian); } @@ -495,7 +493,7 @@ void FGPropagate::ResolveFrictionForces(double dt) // Initializes the Lagrange multipliers i = 0; - for (MultiplierIterator it=MultiplierIterator(GroundReactions); *it; ++it, i++) { + for (MultiplierIterator it=MultiplierIterator(FDMExec->GetGroundReactions()); *it; ++it, i++) { lambda[i] = (*it)->value; lambdaMax[i] = (*it)->Max; lambdaMin[i] = (*it)->Min; @@ -568,10 +566,10 @@ void FGPropagate::ResolveFrictionForces(double dt) // Save the value of the Lagrange multipliers to accelerate the convergence // of the Gauss-Seidel algorithm at next iteration. i = 0; - for (MultiplierIterator it=MultiplierIterator(GroundReactions); *it; ++it) + for (MultiplierIterator it=MultiplierIterator(FDMExec->GetGroundReactions()); *it; ++it) (*it)->value = lambda[i++]; - GroundReactions->UpdateForcesAndMoments(); + FDMExec->GetGroundReactions()->UpdateForcesAndMoments(); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -633,13 +631,11 @@ void FGPropagate::InitializeDerivatives(void) CalculateInertialVelocity(); // Translational position derivative // Initialize past values deques - VState.dqPQRdot.clear(); VState.dqPQRidot.clear(); VState.dqUVWidot.clear(); VState.dqInertialVelocity.clear(); VState.dqQtrndot.clear(); for (int i=0; i<4; i++) { - VState.dqPQRdot.push_front(vPQRdot); VState.dqPQRidot.push_front(vPQRidot); VState.dqUVWidot.push_front(vUVWdot); VState.dqInertialVelocity.push_front(VState.vInertialVelocity); @@ -861,7 +857,7 @@ void FGPropagate::Debug(int from) << reset << endl; cout << endl; cout << highint << " Earth Position Angle (deg): " << setw(8) << setprecision(3) << reset - << Inertial->GetEarthPositionAngleDeg() << endl; + << FDMExec->GetInertial()->GetEarthPositionAngleDeg() << endl; cout << endl; cout << highint << " Body velocity (ft/sec): " << setw(8) << setprecision(3) << reset << VState.vUVW << endl; cout << highint << " Local velocity (ft/sec): " << setw(8) << setprecision(3) << reset << vVel << endl; diff --git a/src/FDM/JSBSim/models/FGPropagate.h b/src/FDM/JSBSim/models/FGPropagate.h index 86e5cd6a0..1c8d70cb5 100644 --- a/src/FDM/JSBSim/models/FGPropagate.h +++ b/src/FDM/JSBSim/models/FGPropagate.h @@ -49,7 +49,7 @@ INCLUDES DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#define ID_PROPAGATE "$Id: FGPropagate.h,v 1.51 2010/10/07 03:45:40 jberndt Exp $" +#define ID_PROPAGATE "$Id: FGPropagate.h,v 1.52 2010/10/31 04:48:46 jberndt Exp $" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FORWARD DECLARATIONS @@ -102,7 +102,7 @@ CLASS DOCUMENTATION @endcode @author Jon S. Berndt, Mathias Froehlich - @version $Id: FGPropagate.h,v 1.51 2010/10/07 03:45:40 jberndt Exp $ + @version $Id: FGPropagate.h,v 1.52 2010/10/31 04:48:46 jberndt Exp $ */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -152,7 +152,6 @@ public: FGColumnVector3 vInertialPosition; - deque dqPQRdot; deque dqPQRidot; deque dqUVWidot; deque dqInertialVelocity; diff --git a/src/FDM/JSBSim/models/FGPropulsion.cpp b/src/FDM/JSBSim/models/FGPropulsion.cpp index 21f469c1f..32d8b42a1 100644 --- a/src/FDM/JSBSim/models/FGPropulsion.cpp +++ b/src/FDM/JSBSim/models/FGPropulsion.cpp @@ -65,7 +65,7 @@ using namespace std; namespace JSBSim { -static const char *IdSrc = "$Id: FGPropulsion.cpp,v 1.41 2010/10/15 11:32:41 jberndt Exp $"; +static const char *IdSrc = "$Id: FGPropulsion.cpp,v 1.43 2010/11/18 12:38:06 jberndt Exp $"; static const char *IdHdr = ID_PROPULSION; extern short debug_lvl; @@ -115,6 +115,8 @@ FGPropulsion::~FGPropulsion() bool FGPropulsion::InitModel(void) { + bool result = true; + if (!FGModel::InitModel()) return false; for (unsigned int i=0; iResetToIC(); @@ -123,18 +125,28 @@ bool FGPropulsion::InitModel(void) switch (Engines[i]->GetType()) { case FGEngine::etPiston: ((FGPiston*)Engines[i])->ResetToIC(); - if (HasInitializedEngines && (InitializedEngines & i)) InitRunning(i); + try { + if (HasInitializedEngines && (InitializedEngines & i)) InitRunning(i); + } catch (string str) { + cerr << str << endl; + result = false; + } break; case FGEngine::etTurbine: ((FGTurbine*)Engines[i])->ResetToIC(); - if (HasInitializedEngines && (InitializedEngines & i)) InitRunning(i); + try { + if (HasInitializedEngines && (InitializedEngines & i)) InitRunning(i); + } catch (string str) { + cerr << str << endl; + result = false; + } break; default: break; } } - return true; + return result; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -226,14 +238,13 @@ bool FGPropulsion::GetSteadyState(void) void FGPropulsion::InitRunning(int n) { - if (n > 0) { // A specific engine is supposed to be initialized + if (n >= 0) { // A specific engine is supposed to be initialized if (n >= (int)GetNumEngines() ) { - cerr << "Tried to initialize a non-existent engine!" << endl; - throw; + throw(string("Tried to initialize a non-existent engine!")); } - FCS->SetThrottleCmd(n,1); - FCS->SetMixtureCmd(n,1); + FDMExec->GetFCS()->SetThrottleCmd(n,1); + FDMExec->GetFCS()->SetMixtureCmd(n,1); GetEngine(n)->InitRunning(); GetSteadyState(); @@ -243,16 +254,14 @@ void FGPropulsion::InitRunning(int n) } else if (n < 0) { // -1 refers to "All Engines" for (unsigned int i=0; iSetThrottleCmd(i,1); - FCS->SetMixtureCmd(i,1); + FDMExec->GetFCS()->SetThrottleCmd(i,1); + FDMExec->GetFCS()->SetMixtureCmd(i,1); GetEngine(i)->InitRunning(); } GetSteadyState(); InitializedEngines = -1; HasInitializedEngines = true; - } else if (n == 0) { // No engines are to be initialized - // Do nothing } } @@ -325,7 +334,7 @@ bool FGPropulsion::Load(Element* el) return false; } - FCS->AddThrottle(); + FDMExec->GetFCS()->AddThrottle(); ThrottleAdded = true; numEngines++; @@ -335,7 +344,7 @@ bool FGPropulsion::Load(Element* el) } CalculateTankInertias(); - if (!ThrottleAdded) FCS->AddThrottle(); // need to have at least one throttle + if (!ThrottleAdded) FDMExec->GetFCS()->AddThrottle(); // need to have at least one throttle // Process fuel dump rate if (el->FindElement("dump-rate")) @@ -401,7 +410,7 @@ ifstream* FGPropulsion::FindEngineFile(const string& engine_filename) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGPropulsion::GetPropulsionStrings(const string& delimiter) +string FGPropulsion::GetPropulsionStrings(const string& delimiter) const { unsigned int i; @@ -425,7 +434,7 @@ string FGPropulsion::GetPropulsionStrings(const string& delimiter) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGPropulsion::GetPropulsionValues(const string& delimiter) +string FGPropulsion::GetPropulsionValues(const string& delimiter) const { unsigned int i; @@ -483,7 +492,7 @@ FGMatrix33& FGPropulsion::CalculateTankInertias(void) tankJ = FGMatrix33(); for (unsigned int i=0; iGetPointmassInertia( lbtoslug * Tanks[i]->GetContents(), + tankJ += FDMExec->GetMassBalance()->GetPointmassInertia( lbtoslug * Tanks[i]->GetContents(), Tanks[i]->GetXYZ() ); tankJ(1,1) += Tanks[i]->GetIxx(); tankJ(2,2) += Tanks[i]->GetIyy(); diff --git a/src/FDM/JSBSim/models/FGPropulsion.h b/src/FDM/JSBSim/models/FGPropulsion.h index ff3502c95..50dd860cd 100644 --- a/src/FDM/JSBSim/models/FGPropulsion.h +++ b/src/FDM/JSBSim/models/FGPropulsion.h @@ -49,7 +49,7 @@ INCLUDES DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#define ID_PROPULSION "$Id: FGPropulsion.h,v 1.25 2010/01/02 17:58:01 andgi Exp $" +#define ID_PROPULSION "$Id: FGPropulsion.h,v 1.26 2010/11/18 12:38:06 jberndt Exp $" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FORWARD DECLARATIONS @@ -91,7 +91,7 @@ CLASS DOCUMENTATION @endcode @author Jon S. Berndt - @version $Id: FGPropulsion.h,v 1.25 2010/01/02 17:58:01 andgi Exp $ + @version $Id: FGPropulsion.h,v 1.26 2010/11/18 12:38:06 jberndt Exp $ @see FGEngine FGTank @@ -125,32 +125,32 @@ public: bool Load(Element* el); /// Retrieves the number of engines defined for the aircraft. - inline unsigned int GetNumEngines(void) const {return (unsigned int)Engines.size();} + unsigned int GetNumEngines(void) const {return (unsigned int)Engines.size();} /** Retrieves an engine object pointer from the list of engines. @param index the engine index within the vector container @return the address of the specific engine, or zero if no such engine is available */ - inline FGEngine* GetEngine(unsigned int index) { + FGEngine* GetEngine(unsigned int index) const { if (index < Engines.size()) return Engines[index]; else return 0L; } /// Retrieves the number of tanks defined for the aircraft. - inline unsigned int GetNumTanks(void) const {return (unsigned int)Tanks.size();} + unsigned int GetNumTanks(void) const {return (unsigned int)Tanks.size();} /** Retrieves a tank object pointer from the list of tanks. @param index the tank index within the vector container @return the address of the specific tank, or zero if no such tank is available */ - inline FGTank* GetTank(unsigned int index) { + FGTank* GetTank(unsigned int index) const { if (index < Tanks.size()) return Tanks[index]; else return 0L; } /** Returns the number of fuel tanks currently actively supplying fuel */ - inline int GetnumSelectedFuelTanks(void) const {return numSelectedFuelTanks;} + int GetnumSelectedFuelTanks(void) const {return numSelectedFuelTanks;} /** Returns the number of oxidizer tanks currently actively supplying oxidizer */ - inline int GetnumSelectedOxiTanks(void) const {return numSelectedOxiTanks;} + int GetnumSelectedOxiTanks(void) const {return numSelectedOxiTanks;} /** Loops the engines until thrust output steady (used for trimming) */ bool GetSteadyState(void); @@ -158,18 +158,18 @@ public: /** Sets up the engines as running */ void InitRunning(int n); - std::string GetPropulsionStrings(const std::string& delimiter); - std::string GetPropulsionValues(const std::string& delimiter); + std::string GetPropulsionStrings(const std::string& delimiter) const; + std::string GetPropulsionValues(const std::string& delimiter) const; - inline FGColumnVector3& GetForces(void) {return vForces; } - inline double GetForces(int n) const { return vForces(n);} - inline FGColumnVector3& GetMoments(void) {return vMoments;} - inline double GetMoments(int n) const {return vMoments(n);} + const FGColumnVector3& GetForces(void) const {return vForces; } + double GetForces(int n) const { return vForces(n);} + const FGColumnVector3& GetMoments(void) const {return vMoments;} + double GetMoments(int n) const {return vMoments(n);} - inline bool GetRefuel(void) const {return refuel;} - inline void SetRefuel(bool setting) {refuel = setting;} - inline bool GetFuelDump(void) const {return dump;} - inline void SetFuelDump(bool setting) {dump = setting;} + bool GetRefuel(void) const {return refuel;} + void SetRefuel(bool setting) {refuel = setting;} + bool GetFuelDump(void) const {return dump;} + void SetFuelDump(bool setting) {dump = setting;} double Transfer(int source, int target, double amount); void DoRefuel(double time_slice); void DumpFuel(double time_slice); diff --git a/src/FDM/JSBSim/models/atmosphere/FGMSIS.cpp b/src/FDM/JSBSim/models/atmosphere/FGMSIS.cpp index 390a11449..0afaa831a 100755 --- a/src/FDM/JSBSim/models/atmosphere/FGMSIS.cpp +++ b/src/FDM/JSBSim/models/atmosphere/FGMSIS.cpp @@ -66,7 +66,7 @@ using namespace std; namespace JSBSim { -static const char *IdSrc = "$Id: FGMSIS.cpp,v 1.13 2010/02/25 05:21:36 jberndt Exp $"; +static const char *IdSrc = "$Id: FGMSIS.cpp,v 1.14 2010/11/18 12:38:06 jberndt Exp $"; static const char *IdHdr = ID_MSIS; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -153,11 +153,11 @@ bool MSIS::Run(void) //do temp, pressure, and density first if (!useExternal) { // get sea-level values - Calculate(Auxiliary->GetDayOfYear(), - Auxiliary->GetSecondsInDay(), + Calculate(FDMExec->GetAuxiliary()->GetDayOfYear(), + FDMExec->GetAuxiliary()->GetSecondsInDay(), 0.0, - Propagate->GetLocation().GetLatitudeDeg(), - Propagate->GetLocation().GetLongitudeDeg()); + FDMExec->GetPropagate()->GetLocation().GetLatitudeDeg(), + FDMExec->GetPropagate()->GetLocation().GetLongitudeDeg()); SLtemperature = output.t[1] * 1.8; SLdensity = output.d[5] * 1.940321; SLpressure = 1716.488 * SLdensity * SLtemperature; @@ -168,11 +168,11 @@ bool MSIS::Run(void) rSLsoundspeed = 1.0/SLsoundspeed; // get at-altitude values - Calculate(Auxiliary->GetDayOfYear(), - Auxiliary->GetSecondsInDay(), - Propagate->GetAltitudeASL(), - Propagate->GetLocation().GetLatitudeDeg(), - Propagate->GetLocation().GetLongitudeDeg()); + Calculate(FDMExec->GetAuxiliary()->GetDayOfYear(), + FDMExec->GetAuxiliary()->GetSecondsInDay(), + FDMExec->GetPropagate()->GetAltitudeASL(), + FDMExec->GetPropagate()->GetLocation().GetLatitudeDeg(), + FDMExec->GetPropagate()->GetLocation().GetLongitudeDeg()); intTemperature = output.t[1] * 1.8; intDensity = output.d[5] * 1.940321; intPressure = 1716.488 * intDensity * intTemperature;