]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGFDMExec.h
Synchronized FG with the removal of 'using std::*' in simgear's easyxml
[flightgear.git] / src / FDM / JSBSim / FGFDMExec.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2  Header:       FGFDMExec.h
3  Author:       Jon Berndt
4  Date started: 11/17/98
5  file The header file for the JSBSim executive.
6
7  ------------- Copyright (C) 1999  Jon S. Berndt (jon@jsbsim.org) -------------
8
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU Lesser General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
17  details.
18
19  You should have received a copy of the GNU Lesser General Public License along with
20  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21  Place - Suite 330, Boston, MA  02111-1307, USA.
22
23  Further information about the GNU Lesser General Public License can also be found on
24  the world wide web at http://www.gnu.org.
25
26 HISTORY
27 --------------------------------------------------------------------------------
28 11/17/98   JSB   Created
29 7/31/99     TP   Added RunIC function that runs the sim so that every frame
30                  begins with the IC values from the given FGInitialCondition
31                  object and dt=0.
32
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34 SENTRY
35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
36
37 #ifndef FGFDMEXEC_HEADER_H
38 #define FGFDMEXEC_HEADER_H
39
40 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
41 INCLUDES
42 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
43
44 #include <vector>
45 #include <string>
46
47 #include "initialization/FGTrim.h"
48 #include "FGJSBBase.h"
49 #include "input_output/FGPropertyManager.h"
50 #include "input_output/FGXMLFileRead.h"
51 #include "models/FGPropagate.h"
52 #include "math/FGColumnVector3.h"
53 #include "models/FGOutput.h"
54
55 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56 DEFINITIONS
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
58
59 #define ID_FDMEXEC "$Id: FGFDMExec.h,v 1.83 2013/06/10 01:46:27 jberndt Exp $"
60
61 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62 FORWARD DECLARATIONS
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
64
65 namespace JSBSim {
66
67 class FGScript;
68 class FGTrim;
69 class FGAerodynamics;
70 class FGAircraft;
71 class FGAtmosphere;
72 class FGAccelerations;
73 class FGWinds;
74 class FGAuxiliary;
75 class FGBuoyantForces;
76 class FGExternalReactions;
77 class FGGroundReactions;
78 class FGFCS;
79 class FGInertial;
80 class FGInput;
81 class FGPropulsion;
82 class FGMassBalance;
83
84 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
85 CLASS DOCUMENTATION
86 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
87
88 /** Encapsulates the JSBSim simulation executive.
89     This class is the executive class through which all other simulation classes
90     are instantiated, initialized, and run. When integrated with FlightGear (or
91     other flight simulator) this class is typically instantiated by an interface
92     class on the simulator side.
93
94     At the time of simulation initialization, the interface
95     class creates an instance of this executive class. The
96     executive is subsequently directed to load the chosen aircraft specification
97     file:
98
99     @code
100     fdmex = new FGFDMExec( ... );
101     result = fdmex->LoadModel( ... );
102     @endcode
103
104     When an aircraft model is loaded, the config file is parsed and for each of the
105     sections of the config file (propulsion, flight control, etc.) the
106     corresponding Load() method is called (e.g. FGFCS::Load()).
107
108     Subsequent to the creation of the executive and loading of the model,
109     initialization is performed. Initialization involves copying control inputs
110     into the appropriate JSBSim data storage locations, configuring it for the set
111     of user supplied initial conditions, and then copying state variables from
112     JSBSim. The state variables are used to drive the instrument displays and to
113     place the vehicle model in world space for visual rendering:
114
115     @code
116     copy_to_JSBsim(); // copy control inputs to JSBSim
117     fdmex->RunIC(); // loop JSBSim once w/o integrating
118     copy_from_JSBsim(); // update the bus
119     @endcode
120
121     Once initialization is complete, cyclic execution proceeds:
122
123     @code
124     copy_to_JSBsim(); // copy control inputs to JSBSim
125     fdmex->Run(); // execute JSBSim
126     copy_from_JSBsim(); // update the bus
127     @endcode
128
129     JSBSim can be used in a standalone mode by creating a compact stub program
130     that effectively performs the same progression of steps as outlined above for
131     the integrated version, but with two exceptions. First, the copy_to_JSBSim()
132     and copy_from_JSBSim() functions are not used because the control inputs are
133     handled directly by the scripting facilities and outputs are handled by the
134     output (data logging) class. Second, the name of a script file can be supplied
135     to the stub program. Scripting (see FGScript) provides a way to supply command
136     inputs to the simulation:
137
138     @code
139     FDMExec = new JSBSim::FGFDMExec();
140     FDMExec->LoadScript( ScriptName ); // the script loads the aircraft and ICs
141     result = FDMExec->Run();
142     while (result) { // cyclic execution
143       result = FDMExec->Run(); // execute JSBSim
144     }
145     @endcode
146
147     The standalone mode has been useful for verifying changes before committing
148     updates to the source code repository. It is also useful for running sets of
149     tests that reveal some aspects of simulated aircraft performance, such as
150     range, time-to-climb, takeoff distance, etc.
151
152     <h3>JSBSim Debugging Directives</h3>
153
154     This describes to any interested entity the debug level
155     requested by setting the JSBSIM_DEBUG environment variable.
156     The bitmasked value choices are as follows:
157     - <b>unset</b>: In this case (the default) JSBSim would only print
158        out the normally expected messages, essentially echoing
159        the config files as they are read. If the environment
160        variable is not set, debug_lvl is set to 1 internally
161     - <b>0</b>: This requests JSBSim not to output any messages
162        whatsoever
163     - <b>1</b>: This value explicity requests the normal JSBSim
164        startup messages
165     - <b>2</b>: This value asks for a message to be printed out when
166        a class is instantiated
167     - <b>4</b>: When this value is set, a message is displayed when a
168        FGModel object executes its Run() method
169     - <b>8</b>: When this value is set, various runtime state variables
170        are printed out periodically
171     - <b>16</b>: When set various parameters are sanity checked and
172        a message is printed out when they go out of bounds
173
174     <h3>Properties</h3>
175     @property simulator/do_trim (write only) Can be set to the integer equivalent to one of
176                                 tLongitudinal (0), tFull (1), tGround (2), tPullup (3),
177                                 tCustom (4), tTurn (5). Setting this to a legal value
178                                 (such as by a script) causes a trim to be performed. This
179                                 property actually maps toa function call of DoTrim().
180
181     @author Jon S. Berndt
182     @version $Revision: 1.83 $
183 */
184
185 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
186 CLASS DECLARATION
187 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
188
189 class FGFDMExec : public FGJSBBase, public FGXMLFileRead
190 {
191   struct childData {
192     FGFDMExec* exec;
193     std::string info;
194     FGColumnVector3 Loc;
195     FGColumnVector3 Orient;
196     bool mated;
197     bool internal;
198
199     childData(void) {
200       info = "";
201       Loc = FGColumnVector3(0,0,0);
202       Orient = FGColumnVector3(0,0,0);
203       mated = true;
204       internal = false;
205     }
206     
207     void Run(void) {exec->Run();}
208     void AssignState(FGPropagate* source_prop) {
209       exec->GetPropagate()->SetVState(source_prop->GetVState());
210     }
211
212     ~childData(void) {
213       delete exec;
214     }
215   };
216
217 public:
218
219   /// Default constructor
220   FGFDMExec(FGPropertyManager* root = 0, unsigned int* fdmctr = 0);
221
222   /// Default destructor
223   ~FGFDMExec();
224
225   // This list of enums is very important! The order in which models are listed here
226   // determines the order of execution of the models.
227   enum eModels { ePropagate=0,
228                  eInput,
229                  eInertial,
230                  eAtmosphere,
231                  eWinds,
232                  eAuxiliary,
233                  eSystems,
234                  ePropulsion,
235                  eAerodynamics,
236                  eGroundReactions,
237                  eExternalReactions,
238                  eBuoyantForces,
239                  eMassBalance,
240                  eAircraft,
241                  eAccelerations,
242                  eOutput,
243                  eNumStandardModels };
244
245   /** Unbind all tied JSBSim properties. */
246   void Unbind(void) {instance->Unbind();}
247
248   /** This routine places a model into the runlist at the specified rate. The
249       "rate" is not really a clock rate. It represents how many calls to the
250       FGFDMExec::Run() method must be made before the model is executed. A
251       value of 1 means that the model will be executed for each call to the
252       exec's Run() method. A value of 5 means that the model will only be
253       executed every 5th call to the exec's Run() method. Use of a rate other than
254       one is at this time not recommended.
255       @param model A pointer to the model being scheduled.
256       @param rate The rate at which to execute the model as described above.
257                   Default is every frame (rate=1).
258       @return Currently returns 0 always. */
259   void Schedule(FGModel* model, int rate=1);
260
261   /** This function executes each scheduled model in succession.
262       @return true if successful, false if sim should be ended  */
263   bool Run(void);
264
265   /** Initializes the sim from the initial condition object and executes
266       each scheduled model without integrating i.e. dt=0.
267       @return true if successful */
268   bool RunIC(void);
269
270   /** Sets the ground callback pointer. For optimal memory management, a shared
271       pointer is used internally that maintains a reference counter. The calling
272       application must therefore use FGGroundCallback_ptr 'smart pointers' to
273       manage their copy of the ground callback.
274       @param gc A pointer to a ground callback object
275       @see FGGroundCallback
276    */
277   void SetGroundCallback(FGGroundCallback* gc) { FGLocation::SetGroundCallback(gc); }
278
279   /** Loads an aircraft model.
280       @param AircraftPath path to the aircraft/ directory. For instance:
281       "aircraft". Under aircraft, then, would be directories for various
282       modeled aircraft such as C172/, x15/, etc.
283       @param EnginePath path to the directory under which engine config
284       files are kept, for instance "engine"
285       @param SystemsPath path to the directory under which systems config
286       files are kept, for instance "systems"
287       @param model the name of the aircraft model itself. This file will
288       be looked for in the directory specified in the AircraftPath variable,
289       and in turn under the directory with the same name as the model. For
290       instance: "aircraft/x15/x15.xml"
291       @param addModelToPath set to true to add the model name to the
292       AircraftPath, defaults to true
293       @return true if successful */
294   bool LoadModel(const std::string& AircraftPath, const std::string& EnginePath,
295                  const std::string& SystemsPath, const std::string& model,
296                  bool addModelToPath = true);
297
298   /** Loads an aircraft model.  The paths to the aircraft and engine
299       config file directories must be set prior to calling this.  See
300       below.
301       @param model the name of the aircraft model itself. This file will
302       be looked for in the directory specified in the AircraftPath variable,
303       and in turn under the directory with the same name as the model. For
304       instance: "aircraft/x15/x15.xml"
305       @param addModelToPath set to true to add the model name to the
306       AircraftPath, defaults to true
307       @return true if successful*/
308   bool LoadModel(const std::string& model, bool addModelToPath = true);
309
310   /** Loads a script
311       @param Script The full path name and file name for the script to be loaded.
312       @param deltaT The simulation integration step size, if given.  If no value is supplied
313                     then 0.0 is used and the value is expected to be supplied in
314                     the script file itself.
315       @param initfile The initialization file that will override the initialization file
316                       specified in the script file. If no file name is given on the command line,
317                       the file specified in the script will be used. If an initialization file 
318                       is not given in either place, an error will result.
319       @return true if successfully loads; false otherwise. */
320   bool LoadScript(const std::string& Script, double deltaT=0.0,
321                   const std::string initfile="");
322
323   /** Sets the path to the engine config file directories.
324       @param path path to the directory under which engine config
325       files are kept, for instance "engine"  */
326   bool SetEnginePath(const std::string& path)   { EnginePath = RootDir + path; return true; }
327
328   /** Sets the path to the aircraft config file directories.
329       @param path path to the aircraft directory. For instance:
330       "aircraft". Under aircraft, then, would be directories for various
331       modeled aircraft such as C172/, x15/, etc.  */
332   bool SetAircraftPath(const std::string& path) { AircraftPath = RootDir + path; return true; }
333   
334   /** Sets the path to the systems config file directories.
335       @param path path to the directory under which systems config
336       files are kept, for instance "systems"  */
337   bool SetSystemsPath(const std::string& path)   { SystemsPath = RootDir + path; return true; }
338   
339   /// @name Top-level executive State and Model retrieval mechanism
340   ///@{
341   /// Returns the FGAtmosphere pointer.
342   FGAtmosphere* GetAtmosphere(void)    {return (FGAtmosphere*)Models[eAtmosphere];}
343   /// Returns the FGAccelerations pointer.
344   FGAccelerations* GetAccelerations(void)    {return (FGAccelerations*)Models[eAccelerations];}
345   /// Returns the FGWinds pointer.
346   FGWinds* GetWinds(void)    {return (FGWinds*)Models[eWinds];}
347   /// Returns the FGFCS pointer.
348   FGFCS* GetFCS(void)                  {return (FGFCS*)Models[eSystems];}
349   /// Returns the FGPropulsion pointer.
350   FGPropulsion* GetPropulsion(void)    {return (FGPropulsion*)Models[ePropulsion];}
351   /// Returns the FGAircraft pointer.
352   FGMassBalance* GetMassBalance(void)  {return (FGMassBalance*)Models[eMassBalance];}
353   /// Returns the FGAerodynamics pointer
354   FGAerodynamics* GetAerodynamics(void){return (FGAerodynamics*)Models[eAerodynamics];}
355   /// Returns the FGInertial pointer.
356   FGInertial* GetInertial(void)        {return (FGInertial*)Models[eInertial];}
357   /// Returns the FGGroundReactions pointer.
358   FGGroundReactions* GetGroundReactions(void) {return (FGGroundReactions*)Models[eGroundReactions];}
359   /// Returns the FGExternalReactions pointer.
360   FGExternalReactions* GetExternalReactions(void) {return (FGExternalReactions*)Models[eExternalReactions];}
361   /// Returns the FGBuoyantForces pointer.
362   FGBuoyantForces* GetBuoyantForces(void) {return (FGBuoyantForces*)Models[eBuoyantForces];}
363   /// Returns the FGAircraft pointer.
364   FGAircraft* GetAircraft(void)        {return (FGAircraft*)Models[eAircraft];}
365   /// Returns the FGPropagate pointer.
366   FGPropagate* GetPropagate(void)      {return (FGPropagate*)Models[ePropagate];}
367   /// Returns the FGAuxiliary pointer.
368   FGAuxiliary* GetAuxiliary(void)      {return (FGAuxiliary*)Models[eAuxiliary];}
369   /// Returns the FGInput pointer.
370   FGInput* GetInput(void)              {return (FGInput*)Models[eInput];}
371   /** Get a pointer to the ground callback currently used. It is recommanded
372       to store the returned pointer in a 'smart pointer' FGGroundCallback_ptr.
373       @return A pointer to the current ground callback object.
374       @see FGGroundCallback
375    */
376   FGGroundCallback* GetGroundCallback(void) {return FGLocation::GetGroundCallback();}
377   /// Retrieves the script object
378   FGScript* GetScript(void) {return Script;}
379   /// Returns a pointer to the FGInitialCondition object
380   FGInitialCondition* GetIC(void)      {return IC;}
381   /// Returns a pointer to the FGTrim object
382   FGTrim* GetTrim(void);
383   ///@}
384
385   /// Retrieves the engine path.
386   const std::string& GetEnginePath(void)    {return EnginePath;}
387   /// Retrieves the aircraft path.
388   const std::string& GetAircraftPath(void)  {return AircraftPath;}
389   /// Retrieves the systems path.
390   const std::string& GetSystemsPath(void)   {return SystemsPath;}
391   /// Retrieves the full aircraft path name.
392   const std::string& GetFullAircraftPath(void) {return FullAircraftPath;}
393
394   /** Retrieves the value of a property.
395       @param property the name of the property
396       @result the value of the specified property */
397   inline double GetPropertyValue(const std::string& property)
398   { return instance->GetNode()->GetDouble(property); }
399
400   /** Sets a property value.
401       @param property the property to be set
402       @param value the value to set the property to */
403   inline void SetPropertyValue(const std::string& property, double value) {
404     instance->GetNode()->SetDouble(property, value);
405   }
406
407   /// Returns the model name.
408   const std::string& GetModelName(void) const { return modelName; }
409 /*
410   /// Returns the current time.
411   double GetSimTime(void);
412
413   /// Returns the current frame time (delta T).
414   double GetDeltaT(void);
415 */  
416   /// Returns a pointer to the property manager object.
417   FGPropertyManager* GetPropertyManager(void);
418   /// Returns a vector of strings representing the names of all loaded models (future)
419   std::vector <std::string> EnumerateFDMs(void);
420   /// Gets the number of child FDMs.
421   int GetFDMCount(void) const {return (int)ChildFDMList.size();}
422   /// Gets a particular child FDM.
423   childData* GetChildFDM(int i) const {return ChildFDMList[i];}
424   /// Marks this instance of the Exec object as a "child" object.
425   void SetChild(bool ch) {IsChild = ch;}
426
427   /** Sets the output (logging) mechanism for this run.
428       Calling this function passes the name of an output directives file to
429       the FGOutput object associated with this run. The call to this function
430       should be made prior to loading an aircraft model. This call results in an
431       FGOutput object being built as the first Output object in the FDMExec-managed
432       list of Output objects that may be created for an aircraft model. If this call
433       is made after an aircraft model is loaded, there is no effect. Any Output
434       objects added by the aircraft model itself (in an &lt;output> element) will be
435       added after this one. Care should be taken not to refer to the same file
436       name.
437       An output directives file contains an &lt;output> &lt;/output> element, within
438       which should be specified the parameters or parameter groups that should
439       be logged.
440       @param fname the filename of an output directives file.
441     */
442   bool SetOutputDirectives(const std::string& fname)
443   {return Output->SetDirectivesFile(RootDir + fname);}
444
445   /** Forces the specified output object to print its items once */
446   void ForceOutput(int idx=0) { Output->ForceOutput(idx); }
447
448   /** Sets the logging rate for all output objects (if any). */
449   void SetLoggingRate(double rate) { Output->SetRate(rate); }
450
451   /** Sets (or overrides) the output filename
452       @param fname the name of the file to output data to
453       @return true if successful, false if there is no output specified for the flight model */
454   bool SetOutputFileName(const int n, const std::string& fname) { return Output->SetOutputName(n, fname); }
455
456   /** Retrieves the current output filename.
457       @param n index of file
458       @return the name of the output file for the output specified by the flight model.
459               If none is specified, the empty string is returned. */
460   std::string GetOutputFileName(int n) const { return Output->GetOutputName(n); }
461
462   /** Executes trimming in the selected mode.
463   *   @param mode Specifies how to trim:
464   * - tLongitudinal=0
465   * - tFull
466   * - tGround
467   * - tPullup
468   * - tCustom
469   * - tTurn
470   * - tNone  */
471   void DoTrim(int mode);
472   void DoSimplexTrim(int mode);
473
474   /** Executes linearization with state-space output
475    * You must trim first to get an accurate state-space model
476    */
477   void DoLinearization(int mode);
478
479   /// Disables data logging to all outputs.
480   void DisableOutput(void) { Output->Disable(); }
481   /// Enables data logging to all outputs.
482   void EnableOutput(void) { Output->Enable(); }
483   /// Pauses execution by preventing time from incrementing.
484   void Hold(void) {holding = true;}
485   /// Turn on hold after increment
486   void EnableIncrementThenHold(int Timesteps) {TimeStepsUntilHold = Timesteps; IncrementThenHolding = true;}
487   /// Checks if required to hold afer increment
488   void CheckIncrementalHold(void);
489   /// Resumes execution from a "Hold".
490   void Resume(void) {holding = false;}
491   /// Returns true if the simulation is Holding (i.e. simulation time is not moving).
492   bool Holding(void) {return holding;}
493   /// Resets the initial conditions object and prepares the simulation to run again.
494   void ResetToInitialConditions(void);
495   /// Sets the debug level.
496   void SetDebugLevel(int level) {debug_lvl = level;}
497
498   struct PropertyCatalogStructure {
499     /// Name of the property.
500     std::string base_string;
501     /// The node for the property.
502     FGPropertyNode_ptr node;
503   };
504
505   /** Builds a catalog of properties.
506   *   This function descends the property tree and creates a list (an STL vector)
507   *   containing the name and node for all properties.
508   *   @param pcs The "root" property catalog structure pointer.  */
509   void BuildPropertyCatalog(struct PropertyCatalogStructure* pcs);
510
511   /** Retrieves property or properties matching the supplied string.
512   *   A string is returned that contains a carriage return delimited list of all
513   *   strings in the property catalog that matches the supplied check string.
514   *   @param check The string to search for in the property catalog.
515   *   @return the carriage-return-delimited string containing all matching strings
516   *               in the catalog.  */
517   std::string QueryPropertyCatalog(const std::string& check);
518
519   // Print the contents of the property catalog for the loaded aircraft.
520   void PrintPropertyCatalog(void);
521
522   std::vector<std::string>& GetPropertyCatalog(void) {return PropertyCatalog;}
523
524   void SetTrimStatus(bool status){ trim_status = status; }
525   bool GetTrimStatus(void) const { return trim_status; }
526   void SetTrimMode(int mode){ ta_mode = mode; }
527   int GetTrimMode(void) const { return ta_mode; }
528
529   std::string GetPropulsionTankReport();
530
531   /// Returns the cumulative simulation time in seconds.
532   double GetSimTime(void) const { return sim_time; }
533
534   /// Returns the simulation delta T.
535   double GetDeltaT(void) const {return dT;}
536
537   /// Suspends the simulation and sets the delta T to zero.
538   void SuspendIntegration(void) {saved_dT = dT; dT = 0.0;}
539
540   /// Resumes the simulation by resetting delta T to the correct value.
541   void ResumeIntegration(void)  {dT = saved_dT;}
542
543   /** Returns the simulation suspension state.
544       @return true if suspended, false if executing  */
545   bool IntegrationSuspended(void) const {return dT == 0.0;}
546
547   /** Sets the current sim time.
548       @param cur_time the current time
549       @return the current simulation time.      */
550   double Setsim_time(double cur_time) {
551     sim_time = cur_time;
552     return sim_time;
553   }
554
555   /** Sets the integration time step for the simulation executive.
556       @param delta_t the time step in seconds.     */
557   void Setdt(double delta_t) { dT = delta_t; }
558
559   /** Sets the root directory where JSBSim starts looking for its system directories.
560       @param rootDir the string containing the root directory. */
561   void SetRootDir(const std::string& rootDir) {RootDir = rootDir;}
562
563   /** Retrieves the Root Directory.
564       @return the string representing the root (base) JSBSim directory. */
565   const std::string& GetRootDir(void) const {return RootDir;}
566
567   /** Increments the simulation time if not in Holding mode. The Frame counter
568       is also incremented.
569       @return the new simulation time.     */
570   double IncrTime(void) {
571     if (!holding) sim_time += dT;
572     Frame++;
573     return sim_time;
574   }
575
576   /** Retrieves the current debug level setting. */
577   int GetDebugLevel(void) const {return debug_lvl;};
578
579   /** Initializes the simulation with initial conditions
580       @param FGIC The initial conditions that will be passed to the simulation. */
581   void Initialize(FGInitialCondition *FGIC);
582
583 private:
584   int Error;
585   unsigned int Frame;
586   unsigned int IdFDM;
587   unsigned short Terminate;
588   double dT;
589   double saved_dT;
590   double sim_time;
591   bool holding;
592   bool IncrementThenHolding;
593   int TimeStepsUntilHold;
594   bool Constructing;
595   bool modelLoaded;
596   bool IsChild;
597   std::string modelName;
598   std::string AircraftPath;
599   std::string FullAircraftPath;
600   std::string EnginePath;
601   std::string SystemsPath;
602   std::string CFGVersion;
603   std::string Release;
604   std::string RootDir;
605
606   // Standard Model pointers - shortcuts for internal executive use only.
607   FGPropagate* Propagate;
608   FGInertial* Inertial;
609   FGAtmosphere* Atmosphere;
610   FGWinds* Winds;
611   FGAuxiliary* Auxiliary;
612   FGFCS* FCS;
613   FGPropulsion* Propulsion;
614   FGAerodynamics* Aerodynamics;
615   FGGroundReactions* GroundReactions;
616   FGExternalReactions* ExternalReactions;
617   FGBuoyantForces* BuoyantForces;
618   FGMassBalance* MassBalance;
619   FGAircraft* Aircraft;
620   FGAccelerations* Accelerations;
621   FGOutput* Output;
622
623   bool trim_status;
624   int ta_mode;
625
626   FGScript*           Script;
627   FGInitialCondition* IC;
628   FGTrim*             Trim;
629
630   FGPropertyManager* Root;
631   bool StandAlone;
632   FGPropertyManager* instance;
633   
634   // The FDM counter is used to give each child FDM an unique ID. The root FDM has the ID 0
635   unsigned int*      FDMctr;
636
637   std::vector <std::string> PropertyCatalog;
638   std::vector <childData*> ChildFDMList;
639   std::vector <FGModel*> Models;
640
641   bool ReadFileHeader(Element*);
642   bool ReadChild(Element*);
643   bool ReadPrologue(Element*);
644   void ResetToInitialConditions(int mode);
645   void SRand(int sr);
646   void LoadInputs(unsigned int idx);
647   void LoadPlanetConstants(void);
648   void LoadModelConstants(void);
649   bool Allocate(void);
650   bool DeAllocate(void);
651
652   void Debug(int from);
653 };
654 }
655 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
656 #endif