JSBSim Flight Dynamics Model 1.3.0 (09 Apr 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 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< 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< 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 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 80 of file FGFDMExec.cpp.

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

169{
170 try {
171 Unbind();
172 DeAllocate();
173 } catch (const string& msg ) {
174 FGLogging log(LogLevel::FATAL);
175 log << "Caught error: " << msg << endl;
176 }
177
178 if (!FDMctr) (*FDMctr)--;
179
180 Debug(1);
181}
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 623 of file FGFDMExec.h.

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

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

1084{
1085 auto pcsNew = std::make_unique<struct PropertyCatalogStructure>();
1086 const SGPropertyNode* root_node = instance->GetNode();
1087 const string root_name = GetFullyQualifiedName(root_node) + "/";
1088 const size_t root_name_length = root_name.length();
1089
1090 for (int i=0; i<pcs->node->nChildren(); i++) {
1091 string access="";
1092 pcsNew->base_string = pcs->base_string + "/" + pcs->node->getChild(i)->getNameString();
1093 int node_idx = pcs->node->getChild(i)->getIndex();
1094 if (node_idx != 0) {
1095 pcsNew->base_string = CreateIndexedPropertyName(pcsNew->base_string, node_idx);
1096 }
1097 if (pcs->node->getChild(i)->nChildren() == 0) {
1098 if (pcsNew->base_string.substr(0, root_name_length) == root_name) {
1099 pcsNew->base_string = pcsNew->base_string.erase(0, root_name_length);
1100 }
1101 if (pcs->node->getChild(i)->getAttribute(SGPropertyNode::READ)) access="R";
1102 if (pcs->node->getChild(i)->getAttribute(SGPropertyNode::WRITE)) access+="W";
1103 PropertyCatalog.push_back(pcsNew->base_string+" ("+access+")");
1104 } else {
1105 pcsNew->node = pcs->node->getChild(i);
1106 BuildPropertyCatalog(pcsNew.get());
1107 }
1108 }
1109}
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 1306 of file FGFDMExec.cpp.

1307{
1308 // Only check if increment then hold is on
1309 if( IncrementThenHolding ) {
1310
1311 if (TimeStepsUntilHold == 0) {
1312
1313 // Should hold simulation if TimeStepsUntilHold has reached zero
1314 holding = true;
1315
1316 // Still need to decrement TimeStepsUntilHold as value of -1
1317 // indicates that incremental then hold is turned off
1318 IncrementThenHolding = false;
1319 TimeStepsUntilHold--;
1320
1321 } else if ( TimeStepsUntilHold > 0 ) {
1322 // Keep decrementing until 0 is reached
1323 TimeStepsUntilHold--;
1324 }
1325 }
1326}

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

1352{
1353 double dt0 = this->GetDeltaT();
1354 FGLinearization lin(this);
1355 lin.WriteScicoslab();
1356 this->Setdt(dt0);
1357}
void Setdt(double delta_t)
Sets the integration time step for the simulation executive.
Definition FGFDMExec.h:572
+ 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 1330 of file FGFDMExec.cpp.

1331{
1332 if (Constructing) return;
1333
1334 if (mode < 0 || mode > JSBSim::tNone)
1335 throw TrimFailureException("Illegal trimming mode!");
1336
1337 FGTrim trim(this, (JSBSim::TrimMode)mode);
1338 bool success = trim.DoTrim();
1339
1340 if (debug_lvl > 0)
1341 trim.Report();
1342
1343 if (!success)
1344 throw TrimFailureException("Trim Failed");
1345
1346 trim_completed = 1;
1347}
+ Here is the caller graph for this function:

◆ EnableIncrementThenHold()

void EnableIncrementThenHold ( int  Timesteps)
inline

Turn on hold after increment.

Definition at line 491 of file FGFDMExec.h.

491{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 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 717 of file FGFDMExec.cpp.

718{
719 vector <string> FDMList;
720 FDMList.push_back(Aircraft->GetAircraftName());
721
722 for (auto &ChildFDM: ChildFDMList)
723 FDMList.push_back(ChildFDM->exec->GetAircraft()->GetAircraftName());
724
725 return FDMList;
726}
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:144

◆ GetAccelerations()

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

Returns the FGAccelerations pointer.

Definition at line 367 of file FGFDMExec.cpp.

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

◆ GetAerodynamics()

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

Returns the FGAerodynamics pointer.

Definition at line 332 of file FGFDMExec.cpp.

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

◆ GetAircraft()

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

Returns the FGAircraft pointer.

Definition at line 360 of file FGFDMExec.cpp.

361{
362 return static_pointer_cast<FGAircraft>(Models[eAircraft]);
363}
+ 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 290 of file FGFDMExec.cpp.

291{
292 return static_pointer_cast<FGAtmosphere>(Models[eAtmosphere]);
293}

◆ GetAuxiliary()

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

Returns the FGAuxiliary pointer.

Definition at line 318 of file FGFDMExec.cpp.

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

◆ GetBuoyantForces()

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

Returns the FGBuoyantForces pointer.

Definition at line 353 of file FGFDMExec.cpp.

354{
355 return static_pointer_cast<FGBuoyantForces>(Models[eBuoyantForces]);
356}
+ 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 602 of file FGFDMExec.h.

602{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 553 of file FGFDMExec.h.

553{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 346 of file FGFDMExec.cpp.

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

◆ GetFCS()

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

Returns the FGFCS pointer.

Definition at line 304 of file FGFDMExec.cpp.

305{
306 return static_pointer_cast<FGFCS>(Models[eSystems]);
307}
+ 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 599 of file FGFDMExec.h.

599{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 339 of file FGFDMExec.cpp.

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

617{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 276 of file FGFDMExec.cpp.

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

◆ GetInput()

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

Returns the FGInput pointer.

Definition at line 283 of file FGFDMExec.cpp.

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

◆ GetMassBalance()

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

Returns the FGAircraft pointer.

Definition at line 311 of file FGFDMExec.cpp.

312{
313 return static_pointer_cast<FGMassBalance>(Models[eMassBalance]);
314}
+ 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 374 of file FGFDMExec.cpp.

375{
376 return static_pointer_cast<FGOutput>(Models[eOutput]);
377}
+ 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:162

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

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

◆ GetPropertyCatalog()

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

Definition at line 540 of file FGFDMExec.h.

540{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 325 of file FGFDMExec.cpp.

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

◆ GetPropulsionTankReport()

string GetPropulsionTankReport ( ) const

Definition at line 1076 of file FGFDMExec.cpp.

1077{
1078 return Propulsion->GetPropulsionTankReport();
1079}

◆ GetRandomGenerator()

auto GetRandomGenerator ( void  ) const
inline

Definition at line 627 of file FGFDMExec.h.

627{ 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 591 of file FGFDMExec.h.

591{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 550 of file FGFDMExec.h.

550{ 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 619 of file FGFDMExec.h.

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

◆ GetTrim()

std::shared_ptr< FGTrim > GetTrim ( void  )

Returns a pointer to the FGTrim object.

Definition at line 1298 of file FGFDMExec.cpp.

1299{
1300 Trim = std::make_shared<FGTrim>(this,tNone);
1301 return Trim;
1302}

◆ GetTrimMode()

int GetTrimMode ( void  ) const
inline

Definition at line 545 of file FGFDMExec.h.

545{ return ta_mode; }

◆ GetTrimStatus()

bool GetTrimStatus ( void  ) const
inline

Definition at line 543 of file FGFDMExec.h.

543{ return trim_status; }

◆ GetWinds()

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

Returns the FGWinds pointer.

Definition at line 297 of file FGFDMExec.cpp.

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

◆ Hold()

void Hold ( void  )
inline

Pauses execution by preventing time from incrementing.

Definition at line 489 of file FGFDMExec.h.

489{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 497 of file FGFDMExec.h.

497{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 193 of file FGFDMExec.cpp.

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

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

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

819{
820 FGFDMExec::AircraftPath = GetFullPath(AircraftPath);
821 FGFDMExec::EnginePath = GetFullPath(EnginePath);
822 FGFDMExec::SystemsPath = GetFullPath(SystemsPath);
823
824 return LoadModel(model, addModelToPath);
825}
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 829 of file FGFDMExec.cpp.

830{
831 SGPath aircraftCfgFileName;
832 bool result = false; // initialize result to false, indicating input file not yet read
833
834 modelName = model; // Set the class modelName attribute
835
836 if( AircraftPath.isNull() || EnginePath.isNull() || SystemsPath.isNull()) {
837 FGLogging log(LogLevel::ERROR);
838 log << "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 FGXMLLogging log(element, LogLevel::ERROR);
869 log << endl << "Aircraft fileheader element has problems in file " << aircraftCfgFileName << endl;
870 return result;
871 }
872 }
873
874 if (IsChild) debug_lvl = 0;
875
876 // Process the planet element. This element is OPTIONAL.
877 element = document->FindElement("planet");
878 if (element) {
879 result = LoadPlanet(element);
880 if (!result) {
881 FGXMLLogging log(element, LogLevel::ERROR);
882 log << endl << "Planet element has problems in file " << aircraftCfgFileName << endl;
883 return result;
884 }
885 }
886
887 // Process the metrics element. This element is REQUIRED.
888 element = document->FindElement("metrics");
889 if (element) {
890 result = Models[eAircraft]->Load(element);
891 if (!result) {
892 FGXMLLogging log(element, LogLevel::ERROR);
893 log << endl << "Aircraft metrics element has problems in file " << aircraftCfgFileName << endl;
894 return result;
895 }
896 } else {
897 FGLogging log(LogLevel::ERROR);
898 log << endl << "No metrics element was found in the aircraft config file." << endl;
899 return false;
900 }
901
902 // Process the mass_balance element. This element is REQUIRED.
903 element = document->FindElement("mass_balance");
904 if (element) {
905 result = Models[eMassBalance]->Load(element);
906 if (!result) {
907 FGXMLLogging log(element, LogLevel::ERROR);
908 log << endl << "Aircraft mass_balance element has problems in file " << aircraftCfgFileName << endl;
909 return result;
910 }
911 } else {
912 FGLogging log(LogLevel::ERROR);
913 log << endl << "No mass_balance element was found in the aircraft config file." << endl;
914 return false;
915 }
916
917 // Process the ground_reactions element. This element is REQUIRED.
918 element = document->FindElement("ground_reactions");
919 if (element) {
920 result = Models[eGroundReactions]->Load(element);
921 if (!result) {
922 FGXMLLogging log(element, LogLevel::ERROR);
923 log << endl
924 << "Aircraft ground_reactions element has problems in file "
925 << aircraftCfgFileName << endl;
926 return result;
927 }
928 } else {
929 FGLogging log(LogLevel::ERROR);
930 log << endl << "No ground_reactions element was found in the aircraft config file." << endl;
931 return false;
932 }
933
934 // Process the external_reactions element. This element is OPTIONAL.
935 element = document->FindElement("external_reactions");
936 if (element) {
937 result = Models[eExternalReactions]->Load(element);
938 if (!result) {
939 FGXMLLogging log(element, LogLevel::ERROR);
940 log << endl << "Aircraft external_reactions element has problems in file " << aircraftCfgFileName << endl;
941 return result;
942 }
943 }
944
945 // Process the buoyant_forces element. This element is OPTIONAL.
946 element = document->FindElement("buoyant_forces");
947 if (element) {
948 result = Models[eBuoyantForces]->Load(element);
949 if (!result) {
950 FGXMLLogging log(element, LogLevel::ERROR);
951 log << endl << "Aircraft buoyant_forces element has problems in file " << aircraftCfgFileName << endl;
952 return result;
953 }
954 }
955
956 // Process the propulsion element. This element is OPTIONAL.
957 element = document->FindElement("propulsion");
958 if (element) {
959 result = Propulsion->Load(element);
960 if (!result) {
961 FGXMLLogging log(element, LogLevel::ERROR);
962 log << endl << "Aircraft propulsion element has problems in file " << aircraftCfgFileName << endl;
963 return result;
964 }
965 for (unsigned int i=0; i < Propulsion->GetNumEngines(); i++)
966 FCS->AddThrottle();
967 }
968
969 // Process the system element[s]. This element is OPTIONAL, and there may be more than one.
970 element = document->FindElement("system");
971 while (element) {
972 result = Models[eSystems]->Load(element);
973 if (!result) {
974 FGXMLLogging log(element, LogLevel::ERROR);
975 log << endl << "Aircraft system element has problems in file " << aircraftCfgFileName << endl;
976 return result;
977 }
978 element = document->FindNextElement("system");
979 }
980
981 // Process the autopilot element. This element is OPTIONAL.
982 element = document->FindElement("autopilot");
983 if (element) {
984 result = Models[eSystems]->Load(element);
985 if (!result) {
986 FGXMLLogging log(element, LogLevel::ERROR);
987 log << endl << "Aircraft autopilot element has problems in file " << aircraftCfgFileName << endl;
988 return result;
989 }
990 }
991
992 // Process the flight_control element. This element is OPTIONAL.
993 element = document->FindElement("flight_control");
994 if (element) {
995 result = Models[eSystems]->Load(element);
996 if (!result) {
997 FGXMLLogging log(element, LogLevel::ERROR);
998 log << endl << "Aircraft flight_control element has problems in file " << aircraftCfgFileName << endl;
999 return result;
1000 }
1001 }
1002
1003 // Process the aerodynamics element. This element is OPTIONAL, but almost always expected.
1004 element = document->FindElement("aerodynamics");
1005 if (element) {
1006 result = Models[eAerodynamics]->Load(element);
1007 if (!result) {
1008 FGXMLLogging log(element, LogLevel::ERROR);
1009 log << endl << "Aircraft aerodynamics element has problems in file " << aircraftCfgFileName << endl;
1010 return result;
1011 }
1012 } else {
1013 FGLogging log(LogLevel::ERROR);
1014 log << endl << "No expected aerodynamics element was found in the aircraft config file." << endl;
1015 }
1016
1017 // Process the input element. This element is OPTIONAL, and there may be more than one.
1018 element = document->FindElement("input");
1019 while (element) {
1020 if (!Input->Load(element))
1021 return false;
1022
1023 element = document->FindNextElement("input");
1024 }
1025
1026 // Process the output element[s]. This element is OPTIONAL, and there may be
1027 // more than one.
1028 element = document->FindElement("output");
1029 while (element) {
1030 if (!Output->Load(element))
1031 return false;
1032
1033 element = document->FindNextElement("output");
1034 }
1035
1036 // Lastly, process the child element. This element is OPTIONAL - and NOT YET SUPPORTED.
1037 element = document->FindElement("child");
1038 if (element) {
1039 result = ReadChild(element);
1040 if (!result) {
1041 FGXMLLogging log(element, LogLevel::ERROR);
1042 log << endl << "Aircraft child element has problems in file " << aircraftCfgFileName << endl;
1043 return result;
1044 }
1045 }
1046
1047 // Since all vehicle characteristics have been loaded, place the values in the Inputs
1048 // structure for the FGModel-derived classes.
1049 LoadModelConstants();
1050
1051 modelLoaded = true;
1052
1053 if (IsChild) debug_lvl = saved_debug_lvl;
1054
1055 } else {
1056 FGLogging log(LogLevel::ERROR);
1057 log << LogFormat::RED
1058 << " JSBSim failed to open the configuration file: " << aircraftCfgFileName
1059 << LogFormat::DEFAULT << endl;
1060 }
1061
1062 for (unsigned int i=0; i< Models.size(); i++) LoadInputs(i);
1063
1064 if (result) {
1065 struct PropertyCatalogStructure masterPCS;
1066 masterPCS.base_string = "";
1067 masterPCS.node = Root;
1068 BuildPropertyCatalog(&masterPCS);
1069 }
1070
1071 return result;
1072}
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:78
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:245
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 739 of file FGFDMExec.cpp.

740{
741 SGPath PlanetFileName;
742
743 if(useAircraftPath && PlanetPath.isRelative()) {
744 PlanetFileName = AircraftPath/PlanetPath.utf8Str();
745 } else {
746 PlanetFileName = PlanetPath;
747 }
748
749 FGXMLFileRead XMLFileRead;
750 Element* document = XMLFileRead.LoadXMLDocument(PlanetFileName);
751
752 // Make sure that the document is valid
753 if (!document) {
754 LogException err;
755 err << "File: " << PlanetFileName << " could not be read." << endl;
756 throw err;
757 }
758
759 if (document->GetName() != "planet") {
760 XMLLogException err(document);
761 err << "File: " << PlanetFileName << " is not a planet file." << endl;
762 throw err;
763 }
764
765 bool result = LoadPlanet(document);
766
767 if (!result) {
768 FGXMLLogging log(document, LogLevel::ERROR);
769 log << endl << "Planet element has problems in file " << PlanetFileName << endl;
770 }
771
772 return result;
773}
+ 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 730 of file FGFDMExec.cpp.

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

◆ PrintPropertyCatalog()

void PrintPropertyCatalog ( void  )

Definition at line 1125 of file FGFDMExec.cpp.

1126{
1127 FGLogging out(LogLevel::STDOUT);
1128 out << endl
1129 << " " << LogFormat::BLUE << highint << LogFormat::UNDERLINE_ON
1130 << "Property Catalog for " << modelName << LogFormat::RESET << endl << endl;
1131 for (auto &catalogElm: PropertyCatalog)
1132 out << " " << catalogElm << endl;
1133}
static char highint[5]
highlights text
Definition FGJSBBase.h:151

◆ PrintSimulationConfiguration()

void PrintSimulationConfiguration ( void  ) const

Definition at line 1137 of file FGFDMExec.cpp.

1138{
1139 FGLogging log(LogLevel::INFO);
1140 log << endl << "Simulation Configuration" << endl << "------------------------" << endl;
1141 log << MassBalance->GetName() << endl;
1142 log << GroundReactions->GetName() << endl;
1143 log << Aerodynamics->GetName() << endl;
1144 log << Propulsion->GetName() << endl;
1145}

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

1114{
1115 string results;
1116 for (auto &catalogElm: PropertyCatalog) {
1117 if (catalogElm.find(in) != string::npos) results += catalogElm + end_of_line;
1118 }
1119 if (results.empty()) return "No matches found"+end_of_line;
1120 return results;
1121}
+ 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 683 of file FGFDMExec.cpp.

684{
685 if (Constructing) return;
686
687 // mode flags
688
689 if (mode & START_NEW_OUTPUT) Output->SetStartNewOutput();
690
691 InitializeModels();
692
693 if (Script)
694 Script->ResetEvents();
695 else
696 Setsim_time(0.0);
697
698 if (!(mode & DONT_EXECUTE_RUN_IC))
699 RunIC();
700}
static const int START_NEW_OUTPUT
Mode flags for ResetToInitialConditions.
Definition FGFDMExec.h:499
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 495 of file FGFDMExec.h.

495{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 559 of file FGFDMExec.h.

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

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

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

510{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 572 of file FGFDMExec.h.

572{ 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 704 of file FGFDMExec.cpp.

705{
706 HoldDown = hd;
707 Accelerations->SetHoldDown(hd);
708 if (hd) {
709 Propagate->in.vPQRidot = Accelerations->GetPQRidot();
710 Propagate->in.vUVWidot = Accelerations->GetUVWidot();
711 }
712 Propagate->SetHoldDown(hd);
713}
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: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 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: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 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: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 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 586 of file FGFDMExec.h.

586{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 185 of file FGFDMExec.cpp.

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

544{ ta_mode = mode; }

◆ SetTrimStatus()

void SetTrimStatus ( bool  status)
inline

Definition at line 542 of file FGFDMExec.h.

542{ trim_status = status; }

◆ SRand()

int SRand ( void  ) const
inline

Definition at line 629 of file FGFDMExec.h.

629{ return RandomSeed; }

◆ SuspendIntegration()

void SuspendIntegration ( void  )
inline

Suspends the simulation and sets the delta T to zero.

Definition at line 556 of file FGFDMExec.h.

556{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 500 of file FGFDMExec.h.

◆ START_NEW_OUTPUT

const int START_NEW_OUTPUT = 0x1
static

Mode flags for ResetToInitialConditions.

Definition at line 499 of file FGFDMExec.h.


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