]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGFDMExec.h
Fix for bug 1304 - crash loading XML route
[flightgear.git] / src / FDM / JSBSim / FGFDMExec.h
index 2192e11ec3d33aad70947bdc69443e8dd7f9252e..408abef1554b4b42c18e60f8a7cddfac693516cc 100644 (file)
@@ -47,7 +47,6 @@ INCLUDES
 #include "initialization/FGTrim.h"
 #include "FGJSBBase.h"
 #include "input_output/FGPropertyManager.h"
-#include "input_output/FGXMLFileRead.h"
 #include "models/FGPropagate.h"
 #include "math/FGColumnVector3.h"
 #include "models/FGOutput.h"
@@ -56,7 +55,7 @@ INCLUDES
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_FDMEXEC "$Id: FGFDMExec.h,v 1.80 2012/10/25 04:56:57 jberndt Exp $"
+#define ID_FDMEXEC "$Id: FGFDMExec.h,v 1.86 2014/01/02 21:37:14 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -179,18 +178,18 @@ CLASS DOCUMENTATION
                                 property actually maps toa function call of DoTrim().
 
     @author Jon S. Berndt
-    @version $Revision: 1.80 $
+    @version $Revision: 1.86 $
 */
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS DECLARATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-class FGFDMExec : public FGJSBBase, public FGXMLFileRead
+class FGFDMExec : public FGJSBBase
 {
   struct childData {
     FGFDMExec* exec;
-    string info;
+    std::string info;
     FGColumnVector3 Loc;
     FGColumnVector3 Orient;
     bool mated;
@@ -291,8 +290,9 @@ public:
       @param addModelToPath set to true to add the model name to the
       AircraftPath, defaults to true
       @return true if successful */
-  bool LoadModel(const string& AircraftPath, const string& EnginePath, const string& SystemsPath,
-                 const string& model, bool addModelToPath = true);
+  bool LoadModel(const std::string& AircraftPath, const std::string& EnginePath,
+                 const std::string& SystemsPath, 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
@@ -304,7 +304,7 @@ public:
       @param addModelToPath set to true to add the model name to the
       AircraftPath, defaults to true
       @return true if successful*/
-  bool LoadModel(const string& model, bool addModelToPath = true);
+  bool LoadModel(const std::string& model, bool addModelToPath = true);
 
   /** Loads a script
       @param Script The full path name and file name for the script to be loaded.
@@ -316,23 +316,24 @@ public:
                       the file specified in the script will be used. If an initialization file 
                       is not given in either place, an error will result.
       @return true if successfully loads; false otherwise. */
-  bool LoadScript(const string& Script, double deltaT=0.0, const string initfile="");
+  bool LoadScript(const std::string& Script, double deltaT=0.0,
+                  const std::string initfile="");
 
   /** Sets the path to the engine config file directories.
       @param path path to the directory under which engine config
       files are kept, for instance "engine"  */
-  bool SetEnginePath(const string& path)   { EnginePath = RootDir + path; return true; }
+  bool SetEnginePath(const std::string& path)   { EnginePath = RootDir + path; return true; }
 
   /** Sets the path to the aircraft config file directories.
       @param path path to the aircraft directory. For instance:
       "aircraft". Under aircraft, then, would be directories for various
       modeled aircraft such as C172/, x15/, etc.  */
-  bool SetAircraftPath(const string& path) { AircraftPath = RootDir + path; return true; }
+  bool SetAircraftPath(const std::string& path) { AircraftPath = RootDir + path; return true; }
   
   /** Sets the path to the systems config file directories.
       @param path path to the directory under which systems config
       files are kept, for instance "systems"  */
-  bool SetSystemsPath(const string& path)   { SystemsPath = RootDir + path; return true; }
+  bool SetSystemsPath(const std::string& path)   { SystemsPath = RootDir + path; return true; }
   
   /// @name Top-level executive State and Model retrieval mechanism
   ///@{
@@ -381,28 +382,29 @@ public:
   ///@}
 
   /// Retrieves the engine path.
-  const string& GetEnginePath(void)    {return EnginePath;}
+  const std::string& GetEnginePath(void)    {return EnginePath;}
   /// Retrieves the aircraft path.
-  const string& GetAircraftPath(void)  {return AircraftPath;}
+  const std::string& GetAircraftPath(void)  {return AircraftPath;}
   /// Retrieves the systems path.
-  const string& GetSystemsPath(void)   {return SystemsPath;}
+  const std::string& GetSystemsPath(void)   {return SystemsPath;}
   /// Retrieves the full aircraft path name.
-  const string& GetFullAircraftPath(void) {return FullAircraftPath;}
+  const std::string& GetFullAircraftPath(void) {return FullAircraftPath;}
 
   /** Retrieves the value of a property.
       @param property the name of the property
       @result the value of the specified property */
-  inline double GetPropertyValue(const string& property) {return instance->GetDouble(property);}
+  inline double GetPropertyValue(const std::string& property)
+  { return instance->GetNode()->GetDouble(property); }
 
   /** Sets a property value.
       @param property the property to be set
       @param value the value to set the property to */
-  inline void SetPropertyValue(const string& property, double value) {
-    instance->SetDouble(property, value);
+  inline void SetPropertyValue(const std::string& property, double value) {
+    instance->GetNode()->SetDouble(property, value);
   }
 
   /// Returns the model name.
-  const string& GetModelName(void) const { return modelName; }
+  const std::string& GetModelName(void) const { return modelName; }
 /*
   /// Returns the current time.
   double GetSimTime(void);
@@ -413,7 +415,7 @@ public:
   /// Returns a pointer to the property manager object.
   FGPropertyManager* GetPropertyManager(void);
   /// Returns a vector of strings representing the names of all loaded models (future)
-  vector <string> EnumerateFDMs(void);
+  std::vector <std::string> EnumerateFDMs(void);
   /// Gets the number of child FDMs.
   int GetFDMCount(void) const {return (int)ChildFDMList.size();}
   /// Gets a particular child FDM.
@@ -436,7 +438,7 @@ public:
       be logged.
       @param fname the filename of an output directives file.
     */
-  bool SetOutputDirectives(const string& fname)
+  bool SetOutputDirectives(const std::string& fname)
   {return Output->SetDirectivesFile(RootDir + fname);}
 
   /** Forces the specified output object to print its items once */
@@ -448,12 +450,13 @@ 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) { return Output->SetOutputName(0, fname); }
+  bool SetOutputFileName(const int n, const std::string& fname) { return Output->SetOutputName(n, fname); }
 
   /** Retrieves the current output filename.
-      @return the name of the output file for the first output specified by the flight model.
+      @param n index of file
+      @return the name of the output file for the output specified by the flight model.
               If none is specified, the empty string is returned. */
-  string GetOutputFileName(void) const { return Output->GetOutputName(0); }
+  std::string GetOutputFileName(int n) const { return Output->GetOutputName(n); }
 
   /** Executes trimming in the selected mode.
   *   @param mode Specifies how to trim:
@@ -467,6 +470,11 @@ public:
   void DoTrim(int mode);
   void DoSimplexTrim(int mode);
 
+  /** Executes linearization with state-space output
+   * You must trim first to get an accurate state-space model
+   */
+  void DoLinearization(int mode);
+
   /// Disables data logging to all outputs.
   void DisableOutput(void) { Output->Disable(); }
   /// Enables data logging to all outputs.
@@ -488,9 +496,9 @@ public:
 
   struct PropertyCatalogStructure {
     /// Name of the property.
-    string base_string;
+    std::string base_string;
     /// The node for the property.
-    FGPropertyManager *node;
+    FGPropertyNode_ptr node;
   };
 
   /** Builds a catalog of properties.
@@ -505,19 +513,19 @@ public:
   *   @param check The string to search for in the property catalog.
   *   @return the carriage-return-delimited string containing all matching strings
   *               in the catalog.  */
-  string QueryPropertyCatalog(const string& check);
+  std::string QueryPropertyCatalog(const std::string& check);
 
   // Print the contents of the property catalog for the loaded aircraft.
   void PrintPropertyCatalog(void);
 
-  vector<string>& GetPropertyCatalog(void) {return PropertyCatalog;}
+  std::vector<std::string>& GetPropertyCatalog(void) {return PropertyCatalog;}
 
   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();
+  std::string GetPropulsionTankReport();
 
   /// Returns the cumulative simulation time in seconds.
   double GetSimTime(void) const { return sim_time; }
@@ -549,11 +557,11 @@ public:
 
   /** Sets the root directory where JSBSim starts looking for its system directories.
       @param rootDir the string containing the root directory. */
-  void SetRootDir(const string& rootDir) {RootDir = rootDir;}
+  void SetRootDir(const std::string& rootDir) {RootDir = rootDir;}
 
   /** Retrieves the Root Directory.
       @return the string representing the root (base) JSBSim directory. */
-  const string& GetRootDir(void) const {return RootDir;}
+  const std::string& GetRootDir(void) const {return RootDir;}
 
   /** Increments the simulation time if not in Holding mode. The Frame counter
       is also incremented.
@@ -585,14 +593,14 @@ private:
   bool Constructing;
   bool modelLoaded;
   bool IsChild;
-  string modelName;
-  string AircraftPath;
-  string FullAircraftPath;
-  string EnginePath;
-  string SystemsPath;
-  string CFGVersion;
-  string Release;
-  string RootDir;
+  std::string modelName;
+  std::string AircraftPath;
+  std::string FullAircraftPath;
+  std::string EnginePath;
+  std::string SystemsPath;
+  std::string CFGVersion;
+  std::string Release;
+  std::string RootDir;
 
   // Standard Model pointers - shortcuts for internal executive use only.
   FGPropagate* Propagate;
@@ -613,6 +621,7 @@ private:
 
   bool trim_status;
   int ta_mode;
+  unsigned int ResetMode;
 
   FGScript*           Script;
   FGInitialCondition* IC;
@@ -625,14 +634,13 @@ private:
   // The FDM counter is used to give each child FDM an unique ID. The root FDM has the ID 0
   unsigned int*      FDMctr;
 
-  vector <string> PropertyCatalog;
-  vector <childData*> ChildFDMList;
-  vector <FGModel*> Models;
+  std::vector <std::string> PropertyCatalog;
+  std::vector <childData*> ChildFDMList;
+  std::vector <FGModel*> Models;
 
   bool ReadFileHeader(Element*);
   bool ReadChild(Element*);
   bool ReadPrologue(Element*);
-  void ResetToInitialConditions(int mode);
   void SRand(int sr);
   void LoadInputs(unsigned int idx);
   void LoadPlanetConstants(void);