]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGFDMExec.h
Updated to match changes in radiostack.[ch]xx
[flightgear.git] / src / FDM / JSBSim / FGFDMExec.h
index b5a3ee7cf7023d38d28c6ae7c18c44cf3be97cff..10262d8d3764f777e75cf3bb916252a57d2a08b3 100644 (file)
@@ -42,8 +42,10 @@ INCLUDES
 
 #include "FGModel.h"
 #include "FGInitialCondition.h"
-#include <vector>
+#include "FGJSBBase.h"
+#include "FGPropertyManager.h"
 
+#include <vector>
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -54,41 +56,8 @@ DEFINITIONS
 FORWARD DECLARATIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-class FGState;
-class FGAtmosphere;
-class FGFCS;
-class FGPropulsion;
-class FGMassBalance;
-class FGAerodynamics;
-class FGInertial;
-class FGAircraft;
-class FGTranslation;
-class FGRotation;
-class FGPosition;
-class FGAuxiliary;
-class FGOutput;
 class FGInitialCondition;
 
-struct condition {
-  vector <eParam>  TestParam;
-  vector <eParam>  SetParam;
-  vector <float>   TestValue;
-  vector <float>   SetValue;
-  vector <string>  Comparison;
-  vector <float>   TC;
-  vector <bool>    Persistent;
-  vector <eAction> Action;
-  vector <eType>   Type;
-  vector <bool>    Triggered;
-  vector <float>   newValue;
-  vector <float>   OriginalValue;
-  vector <float>   StartTime;
-  vector <float>   EndTime;
-
-  condition() {
-  }
-};
-
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -100,70 +69,20 @@ CLASS DOCUMENTATION
 /** Encapsulates the JSBSim simulation executive.
     @author Jon S. Berndt
     @version $Id$
+    @see <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jsbsim/JSBSim/FGFDMExec.h?rev=HEAD&content-type=text/vnd.viewcvs-markup">
+         Header File </a>
+    @see <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jsbsim/JSBSim/FGFDMExec.cpp?rev=HEAD&content-type=text/vnd.viewcvs-markup">
+         Source File </a>
 
     @doc This class is the interface 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.
 
-    <h4>Scripting support provided in the Executive</h4>
-
-    <p>There is simple scripting support provided in the FGFDMExec
-    class. Commands are specified using the <u>Simple Scripting
-    Directives for JSBSim</u> (SSDJ). The script file is in XML
-    format. A test condition (or conditions) can be set up in the
-    script and when the condition evaluates to true, the specified
-    action[s] is/are taken. A test condition can be <em>persistent</em>,
-    meaning that if a test condition evaluates to true, then passes
-    and evaluates to false, the condition is reset and may again be
-    triggered. When the set of tests evaluates to true for a given
-    condition, an item may be set to another value. This value might
-    be a boolean, a value, or a delta value, and the change from the
-    current value to the new value can be either via a step function,
-    a ramp, or an exponential approach. The speed of a ramp or
-    approach is specified via the time constant. Here is the format
-    of the script file:</p>
-
-    <pre><strong>&lt;?xml version=&quot;1.0&quot;?&gt;
-    &lt;runscript name=&quot;C172-01A&quot;&gt;
-
-    &lt;!--
-    This run is for testing C172 runs
-    --&gt;
-
-    &lt;use aircraft=&quot;c172&quot;&gt;
-    &lt;use initialize=&quot;reset00&quot;&gt;
-
-    &lt;run start=&quot;0.0&quot; end=&quot;4.5&quot; dt=&quot;0.05&quot;&gt;
-      &lt;when&gt;
-        &lt;parameter name=&quot;FG_TIME&quot; comparison=&quot;ge&quot; value=&quot;0.25&quot;&gt;
-        &lt;parameter name=&quot;FG_TIME&quot; comparison=&quot;le&quot; value=&quot;0.50&quot;&gt;
-        &lt;set name=&quot;FG_AILERON_CMD&quot; type=&quot;FG_VALUE&quot; value=&quot;0.25&quot;
-        action=&quot;FG_STEP&quot; persistent=&quot;false&quot; tc =&quot;0.25&quot;&gt;
-      &lt;/when&gt;
-      &lt;when&gt;
-        &lt;parameter name=&quot;FG_TIME&quot; comparison=&quot;ge&quot; value=&quot;0.5&quot;&gt;
-        &lt;parameter name=&quot;FG_TIME&quot; comparison=&quot;le&quot; value=&quot;1.5&quot;&gt;
-        &lt;set name=&quot;FG_AILERON_CMD&quot; type=&quot;FG_DELTA&quot; value=&quot;0.5&quot;
-        action=&quot;FG_EXP&quot; persistent=&quot;false&quot; tc =&quot;0.5&quot;&gt;
-      &lt;/when&gt;
-      &lt;when&gt;
-        &lt;parameter name=&quot;FG_TIME&quot; comparison=&quot;ge&quot; value=&quot;1.5&quot;&gt;
-        &lt;parameter name=&quot;FG_TIME&quot; comparison=&quot;le&quot; value=&quot;2.5&quot;&gt;
-        &lt;set name=&quot;FG_RUDDER_CMD&quot; type=&quot;FG_DELTA&quot; value=&quot;0.5&quot;
-        action=&quot;FG_RAMP&quot; persistent=&quot;false&quot; tc =&quot;0.5&quot;&gt;
-      &lt;/when&gt;
-    &lt;/run&gt;
-
-    &lt;/runscript&gt;</strong></pre>
-
-    <p>The first line must always be present. The second line
-    identifies this file as a script file, and gives a descriptive
-    name to the script file. Comments are next, delineated by the
-    &lt;!-- and --&gt; symbols. The aircraft and initialization files
-    to be used are specified in the &quot;use&quot; lines. Next,
-    comes the &quot;run&quot; section, where the conditions are
-    described in &quot;when&quot; clauses.</p>
+    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 "ReadXXX()" method is called. From within this method the 
+    "Load()" method of that system is called (e.g. LoadFCS).
 
     <h4>JSBSim Debugging Directives</h4>
 
@@ -194,12 +113,13 @@ CLASS DOCUMENTATION
 CLASS DECLARATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-class FGFDMExec
+class FGFDMExec : public FGJSBBase
 {
 public:
-  /// Default constructor
-  FGFDMExec(void);
 
+  /// Default constructor
+  FGFDMExec(FGPropertyManager* root = 0);
+  
   /// Default destructor
   ~FGFDMExec();
 
@@ -214,8 +134,7 @@ public:
       @return Currently returns 0 always. */
   int  Schedule(FGModel* model, int rate);
 
-  /** This executes each scheduled model in succession, as well as running any
-      scripts which are loaded.
+  /** This executes each scheduled model in succession.
       @return true if successful, false if sim should be ended  */
   bool Run(void);
 
@@ -245,19 +164,8 @@ public:
       @return true if successful*/
   bool LoadModel(string AircraftPath, string EnginePath, string model);
 
-  /** Loads a script to drive JSBSim (usually in standalone mode).
-      The language is the Simple Script Directives for JSBSim (SSDJ).
-      @param script the filename (including path name, if any) for the script.
-      @return true if successful */
-  bool LoadScript(string script);
-
-  /** This function is called each pass through the executive Run() method IF
-      scripting is enabled. */
-  void RunScript(void);
-
   bool SetEnginePath(string path)   {EnginePath = path; return true;}
   bool SetAircraftPath(string path) {AircraftPath = path; return true;}
-  bool SetScriptPath(string path)   {ScriptPath = path; return true;}
 
   /// @name Top-level executive State and Model retrieval mechanism
   //@{
@@ -275,6 +183,8 @@ public:
   inline FGAerodynamics* GetAerodynamics(void){return Aerodynamics;}
   /// Returns the FGInertial pointer.
   inline FGInertial* GetInertial(void)        {return Inertial;}
+  /// Returns the FGGroundReactions pointer.
+  inline FGGroundReactions* GetGroundReactions(void) {return GroundReactions;}
   /// Returns the FGAircraft pointer.
   inline FGAircraft* GetAircraft(void)        {return Aircraft;}
   /// Returns the FGTranslation pointer.
@@ -293,42 +203,77 @@ public:
   inline string GetEnginePath(void)          {return EnginePath;}
   /// Retrieves the aircraft path.
   inline string GetAircraftPath(void)        {return AircraftPath;}
-
+  
+  FGPropertyManager* GetPropertyManager(void);
+  vector <string> EnumerateFDMs(void);
+  void SetSlave(void) {IsSlave = true;}
+  
 private:
   FGModel* FirstModel;
 
   bool frozen;
   bool terminate;
   int  Error;
-  int  Frame;
+  unsigned int Frame;
+  unsigned int IdFDM;
+  static unsigned int FDMctr;
   bool modelLoaded;
-  bool Scripted;
+  bool IsSlave;
+  static FGPropertyManager *master;
+  FGPropertyManager *instance;
+  
+  struct slaveData {
+    FGFDMExec* exec;
+    string info;
+    double x, y, z;
+    double roll, pitch, yaw;
+    bool mated;
+
+    slaveData(void) {
+      info = "";
+      x = y = z = 0.0;
+      roll = pitch = yaw = 0.0;
+      mated = true;
+    }
+
+    ~slaveData(void) {
+      delete exec;
+    }
+  };
 
   string AircraftPath;
   string EnginePath;
-  string ScriptPath;
-  string ScriptName;
-  float  StartTime;
-  float  EndTime;
-  vector <struct condition> Conditions;
-
-  FGState*        State;
-  FGAtmosphere*   Atmosphere;
-  FGFCS*          FCS;
-  FGPropulsion*   Propulsion;
-  FGMassBalance*  MassBalance;
-  FGAerodynamics* Aerodynamics;
-  FGInertial*     Inertial;
-  FGAircraft*     Aircraft;
-  FGTranslation*  Translation;
-  FGRotation*     Rotation;
-  FGPosition*     Position;
-  FGAuxiliary*    Auxiliary;
-  FGOutput*       Output;
+  string CFGVersion;
+
+  FGState*           State;
+  FGAtmosphere*      Atmosphere;
+  FGFCS*             FCS;
+  FGPropulsion*      Propulsion;
+  FGMassBalance*     MassBalance;
+  FGAerodynamics*    Aerodynamics;
+  FGInertial*        Inertial;
+  FGGroundReactions* GroundReactions;
+  FGAircraft*        Aircraft;
+  FGTranslation*     Translation;
+  FGRotation*        Rotation;
+  FGPosition*        Position;
+  FGAuxiliary*       Auxiliary;
+  FGOutput*          Output;
+
+  vector <slaveData*> SlaveFDMList;
+
+  bool ReadMetrics(FGConfigFile*);
+  bool ReadSlave(FGConfigFile*);
+  bool ReadPropulsion(FGConfigFile*);
+  bool ReadFlightControls(FGConfigFile*);
+  bool ReadAerodynamics(FGConfigFile*);
+  bool ReadUndercarriage(FGConfigFile*);
+  bool ReadPrologue(FGConfigFile*);
+  bool ReadOutput(FGConfigFile*);
 
   bool Allocate(void);
   bool DeAllocate(void);
-  void Debug(void);
+  void Debug(int from);
 };
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%