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