FORWARD DECLARATIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-class FGState;
-class FGAtmosphere;
-class FGFCS;
-class FGPropulsion;
-class FGMassBalance;
-class FGAerodynamics;
-class FGInertial;
-class FGGroundReactions;
-class FGAircraft;
-class FGTranslation;
-class FGRotation;
-class FGPosition;
-class FGAuxiliary;
-class FGOutput;
class FGInitialCondition;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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><?xml version="1.0"?>
- <runscript name="C172-01A">
-
- <!--
- This run is for testing C172 runs
- -->
-
- <use aircraft="c172">
- <use initialize="reset00">
-
- <run start="0.0" end="4.5" dt="0.05">
- <when>
- <parameter name="FG_TIME" comparison="ge" value="0.25">
- <parameter name="FG_TIME" comparison="le" value="0.50">
- <set name="FG_AILERON_CMD" type="FG_VALUE" value="0.25"
- action="FG_STEP" persistent="false" tc ="0.25">
- </when>
- <when>
- <parameter name="FG_TIME" comparison="ge" value="0.5">
- <parameter name="FG_TIME" comparison="le" value="1.5">
- <set name="FG_AILERON_CMD" type="FG_DELTA" value="0.5"
- action="FG_EXP" persistent="false" tc ="0.5">
- </when>
- <when>
- <parameter name="FG_TIME" comparison="ge" value="1.5">
- <parameter name="FG_TIME" comparison="le" value="2.5">
- <set name="FG_RUDDER_CMD" type="FG_DELTA" value="0.5"
- action="FG_RAMP" persistent="false" tc ="0.5">
- </when>
- </run>
-
- </runscript></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
- <!-- and --> symbols. The aircraft and initialization files
- to be used are specified in the "use" lines. Next,
- comes the "run" section, where the conditions are
- described in "when" 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>
@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);
@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
//@{
inline string GetAircraftPath(void) {return AircraftPath;}
private:
- enum eAction {
- FG_RAMP = 1,
- FG_STEP = 2,
- FG_EXP = 3
- };
-
- enum eType {
- FG_VALUE = 1,
- FG_DELTA = 2,
- FG_BOOL = 3
- };
-
- struct condition {
- vector <eParam> TestParam;
- vector <eParam> SetParam;
- vector <double> TestValue;
- vector <double> SetValue;
- vector <string> Comparison;
- vector <double> TC;
- vector <bool> Persistent;
- vector <eAction> Action;
- vector <eType> Type;
- vector <bool> Triggered;
- vector <double> newValue;
- vector <double> OriginalValue;
- vector <double> StartTime;
- vector <double> EndTime;
-
- condition() {
- }
- };
-
FGModel* FirstModel;
bool frozen;
unsigned int IdFDM;
static unsigned int FDMctr;
bool modelLoaded;
- bool Scripted;
string AircraftPath;
string EnginePath;
- string ScriptPath;
- string ScriptName;
- double StartTime;
- double EndTime;
- vector <struct condition> Conditions;
+ string CFGVersion;
FGState* State;
FGAtmosphere* Atmosphere;
FGAuxiliary* Auxiliary;
FGOutput* Output;
+ bool ReadMetrics(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(int from);