]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGFDMExec.h
Remove the deprecated warning for JSBSim's egt_degf
[flightgear.git] / src / FDM / JSBSim / FGFDMExec.h
index 5f103fe159cc2f7e4ad4de2412245713042b2cc7..2628a66ff5bae9c08d8295e653ff1029998b389f 100644 (file)
@@ -44,12 +44,9 @@ INCLUDES
 #include <vector>
 #include <string>
 
-#include "models/FGOutput.h"
-#include "models/FGInput.h"
 #include "initialization/FGTrim.h"
 #include "FGJSBBase.h"
 #include "input_output/FGPropertyManager.h"
-#include "input_output/FGGroundCallback.h"
 #include "input_output/FGXMLFileRead.h"
 #include "models/FGPropagate.h"
 #include "math/FGColumnVector3.h"
@@ -58,7 +55,7 @@ INCLUDES
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_FDMEXEC "$Id: FGFDMExec.h,v 1.63 2011/02/19 16:44:41 jberndt Exp $"
+#define ID_FDMEXEC "$Id: FGFDMExec.h,v 1.74 2011/11/09 21:58:26 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -71,6 +68,8 @@ class FGTrim;
 class FGAerodynamics;
 class FGAircraft;
 class FGAtmosphere;
+class FGAccelerations;
+class FGWinds;
 class FGAuxiliary;
 class FGBuoyantForces;
 class FGExternalReactions;
@@ -181,7 +180,7 @@ CLASS DOCUMENTATION
                                 property actually maps toa function call of DoTrim().
 
     @author Jon S. Berndt
-    @version $Revision: 1.63 $
+    @version $Revision: 1.74 $
 */
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -224,6 +223,25 @@ public:
   /// Default destructor
   ~FGFDMExec();
 
+  // This list of enums is very important! The order in which models are listed here
+  // determines the order of execution of the models.
+  enum eModels { ePropagate=0,
+                 eInput,
+                 eInertial,
+                 eAtmosphere,
+                 eWinds,
+                 eAuxiliary,
+                 eSystems,
+                 ePropulsion,
+                 eAerodynamics,
+                 eGroundReactions,
+                 eExternalReactions,
+                 eBuoyantForces,
+                 eMassBalance,
+                 eAircraft,
+                 eAccelerations,
+                 eNumStandardModels };
+
   /** Unbind all tied JSBSim properties. */
   void Unbind(void) {instance->Unbind();}
 
@@ -236,8 +254,9 @@ public:
       one is at this time not recommended.
       @param model A pointer to the model being scheduled.
       @param rate The rate at which to execute the model as described above.
+                  Default is every frame (rate=1).
       @return Currently returns 0 always. */
-  void Schedule(FGModel* model, int rate);
+  void Schedule(FGModel* model, int rate=1);
 
   /** This function executes each scheduled model in succession.
       @return true if successful, false if sim should be ended  */
@@ -248,9 +267,14 @@ public:
       @return true if successful */
   bool RunIC(void);
 
-  /** Sets the ground callback pointer.
-      @param gc A pointer to a ground callback object.  */
-  void SetGroundCallback(FGGroundCallback* gc);
+  /** Sets the ground callback pointer. For optimal memory management, a shared
+      pointer is used internally that maintains a reference counter. The calling
+      application must therefore use FGGroundCallback_ptr 'smart pointers' to
+      manage their copy of the ground callback.
+      @param gc A pointer to a ground callback object
+      @see FGGroundCallback
+   */
+  void SetGroundCallback(FGGroundCallback* gc) { FGLocation::SetGroundCallback(gc); }
 
   /** Loads an aircraft model.
       @param AircraftPath path to the aircraft/ directory. For instance:
@@ -307,42 +331,50 @@ public:
   bool SetSystemsPath(const string& path)   { SystemsPath = RootDir + path; return true; }
   
   /// @name Top-level executive State and Model retrieval mechanism
-  //@{
+  ///@{
   /// Returns the FGAtmosphere pointer.
-  FGAtmosphere* GetAtmosphere(void)    {return Atmosphere;}
+  FGAtmosphere* GetAtmosphere(void)    {return (FGAtmosphere*)Models[eAtmosphere];}
+  /// Returns the FGAccelerations pointer.
+  FGAccelerations* GetAccelerations(void)    {return (FGAccelerations*)Models[eAccelerations];}
+  /// Returns the FGWinds pointer.
+  FGWinds* GetWinds(void)    {return (FGWinds*)Models[eWinds];}
   /// Returns the FGFCS pointer.
-  FGFCS* GetFCS(void)                  {return FCS;}
+  FGFCS* GetFCS(void)                  {return (FGFCS*)Models[eSystems];}
   /// Returns the FGPropulsion pointer.
-  FGPropulsion* GetPropulsion(void)    {return Propulsion;}
+  FGPropulsion* GetPropulsion(void)    {return (FGPropulsion*)Models[ePropulsion];}
   /// Returns the FGAircraft pointer.
-  FGMassBalance* GetMassBalance(void)  {return MassBalance;}
+  FGMassBalance* GetMassBalance(void)  {return (FGMassBalance*)Models[eMassBalance];}
   /// Returns the FGAerodynamics pointer
-  FGAerodynamics* GetAerodynamics(void){return Aerodynamics;}
+  FGAerodynamics* GetAerodynamics(void){return (FGAerodynamics*)Models[eAerodynamics];}
   /// Returns the FGInertial pointer.
-  FGInertial* GetInertial(void)        {return Inertial;}
+  FGInertial* GetInertial(void)        {return (FGInertial*)Models[eInertial];}
   /// Returns the FGGroundReactions pointer.
-  FGGroundReactions* GetGroundReactions(void) {return GroundReactions;}
+  FGGroundReactions* GetGroundReactions(void) {return (FGGroundReactions*)Models[eGroundReactions];}
   /// Returns the FGExternalReactions pointer.
-  FGExternalReactions* GetExternalReactions(void) {return ExternalReactions;}
+  FGExternalReactions* GetExternalReactions(void) {return (FGExternalReactions*)Models[eExternalReactions];}
   /// Returns the FGBuoyantForces pointer.
-  FGBuoyantForces* GetBuoyantForces(void) {return BuoyantForces;}
+  FGBuoyantForces* GetBuoyantForces(void) {return (FGBuoyantForces*)Models[eBuoyantForces];}
   /// Returns the FGAircraft pointer.
-  FGAircraft* GetAircraft(void)        {return Aircraft;}
+  FGAircraft* GetAircraft(void)        {return (FGAircraft*)Models[eAircraft];}
   /// Returns the FGPropagate pointer.
-  FGPropagate* GetPropagate(void)      {return Propagate;}
+  FGPropagate* GetPropagate(void)      {return (FGPropagate*)Models[ePropagate];}
   /// Returns the FGAuxiliary pointer.
-  FGAuxiliary* GetAuxiliary(void)      {return Auxiliary;}
+  FGAuxiliary* GetAuxiliary(void)      {return (FGAuxiliary*)Models[eAuxiliary];}
   /// Returns the FGInput pointer.
-  FGInput* GetInput(void)              {return Input;}
-  /// Returns the FGGroundCallback pointer.
-  FGGroundCallback* GetGroundCallback(void) {return GroundCallback;}
+  FGInput* GetInput(void)              {return (FGInput*)Models[eInput];}
+  /** Get a pointer to the ground callback currently used. It is recommanded
+      to store the returned pointer in a 'smart pointer' FGGroundCallback_ptr.
+      @return A pointer to the current ground callback object.
+      @see FGGroundCallback
+   */
+  FGGroundCallback* GetGroundCallback(void) {return FGLocation::GetGroundCallback();}
   /// Retrieves the script object
   FGScript* GetScript(void) {return Script;}
-  // Returns a pointer to the FGInitialCondition object
+  /// Returns a pointer to the FGInitialCondition object
   FGInitialCondition* GetIC(void)      {return IC;}
-  // Returns a pointer to the FGTrim object
+  /// Returns a pointer to the FGTrim object
   FGTrim* GetTrim(void);
-  //@}
+  ///@}
 
   /// Retrieves the engine path.
   const string& GetEnginePath(void)    {return EnginePath;}
@@ -366,7 +398,7 @@ public:
   }
 
   /// Returns the model name.
-  const string& GetModelName(void) { return modelName; }
+  const string& GetModelName(void) const { return modelName; }
 /*
   /// Returns the current time.
   double GetSimTime(void);
@@ -379,9 +411,9 @@ public:
   /// Returns a vector of strings representing the names of all loaded models (future)
   vector <string> EnumerateFDMs(void);
   /// Gets the number of child FDMs.
-  int GetFDMCount(void) {return (int)ChildFDMList.size();}
+  int GetFDMCount(void) const {return (int)ChildFDMList.size();}
   /// Gets a particular child FDM.
-  childData* GetChildFDM(int i) {return ChildFDMList[i];}
+  childData* GetChildFDM(int i) const {return ChildFDMList[i];}
   /// Marks this instance of the Exec object as a "child" object.
   void SetChild(bool ch) {IsChild = ch;}
 
@@ -408,19 +440,12 @@ public:
   /** Sets (or overrides) the output filename
       @param fname the name of the file to output data to
       @return true if successful, false if there is no output specified for the flight model */
-  bool SetOutputFileName(const string& fname) {
-    if (Outputs.size() > 0) Outputs[0]->SetOutputFileName(fname);
-    else return false;
-    return true;
-  }
+  bool SetOutputFileName(const string& fname);
 
   /** Retrieves the current output filename.
       @return the name of the output file for the first output specified by the flight model.
               If none is specified, the empty string is returned. */
-  string GetOutputFileName(void) {
-    if (Outputs.size() > 0) return Outputs[0]->GetOutputFileName();
-    else return string("");
-  }
+  string GetOutputFileName(void);
 
   /** Executes trimming in the selected mode.
   *   @param mode Specifies how to trim:
@@ -432,7 +457,6 @@ public:
   * - tTurn
   * - tNone  */
   void DoTrim(int mode);
-//  void DoTrimAnalysis(int mode);
 
   /// Disables data logging to all outputs.
   void DisableOutput(void);
@@ -475,22 +499,18 @@ public:
 
   vector<string>& GetPropertyCatalog(void) {return PropertyCatalog;}
 
-  /// Use the MSIS atmosphere model.
-  void UseAtmosphereMSIS(void);
-
-  /// Use the Mars atmosphere model. (Not operative yet.)
-  void UseAtmosphereMars(void);
-
   void SetTrimStatus(bool status){ trim_status = status; }
   bool GetTrimStatus(void) const { return trim_status; }
   void SetTrimMode(int mode){ ta_mode = mode; }
   int GetTrimMode(void) const { return ta_mode; }
 
+  string GetPropulsionTankReport();
+
   /// Returns the cumulative simulation time in seconds.
   double GetSimTime(void) const { return sim_time; }
 
   /// Returns the simulation delta T.
-  double GetDeltaT(void) {return dT;}
+  double GetDeltaT(void) const {return dT;}
 
   /// Suspends the simulation and sets the delta T to zero.
   void SuspendIntegration(void) {saved_dT = dT; dT = 0.0;}
@@ -500,7 +520,7 @@ public:
 
   /** Returns the simulation suspension state.
       @return true if suspended, false if executing  */
-  bool IntegrationSuspended(void) {return dT == 0.0;}
+  bool IntegrationSuspended(void) const {return dT == 0.0;}
 
   /** Sets the current sim time.
       @param cur_time the current time
@@ -522,10 +542,12 @@ public:
       @return the string representing the root (base) JSBSim directory. */
   const string& GetRootDir(void) const {return RootDir;}
 
-  /** Increments the simulation time.
+  /** Increments the simulation time if not in Holding mode. The Frame counter
+      is also incremented.
       @return the new simulation time.     */
   double IncrTime(void) {
-    sim_time += dT;
+    if (!holding) sim_time += dT;
+    Frame++;
     return sim_time;
   }
 
@@ -544,6 +566,7 @@ private:
   bool Constructing;
   bool modelLoaded;
   bool IsChild;
+  bool firstPass;
   string modelName;
   string AircraftPath;
   string FullAircraftPath;
@@ -553,23 +576,25 @@ private:
   string Release;
   string RootDir;
 
+  // Standard Model pointers - shortcuts for internal executive use only.
+  FGPropagate* Propagate;
+  FGInertial* Inertial;
+  FGAtmosphere* Atmosphere;
+  FGWinds* Winds;
+  FGAuxiliary* Auxiliary;
+  FGFCS* FCS;
+  FGPropulsion* Propulsion;
+  FGAerodynamics* Aerodynamics;
+  FGGroundReactions* GroundReactions;
+  FGExternalReactions* ExternalReactions;
+  FGBuoyantForces* BuoyantForces;
+  FGMassBalance* MassBalance;
+  FGAircraft* Aircraft;
+  FGAccelerations* Accelerations;
+
   bool trim_status;
   int ta_mode;
 
-  FGGroundCallback*   GroundCallback;
-  FGAtmosphere*       Atmosphere;
-  FGFCS*              FCS;
-  FGPropulsion*       Propulsion;
-  FGMassBalance*      MassBalance;
-  FGAerodynamics*     Aerodynamics;
-  FGInertial*         Inertial;
-  FGGroundReactions*  GroundReactions;
-  FGExternalReactions* ExternalReactions;
-  FGBuoyantForces*    BuoyantForces;
-  FGAircraft*         Aircraft;
-  FGPropagate*        Propagate;
-  FGAuxiliary*        Auxiliary;
-  FGInput*            Input;
   FGScript*           Script;
   FGInitialCondition* IC;
   FGTrim*             Trim;
@@ -590,6 +615,9 @@ private:
   bool ReadChild(Element*);
   bool ReadPrologue(Element*);
   void ResetToInitialConditions(int mode);
+  void LoadInputs(unsigned int idx);
+  void LoadPlanetConstants(void);
+  void LoadModelConstants(void);
   bool Allocate(void);
   bool DeAllocate(void);
   void Initialize(FGInitialCondition *FGIC);