JSBSim Flight Dynamics Model 1.2.3 (07 Jun 2025)
An Open Source Flight Dynamics and Control Software Library in C++
Loading...
Searching...
No Matches
FGFDMExec Class Reference

Detailed Description

Encapsulates the JSBSim simulation executive.

This class is the executive class through which all other simulation classes are instantiated, initialized, and run. When integrated with FlightGear (or other flight simulator) this class is typically instantiated by an interface class on the simulator side.

At the time of simulation initialization, the interface class creates an instance of this executive class. The executive is subsequently directed to load the chosen aircraft specification file:

fdmex = new FGFDMExec( ... );
result = fdmex->LoadModel( ... );
Encapsulates the JSBSim simulation executive.
Definition FGFDMExec.h:184

When an aircraft model is loaded, the config file is parsed and for each of the sections of the config file (propulsion, flight control, etc.) the corresponding Load() method is called (e.g. FGFCS::Load()).

Subsequent to the creation of the executive and loading of the model, initialization is performed. Initialization involves copying control inputs into the appropriate JSBSim data storage locations, configuring it for the set of user supplied initial conditions, and then copying state variables from JSBSim. The state variables are used to drive the instrument displays and to place the vehicle model in world space for visual rendering:

copy_to_JSBsim(); // copy control inputs to JSBSim
fdmex->RunIC(); // loop JSBSim once w/o integrating
copy_from_JSBsim(); // update the bus

Once initialization is complete, cyclic execution proceeds:

copy_to_JSBsim(); // copy control inputs to JSBSim
fdmex->Run(); // execute JSBSim
copy_from_JSBsim(); // update the bus

JSBSim can be used in a standalone mode by creating a compact stub program that effectively performs the same progression of steps as outlined above for the integrated version, but with two exceptions. First, the copy_to_JSBSim() and copy_from_JSBSim() functions are not used because the control inputs are handled directly by the scripting facilities and outputs are handled by the output (data logging) class. Second, the name of a script file can be supplied to the stub program. Scripting (see FGScript) provides a way to supply command inputs to the simulation:

FDMExec = new JSBSim::FGFDMExec();
FDMExec->LoadScript( ScriptName ); // the script loads the aircraft and ICs
result = FDMExec->Run();
while (result) { // cyclic execution
result = FDMExec->Run(); // execute JSBSim
}
bool LoadScript(const SGPath &Script, double deltaT=0.0, const SGPath &initfile=SGPath())
Load a script.
bool Run(void)
This function executes each scheduled model in succession.

The standalone mode has been useful for verifying changes before committing updates to the source code repository. It is also useful for running sets of tests that reveal some aspects of simulated aircraft performance, such as range, time-to-climb, takeoff distance, etc.

JSBSim Debugging Directives

This describes to any interested entity the debug level requested by setting the JSBSIM_DEBUG environment variable. The bitmasked value choices are as follows:

  • unset: In this case (the default) JSBSim would only print out the normally expected messages, essentially echoing the config files as they are read. If the environment variable is not set, debug_lvl is set to 1 internally
  • 0: This requests JSBSim not to output any messages whatsoever
  • 1: This value explicity requests the normal JSBSim startup messages
  • 2: This value asks for a message to be printed out when a class is instantiated
  • 4: When this value is set, a message is displayed when a FGModel object executes its Run() method
  • 8: When this value is set, various runtime state variables are printed out periodically
  • 16: When set various parameters are sanity checked and a message is printed out when they go out of bounds

Properties

  • simulator/do_trim (write only) Can be set to the integer equivalent to one of tLongitudinal (0), tFull (1), tGround (2), tPullup (3), tCustom (4), tTurn (5). Setting this to a legal value (such as by a script) causes a trim to be performed. This property actually maps toa function call of DoTrim().
Author
Jon S. Berndt
Version
Revision
1.106

Definition at line 183 of file FGFDMExec.h.

#include <FGFDMExec.h>

+ Inheritance diagram for FGFDMExec:
+ Collaboration diagram for FGFDMExec:

Classes

struct  PropertyCatalogStructure
 

Public Types

enum  eModels {
  ePropagate =0 , eInput , eInertial , eAtmosphere ,
  eWinds , eSystems , eMassBalance , eAuxiliary ,
  ePropulsion , eAerodynamics , eGroundReactions , eExternalReactions ,
  eBuoyantForces , eAircraft , eAccelerations , eOutput ,
  eNumStandardModels
}
 
- Public Types inherited from FGJSBBase
enum  { eL = 1 , eM , eN }
 Moments L, M, N. More...
 
enum  { eP = 1 , eQ , eR }
 Rates P, Q, R. More...
 
enum  { eU = 1 , eV , eW }
 Velocities U, V, W. More...
 
enum  { eX = 1 , eY , eZ }
 Positions X, Y, Z. More...
 
enum  { ePhi = 1 , eTht , ePsi }
 Euler angles Phi, Theta, Psi. More...
 
enum  { eDrag = 1 , eSide , eLift }
 Stability axis forces, Drag, Side force, Lift. More...
 
enum  { eRoll = 1 , ePitch , eYaw }
 Local frame orientation Roll, Pitch, Yaw. More...
 
enum  { eNorth = 1 , eEast , eDown }
 Local frame position North, East, Down. More...
 
enum  { eLat = 1 , eLong , eRad }
 Locations Radius, Latitude, Longitude. More...
 
enum  {
  inNone = 0 , inDegrees , inRadians , inMeters ,
  inFeet
}
 Conversion specifiers. More...
 

Public Member Functions

 FGFDMExec (FGPropertyManager *root=nullptr, std::shared_ptr< unsigned int > fdmctr=nullptr)
 Default constructor.
 
 ~FGFDMExec ()
 Default destructor.
 
void AddTemplateFunc (const std::string &name, Element *el)
 
void BuildPropertyCatalog (struct PropertyCatalogStructure *pcs)
 Builds a catalog of properties.
 
void CheckIncrementalHold (void)
 Checks if required to hold afer increment.
 
void DisableOutput (void)
 Disables data logging to all outputs.
 
void DoLinearization (int)
 Executes linearization with state-space output You must trim first to get an accurate state-space model.
 
void DoTrim (int mode)
 Executes trimming in the selected mode.
 
void EnableIncrementThenHold (int Timesteps)
 Turn on hold after increment.
 
void EnableOutput (void)
 Enables data logging to all outputs.
 
std::vector< std::string > EnumerateFDMs (void)
 Returns a vector of strings representing the names of all loaded models (future)
 
void ForceOutput (int idx=0)
 Forces the specified output object to print its items once.
 
const SGPath & GetAircraftPath (void)
 Retrieves the aircraft path.
 
auto GetChildFDM (int i) const
 Gets a particular child FDM.
 
int GetDebugLevel (void) const
 Retrieves the current debug level setting.
 
double GetDeltaT (void) const
 Returns the simulation delta T.
 
const SGPath & GetEnginePath (void)
 Retrieves the engine path.
 
size_t GetFDMCount (void) const
 Gets the number of child FDMs.
 
unsigned int GetFrame (void) const
 Retrieves the current frame count.
 
const SGPath & GetFullAircraftPath (void)
 Retrieves the full aircraft path name.
 
bool GetHoldDown (void) const
 Gets the value of the property forces/hold-down.
 
const std::string & GetModelName (void) const
 Returns the model name.
 
std::string GetOutputFileName (int n) const
 Retrieves the current output filename.
 
const SGPath & GetOutputPath (void)
 Retrieves the path to the output files.
 
std::vector< std::string > & GetPropertyCatalog (void)
 
std::shared_ptr< FGPropertyManagerGetPropertyManager (void) const
 Returns a pointer to the property manager object.
 
double GetPropertyValue (const std::string &property)
 Retrieves the value of a property.
 
std::string GetPropulsionTankReport () const
 
auto GetRandomGenerator (void) const
 
const SGPath & GetRootDir (void) const
 Retrieve the Root Directory.
 
double GetSimTime (void) const
 Returns the cumulative simulation time in seconds.
 
const SGPath & GetSystemsPath (void)
 Retrieves the systems path.
 
FGTemplateFunc_ptr GetTemplateFunc (const std::string &name)
 
int GetTrimMode (void) const
 
bool GetTrimStatus (void) const
 
void Hold (void)
 Pauses execution by preventing time from incrementing.
 
bool Holding (void)
 Returns true if the simulation is Holding (i.e. simulation time is not moving).
 
double IncrTime (void)
 Increments the simulation time if not in Holding mode.
 
void Initialize (const FGInitialCondition *FGIC)
 Initializes the simulation with initial conditions.
 
bool IntegrationSuspended (void) const
 Returns the simulation suspension state.
 
bool LoadModel (const SGPath &AircraftPath, const SGPath &EnginePath, const SGPath &SystemsPath, const std::string &model, bool addModelToPath=true)
 Loads an aircraft model.
 
bool LoadModel (const std::string &model, bool addModelToPath=true)
 Loads an aircraft model.
 
bool LoadPlanet (const SGPath &PlanetPath, bool useAircraftPath=true)
 Loads the planet.
 
bool LoadScript (const SGPath &Script, double deltaT=0.0, const SGPath &initfile=SGPath())
 Load a script.
 
void PrintPropertyCatalog (void)
 
void PrintSimulationConfiguration (void) const
 
std::string QueryPropertyCatalog (const std::string &check, const std::string &end_of_line="\n")
 Retrieves property or properties matching the supplied string.
 
void ResetToInitialConditions (int mode)
 Resets the initial conditions object and prepares the simulation to run again.
 
void Resume (void)
 Resumes execution from a "Hold".
 
void ResumeIntegration (void)
 Resumes the simulation by resetting delta T to the correct value.
 
bool Run (void)
 This function executes each scheduled model in succession.
 
bool RunIC (void)
 Initializes the sim from the initial condition object and executes each scheduled model without integrating i.e.
 
bool SetAircraftPath (const SGPath &path)
 Set the path to the aircraft config file directories.
 
void SetChild (bool ch)
 Marks this instance of the Exec object as a "child" object.
 
void SetDebugLevel (int level)
 Sets the debug level.
 
void Setdt (double delta_t)
 Sets the integration time step for the simulation executive.
 
bool SetEnginePath (const SGPath &path)
 Set the path to the engine config file directories.
 
void SetHoldDown (bool hd)
 Sets the property forces/hold-down.
 
void SetLoggingRate (double rate)
 Sets the logging rate in Hz for all output objects (if any).
 
bool SetOutputDirectives (const SGPath &fname)
 Sets the output (logging) mechanism for this run.
 
bool SetOutputFileName (const int n, const std::string &fname)
 Sets (or overrides) the output filename.
 
bool SetOutputPath (const SGPath &path)
 Set the directory where the output files will be written.
 
void SetPropertyValue (const std::string &property, double value)
 Sets a property value.
 
void SetRootDir (const SGPath &rootDir)
 Set the root directory that is used to obtain absolute paths from relative paths.
 
double Setsim_time (double cur_time)
 Sets the current sim time.
 
bool SetSystemsPath (const SGPath &path)
 Set the path to the systems config file directories.
 
void SetTrimMode (int mode)
 
void SetTrimStatus (bool status)
 
int SRand (void) const
 
void SuspendIntegration (void)
 Suspends the simulation and sets the delta T to zero.
 
void Unbind (void)
 Unbind all tied JSBSim properties.
 
Top-level executive State and Model retrieval mechanism

Returns the FGAtmosphere pointer.

std::shared_ptr< FGAtmosphereGetAtmosphere (void) const
 
std::shared_ptr< FGAccelerationsGetAccelerations (void) const
 Returns the FGAccelerations pointer.
 
std::shared_ptr< FGWindsGetWinds (void) const
 Returns the FGWinds pointer.
 
std::shared_ptr< FGFCSGetFCS (void) const
 Returns the FGFCS pointer.
 
std::shared_ptr< FGPropulsionGetPropulsion (void) const
 Returns the FGPropulsion pointer.
 
std::shared_ptr< FGMassBalanceGetMassBalance (void) const
 Returns the FGAircraft pointer.
 
std::shared_ptr< FGAerodynamicsGetAerodynamics (void) const
 Returns the FGAerodynamics pointer.
 
std::shared_ptr< FGInertialGetInertial (void) const
 Returns the FGInertial pointer.
 
std::shared_ptr< FGGroundReactionsGetGroundReactions (void) const
 Returns the FGGroundReactions pointer.
 
std::shared_ptr< FGExternalReactionsGetExternalReactions (void) const
 Returns the FGExternalReactions pointer.
 
std::shared_ptr< FGBuoyantForcesGetBuoyantForces (void) const
 Returns the FGBuoyantForces pointer.
 
std::shared_ptr< FGAircraftGetAircraft (void) const
 Returns the FGAircraft pointer.
 
std::shared_ptr< FGPropagateGetPropagate (void) const
 Returns the FGPropagate pointer.
 
std::shared_ptr< FGAuxiliaryGetAuxiliary (void) const
 Returns the FGAuxiliary pointer.
 
std::shared_ptr< FGInputGetInput (void) const
 Returns the FGInput pointer.
 
std::shared_ptr< FGOutputGetOutput (void) const
 Returns the FGOutput pointer.
 
std::shared_ptr< FGScriptGetScript (void) const
 Retrieves the script object.
 
std::shared_ptr< FGInitialConditionGetIC (void) const
 Returns a pointer to the FGInitialCondition object.
 
std::shared_ptr< FGTrimGetTrim (void)
 Returns a pointer to the FGTrim object.
 
- Public Member Functions inherited from FGJSBBase
 FGJSBBase ()
 Constructor for FGJSBBase.
 
virtual ~FGJSBBase ()
 Destructor for FGJSBBase.
 
void disableHighLighting (void)
 Disables highlighting in the console output.
 

Static Public Attributes

static const int DONT_EXECUTE_RUN_IC = 0x2
 
static const int START_NEW_OUTPUT = 0x1
 Mode flags for ResetToInitialConditions.
 
- Static Public Attributes inherited from FGJSBBase
static char highint [5] = {27, '[', '1', 'm', '\0' }
 highlights text
 
static char halfint [5] = {27, '[', '2', 'm', '\0' }
 low intensity text
 
static char normint [6] = {27, '[', '2', '2', 'm', '\0' }
 normal intensity text
 
static char reset [5] = {27, '[', '0', 'm', '\0' }
 resets text properties
 
static char underon [5] = {27, '[', '4', 'm', '\0' }
 underlines text
 
static char underoff [6] = {27, '[', '2', '4', 'm', '\0' }
 underline off
 
static char fgblue [6] = {27, '[', '3', '4', 'm', '\0' }
 blue text
 
static char fgcyan [6] = {27, '[', '3', '6', 'm', '\0' }
 cyan text
 
static char fgred [6] = {27, '[', '3', '1', 'm', '\0' }
 red text
 
static char fggreen [6] = {27, '[', '3', '2', 'm', '\0' }
 green text
 
static char fgdef [6] = {27, '[', '3', '9', 'm', '\0' }
 default text
 
static short debug_lvl = 1
 

Additional Inherited Members

- Static Public Member Functions inherited from FGJSBBase
static const std::string & GetVersion (void)
 Returns the version number of JSBSim.
 
static constexpr double KelvinToFahrenheit (double kelvin)
 Converts from degrees Kelvin to degrees Fahrenheit.
 
static constexpr double CelsiusToRankine (double celsius)
 Converts from degrees Celsius to degrees Rankine.
 
static constexpr double RankineToCelsius (double rankine)
 Converts from degrees Rankine to degrees Celsius.
 
static constexpr double KelvinToRankine (double kelvin)
 Converts from degrees Kelvin to degrees Rankine.
 
static constexpr double RankineToKelvin (double rankine)
 Converts from degrees Rankine to degrees Kelvin.
 
static constexpr double FahrenheitToCelsius (double fahrenheit)
 Converts from degrees Fahrenheit to degrees Celsius.
 
static constexpr double CelsiusToFahrenheit (double celsius)
 Converts from degrees Celsius to degrees Fahrenheit.
 
static constexpr double CelsiusToKelvin (double celsius)
 Converts from degrees Celsius to degrees Kelvin.
 
static constexpr double KelvinToCelsius (double kelvin)
 Converts from degrees Kelvin to degrees Celsius.
 
static constexpr double FeetToMeters (double measure)
 Converts from feet to meters.
 
static bool EqualToRoundoff (double a, double b)
 Finite precision comparison.
 
static bool EqualToRoundoff (float a, float b)
 Finite precision comparison.
 
static bool EqualToRoundoff (float a, double b)
 Finite precision comparison.
 
static bool EqualToRoundoff (double a, float b)
 Finite precision comparison.
 
static constexpr double Constrain (double min, double value, double max)
 Constrain a value between a minimum and a maximum value.
 
static constexpr double sign (double num)
 
- Static Protected Member Functions inherited from FGJSBBase
static std::string CreateIndexedPropertyName (const std::string &Property, int index)
 
- Static Protected Attributes inherited from FGJSBBase
static constexpr double radtodeg = 180. / M_PI
 
static constexpr double degtorad = M_PI / 180.
 
static constexpr double hptoftlbssec = 550.0
 
static constexpr double psftoinhg = 0.014138
 
static constexpr double psftopa = 47.88
 
static constexpr double fttom = 0.3048
 
static constexpr double ktstofps = 1852./(3600*fttom)
 
static constexpr double fpstokts = 1.0 / ktstofps
 
static constexpr double inchtoft = 1.0/12.0
 
static constexpr double m3toft3 = 1.0/(fttom*fttom*fttom)
 
static constexpr double in3tom3 = inchtoft*inchtoft*inchtoft/m3toft3
 
static constexpr double inhgtopa = 3386.38
 
static constexpr double slugtolb = 32.174049
 Note that definition of lbtoslug by the inverse of slugtolb and not to a different constant you can also get from some tables will make lbtoslug*slugtolb == 1 up to the magnitude of roundoff.
 
static constexpr double lbtoslug = 1.0/slugtolb
 
static constexpr double kgtolb = 2.20462
 
static constexpr double kgtoslug = 0.06852168
 
static const std::string needed_cfg_version = "2.0"
 
static const std::string JSBSim_version = JSBSIM_VERSION " " __DATE__ " " __TIME__
 

Member Enumeration Documentation

◆ eModels

enum eModels

Definition at line 224 of file FGFDMExec.h.

224 { ePropagate=0,
225 eInput,
226 eInertial,
227 eAtmosphere,
228 eWinds,
229 eSystems,
230 eMassBalance,
231 eAuxiliary,
232 ePropulsion,
233 eAerodynamics,
234 eGroundReactions,
235 eExternalReactions,
236 eBuoyantForces,
237 eAircraft,
238 eAccelerations,
239 eOutput,
240 eNumStandardModels };

Constructor & Destructor Documentation

◆ FGFDMExec()

FGFDMExec ( FGPropertyManager root = nullptr,
std::shared_ptr< unsigned int >  fdmctr = nullptr 
)

Default constructor.

Definition at line 79 of file FGFDMExec.cpp.

80 : RandomSeed(0), RandomGenerator(make_shared<RandomNumberGenerator>(RandomSeed)),
81 FDMctr(fdmctr)
82{
83 Frame = 0;
84 disperse = 0;
85
86 RootDir = "";
87
88 modelLoaded = false;
89 IsChild = false;
90 holding = false;
91 Terminate = false;
92 HoldDown = false;
93
94 IncrementThenHolding = false; // increment then hold is off by default
95 TimeStepsUntilHold = -1;
96
97 sim_time = 0.0;
98 dT = 1.0/120.0; // a default timestep size. This is needed for when JSBSim is
99 // run in standalone mode with no initialization file.
100
101 AircraftPath = "aircraft";
102 EnginePath = "engine";
103 SystemsPath = "systems";
104
105 if (const char* num = getenv("JSBSIM_DEBUG"); num != nullptr)
106 debug_lvl = strtol(num, nullptr, 0);
107 else
108 debug_lvl = 1;
109
110 if (!FDMctr) {
111 FDMctr = std::make_shared<unsigned int>(); // Create and initialize the child FDM counter
112 *FDMctr = 0;
113 }
114
115 // Store this FDM's ID
116 IdFDM = *FDMctr; // The main (parent) JSBSim instance is always the "zeroth"
117
118 // Prepare FDMctr for the next child FDM id
119 (*FDMctr)++; // instance. "child" instances are loaded last.
120
121 if (root == nullptr) // Then this is the root FDM
122 Root = new SGPropertyNode();
123 else
124 Root = root->GetNode();
125
126 SGPropertyNode* instanceRoot = Root->getNode("fdm/jsbsim", IdFDM, true);
127 instance = std::make_shared<FGPropertyManager>(instanceRoot);
128
129 if (const char* num = getenv("JSBSIM_DISPERSE");
130 num != nullptr && strtol(num, nullptr, 0) != 0)
131 {
132 disperse = 1; // set dispersions on
133 }
134
135 Debug(0);
136 // this is to catch errors in binding member functions to the property tree.
137 try {
138 Allocate();
139 }
140 catch (const string& msg) {
141 cerr << endl << "Caught error: " << msg << endl;
142 throw;
143 }
144 catch (const BaseException& e) {
145 cout << endl << "Caught error: " << e.what() << endl;
146 throw;
147 }
148
149 trim_status = false;
150 ta_mode = 99;
151 trim_completed = 0;
152
153 Constructing = true;
154 typedef int (FGFDMExec::*iPMF)(void) const;
155 instance->Tie("simulation/do_simple_trim", this, (iPMF)0, &FGFDMExec::DoTrim);
156 instance->Tie("simulation/do_linearization", this, (iPMF)0, &FGFDMExec::DoLinearization);
157 instance->Tie("simulation/reset", this, (iPMF)0, &FGFDMExec::ResetToInitialConditions);
158 instance->Tie("simulation/disperse", this, &FGFDMExec::GetDisperse);
159 instance->Tie("simulation/randomseed", this, (iPMF)&FGFDMExec::SRand, &FGFDMExec::SRand);
160 instance->Tie("simulation/terminate", (bool *)&Terminate);
161 instance->Tie("simulation/pause", (bool *)&holding);
162 instance->Tie("simulation/sim-time-sec", this, &FGFDMExec::GetSimTime);
163 instance->Tie("simulation/dt", this, &FGFDMExec::GetDeltaT);
164 instance->Tie("simulation/jsbsim-debug", this, &FGFDMExec::GetDebugLevel, &FGFDMExec::SetDebugLevel);
165 instance->Tie("simulation/frame", (int *)&Frame);
166 instance->Tie("simulation/trim-completed", (int *)&trim_completed);
167 instance->Tie("forces/hold-down", this, &FGFDMExec::GetHoldDown, &FGFDMExec::SetHoldDown);
168
169 Constructing = false;
170}
bool GetHoldDown(void) const
Gets the value of the property forces/hold-down.
Definition FGFDMExec.h:616
void DoLinearization(int)
Executes linearization with state-space output You must trim first to get an accurate state-space mod...
void SetDebugLevel(int level)
Sets the debug level.
Definition FGFDMExec.h:509
int GetDebugLevel(void) const
Retrieves the current debug level setting.
Definition FGFDMExec.h:601
double GetDeltaT(void) const
Returns the simulation delta T.
Definition FGFDMExec.h:552
void DoTrim(int mode)
Executes trimming in the selected mode.
void ResetToInitialConditions(int mode)
Resets the initial conditions object and prepares the simulation to run again.
double GetSimTime(void) const
Returns the cumulative simulation time in seconds.
Definition FGFDMExec.h:549
void SetHoldDown(bool hd)
Sets the property forces/hold-down.
A node in a property tree.
Definition props.hxx:754
+ Here is the call graph for this function:

◆ ~FGFDMExec()

~FGFDMExec ( )

Default destructor.

Definition at line 174 of file FGFDMExec.cpp.

175{
176 try {
177 Unbind();
178 DeAllocate();
179 } catch (const string& msg ) {
180 cout << "Caught error: " << msg << endl;
181 }
182
183 if (!FDMctr) (*FDMctr)--;
184
185 Debug(1);
186}
void Unbind(void)
Unbind all tied JSBSim properties.
Definition FGFDMExec.h:243
+ Here is the call graph for this function:

Member Function Documentation

◆ AddTemplateFunc()

void AddTemplateFunc ( const std::string &  name,
Element el 
)
inline

Definition at line 622 of file FGFDMExec.h.

622 {
623 TemplateFunctions[name] = std::make_shared<FGTemplateFunc>(this, el);
624 }

◆ BuildPropertyCatalog()

void BuildPropertyCatalog ( struct PropertyCatalogStructure pcs)

Builds a catalog of properties.

This function descends the property tree and creates a list (an STL vector) containing the name and node for all properties.

Parameters
pcsThe "root" property catalog structure pointer.

Definition at line 1065 of file FGFDMExec.cpp.

1066{
1067 auto pcsNew = std::make_unique<struct PropertyCatalogStructure>();
1068
1069 for (int i=0; i<pcs->node->nChildren(); i++) {
1070 string access="";
1071 pcsNew->base_string = pcs->base_string + "/" + pcs->node->getChild(i)->getNameString();
1072 int node_idx = pcs->node->getChild(i)->getIndex();
1073 if (node_idx != 0) {
1074 pcsNew->base_string = CreateIndexedPropertyName(pcsNew->base_string, node_idx);
1075 }
1076 if (pcs->node->getChild(i)->nChildren() == 0) {
1077 if (pcsNew->base_string.substr(0,12) == string("/fdm/jsbsim/")) {
1078 pcsNew->base_string = pcsNew->base_string.erase(0,12);
1079 }
1080 if (pcs->node->getChild(i)->getAttribute(SGPropertyNode::READ)) access="R";
1081 if (pcs->node->getChild(i)->getAttribute(SGPropertyNode::WRITE)) access+="W";
1082 PropertyCatalog.push_back(pcsNew->base_string+" ("+access+")");
1083 } else {
1084 pcsNew->node = pcs->node->getChild(i);
1085 BuildPropertyCatalog(pcsNew.get());
1086 }
1087 }
1088}
void BuildPropertyCatalog(struct PropertyCatalogStructure *pcs)
Builds a catalog of properties.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CheckIncrementalHold()

void CheckIncrementalHold ( void  )

Checks if required to hold afer increment.

Definition at line 1269 of file FGFDMExec.cpp.

1270{
1271 // Only check if increment then hold is on
1272 if( IncrementThenHolding ) {
1273
1274 if (TimeStepsUntilHold == 0) {
1275
1276 // Should hold simulation if TimeStepsUntilHold has reached zero
1277 holding = true;
1278
1279 // Still need to decrement TimeStepsUntilHold as value of -1
1280 // indicates that incremental then hold is turned off
1281 IncrementThenHolding = false;
1282 TimeStepsUntilHold--;
1283
1284 } else if ( TimeStepsUntilHold > 0 ) {
1285 // Keep decrementing until 0 is reached
1286 TimeStepsUntilHold--;
1287 }
1288 }
1289}

◆ DisableOutput()

void DisableOutput ( void  )
inline

Disables data logging to all outputs.

Definition at line 484 of file FGFDMExec.h.

484{ Output->Disable(); }
void Disable(void)
Disables the output generation for all output instances.
Definition FGOutput.h:182

◆ DoLinearization()

void DoLinearization ( int  )

Executes linearization with state-space output You must trim first to get an accurate state-space model.

Definition at line 1314 of file FGFDMExec.cpp.

1315{
1316 double dt0 = this->GetDeltaT();
1317 FGLinearization lin(this);
1318 lin.WriteScicoslab();
1319 this->Setdt(dt0);
1320}
void Setdt(double delta_t)
Sets the integration time step for the simulation executive.
Definition FGFDMExec.h:571
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DoTrim()

void DoTrim ( int  mode)

Executes trimming in the selected mode.

Parameters
modeSpecifies how to trim:
  • tLongitudinal=0
  • tFull
  • tGround
  • tPullup
  • tCustom
  • tTurn
  • tNone

Definition at line 1293 of file FGFDMExec.cpp.

1294{
1295 if (Constructing) return;
1296
1297 if (mode < 0 || mode > JSBSim::tNone)
1298 throw("Illegal trimming mode!");
1299
1300 FGTrim trim(this, (JSBSim::TrimMode)mode);
1301 bool success = trim.DoTrim();
1302
1303 if (debug_lvl > 0)
1304 trim.Report();
1305
1306 if (!success)
1307 throw TrimFailureException("Trim Failed");
1308
1309 trim_completed = 1;
1310}
+ Here is the caller graph for this function:

◆ EnableIncrementThenHold()

void EnableIncrementThenHold ( int  Timesteps)
inline

Turn on hold after increment.

Definition at line 490 of file FGFDMExec.h.

490{TimeStepsUntilHold = Timesteps; IncrementThenHolding = true;}
+ Here is the caller graph for this function:

◆ EnableOutput()

void EnableOutput ( void  )
inline

Enables data logging to all outputs.

Definition at line 486 of file FGFDMExec.h.

486{ Output->Enable(); }
void Enable(void)
Enables the output generation for all output instances.
Definition FGOutput.h:180

◆ EnumerateFDMs()

vector< string > EnumerateFDMs ( void  )

Returns a vector of strings representing the names of all loaded models (future)

Definition at line 719 of file FGFDMExec.cpp.

720{
721 vector <string> FDMList;
722 FDMList.push_back(Aircraft->GetAircraftName());
723
724 for (auto &ChildFDM: ChildFDMList)
725 FDMList.push_back(ChildFDM->exec->GetAircraft()->GetAircraftName());
726
727 return FDMList;
728}
const std::string & GetAircraftName(void) const
Gets the aircraft name.
Definition FGAircraft.h:131
std::shared_ptr< FGAircraft > GetAircraft(void) const
Returns the FGAircraft pointer.
+ Here is the call graph for this function:

◆ ForceOutput()

void ForceOutput ( int  idx = 0)
inline

Forces the specified output object to print its items once.

Definition at line 450 of file FGFDMExec.h.

450{ Output->ForceOutput(idx); }
void ForceOutput(int idx)
Force an output instance to generate its output.
Definition FGOutput.cpp:144

◆ GetAccelerations()

std::shared_ptr< FGAccelerations > GetAccelerations ( void  ) const

Returns the FGAccelerations pointer.

Definition at line 372 of file FGFDMExec.cpp.

373{
374 return static_pointer_cast<FGAccelerations>(Models[eAccelerations]);
375}
+ Here is the caller graph for this function:

◆ GetAerodynamics()

std::shared_ptr< FGAerodynamics > GetAerodynamics ( void  ) const

Returns the FGAerodynamics pointer.

Definition at line 337 of file FGFDMExec.cpp.

338{
339 return static_pointer_cast<FGAerodynamics>(Models[eAerodynamics]);
340}
+ Here is the caller graph for this function:

◆ GetAircraft()

std::shared_ptr< FGAircraft > GetAircraft ( void  ) const

Returns the FGAircraft pointer.

Definition at line 365 of file FGFDMExec.cpp.

366{
367 return static_pointer_cast<FGAircraft>(Models[eAircraft]);
368}
+ Here is the caller graph for this function:

◆ GetAircraftPath()

const SGPath & GetAircraftPath ( void  )
inline

Retrieves the aircraft path.

Definition at line 397 of file FGFDMExec.h.

397{ return AircraftPath; }

◆ GetAtmosphere()

std::shared_ptr< FGAtmosphere > GetAtmosphere ( void  ) const

Definition at line 295 of file FGFDMExec.cpp.

296{
297 return static_pointer_cast<FGAtmosphere>(Models[eAtmosphere]);
298}

◆ GetAuxiliary()

std::shared_ptr< FGAuxiliary > GetAuxiliary ( void  ) const

Returns the FGAuxiliary pointer.

Definition at line 323 of file FGFDMExec.cpp.

324{
325 return static_pointer_cast<FGAuxiliary>(Models[eAuxiliary]);
326}
+ Here is the caller graph for this function:

◆ GetBuoyantForces()

std::shared_ptr< FGBuoyantForces > GetBuoyantForces ( void  ) const

Returns the FGBuoyantForces pointer.

Definition at line 358 of file FGFDMExec.cpp.

359{
360 return static_pointer_cast<FGBuoyantForces>(Models[eBuoyantForces]);
361}
+ Here is the caller graph for this function:

◆ GetChildFDM()

auto GetChildFDM ( int  i) const
inline

Gets a particular child FDM.

Definition at line 427 of file FGFDMExec.h.

427{return ChildFDMList[i];}
+ Here is the caller graph for this function:

◆ GetDebugLevel()

int GetDebugLevel ( void  ) const
inline

Retrieves the current debug level setting.

Definition at line 601 of file FGFDMExec.h.

601{return debug_lvl;};
+ Here is the caller graph for this function:

◆ GetDeltaT()

double GetDeltaT ( void  ) const
inline

Returns the simulation delta T.

Definition at line 552 of file FGFDMExec.h.

552{return dT;}
+ Here is the caller graph for this function:

◆ GetEnginePath()

const SGPath & GetEnginePath ( void  )
inline

Retrieves the engine path.

Definition at line 395 of file FGFDMExec.h.

395{ return EnginePath; }

◆ GetExternalReactions()

std::shared_ptr< FGExternalReactions > GetExternalReactions ( void  ) const

Returns the FGExternalReactions pointer.

Definition at line 351 of file FGFDMExec.cpp.

352{
353 return static_pointer_cast<FGExternalReactions>(Models[eExternalReactions]);
354}
+ Here is the caller graph for this function:

◆ GetFCS()

std::shared_ptr< FGFCS > GetFCS ( void  ) const

Returns the FGFCS pointer.

Definition at line 309 of file FGFDMExec.cpp.

310{
311 return static_pointer_cast<FGFCS>(Models[eSystems]);
312}
+ Here is the caller graph for this function:

◆ GetFDMCount()

size_t GetFDMCount ( void  ) const
inline

Gets the number of child FDMs.

Definition at line 425 of file FGFDMExec.h.

425{return ChildFDMList.size();}
+ Here is the caller graph for this function:

◆ GetFrame()

unsigned int GetFrame ( void  ) const
inline

Retrieves the current frame count.

Definition at line 598 of file FGFDMExec.h.

598{return Frame;}

◆ GetFullAircraftPath()

const SGPath & GetFullAircraftPath ( void  )
inline

Retrieves the full aircraft path name.

Definition at line 401 of file FGFDMExec.h.

401{ return FullAircraftPath; }
+ Here is the caller graph for this function:

◆ GetGroundReactions()

std::shared_ptr< FGGroundReactions > GetGroundReactions ( void  ) const

Returns the FGGroundReactions pointer.

Definition at line 344 of file FGFDMExec.cpp.

345{
346 return static_pointer_cast<FGGroundReactions>(Models[eGroundReactions]);
347}
+ Here is the caller graph for this function:

◆ GetHoldDown()

bool GetHoldDown ( void  ) const
inline

Gets the value of the property forces/hold-down.

Returns
zero if the 'hold-down' function is disabled, non-zero otherwise.

Definition at line 616 of file FGFDMExec.h.

616{return HoldDown;}
+ Here is the caller graph for this function:

◆ GetIC()

std::shared_ptr< FGInitialCondition > GetIC ( void  ) const
inline

Returns a pointer to the FGInitialCondition object.

Definition at line 389 of file FGFDMExec.h.

389{return IC;}
+ Here is the caller graph for this function:

◆ GetInertial()

std::shared_ptr< FGInertial > GetInertial ( void  ) const

Returns the FGInertial pointer.

Definition at line 281 of file FGFDMExec.cpp.

282{
283 return static_pointer_cast<FGInertial>(Models[eInertial]);
284}
+ Here is the caller graph for this function:

◆ GetInput()

std::shared_ptr< FGInput > GetInput ( void  ) const

Returns the FGInput pointer.

Definition at line 288 of file FGFDMExec.cpp.

289{
290 return static_pointer_cast<FGInput>(Models[eInput]);
291}
+ Here is the caller graph for this function:

◆ GetMassBalance()

std::shared_ptr< FGMassBalance > GetMassBalance ( void  ) const

Returns the FGAircraft pointer.

Definition at line 316 of file FGFDMExec.cpp.

317{
318 return static_pointer_cast<FGMassBalance>(Models[eMassBalance]);
319}
+ Here is the caller graph for this function:

◆ GetModelName()

const std::string & GetModelName ( void  ) const
inline

Returns the model name.

Definition at line 418 of file FGFDMExec.h.

418{ return modelName; }

◆ GetOutput()

std::shared_ptr< FGOutput > GetOutput ( void  ) const

Returns the FGOutput pointer.

Definition at line 379 of file FGFDMExec.cpp.

380{
381 return static_pointer_cast<FGOutput>(Models[eOutput]);
382}
+ Here is the caller graph for this function:

◆ GetOutputFileName()

std::string GetOutputFileName ( int  n) const
inline

Retrieves the current output filename.

Parameters
nindex of file
Returns
the name of the output file for the output specified by the flight model. If none is specified, the empty string is returned.

Definition at line 465 of file FGFDMExec.h.

465{ return Output->GetOutputName(n); }
std::string GetOutputName(unsigned int idx) const
Get the name identifier to which the output will be directed.
Definition FGOutput.cpp:162

◆ GetOutputPath()

const SGPath & GetOutputPath ( void  )
inline

Retrieves the path to the output files.

Definition at line 403 of file FGFDMExec.h.

403{ return OutputPath; }
+ Here is the caller graph for this function:

◆ GetPropagate()

std::shared_ptr< FGPropagate > GetPropagate ( void  ) const

Returns the FGPropagate pointer.

Definition at line 274 of file FGFDMExec.cpp.

275{
276 return static_pointer_cast<FGPropagate>(Models[ePropagate]);
277}
+ Here is the caller graph for this function:

◆ GetPropertyCatalog()

std::vector< std::string > & GetPropertyCatalog ( void  )
inline

Definition at line 539 of file FGFDMExec.h.

539{return PropertyCatalog;}

◆ GetPropertyManager()

std::shared_ptr< FGPropertyManager > GetPropertyManager ( void  ) const
inline

Returns a pointer to the property manager object.

Definition at line 421 of file FGFDMExec.h.

421{ return instance; }
+ Here is the caller graph for this function:

◆ GetPropertyValue()

double GetPropertyValue ( const std::string &  property)
inline

Retrieves the value of a property.

Parameters
propertythe name of the property
Returns
the value of the specified property

Definition at line 408 of file FGFDMExec.h.

409 { return instance->GetNode()->getDoubleValue(property.c_str()); }

◆ GetPropulsion()

std::shared_ptr< FGPropulsion > GetPropulsion ( void  ) const

Returns the FGPropulsion pointer.

Definition at line 330 of file FGFDMExec.cpp.

331{
332 return static_pointer_cast<FGPropulsion>(Models[ePropulsion]);
333}
+ Here is the caller graph for this function:

◆ GetPropulsionTankReport()

string GetPropulsionTankReport ( ) const

Definition at line 1058 of file FGFDMExec.cpp.

1059{
1060 return Propulsion->GetPropulsionTankReport();
1061}

◆ GetRandomGenerator()

auto GetRandomGenerator ( void  ) const
inline

Definition at line 626 of file FGFDMExec.h.

626{ return RandomGenerator; }

◆ GetRootDir()

const SGPath & GetRootDir ( void  ) const
inline

Retrieve the Root Directory.

Returns
the path to the root (base) JSBSim directory.
See also
SetRootDir

Definition at line 590 of file FGFDMExec.h.

590{return RootDir;}

◆ GetScript()

std::shared_ptr< FGScript > GetScript ( void  ) const
inline

Retrieves the script object.

Definition at line 387 of file FGFDMExec.h.

387{return Script;}

◆ GetSimTime()

double GetSimTime ( void  ) const
inline

Returns the cumulative simulation time in seconds.

Definition at line 549 of file FGFDMExec.h.

549{ return sim_time; }
+ Here is the caller graph for this function:

◆ GetSystemsPath()

const SGPath & GetSystemsPath ( void  )
inline

Retrieves the systems path.

Definition at line 399 of file FGFDMExec.h.

399{ return SystemsPath; }

◆ GetTemplateFunc()

FGTemplateFunc_ptr GetTemplateFunc ( const std::string &  name)
inline

Definition at line 618 of file FGFDMExec.h.

618 {
619 return TemplateFunctions.count(name) ? TemplateFunctions[name] : nullptr;
620 }

◆ GetTrim()

std::shared_ptr< FGTrim > GetTrim ( void  )

Returns a pointer to the FGTrim object.

Definition at line 1261 of file FGFDMExec.cpp.

1262{
1263 Trim = std::make_shared<FGTrim>(this,tNone);
1264 return Trim;
1265}

◆ GetTrimMode()

int GetTrimMode ( void  ) const
inline

Definition at line 544 of file FGFDMExec.h.

544{ return ta_mode; }

◆ GetTrimStatus()

bool GetTrimStatus ( void  ) const
inline

Definition at line 542 of file FGFDMExec.h.

542{ return trim_status; }

◆ GetWinds()

std::shared_ptr< FGWinds > GetWinds ( void  ) const

Returns the FGWinds pointer.

Definition at line 302 of file FGFDMExec.cpp.

303{
304 return static_pointer_cast<FGWinds>(Models[eWinds]);
305}
+ Here is the caller graph for this function:

◆ Hold()

void Hold ( void  )
inline

Pauses execution by preventing time from incrementing.

Definition at line 488 of file FGFDMExec.h.

488{holding = true;}
+ Here is the caller graph for this function:

◆ Holding()

bool Holding ( void  )
inline

Returns true if the simulation is Holding (i.e. simulation time is not moving).

Definition at line 496 of file FGFDMExec.h.

496{return holding;}

◆ IncrTime()

double IncrTime ( void  )

Increments the simulation time if not in Holding mode.

The Frame counter is also incremented.

Returns
the new simulation time.

Definition at line 198 of file FGFDMExec.cpp.

198 {
199 if (!holding && !IntegrationSuspended()) {
200 sim_time += dT;
201 Inertial->SetTime(sim_time);
202 Frame++;
203 }
204 return sim_time;
205}
bool IntegrationSuspended(void) const
Returns the simulation suspension state.
Definition FGFDMExec.h:562
void SetTime(double time)
Set the simulation time.
Definition FGInertial.h:140
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Initialize()

void Initialize ( const FGInitialCondition FGIC)

Initializes the simulation with initial conditions.

Parameters
FGICThe initial conditions that will be passed to the simulation.

Definition at line 676 of file FGFDMExec.cpp.

677{
678 Propagate->SetInitialState(FGIC);
679 Winds->SetWindNED(FGIC->GetWindNEDFpsIC());
680 Run();
681}
virtual void SetWindNED(double wN, double wE, double wD)
Sets the wind components in NED frame.
Definition FGWinds.h:196
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IntegrationSuspended()

bool IntegrationSuspended ( void  ) const
inline

Returns the simulation suspension state.

Returns
true if suspended, false if executing

Definition at line 562 of file FGFDMExec.h.

562{return dT == 0.0;}
+ Here is the caller graph for this function:

◆ LoadModel() [1/2]

bool LoadModel ( const SGPath &  AircraftPath,
const SGPath &  EnginePath,
const SGPath &  SystemsPath,
const std::string &  model,
bool  addModelToPath = true 
)

Loads an aircraft model.

Parameters
AircraftPathpath to the aircraft/ directory. For instance: "aircraft". Under aircraft, then, would be directories for various modeled aircraft such as C172/, x15/, etc.
EnginePathpath to the directory under which engine config files are kept, for instance "engine"
SystemsPathpath to the directory under which systems config files are kept, for instance "systems"
modelthe name of the aircraft model itself. This file will be looked for in the directory specified in the AircraftPath variable, and in turn under the directory with the same name as the model. For instance: "aircraft/x15/x15.xml"
addModelToPathset to true to add the model name to the AircraftPath, defaults to true
Returns
true if successful

Definition at line 817 of file FGFDMExec.cpp.

820{
821 FGFDMExec::AircraftPath = GetFullPath(AircraftPath);
822 FGFDMExec::EnginePath = GetFullPath(EnginePath);
823 FGFDMExec::SystemsPath = GetFullPath(SystemsPath);
824
825 return LoadModel(model, addModelToPath);
826}
bool LoadModel(const SGPath &AircraftPath, const SGPath &EnginePath, const SGPath &SystemsPath, const std::string &model, bool addModelToPath=true)
Loads an aircraft model.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LoadModel() [2/2]

bool LoadModel ( const std::string &  model,
bool  addModelToPath = true 
)

Loads an aircraft model.

The paths to the aircraft and engine config file directories must be set prior to calling this. See below.

Parameters
modelthe name of the aircraft model itself. This file will be looked for in the directory specified in the AircraftPath variable, and in turn under the directory with the same name as the model. For instance: "aircraft/x15/x15.xml"
addModelToPathset to true to add the model name to the AircraftPath, defaults to true
Returns
true if successful

Definition at line 830 of file FGFDMExec.cpp.

831{
832 SGPath aircraftCfgFileName;
833 bool result = false; // initialize result to false, indicating input file not yet read
834
835 modelName = model; // Set the class modelName attribute
836
837 if( AircraftPath.isNull() || EnginePath.isNull() || SystemsPath.isNull()) {
838 cerr << "Error: attempted to load aircraft with undefined "
839 << "aircraft, engine, and system paths" << endl;
840 return false;
841 }
842
843 FullAircraftPath = AircraftPath;
844 if (addModelToPath) FullAircraftPath.append(model);
845 aircraftCfgFileName = FullAircraftPath/(model + ".xml");
846
847 if (modelLoaded) {
848 DeAllocate();
849 Allocate();
850 }
851
852 int saved_debug_lvl = debug_lvl;
853 FGXMLFileRead XMLFileRead;
854 Element *document = XMLFileRead.LoadXMLDocument(aircraftCfgFileName); // "document" is a class member
855
856 if (document) {
857 if (IsChild) debug_lvl = 0;
858
859 ReadPrologue(document);
860
861 if (IsChild) debug_lvl = saved_debug_lvl;
862
863 // Process the fileheader element in the aircraft config file. This element is OPTIONAL.
864 Element* element = document->FindElement("fileheader");
865 if (element) {
866 result = ReadFileHeader(element);
867 if (!result) {
868 cerr << endl << "Aircraft fileheader element has problems in file " << aircraftCfgFileName << endl;
869 return result;
870 }
871 }
872
873 if (IsChild) debug_lvl = 0;
874
875 // Process the planet element. This element is OPTIONAL.
876 element = document->FindElement("planet");
877 if (element) {
878 result = LoadPlanet(element);
879 if (!result) {
880 cerr << endl << "Planet element has problems in file " << aircraftCfgFileName << endl;
881 return result;
882 }
883 }
884
885 // Process the metrics element. This element is REQUIRED.
886 element = document->FindElement("metrics");
887 if (element) {
888 result = Models[eAircraft]->Load(element);
889 if (!result) {
890 cerr << endl << "Aircraft metrics element has problems in file " << aircraftCfgFileName << endl;
891 return result;
892 }
893 } else {
894 cerr << endl << "No metrics element was found in the aircraft config file." << endl;
895 return false;
896 }
897
898 // Process the mass_balance element. This element is REQUIRED.
899 element = document->FindElement("mass_balance");
900 if (element) {
901 result = Models[eMassBalance]->Load(element);
902 if (!result) {
903 cerr << endl << "Aircraft mass_balance element has problems in file " << aircraftCfgFileName << endl;
904 return result;
905 }
906 } else {
907 cerr << endl << "No mass_balance element was found in the aircraft config file." << endl;
908 return false;
909 }
910
911 // Process the ground_reactions element. This element is REQUIRED.
912 element = document->FindElement("ground_reactions");
913 if (element) {
914 result = Models[eGroundReactions]->Load(element);
915 if (!result) {
916 cerr << endl << element->ReadFrom()
917 << "Aircraft ground_reactions element has problems in file "
918 << aircraftCfgFileName << endl;
919 return result;
920 }
921 } else {
922 cerr << endl << "No ground_reactions element was found in the aircraft config file." << endl;
923 return false;
924 }
925
926 // Process the external_reactions element. This element is OPTIONAL.
927 element = document->FindElement("external_reactions");
928 if (element) {
929 result = Models[eExternalReactions]->Load(element);
930 if (!result) {
931 cerr << endl << "Aircraft external_reactions element has problems in file " << aircraftCfgFileName << endl;
932 return result;
933 }
934 }
935
936 // Process the buoyant_forces element. This element is OPTIONAL.
937 element = document->FindElement("buoyant_forces");
938 if (element) {
939 result = Models[eBuoyantForces]->Load(element);
940 if (!result) {
941 cerr << endl << "Aircraft buoyant_forces element has problems in file " << aircraftCfgFileName << endl;
942 return result;
943 }
944 }
945
946 // Process the propulsion element. This element is OPTIONAL.
947 element = document->FindElement("propulsion");
948 if (element) {
949 result = Propulsion->Load(element);
950 if (!result) {
951 cerr << endl << "Aircraft propulsion element has problems in file " << aircraftCfgFileName << endl;
952 return result;
953 }
954 for (unsigned int i=0; i < Propulsion->GetNumEngines(); i++)
955 FCS->AddThrottle();
956 }
957
958 // Process the system element[s]. This element is OPTIONAL, and there may be more than one.
959 element = document->FindElement("system");
960 while (element) {
961 result = Models[eSystems]->Load(element);
962 if (!result) {
963 cerr << endl << "Aircraft system element has problems in file " << aircraftCfgFileName << endl;
964 return result;
965 }
966 element = document->FindNextElement("system");
967 }
968
969 // Process the autopilot element. This element is OPTIONAL.
970 element = document->FindElement("autopilot");
971 if (element) {
972 result = Models[eSystems]->Load(element);
973 if (!result) {
974 cerr << endl << "Aircraft autopilot element has problems in file " << aircraftCfgFileName << endl;
975 return result;
976 }
977 }
978
979 // Process the flight_control element. This element is OPTIONAL.
980 element = document->FindElement("flight_control");
981 if (element) {
982 result = Models[eSystems]->Load(element);
983 if (!result) {
984 cerr << endl << "Aircraft flight_control element has problems in file " << aircraftCfgFileName << endl;
985 return result;
986 }
987 }
988
989 // Process the aerodynamics element. This element is OPTIONAL, but almost always expected.
990 element = document->FindElement("aerodynamics");
991 if (element) {
992 result = Models[eAerodynamics]->Load(element);
993 if (!result) {
994 cerr << endl << "Aircraft aerodynamics element has problems in file " << aircraftCfgFileName << endl;
995 return result;
996 }
997 } else {
998 cerr << endl << "No expected aerodynamics element was found in the aircraft config file." << endl;
999 }
1000
1001 // Process the input element. This element is OPTIONAL, and there may be more than one.
1002 element = document->FindElement("input");
1003 while (element) {
1004 if (!Input->Load(element))
1005 return false;
1006
1007 element = document->FindNextElement("input");
1008 }
1009
1010 // Process the output element[s]. This element is OPTIONAL, and there may be
1011 // more than one.
1012 element = document->FindElement("output");
1013 while (element) {
1014 if (!Output->Load(element))
1015 return false;
1016
1017 element = document->FindNextElement("output");
1018 }
1019
1020 // Lastly, process the child element. This element is OPTIONAL - and NOT YET SUPPORTED.
1021 element = document->FindElement("child");
1022 if (element) {
1023 result = ReadChild(element);
1024 if (!result) {
1025 cerr << endl << "Aircraft child element has problems in file " << aircraftCfgFileName << endl;
1026 return result;
1027 }
1028 }
1029
1030 // Since all vehicle characteristics have been loaded, place the values in the Inputs
1031 // structure for the FGModel-derived classes.
1032 LoadModelConstants();
1033
1034 modelLoaded = true;
1035
1036 if (IsChild) debug_lvl = saved_debug_lvl;
1037
1038 } else {
1039 cerr << fgred
1040 << " JSBSim failed to open the configuration file: " << aircraftCfgFileName
1041 << fgdef << endl;
1042 }
1043
1044 for (unsigned int i=0; i< Models.size(); i++) LoadInputs(i);
1045
1046 if (result) {
1047 struct PropertyCatalogStructure masterPCS;
1048 masterPCS.base_string = "";
1049 masterPCS.node = Root;
1050 BuildPropertyCatalog(&masterPCS);
1051 }
1052
1053 return result;
1054}
bool LoadPlanet(const SGPath &PlanetPath, bool useAircraftPath=true)
Loads the planet.
bool Load(Element *el) override
Load the input directives and adds a new input instance to the Input Manager list.
Definition FGInput.cpp:77
static char fgred[6]
red text
Definition FGJSBBase.h:166
static char fgdef[6]
default text
Definition FGJSBBase.h:170
bool Load(Element *el, const SGPath &dir)
Load the output directives and adds a new output instance to the Output Manager list.
Definition FGOutput.cpp:239
bool Load(Element *el) override
Loads the propulsion system (engine[s] and tank[s]).
size_t GetNumEngines(void) const
Retrieves the number of engines defined for the aircraft.
+ Here is the call graph for this function:

◆ LoadPlanet()

bool LoadPlanet ( const SGPath &  PlanetPath,
bool  useAircraftPath = true 
)

Loads the planet.

Loads the definition of the planet on which the vehicle will evolve such as its radius, gravity or its atmosphere characteristics.

Parameters
PlanetPathThe name of a planet definition file
useAircraftPathtrue if path is given relative to the aircraft path.
Returns
true if successful

Definition at line 741 of file FGFDMExec.cpp.

742{
743 SGPath PlanetFileName;
744
745 if(useAircraftPath && PlanetPath.isRelative()) {
746 PlanetFileName = AircraftPath/PlanetPath.utf8Str();
747 } else {
748 PlanetFileName = PlanetPath;
749 }
750
751 FGXMLFileRead XMLFileRead;
752 Element* document = XMLFileRead.LoadXMLDocument(PlanetFileName);
753
754 // Make sure that the document is valid
755 if (!document) {
756 stringstream s;
757 s << "File: " << PlanetFileName << " could not be read.";
758 cerr << s.str() << endl;
759 throw BaseException(s.str());
760 }
761
762 if (document->GetName() != "planet") {
763 stringstream s;
764 s << "File: " << PlanetFileName << " is not a planet file.";
765 cerr << s.str() << endl;
766 throw BaseException(s.str());
767 }
768
769 bool result = LoadPlanet(document);
770
771 if (!result)
772 cerr << endl << "Planet element has problems in file " << PlanetFileName << endl;
773
774 return result;
775}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LoadScript()

bool LoadScript ( const SGPath &  Script,
double  deltaT = 0.0,
const SGPath &  initfile = SGPath() 
)

Load a script.

Parameters
ScriptThe full path name and file name for the script to be loaded.
deltaTThe simulation integration step size, if given. If no value is supplied then 0.0 is used and the value is expected to be supplied in the script file itself.
initfileThe initialization file that will override the initialization file specified in the script file. If no file name is given on the command line, the file specified in the script will be used. If an initialization file is not given in either place, an error will result.
Returns
true if successfully loads; false otherwise.

Definition at line 732 of file FGFDMExec.cpp.

734{
735 Script = std::make_shared<FGScript>(this);
736 return Script->LoadScript(GetFullPath(script), deltaT, initfile);
737}

◆ PrintPropertyCatalog()

void PrintPropertyCatalog ( void  )

Definition at line 1104 of file FGFDMExec.cpp.

1105{
1106 cout << endl;
1107 cout << " " << fgblue << highint << underon << "Property Catalog for "
1108 << modelName << reset << endl << endl;
1109 for (auto &catalogElm: PropertyCatalog)
1110 cout << " " << catalogElm << endl;
1111}
static char fgblue[6]
blue text
Definition FGJSBBase.h:162
static char underon[5]
underlines text
Definition FGJSBBase.h:158
static char reset[5]
resets text properties
Definition FGJSBBase.h:156
static char highint[5]
highlights text
Definition FGJSBBase.h:150

◆ PrintSimulationConfiguration()

void PrintSimulationConfiguration ( void  ) const

Definition at line 1115 of file FGFDMExec.cpp.

1116{
1117 cout << endl << "Simulation Configuration" << endl << "------------------------" << endl;
1118 cout << MassBalance->GetName() << endl;
1119 cout << GroundReactions->GetName() << endl;
1120 cout << Aerodynamics->GetName() << endl;
1121 cout << Propulsion->GetName() << endl;
1122}

◆ QueryPropertyCatalog()

string QueryPropertyCatalog ( const std::string &  check,
const std::string &  end_of_line = "\n" 
)

Retrieves property or properties matching the supplied string.

A string is returned that contains a carriage return delimited list of all strings in the property catalog that matches the supplied check string.

Parameters
checkThe string to search for in the property catalog.
end_of_lineEnd of line (CR+LF if needed for Windows).
Returns
the carriage-return-delimited string containing all matching strings in the catalog.

Definition at line 1092 of file FGFDMExec.cpp.

1093{
1094 string results;
1095 for (auto &catalogElm: PropertyCatalog) {
1096 if (catalogElm.find(in) != string::npos) results += catalogElm + end_of_line;
1097 }
1098 if (results.empty()) return "No matches found"+end_of_line;
1099 return results;
1100}
+ Here is the caller graph for this function:

◆ ResetToInitialConditions()

void ResetToInitialConditions ( int  mode)

Resets the initial conditions object and prepares the simulation to run again.

If the mode's first bit is set the output instances will take special actions such as closing the current output file and open a new one with a different name. If the second bit is set then RunIC() won't be executed, leaving it to the caller to call RunIC(), e.g. in case the caller wants to set some other state like control surface deflections which would've been reset.

Parameters
modeSets the reset mode.

Definition at line 685 of file FGFDMExec.cpp.

686{
687 if (Constructing) return;
688
689 // mode flags
690
691 if (mode & START_NEW_OUTPUT) Output->SetStartNewOutput();
692
693 InitializeModels();
694
695 if (Script)
696 Script->ResetEvents();
697 else
698 Setsim_time(0.0);
699
700 if (!(mode & DONT_EXECUTE_RUN_IC))
701 RunIC();
702}
static const int START_NEW_OUTPUT
Mode flags for ResetToInitialConditions.
Definition FGFDMExec.h:498
double Setsim_time(double cur_time)
Sets the current sim time.
bool RunIC(void)
Initializes the sim from the initial condition object and executes each scheduled model without integ...
void SetStartNewOutput(void)
Reset the output prior to a restart of the simulation.
Definition FGOutput.cpp:118
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Resume()

void Resume ( void  )
inline

Resumes execution from a "Hold".

Definition at line 494 of file FGFDMExec.h.

494{holding = false;}
+ Here is the caller graph for this function:

◆ ResumeIntegration()

void ResumeIntegration ( void  )
inline

Resumes the simulation by resetting delta T to the correct value.

Definition at line 558 of file FGFDMExec.h.

558{dT = saved_dT;}
+ Here is the caller graph for this function:

◆ Run()

bool Run ( void  )

This function executes each scheduled model in succession.

Returns
true if successful, false if sim should be ended

Definition at line 409 of file FGFDMExec.cpp.

410{
411 bool success=true;
412
413 Debug(2);
414
415 for (auto &ChildFDM: ChildFDMList) {
416 ChildFDM->AssignState(Propagate); // Transfer state to the child FDM
417 ChildFDM->Run();
418 }
419
420 IncrTime();
421
422 // returns true if success, false if complete
423 if (Script && !IntegrationSuspended()) success = Script->RunScript();
424
425 for (unsigned int i = 0; i < Models.size(); i++) {
426 LoadInputs(i);
427 Models[i]->Run(holding);
428 }
429
430 if (Terminate) success = false;
431
432 return success;
433}
double IncrTime(void)
Increments the simulation time if not in Holding mode.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RunIC()

bool RunIC ( void  )

Initializes the sim from the initial condition object and executes each scheduled model without integrating i.e.

dt=0.

Returns
true if successful

Definition at line 639 of file FGFDMExec.cpp.

640{
641 SuspendIntegration(); // saves the integration rate, dt, then sets it to 0.0.
642 Initialize(IC.get());
643
644 Models[eInput]->InitModel();
645 Models[eOutput]->InitModel();
646
647 Run();
648 Propagate->InitializeDerivatives();
649 ResumeIntegration(); // Restores the integration rate to what it was.
650
651 if (debug_lvl > 0) {
652 MassBalance->GetMassPropertiesReport(0);
653
654 cout << endl << fgblue << highint
655 << "End of vehicle configuration loading." << endl
656 << "-------------------------------------------------------------------------------"
657 << reset << std::setprecision(6) << endl;
658 }
659
660 for (unsigned int n=0; n < Propulsion->GetNumEngines(); ++n) {
661 if (IC->IsEngineRunning(n)) {
662 try {
663 Propulsion->InitRunning(n);
664 } catch (const string& str) {
665 cerr << str << endl;
666 return false;
667 }
668 }
669 }
670
671 return true;
672}
void SuspendIntegration(void)
Suspends the simulation and sets the delta T to zero.
Definition FGFDMExec.h:555
void Initialize(const FGInitialCondition *FGIC)
Initializes the simulation with initial conditions.
void ResumeIntegration(void)
Resumes the simulation by resetting delta T to the correct value.
Definition FGFDMExec.h:558
void InitRunning(int n)
Sets up the engines as running.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetAircraftPath()

bool SetAircraftPath ( const SGPath &  path)
inline

Set the path to the aircraft config file directories.

Under this path, then, would be directories for various modeled aircraft such as C172/, x15/, etc. Relative paths are taken from the root directory.

Parameters
pathpath to the aircraft directory, for instance "aircraft".
See also
SetRootDir
GetAircraftPath

Definition at line 325 of file FGFDMExec.h.

325 {
326 AircraftPath = GetFullPath(path);
327 return true;
328 }

◆ SetChild()

void SetChild ( bool  ch)
inline

Marks this instance of the Exec object as a "child" object.

Definition at line 429 of file FGFDMExec.h.

429{IsChild = ch;}

◆ SetDebugLevel()

void SetDebugLevel ( int  level)
inline

Sets the debug level.

Definition at line 509 of file FGFDMExec.h.

509{debug_lvl = level;}
+ Here is the caller graph for this function:

◆ Setdt()

void Setdt ( double  delta_t)
inline

Sets the integration time step for the simulation executive.

Parameters
delta_tthe time step in seconds.

Definition at line 571 of file FGFDMExec.h.

571{ dT = delta_t; }
+ Here is the caller graph for this function:

◆ SetEnginePath()

bool SetEnginePath ( const SGPath &  path)
inline

Set the path to the engine config file directories.

Relative paths are taken from the root directory.

Parameters
pathpath to the directory under which engine config files are kept, for instance "engine".
See also
SetRootDir
GetEnginePath

Definition at line 313 of file FGFDMExec.h.

313 {
314 EnginePath = GetFullPath(path);
315 return true;
316 }

◆ SetHoldDown()

void SetHoldDown ( bool  hd)

Sets the property forces/hold-down.

This allows to do hard 'hold-down' such as for rockets on a launch pad with engines ignited.

Parameters
hdenables the 'hold-down' function if non-zero

Definition at line 706 of file FGFDMExec.cpp.

707{
708 HoldDown = hd;
709 Accelerations->SetHoldDown(hd);
710 if (hd) {
711 Propagate->in.vPQRidot = Accelerations->GetPQRidot();
712 Propagate->in.vUVWidot = Accelerations->GetUVWidot();
713 }
714 Propagate->SetHoldDown(hd);
715}
const FGColumnVector3 & GetUVWidot(void) const
Retrieves the body axis acceleration in the ECI frame.
const FGColumnVector3 & GetPQRidot(void) const
Retrieves the axis angular acceleration vector in the ECI frame.
void SetHoldDown(bool hd)
Sets the property forces/hold-down.
void SetHoldDown(bool hd)
Sets the property forces/hold-down.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetLoggingRate()

void SetLoggingRate ( double  rate)
inline

Sets the logging rate in Hz for all output objects (if any).

Definition at line 453 of file FGFDMExec.h.

453{ Output->SetRateHz(rate); }
void SetRateHz(double rate)
Modifies the output rate for all output instances.
Definition FGOutput.cpp:136

◆ SetOutputDirectives()

bool SetOutputDirectives ( const SGPath &  fname)
inline

Sets the output (logging) mechanism for this run.

Calling this function passes the name of an output directives file to the FGOutput object associated with this run. The call to this function should be made prior to loading an aircraft model. This call results in an FGOutput object being built as the first Output object in the FDMExec-managed list of Output objects that may be created for an aircraft model. If this call is made after an aircraft model is loaded, there is no effect. Any Output objects added by the aircraft model itself (in an <output> element) will be added after this one. Care should be taken not to refer to the same file name. An output directives file contains an <output> </output> element, within which should be specified the parameters or parameter groups that should be logged.

Parameters
fnamethe filename of an output directives file.

Definition at line 446 of file FGFDMExec.h.

447 { return Output->SetDirectivesFile(GetFullPath(fname)); }
bool SetDirectivesFile(const SGPath &fname)
Adds a new output instance to the Output Manager.
Definition FGOutput.cpp:173

◆ SetOutputFileName()

bool SetOutputFileName ( const int  n,
const std::string &  fname 
)
inline

Sets (or overrides) the output filename.

Parameters
nindex of file
fnamethe name of the file to output data to
Returns
true if successful, false if there is no output specified for the flight model

Definition at line 459 of file FGFDMExec.h.

459{ return Output->SetOutputName(n, fname); }
bool SetOutputName(unsigned int idx, const std::string &name)
Overwrites the name identifier under which the output will be logged.
Definition FGOutput.cpp:152

◆ SetOutputPath()

bool SetOutputPath ( const SGPath &  path)
inline

Set the directory where the output files will be written.

Relative paths are taken from the root directory.

Parameters
pathpath to the directory under which the output files will be written.
See also
SetRootDir
GetOutputPath

Definition at line 347 of file FGFDMExec.h.

347 {
348 OutputPath = GetFullPath(path);
349 return true;
350 }

◆ SetPropertyValue()

void SetPropertyValue ( const std::string &  property,
double  value 
)
inline

Sets a property value.

Parameters
propertythe property to be set
valuethe value to set the property to

Definition at line 414 of file FGFDMExec.h.

415 { instance->GetNode()->setDoubleValue(property.c_str(), value); }

◆ SetRootDir()

void SetRootDir ( const SGPath &  rootDir)
inline

Set the root directory that is used to obtain absolute paths from relative paths.

Aircraft, engine, systems and output paths are not updated by this method. You must call each methods (SetAircraftPath(), SetEnginePath(), etc.) individually if you need to update these paths as well.

Parameters
rootDirthe path to the root directory.
See also
GetRootDir
SetAircraftPath
SetEnginePath
SetSystemsPath
SetOutputPath

Definition at line 585 of file FGFDMExec.h.

585{RootDir = rootDir;}

◆ Setsim_time()

double Setsim_time ( double  cur_time)

Sets the current sim time.

Parameters
cur_timethe current time
Returns
the current simulation time.

Definition at line 190 of file FGFDMExec.cpp.

190 {
191 sim_time = cur_time;
192 Inertial->SetTime(sim_time);
193 return sim_time;
194}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetSystemsPath()

bool SetSystemsPath ( const SGPath &  path)
inline

Set the path to the systems config file directories.

Relative paths are taken from the root directory.

Parameters
pathpath to the directory under which systems config files are kept, for instance "systems"
See also
SetRootDir
GetSystemsPath

Definition at line 336 of file FGFDMExec.h.

336 {
337 SystemsPath = GetFullPath(path);
338 return true;
339 }

◆ SetTrimMode()

void SetTrimMode ( int  mode)
inline

Definition at line 543 of file FGFDMExec.h.

543{ ta_mode = mode; }

◆ SetTrimStatus()

void SetTrimStatus ( bool  status)
inline

Definition at line 541 of file FGFDMExec.h.

541{ trim_status = status; }

◆ SRand()

int SRand ( void  ) const
inline

Definition at line 628 of file FGFDMExec.h.

628{ return RandomSeed; }

◆ SuspendIntegration()

void SuspendIntegration ( void  )
inline

Suspends the simulation and sets the delta T to zero.

Definition at line 555 of file FGFDMExec.h.

555{saved_dT = dT; dT = 0.0;}
+ Here is the caller graph for this function:

◆ Unbind()

void Unbind ( void  )
inline

Unbind all tied JSBSim properties.

Definition at line 243 of file FGFDMExec.h.

243{instance->Unbind();}
+ Here is the caller graph for this function:

Member Data Documentation

◆ DONT_EXECUTE_RUN_IC

const int DONT_EXECUTE_RUN_IC = 0x2
static

Definition at line 499 of file FGFDMExec.h.

◆ START_NEW_OUTPUT

const int START_NEW_OUTPUT = 0x1
static

Mode flags for ResetToInitialConditions.

Definition at line 498 of file FGFDMExec.h.


The documentation for this class was generated from the following files: