JSBSim Flight Dynamics Model 1.3.3 (16 Oct 2026)
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:185

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 184 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 DisableInput (void)
 Disables input from all inputs.
 
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 EnableInput (void)
 Enables input from all inputs.
 
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< FGPropertyManager > GetPropertyManager (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< FGAtmosphere > GetAtmosphere (void) const
 
std::shared_ptr< FGAccelerations > GetAccelerations (void) const
 Returns the FGAccelerations pointer.
 
std::shared_ptr< FGWinds > GetWinds (void) const
 Returns the FGWinds pointer.
 
std::shared_ptr< FGFCS > GetFCS (void) const
 Returns the FGFCS pointer.
 
std::shared_ptr< FGPropulsion > GetPropulsion (void) const
 Returns the FGPropulsion pointer.
 
std::shared_ptr< FGMassBalance > GetMassBalance (void) const
 Returns the FGAircraft pointer.
 
std::shared_ptr< FGAerodynamics > GetAerodynamics (void) const
 Returns the FGAerodynamics pointer.
 
std::shared_ptr< FGInertial > GetInertial (void) const
 Returns the FGInertial pointer.
 
std::shared_ptr< FGGroundReactions > GetGroundReactions (void) const
 Returns the FGGroundReactions pointer.
 
std::shared_ptr< FGExternalReactions > GetExternalReactions (void) const
 Returns the FGExternalReactions pointer.
 
std::shared_ptr< FGBuoyantForces > GetBuoyantForces (void) const
 Returns the FGBuoyantForces pointer.
 
std::shared_ptr< FGAircraft > GetAircraft (void) const
 Returns the FGAircraft pointer.
 
std::shared_ptr< FGPropagate > GetPropagate (void) const
 Returns the FGPropagate pointer.
 
std::shared_ptr< FGAuxiliary > GetAuxiliary (void) const
 Returns the FGAuxiliary pointer.
 
std::shared_ptr< FGInput > GetInput (void) const
 Returns the FGInput pointer.
 
std::shared_ptr< FGOutput > GetOutput (void) const
 Returns the FGOutput pointer.
 
std::shared_ptr< FGScript > GetScript (void) const
 Retrieves the script object.
 
std::shared_ptr< FGInitialCondition > GetIC (void) const
 Returns a pointer to the FGInitialCondition object.
 
std::shared_ptr< FGTrim > GetTrim (void)
 Returns a pointer to the FGTrim object.
 
- Public Member Functions inherited from FGJSBBase
 FGJSBBase ()
 Constructor for FGJSBBase.
 
virtual ~FGJSBBase ()
 Destructor for FGJSBBase.
 

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 short debug_lvl = 1
 

Additional Inherited Members

- Static Public Member Functions inherited from FGJSBBase
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 CelsiusToRankine (double celsius)
 Converts from degrees Celsius to degrees Rankine.
 
static constexpr double Constrain (double min, double value, double max)
 Constrain a value between a minimum and a maximum value.
 
static bool EqualToRoundoff (double a, double b)
 Finite precision comparison.
 
static bool EqualToRoundoff (double a, float b)
 Finite precision comparison.
 
static bool EqualToRoundoff (float a, double b)
 Finite precision comparison.
 
static bool EqualToRoundoff (float a, float b)
 Finite precision comparison.
 
static constexpr double FahrenheitToCelsius (double fahrenheit)
 Converts from degrees Fahrenheit to degrees Celsius.
 
static constexpr double FeetToMeters (double measure)
 Converts from feet to meters.
 
static const std::string & GetVersion (void)
 Returns the version number of JSBSim.
 
static constexpr double KelvinToCelsius (double kelvin)
 Converts from degrees Kelvin to degrees Celsius.
 
static constexpr double KelvinToFahrenheit (double kelvin)
 Converts from degrees Kelvin to degrees Fahrenheit.
 
static constexpr double KelvinToRankine (double kelvin)
 Converts from degrees Kelvin to degrees Rankine.
 
static constexpr double RankineToCelsius (double rankine)
 Converts from degrees Rankine to degrees Celsius.
 
static constexpr double RankineToKelvin (double rankine)
 Converts from degrees Rankine to degrees Kelvin.
 
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 degtorad = M_PI / 180.
 
static constexpr double fpstokts = 1.0 / ktstofps
 
static constexpr double fttom = 0.3048
 
static constexpr double hptoftlbssec = 550.0
 
static constexpr double in3tom3 = inchtoft*inchtoft*inchtoft/m3toft3
 
static constexpr double inchtoft = 1.0/12.0
 
static constexpr double inhgtopa = 3386.38
 
static const std::string JSBSim_version = JSBSIM_VERSION " " __DATE__ " " __TIME__
 
static constexpr double kgtolb = 2.20462
 
static constexpr double kgtoslug = 0.06852168
 
static constexpr double ktstofps = 1852./(3600*fttom)
 
static constexpr double lbtoslug = 1.0/slugtolb
 
static constexpr double m3toft3 = 1.0/(fttom*fttom*fttom)
 
static const std::string needed_cfg_version = "2.0"
 
static constexpr double psftoinhg = 0.014138
 
static constexpr double psftopa = 47.88
 
static constexpr double radtodeg = 180. / M_PI
 
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.
 

Member Enumeration Documentation

◆ eModels

enum eModels

Definition at line 225 of file FGFDMExec.h.

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

Constructor & Destructor Documentation

◆ FGFDMExec()

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

Default constructor.

Definition at line 82 of file FGFDMExec.cpp.

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

◆ ~FGFDMExec()

~FGFDMExec ( )

Default destructor.

Definition at line 170 of file FGFDMExec.cpp.

171{
172 try {
173 Unbind();
174 DeAllocate();
175 } catch (const string& msg ) {
176 FGLogging log(LogLevel::FATAL);
177 log << "Caught error: " << msg << endl;
178 }
179
180 if (FDMctr) (*FDMctr)--;
181
182 Debug(1);
183}
void Unbind(void)
Unbind all tied JSBSim properties.
Definition FGFDMExec.h:244
+ Here is the call graph for this function:

Member Function Documentation

◆ AddTemplateFunc()

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

Definition at line 627 of file FGFDMExec.h.

627 {
628 TemplateFunctions[name] = std::make_shared<FGTemplateFunc>(this, el);
629 }

◆ 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 1095 of file FGFDMExec.cpp.

1096{
1097 auto pcsNew = std::make_unique<struct PropertyCatalogStructure>();
1098 const SGPropertyNode* root_node = instance->GetNode();
1099 const string root_name = GetFullyQualifiedName(root_node) + "/";
1100 const size_t root_name_length = root_name.length();
1101
1102 for (int i=0; i<pcs->node->nChildren(); i++) {
1103 string access="";
1104 pcsNew->base_string = pcs->base_string + "/" + pcs->node->getChild(i)->getNameString();
1105 int node_idx = pcs->node->getChild(i)->getIndex();
1106 if (node_idx != 0) {
1107 pcsNew->base_string = CreateIndexedPropertyName(pcsNew->base_string, node_idx);
1108 }
1109 if (pcs->node->getChild(i)->nChildren() == 0) {
1110 if (pcsNew->base_string.substr(0, root_name_length) == root_name) {
1111 pcsNew->base_string = pcsNew->base_string.erase(0, root_name_length);
1112 }
1113 if (pcs->node->getChild(i)->getAttribute(SGPropertyNode::READ)) access="R";
1114 if (pcs->node->getChild(i)->getAttribute(SGPropertyNode::WRITE)) access+="W";
1115 PropertyCatalog.push_back(pcsNew->base_string+" ("+access+")");
1116 } else {
1117 pcsNew->node = pcs->node->getChild(i);
1118 BuildPropertyCatalog(pcsNew.get());
1119 }
1120 }
1121}
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 1318 of file FGFDMExec.cpp.

1319{
1320 // Only check if increment then hold is on
1321 if( IncrementThenHolding ) {
1322
1323 if (TimeStepsUntilHold == 0) {
1324
1325 // Should hold simulation if TimeStepsUntilHold has reached zero
1326 holding = true;
1327
1328 // Still need to decrement TimeStepsUntilHold as value of -1
1329 // indicates that incremental then hold is turned off
1330 IncrementThenHolding = false;
1331 TimeStepsUntilHold--;
1332
1333 } else if ( TimeStepsUntilHold > 0 ) {
1334 // Keep decrementing until 0 is reached
1335 TimeStepsUntilHold--;
1336 }
1337 }
1338}

◆ DisableInput()

void DisableInput ( void  )
inline

Disables input from all inputs.

Definition at line 489 of file FGFDMExec.h.

489{ Input->Disable(); }
void Disable(void)
Disables the input generation for all input instances.
Definition FGInput.cpp:215

◆ DisableOutput()

void DisableOutput ( void  )
inline

Disables data logging to all outputs.

Definition at line 485 of file FGFDMExec.h.

485{ 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 1363 of file FGFDMExec.cpp.

1364{
1365 double dt0 = this->GetDeltaT();
1366 FGLinearization lin(this);
1367 lin.WriteScicoslab();
1368 this->Setdt(dt0);
1369}
void Setdt(double delta_t)
Sets the integration time step for the simulation executive.
Definition FGFDMExec.h:576
+ 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 1342 of file FGFDMExec.cpp.

1343{
1344 if (Constructing) return;
1345
1346 if (mode < 0 || mode > JSBSim::tNone)
1347 throw TrimFailureException("Illegal trimming mode!");
1348
1349 FGTrim trim(this, (JSBSim::TrimMode)mode);
1350 bool success = trim.DoTrim();
1351
1352 if (debug_lvl > 0)
1353 trim.Report();
1354
1355 if (!success)
1356 throw TrimFailureException("Trim Failed");
1357
1358 trim_completed = 1;
1359}
+ Here is the caller graph for this function:

◆ EnableIncrementThenHold()

void EnableIncrementThenHold ( int  Timesteps)
inline

Turn on hold after increment.

Definition at line 495 of file FGFDMExec.h.

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

◆ EnableInput()

void EnableInput ( void  )
inline

Enables input from all inputs.

Definition at line 491 of file FGFDMExec.h.

491{ Input->Enable(); }
void Enable(void)
Enables the input generation for all input instances.
Definition FGInput.cpp:207

◆ EnableOutput()

void EnableOutput ( void  )
inline

Enables data logging to all outputs.

Definition at line 487 of file FGFDMExec.h.

487{ 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 451 of file FGFDMExec.h.

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

◆ GetAccelerations()

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

Returns the FGAccelerations pointer.

Definition at line 369 of file FGFDMExec.cpp.

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

◆ GetAerodynamics()

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

Returns the FGAerodynamics pointer.

Definition at line 334 of file FGFDMExec.cpp.

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

◆ GetAircraft()

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

Returns the FGAircraft pointer.

Definition at line 362 of file FGFDMExec.cpp.

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

◆ GetAircraftPath()

const SGPath & GetAircraftPath ( void  )
inline

Retrieves the aircraft path.

Definition at line 398 of file FGFDMExec.h.

398{ return AircraftPath; }

◆ GetAtmosphere()

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

Definition at line 292 of file FGFDMExec.cpp.

293{
294 return static_pointer_cast<FGAtmosphere>(Models[eAtmosphere]);
295}

◆ GetAuxiliary()

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

Returns the FGAuxiliary pointer.

Definition at line 320 of file FGFDMExec.cpp.

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

◆ GetBuoyantForces()

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

Returns the FGBuoyantForces pointer.

Definition at line 355 of file FGFDMExec.cpp.

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

◆ GetChildFDM()

auto GetChildFDM ( int  i) const
inline

Gets a particular child FDM.

Definition at line 428 of file FGFDMExec.h.

428{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 606 of file FGFDMExec.h.

606{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 557 of file FGFDMExec.h.

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

◆ GetEnginePath()

const SGPath & GetEnginePath ( void  )
inline

Retrieves the engine path.

Definition at line 396 of file FGFDMExec.h.

396{ return EnginePath; }

◆ GetExternalReactions()

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

Returns the FGExternalReactions pointer.

Definition at line 348 of file FGFDMExec.cpp.

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

◆ GetFCS()

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

Returns the FGFCS pointer.

Definition at line 306 of file FGFDMExec.cpp.

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

◆ GetFDMCount()

size_t GetFDMCount ( void  ) const
inline

Gets the number of child FDMs.

Definition at line 426 of file FGFDMExec.h.

426{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 603 of file FGFDMExec.h.

603{return Frame;}

◆ GetFullAircraftPath()

const SGPath & GetFullAircraftPath ( void  )
inline

Retrieves the full aircraft path name.

Definition at line 402 of file FGFDMExec.h.

402{ 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 341 of file FGFDMExec.cpp.

342{
343 return static_pointer_cast<FGGroundReactions>(Models[eGroundReactions]);
344}
+ 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 621 of file FGFDMExec.h.

621{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 390 of file FGFDMExec.h.

390{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 278 of file FGFDMExec.cpp.

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

◆ GetInput()

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

Returns the FGInput pointer.

Definition at line 285 of file FGFDMExec.cpp.

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

◆ GetMassBalance()

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

Returns the FGAircraft pointer.

Definition at line 313 of file FGFDMExec.cpp.

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

◆ GetModelName()

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

Returns the model name.

Definition at line 419 of file FGFDMExec.h.

419{ return modelName; }

◆ GetOutput()

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

Returns the FGOutput pointer.

Definition at line 376 of file FGFDMExec.cpp.

377{
378 return static_pointer_cast<FGOutput>(Models[eOutput]);
379}
+ 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 466 of file FGFDMExec.h.

466{ 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:160

◆ GetOutputPath()

const SGPath & GetOutputPath ( void  )
inline

Retrieves the path to the output files.

Definition at line 404 of file FGFDMExec.h.

404{ 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 271 of file FGFDMExec.cpp.

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

◆ GetPropertyCatalog()

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

Definition at line 544 of file FGFDMExec.h.

544{return PropertyCatalog;}

◆ GetPropertyManager()

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

Returns a pointer to the property manager object.

Definition at line 422 of file FGFDMExec.h.

422{ 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 409 of file FGFDMExec.h.

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

◆ GetPropulsion()

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

Returns the FGPropulsion pointer.

Definition at line 327 of file FGFDMExec.cpp.

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

◆ GetPropulsionTankReport()

string GetPropulsionTankReport ( ) const

Definition at line 1088 of file FGFDMExec.cpp.

1089{
1090 return Propulsion->GetPropulsionTankReport();
1091}

◆ GetRandomGenerator()

auto GetRandomGenerator ( void  ) const
inline

Definition at line 631 of file FGFDMExec.h.

631{ 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 595 of file FGFDMExec.h.

595{return RootDir;}

◆ GetScript()

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

Retrieves the script object.

Definition at line 388 of file FGFDMExec.h.

388{return Script;}

◆ GetSimTime()

double GetSimTime ( void  ) const
inline

Returns the cumulative simulation time in seconds.

Definition at line 554 of file FGFDMExec.h.

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

◆ GetSystemsPath()

const SGPath & GetSystemsPath ( void  )
inline

Retrieves the systems path.

Definition at line 400 of file FGFDMExec.h.

400{ return SystemsPath; }

◆ GetTemplateFunc()

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

Definition at line 623 of file FGFDMExec.h.

623 {
624 return TemplateFunctions.count(name) ? TemplateFunctions[name] : nullptr;
625 }

◆ GetTrim()

std::shared_ptr< FGTrim > GetTrim ( void  )

Returns a pointer to the FGTrim object.

Definition at line 1310 of file FGFDMExec.cpp.

1311{
1312 Trim = std::make_shared<FGTrim>(this,tNone);
1313 return Trim;
1314}

◆ GetTrimMode()

int GetTrimMode ( void  ) const
inline

Definition at line 549 of file FGFDMExec.h.

549{ return ta_mode; }

◆ GetTrimStatus()

bool GetTrimStatus ( void  ) const
inline

Definition at line 547 of file FGFDMExec.h.

547{ return trim_status; }

◆ GetWinds()

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

Returns the FGWinds pointer.

Definition at line 299 of file FGFDMExec.cpp.

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

◆ Hold()

void Hold ( void  )
inline

Pauses execution by preventing time from incrementing.

Definition at line 493 of file FGFDMExec.h.

493{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 501 of file FGFDMExec.h.

501{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 195 of file FGFDMExec.cpp.

195 {
196 if (!holding && !IntegrationSuspended()) {
197 sim_time += dT;
198 Inertial->SetTime(sim_time);
199 Frame++;
200 }
201 return sim_time;
202}
bool IntegrationSuspended(void) const
Returns the simulation suspension state.
Definition FGFDMExec.h:567
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 675 of file FGFDMExec.cpp.

676{
677 Propagate->SetInitialState(FGIC);
678 Winds->SetWindNED(FGIC->GetWindNEDFpsIC());
679 Auxiliary->SetInitialState(FGIC);
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 567 of file FGFDMExec.h.

567{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 828 of file FGFDMExec.cpp.

831{
832 FGFDMExec::AircraftPath = GetFullPath(AircraftPath);
833 FGFDMExec::EnginePath = GetFullPath(EnginePath);
834 FGFDMExec::SystemsPath = GetFullPath(SystemsPath);
835
836 return LoadModel(model, addModelToPath);
837}
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 841 of file FGFDMExec.cpp.

842{
843 SGPath aircraftCfgFileName;
844 bool result = false; // initialize result to false, indicating input file not yet read
845
846 modelName = model; // Set the class modelName attribute
847
848 if( AircraftPath.isNull() || EnginePath.isNull() || SystemsPath.isNull()) {
849 FGLogging log(LogLevel::ERROR);
850 log << "Error: attempted to load aircraft with undefined "
851 << "aircraft, engine, and system paths" << endl;
852 return false;
853 }
854
855 FullAircraftPath = AircraftPath;
856 if (addModelToPath) FullAircraftPath.append(model);
857 aircraftCfgFileName = FullAircraftPath/(model + ".xml");
858
859 if (modelLoaded) {
860 DeAllocate();
861 Allocate();
862 }
863
864 int saved_debug_lvl = debug_lvl;
865 FGXMLFileRead XMLFileRead;
866 Element *document = XMLFileRead.LoadXMLDocument(aircraftCfgFileName); // "document" is a class member
867
868 if (document) {
869 if (IsChild) debug_lvl = 0;
870
871 ReadPrologue(document);
872
873 if (IsChild) debug_lvl = saved_debug_lvl;
874
875 // Process the fileheader element in the aircraft config file. This element is OPTIONAL.
876 Element* element = document->FindElement("fileheader");
877 if (element) {
878 result = ReadFileHeader(element);
879 if (!result) {
880 FGXMLLogging log(element, LogLevel::ERROR);
881 log << endl << "Aircraft fileheader element has problems in file " << aircraftCfgFileName << endl;
882 return result;
883 }
884 }
885
886 if (IsChild) debug_lvl = 0;
887
888 // Process the planet element. This element is OPTIONAL.
889 element = document->FindElement("planet");
890 if (element) {
891 result = LoadPlanet(element);
892 if (!result) {
893 FGXMLLogging log(element, LogLevel::ERROR);
894 log << endl << "Planet element has problems in file " << aircraftCfgFileName << endl;
895 return result;
896 }
897 }
898
899 // Process the metrics element. This element is REQUIRED.
900 element = document->FindElement("metrics");
901 if (element) {
902 result = Models[eAircraft]->Load(element);
903 if (!result) {
904 FGXMLLogging log(element, LogLevel::ERROR);
905 log << endl << "Aircraft metrics element has problems in file " << aircraftCfgFileName << endl;
906 return result;
907 }
908 } else {
909 FGLogging log(LogLevel::ERROR);
910 log << endl << "No metrics element was found in the aircraft config file." << endl;
911 return false;
912 }
913
914 // Process the mass_balance element. This element is REQUIRED.
915 element = document->FindElement("mass_balance");
916 if (element) {
917 result = Models[eMassBalance]->Load(element);
918 if (!result) {
919 FGXMLLogging log(element, LogLevel::ERROR);
920 log << endl << "Aircraft mass_balance element has problems in file " << aircraftCfgFileName << endl;
921 return result;
922 }
923 } else {
924 FGLogging log(LogLevel::ERROR);
925 log << endl << "No mass_balance element was found in the aircraft config file." << endl;
926 return false;
927 }
928
929 // Process the ground_reactions element. This element is REQUIRED.
930 element = document->FindElement("ground_reactions");
931 if (element) {
932 result = Models[eGroundReactions]->Load(element);
933 if (!result) {
934 FGXMLLogging log(element, LogLevel::ERROR);
935 log << endl
936 << "Aircraft ground_reactions element has problems in file "
937 << aircraftCfgFileName << endl;
938 return result;
939 }
940 } else {
941 FGLogging log(LogLevel::ERROR);
942 log << endl << "No ground_reactions element was found in the aircraft config file." << endl;
943 return false;
944 }
945
946 // Process the external_reactions element. This element is OPTIONAL.
947 element = document->FindElement("external_reactions");
948 if (element) {
949 result = Models[eExternalReactions]->Load(element);
950 if (!result) {
951 FGXMLLogging log(element, LogLevel::ERROR);
952 log << endl << "Aircraft external_reactions element has problems in file " << aircraftCfgFileName << endl;
953 return result;
954 }
955 }
956
957 // Process the buoyant_forces element. This element is OPTIONAL.
958 element = document->FindElement("buoyant_forces");
959 if (element) {
960 result = Models[eBuoyantForces]->Load(element);
961 if (!result) {
962 FGXMLLogging log(element, LogLevel::ERROR);
963 log << endl << "Aircraft buoyant_forces element has problems in file " << aircraftCfgFileName << endl;
964 return result;
965 }
966 }
967
968 // Process the propulsion element. This element is OPTIONAL.
969 element = document->FindElement("propulsion");
970 if (element) {
971 result = Propulsion->Load(element);
972 if (!result) {
973 FGXMLLogging log(element, LogLevel::ERROR);
974 log << endl << "Aircraft propulsion element has problems in file " << aircraftCfgFileName << endl;
975 return result;
976 }
977 for (unsigned int i=0; i < Propulsion->GetNumEngines(); i++)
978 FCS->AddThrottle();
979 }
980
981 // Process the system element[s]. This element is OPTIONAL, and there may be more than one.
982 element = document->FindElement("system");
983 while (element) {
984 result = Models[eSystems]->Load(element);
985 if (!result) {
986 FGXMLLogging log(element, LogLevel::ERROR);
987 log << endl << "Aircraft system element has problems in file " << aircraftCfgFileName << endl;
988 return result;
989 }
990 element = document->FindNextElement("system");
991 }
992
993 // Process the autopilot element. This element is OPTIONAL.
994 element = document->FindElement("autopilot");
995 if (element) {
996 result = Models[eSystems]->Load(element);
997 if (!result) {
998 FGXMLLogging log(element, LogLevel::ERROR);
999 log << endl << "Aircraft autopilot element has problems in file " << aircraftCfgFileName << endl;
1000 return result;
1001 }
1002 }
1003
1004 // Process the flight_control element. This element is OPTIONAL.
1005 element = document->FindElement("flight_control");
1006 if (element) {
1007 result = Models[eSystems]->Load(element);
1008 if (!result) {
1009 FGXMLLogging log(element, LogLevel::ERROR);
1010 log << endl << "Aircraft flight_control element has problems in file " << aircraftCfgFileName << endl;
1011 return result;
1012 }
1013 }
1014
1015 // Process the aerodynamics element. This element is OPTIONAL, but almost always expected.
1016 element = document->FindElement("aerodynamics");
1017 if (element) {
1018 result = Models[eAerodynamics]->Load(element);
1019 if (!result) {
1020 FGXMLLogging log(element, LogLevel::ERROR);
1021 log << endl << "Aircraft aerodynamics element has problems in file " << aircraftCfgFileName << endl;
1022 return result;
1023 }
1024 } else {
1025 FGLogging log(LogLevel::ERROR);
1026 log << endl << "No expected aerodynamics element was found in the aircraft config file." << endl;
1027 }
1028
1029 // Process the input element. This element is OPTIONAL, and there may be more than one.
1030 element = document->FindElement("input");
1031 while (element) {
1032 if (!Input->Load(element))
1033 return false;
1034
1035 element = document->FindNextElement("input");
1036 }
1037
1038 // Process the output element[s]. This element is OPTIONAL, and there may be
1039 // more than one.
1040 element = document->FindElement("output");
1041 while (element) {
1042 if (!Output->Load(element))
1043 return false;
1044
1045 element = document->FindNextElement("output");
1046 }
1047
1048 // Lastly, process the child element. This element is OPTIONAL - and NOT YET SUPPORTED.
1049 element = document->FindElement("child");
1050 if (element) {
1051 result = ReadChild(element);
1052 if (!result) {
1053 FGXMLLogging log(element, LogLevel::ERROR);
1054 log << endl << "Aircraft child element has problems in file " << aircraftCfgFileName << endl;
1055 return result;
1056 }
1057 }
1058
1059 // Since all vehicle characteristics have been loaded, place the values in the Inputs
1060 // structure for the FGModel-derived classes.
1061 LoadModelConstants();
1062
1063 modelLoaded = true;
1064
1065 if (IsChild) debug_lvl = saved_debug_lvl;
1066
1067 } else {
1068 FGLogging log(LogLevel::ERROR);
1069 log << LogFormat::RED
1070 << " JSBSim failed to open the configuration file: " << aircraftCfgFileName
1071 << LogFormat::DEFAULT << endl;
1072 }
1073
1074 for (unsigned int i=0; i< Models.size(); i++) LoadInputs(i);
1075
1076 if (result) {
1077 struct PropertyCatalogStructure masterPCS;
1078 masterPCS.base_string = "";
1079 masterPCS.node = Root;
1080 BuildPropertyCatalog(&masterPCS);
1081 }
1082
1083 return result;
1084}
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
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:243
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 LogException err;
757 err << "File: " << PlanetFileName << " could not be read." << endl;
758 throw err;
759 }
760
761 if (document->GetName() != "planet") {
762 XMLLogException err(document);
763 err << "File: " << PlanetFileName << " is not a planet file." << endl;
764 throw err;
765 }
766
767 bool result = LoadPlanet(document);
768
769 if (!result) {
770 FGXMLLogging log(document, LogLevel::ERROR);
771 log << endl << "Planet element has problems in file " << PlanetFileName << endl;
772 }
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 1137 of file FGFDMExec.cpp.

1138{
1139 FGLogging out(LogLevel::STDOUT);
1140 out << endl
1141 << " " << LogFormat::BLUE << LogFormat::BOLD << LogFormat::UNDERLINE_ON
1142 << "Property Catalog for " << modelName << LogFormat::RESET << endl << endl;
1143 for (auto &catalogElm: PropertyCatalog)
1144 out << " " << catalogElm << endl;
1145}

◆ PrintSimulationConfiguration()

void PrintSimulationConfiguration ( void  ) const

Definition at line 1149 of file FGFDMExec.cpp.

1150{
1151 FGLogging log(LogLevel::INFO);
1152 log << endl << "Simulation Configuration" << endl << "------------------------" << endl;
1153 log << MassBalance->GetName() << endl;
1154 log << GroundReactions->GetName() << endl;
1155 log << Aerodynamics->GetName() << endl;
1156 log << Propulsion->GetName() << endl;
1157}

◆ 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 1125 of file FGFDMExec.cpp.

1126{
1127 string results;
1128 for (auto &catalogElm: PropertyCatalog) {
1129 if (catalogElm.find(in) != string::npos) results += catalogElm + end_of_line;
1130 }
1131 if (results.empty()) return "No matches found"+end_of_line;
1132 return results;
1133}
+ 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:503
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:116
+ 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 499 of file FGFDMExec.h.

499{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 563 of file FGFDMExec.h.

563{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 406 of file FGFDMExec.cpp.

407{
408 bool success=true;
409
410 Debug(2);
411
412 for (auto &ChildFDM: ChildFDMList) {
413 ChildFDM->AssignState(Propagate); // Transfer state to the child FDM
414 ChildFDM->Run();
415 }
416
417 IncrTime();
418
419 // returns true if success, false if complete
420 if (Script && !IntegrationSuspended()) success = Script->RunScript();
421
422 for (unsigned int i = 0; i < Models.size(); i++) {
423 LoadInputs(i);
424 Models[i]->Run(holding);
425 }
426
427 if (Terminate) success = false;
428
429 return success;
430}
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 636 of file FGFDMExec.cpp.

637{
638 SuspendIntegration(); // saves the integration rate, dt, then sets it to 0.0.
639 Initialize(IC.get());
640
641 Models[eInput]->InitModel();
642 Models[eOutput]->InitModel();
643
644 Run();
645 Propagate->InitializeDerivatives();
646 ResumeIntegration(); // Restores the integration rate to what it was.
647
648 if (debug_lvl > 0) {
649 MassBalance->GetMassPropertiesReport(0);
650
651 FGLogging log(LogLevel::DEBUG);
652 log << endl << LogFormat::BLUE << LogFormat::BOLD
653 << "End of vehicle configuration loading." << endl
654 << "-------------------------------------------------------------------------------"
655 << LogFormat::RESET << std::setprecision(6) << endl;
656 }
657
658 for (unsigned int n=0; n < Propulsion->GetNumEngines(); ++n) {
659 if (IC->IsEngineRunning(n)) {
660 try {
661 Propulsion->InitRunning(n);
662 } catch (const string& str) {
663 FGLogging log(LogLevel::ERROR);
664 log << str << endl;
665 return false;
666 }
667 }
668 }
669
670 return true;
671}
void SuspendIntegration(void)
Suspends the simulation and sets the delta T to zero.
Definition FGFDMExec.h:560
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:563
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 326 of file FGFDMExec.h.

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

◆ SetChild()

void SetChild ( bool  ch)
inline

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

Definition at line 430 of file FGFDMExec.h.

430{IsChild = ch;}

◆ SetDebugLevel()

void SetDebugLevel ( int  level)
inline

Sets the debug level.

Definition at line 514 of file FGFDMExec.h.

514{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 576 of file FGFDMExec.h.

576{ 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 314 of file FGFDMExec.h.

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

◆ 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 454 of file FGFDMExec.h.

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

◆ 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 447 of file FGFDMExec.h.

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

◆ 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 460 of file FGFDMExec.h.

460{ 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:150

◆ 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 348 of file FGFDMExec.h.

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

◆ 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 415 of file FGFDMExec.h.

416 { 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 590 of file FGFDMExec.h.

590{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 187 of file FGFDMExec.cpp.

187 {
188 sim_time = cur_time;
189 Inertial->SetTime(sim_time);
190 return sim_time;
191}
+ 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 337 of file FGFDMExec.h.

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

◆ SetTrimMode()

void SetTrimMode ( int  mode)
inline

Definition at line 548 of file FGFDMExec.h.

548{ ta_mode = mode; }

◆ SetTrimStatus()

void SetTrimStatus ( bool  status)
inline

Definition at line 546 of file FGFDMExec.h.

546{ trim_status = status; }

◆ SRand()

int SRand ( void  ) const
inline

Definition at line 633 of file FGFDMExec.h.

633{ return RandomSeed; }

◆ SuspendIntegration()

void SuspendIntegration ( void  )
inline

Suspends the simulation and sets the delta T to zero.

Definition at line 560 of file FGFDMExec.h.

560{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 244 of file FGFDMExec.h.

244{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 504 of file FGFDMExec.h.

◆ START_NEW_OUTPUT

const int START_NEW_OUTPUT = 0x1
static

Mode flags for ResetToInitialConditions.

Definition at line 503 of file FGFDMExec.h.


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