2001-04-02 03:12:38 +00:00
|
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
Header: FGFDMExec.h
|
|
|
|
|
Author: Jon Berndt
|
|
|
|
|
Date started: 11/17/98
|
2007-01-15 12:48:54 +00:00
|
|
|
|
file The header file for the JSBSim executive.
|
2001-04-02 03:12:38 +00:00
|
|
|
|
|
|
|
|
|
------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under
|
2007-01-15 12:48:54 +00:00
|
|
|
|
the terms of the GNU Lesser General Public License as published by the Free Software
|
2001-04-02 03:12:38 +00:00
|
|
|
|
Foundation; either version 2 of the License, or (at your option) any later
|
|
|
|
|
version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
2007-01-15 12:48:54 +00:00
|
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
2001-04-02 03:12:38 +00:00
|
|
|
|
details.
|
|
|
|
|
|
2007-01-15 12:48:54 +00:00
|
|
|
|
You should have received a copy of the GNU Lesser General Public License along with
|
2001-04-02 03:12:38 +00:00
|
|
|
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|
|
|
|
Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
2007-01-15 12:48:54 +00:00
|
|
|
|
Further information about the GNU Lesser General Public License can also be found on
|
2001-04-02 03:12:38 +00:00
|
|
|
|
the world wide web at http://www.gnu.org.
|
|
|
|
|
|
|
|
|
|
HISTORY
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
11/17/98 JSB Created
|
|
|
|
|
7/31/99 TP Added RunIC function that runs the sim so that every frame
|
|
|
|
|
begins with the IC values from the given FGInitialCondition
|
2004-06-14 11:40:45 +00:00
|
|
|
|
object and dt=0.
|
2001-04-02 03:12:38 +00:00
|
|
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
SENTRY
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
|
|
|
|
|
#ifndef FGFDMEXEC_HEADER_H
|
|
|
|
|
#define FGFDMEXEC_HEADER_H
|
|
|
|
|
|
|
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
INCLUDES
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
|
2006-01-12 15:04:22 +00:00
|
|
|
|
#include <models/FGModel.h>
|
|
|
|
|
#include <models/FGOutput.h>
|
|
|
|
|
#include <models/FGInput.h>
|
|
|
|
|
#include <initialization/FGTrim.h>
|
|
|
|
|
#include <initialization/FGInitialCondition.h>
|
|
|
|
|
#include <FGJSBBase.h>
|
|
|
|
|
#include <input_output/FGPropertyManager.h>
|
|
|
|
|
#include <input_output/FGGroundCallback.h>
|
2007-06-03 09:37:02 +00:00
|
|
|
|
#include <input_output/FGXMLFileRead.h>
|
2006-01-12 15:04:22 +00:00
|
|
|
|
#include <models/FGPropagate.h>
|
2001-04-02 03:12:38 +00:00
|
|
|
|
|
2002-03-20 12:45:02 +00:00
|
|
|
|
#include <vector>
|
2008-07-10 17:23:02 +00:00
|
|
|
|
#include <string>
|
2004-01-14 22:09:39 +00:00
|
|
|
|
|
2001-04-02 03:12:38 +00:00
|
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
DEFINITIONS
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
|
|
|
|
|
#define ID_FDMEXEC "$Id$"
|
|
|
|
|
|
|
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
FORWARD DECLARATIONS
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
|
2003-06-03 08:46:15 +00:00
|
|
|
|
namespace JSBSim {
|
|
|
|
|
|
2007-01-15 12:48:54 +00:00
|
|
|
|
class FGScript;
|
2008-07-22 08:49:15 +00:00
|
|
|
|
class FGTrim;
|
2007-01-15 12:48:54 +00:00
|
|
|
|
|
2001-04-02 03:12:38 +00:00
|
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
CLASS DOCUMENTATION
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
|
|
|
|
|
/** Encapsulates the JSBSim simulation executive.
|
2006-01-20 17:50:45 +00:00
|
|
|
|
This class is the executive class through which all other simulation classes
|
2001-04-02 03:12:38 +00:00
|
|
|
|
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.
|
|
|
|
|
|
2006-01-20 17:50:45 +00:00
|
|
|
|
At the time of simulation initialization, the interface
|
|
|
|
|
class creates an instance of this executive class. The
|
|
|
|
|
executive is subsequently directed to load the chosen aircraft specification
|
|
|
|
|
file:
|
|
|
|
|
|
|
|
|
|
@code
|
|
|
|
|
fdmex = new FGFDMExec( <EFBFBD> );
|
|
|
|
|
result = fdmex->LoadModel( <EFBFBD> );
|
|
|
|
|
@endcode
|
2001-04-02 03:12:38 +00:00
|
|
|
|
|
2006-01-20 17:50:45 +00:00
|
|
|
|
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 Load() method is called (e.g. FGFCS::Load()).
|
|
|
|
|
|
|
|
|
|
Subsequent to the creation of the executive and loading of the model,
|
|
|
|
|
initialization is performed. Initialization involves copying control inputs
|
|
|
|
|
into the appropriate JSBSim data storage locations, configuring it for the set
|
|
|
|
|
of user supplied initial conditions, and then copying state variables from
|
|
|
|
|
JSBSim. The state variables are used to drive the instrument displays and to
|
|
|
|
|
place the vehicle model in world space for visual rendering:
|
|
|
|
|
|
|
|
|
|
@code
|
|
|
|
|
copy_to_JSBsim(); // copy control inputs to JSBSim
|
|
|
|
|
fdmex->RunIC(); // loop JSBSim once w/o integrating
|
|
|
|
|
copy_from_JSBsim(); // update the bus
|
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
|
|
Once initialization is complete, cyclic execution proceeds:
|
|
|
|
|
|
|
|
|
|
@code
|
|
|
|
|
copy_to_JSBsim(); // copy control inputs to JSBSim
|
|
|
|
|
fdmex->Run(); // execute JSBSim
|
|
|
|
|
copy_from_JSBsim(); // update the bus
|
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
|
|
JSBSim can be used in a standalone mode by creating a compact stub program
|
|
|
|
|
that effectively performs the same progression of steps as outlined above for
|
|
|
|
|
the integrated version, but with two exceptions. First, the copy_to_JSBSim()
|
|
|
|
|
and copy_from_JSBSim() functions are not used because the control inputs are
|
|
|
|
|
handled directly by the scripting facilities and outputs are handled by the
|
|
|
|
|
output (data logging) class. Second, the name of a script file can be supplied
|
|
|
|
|
to the stub program. Scripting (see FGScript) provides a way to supply command
|
|
|
|
|
inputs to the simulation:
|
|
|
|
|
|
|
|
|
|
@code
|
|
|
|
|
FDMExec = new JSBSim::FGFDMExec();
|
2007-01-15 12:48:54 +00:00
|
|
|
|
FDMExec->LoadScript( ScriptName ); // the script loads the aircraft and ICs
|
2006-01-20 17:50:45 +00:00
|
|
|
|
result = FDMExec->Run();
|
|
|
|
|
while (result) { // cyclic execution
|
|
|
|
|
result = FDMExec->Run(); // execute JSBSim
|
|
|
|
|
}
|
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
|
|
The standalone mode has been useful for verifying changes before committing
|
|
|
|
|
updates to the source code repository. It is also useful for running sets of
|
|
|
|
|
tests that reveal some aspects of simulated aircraft performance, such as
|
|
|
|
|
range, time-to-climb, takeoff distance, etc.
|
|
|
|
|
|
|
|
|
|
<h3>JSBSim Debugging Directives</h3>
|
2001-04-02 03:12:38 +00:00
|
|
|
|
|
|
|
|
|
This describes to any interested entity the debug level
|
|
|
|
|
requested by setting the JSBSIM_DEBUG environment variable.
|
2004-06-14 11:40:45 +00:00
|
|
|
|
The bitmasked value choices are as follows:
|
|
|
|
|
- <b>unset</b>: In this case (the default) JSBSim would only print
|
2001-04-02 03:12:38 +00:00
|
|
|
|
out the normally expected messages, essentially echoing
|
|
|
|
|
the config files as they are read. If the environment
|
2004-06-14 11:40:45 +00:00
|
|
|
|
variable is not set, debug_lvl is set to 1 internally
|
|
|
|
|
- <b>0</b>: This requests JSBSim not to output any messages
|
|
|
|
|
whatsoever
|
|
|
|
|
- <b>1</b>: This value explicity requests the normal JSBSim
|
|
|
|
|
startup messages
|
|
|
|
|
- <b>2</b>: This value asks for a message to be printed out when
|
|
|
|
|
a class is instantiated
|
|
|
|
|
- <b>4</b>: When this value is set, a message is displayed when a
|
|
|
|
|
FGModel object executes its Run() method
|
|
|
|
|
- <b>8</b>: When this value is set, various runtime state variables
|
|
|
|
|
are printed out periodically
|
|
|
|
|
- <b>16</b>: When set various parameters are sanity checked and
|
|
|
|
|
a message is printed out when they go out of bounds
|
2001-04-02 03:12:38 +00:00
|
|
|
|
|
2006-01-20 17:50:45 +00:00
|
|
|
|
<h3>Properties</h3>
|
2006-02-02 09:35:25 +00:00
|
|
|
|
@property simulator/do_trim (write only) Can be set to the integer equivalent to one of
|
2006-01-20 17:50:45 +00:00
|
|
|
|
tLongitudinal (0), tFull (1), tGround (2), tPullup (3),
|
|
|
|
|
tCustom (4), tTurn (5). Setting this to a legal value
|
2006-02-02 09:35:25 +00:00
|
|
|
|
(such as by a script) causes a trim to be performed. This
|
|
|
|
|
property actually maps toa function call of DoTrim().
|
2006-01-20 17:50:45 +00:00
|
|
|
|
|
2004-01-14 22:09:39 +00:00
|
|
|
|
@author Jon S. Berndt
|
2006-01-20 17:50:45 +00:00
|
|
|
|
@version $Revision$
|
2001-04-02 03:12:38 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
CLASS DECLARATION
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
|
2007-06-03 09:37:02 +00:00
|
|
|
|
class FGFDMExec : public FGJSBBase, public FGXMLFileRead
|
2001-04-02 03:12:38 +00:00
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
2002-03-20 12:45:02 +00:00
|
|
|
|
/// Default constructor
|
|
|
|
|
FGFDMExec(FGPropertyManager* root = 0);
|
2004-06-14 11:40:45 +00:00
|
|
|
|
|
2001-04-02 03:12:38 +00:00
|
|
|
|
/// Default destructor
|
|
|
|
|
~FGFDMExec();
|
|
|
|
|
|
|
|
|
|
/** This routine places a model into the runlist at the specified rate. The
|
|
|
|
|
"rate" is not really a clock rate. It represents how many calls to the
|
|
|
|
|
FGFDMExec::Run() method must be made before the model is executed. A
|
|
|
|
|
value of 1 means that the model will be executed for each call to the
|
|
|
|
|
exec's Run() method. A value of 5 means that the model will only be
|
2006-01-20 17:50:45 +00:00
|
|
|
|
executed every 5th call to the exec's Run() method. Use of a rate other than
|
|
|
|
|
one is at this time not recommended.
|
2001-04-02 03:12:38 +00:00
|
|
|
|
@param model A pointer to the model being scheduled.
|
|
|
|
|
@param rate The rate at which to execute the model as described above.
|
|
|
|
|
@return Currently returns 0 always. */
|
|
|
|
|
int Schedule(FGModel* model, int rate);
|
|
|
|
|
|
2006-01-20 17:50:45 +00:00
|
|
|
|
/** This function executes each scheduled model in succession.
|
2001-04-02 03:12:38 +00:00
|
|
|
|
@return true if successful, false if sim should be ended */
|
|
|
|
|
bool Run(void);
|
|
|
|
|
|
2002-09-22 15:31:09 +00:00
|
|
|
|
/** Initializes the sim from the initial condition object and executes
|
|
|
|
|
each scheduled model without integrating i.e. dt=0.
|
2006-01-12 15:04:22 +00:00
|
|
|
|
@return true if successful */
|
2002-09-22 15:31:09 +00:00
|
|
|
|
bool RunIC(void);
|
2001-04-02 03:12:38 +00:00
|
|
|
|
|
2006-01-12 15:04:22 +00:00
|
|
|
|
/** Sets the ground callback pointer.
|
|
|
|
|
@param gc A pointer to a ground callback object. */
|
|
|
|
|
void SetGroundCallback(FGGroundCallback* gc);
|
2005-05-22 08:06:47 +00:00
|
|
|
|
|
2004-06-14 11:40:45 +00:00
|
|
|
|
/** Loads an aircraft model.
|
2006-01-20 17:50:45 +00:00
|
|
|
|
@param AircraftPath path to the aircraft/ directory. For instance:
|
2001-04-02 03:12:38 +00:00
|
|
|
|
"aircraft". Under aircraft, then, would be directories for various
|
|
|
|
|
modeled aircraft such as C172/, x15/, etc.
|
|
|
|
|
@param EnginePath path to the directory under which engine config
|
|
|
|
|
files are kept, for instance "engine"
|
2008-07-10 17:23:02 +00:00
|
|
|
|
@param SystemsPath path to the directory under which systems config
|
|
|
|
|
files are kept, for instance "systems"
|
2001-04-02 03:12:38 +00:00
|
|
|
|
@param model the name of the aircraft model itself. This file will
|
|
|
|
|
be looked for in the directory specified in the AircraftPath variable,
|
|
|
|
|
and in turn under the directory with the same name as the model. For
|
|
|
|
|
instance: "aircraft/x15/x15.xml"
|
2004-06-27 19:35:54 +00:00
|
|
|
|
@param addModelToPath set to true to add the model name to the
|
|
|
|
|
AircraftPath, defaults to true
|
2006-01-20 17:50:45 +00:00
|
|
|
|
@return true if successful */
|
2008-07-10 17:23:02 +00:00
|
|
|
|
bool LoadModel(string AircraftPath, string EnginePath, string SystemsPath,
|
|
|
|
|
string model, bool addModelToPath = true);
|
2004-06-14 11:40:45 +00:00
|
|
|
|
|
2002-09-22 15:31:09 +00:00
|
|
|
|
/** Loads an aircraft model. The paths to the aircraft and engine
|
|
|
|
|
config file directories must be set prior to calling this. See
|
|
|
|
|
below.
|
|
|
|
|
@param model the name of the aircraft model itself. This file will
|
|
|
|
|
be looked for in the directory specified in the AircraftPath variable,
|
|
|
|
|
and in turn under the directory with the same name as the model. For
|
|
|
|
|
instance: "aircraft/x15/x15.xml"
|
2004-06-27 19:35:54 +00:00
|
|
|
|
@param addModelToPath set to true to add the model name to the
|
|
|
|
|
AircraftPath, defaults to true
|
2002-09-22 15:31:09 +00:00
|
|
|
|
@return true if successful*/
|
2004-06-27 19:35:54 +00:00
|
|
|
|
bool LoadModel(string model, bool addModelToPath = true);
|
2004-06-14 11:40:45 +00:00
|
|
|
|
|
2007-01-15 12:48:54 +00:00
|
|
|
|
/** Loads a script
|
|
|
|
|
@param Script the full path name and file name for the script to be loaded.
|
|
|
|
|
@return true if successfully loadsd; false otherwise. */
|
|
|
|
|
bool LoadScript(string Script);
|
|
|
|
|
|
2002-09-22 15:31:09 +00:00
|
|
|
|
/** Sets the path to the engine config file directories.
|
2004-01-14 22:09:39 +00:00
|
|
|
|
@param path path to the directory under which engine config
|
2006-01-12 15:04:22 +00:00
|
|
|
|
files are kept, for instance "engine" */
|
2002-09-22 15:31:09 +00:00
|
|
|
|
bool SetEnginePath(string path) { EnginePath = path; return true; }
|
2001-04-02 03:12:38 +00:00
|
|
|
|
|
2002-09-22 15:31:09 +00:00
|
|
|
|
/** Sets the path to the aircraft config file directories.
|
2004-01-14 22:09:39 +00:00
|
|
|
|
@param path path to the aircraft directory. For instance:
|
2002-09-22 15:31:09 +00:00
|
|
|
|
"aircraft". Under aircraft, then, would be directories for various
|
2006-01-12 15:04:22 +00:00
|
|
|
|
modeled aircraft such as C172/, x15/, etc. */
|
2002-09-22 15:31:09 +00:00
|
|
|
|
bool SetAircraftPath(string path) { AircraftPath = path; return true; }
|
2008-07-10 17:23:02 +00:00
|
|
|
|
|
|
|
|
|
/** 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(string path) { SystemsPath = path; return true; }
|
|
|
|
|
|
2001-04-02 03:12:38 +00:00
|
|
|
|
/// @name Top-level executive State and Model retrieval mechanism
|
|
|
|
|
//@{
|
|
|
|
|
/// Returns the FGAtmosphere pointer.
|
|
|
|
|
inline FGAtmosphere* GetAtmosphere(void) {return Atmosphere;}
|
|
|
|
|
/// Returns the FGFCS pointer.
|
|
|
|
|
inline FGFCS* GetFCS(void) {return FCS;}
|
|
|
|
|
/// Returns the FGPropulsion pointer.
|
|
|
|
|
inline FGPropulsion* GetPropulsion(void) {return Propulsion;}
|
|
|
|
|
/// Returns the FGAircraft pointer.
|
2001-06-05 20:58:48 +00:00
|
|
|
|
inline FGMassBalance* GetMassBalance(void) {return MassBalance;}
|
|
|
|
|
/// Returns the FGAerodynamics pointer
|
|
|
|
|
inline FGAerodynamics* GetAerodynamics(void){return Aerodynamics;}
|
|
|
|
|
/// Returns the FGInertial pointer.
|
|
|
|
|
inline FGInertial* GetInertial(void) {return Inertial;}
|
2001-10-05 20:19:59 +00:00
|
|
|
|
/// Returns the FGGroundReactions pointer.
|
|
|
|
|
inline FGGroundReactions* GetGroundReactions(void) {return GroundReactions;}
|
2008-07-10 17:23:02 +00:00
|
|
|
|
/// Returns the FGExternalReactions pointer.
|
|
|
|
|
inline FGExternalReactions* GetExternalReactions(void) {return ExternalReactions;}
|
|
|
|
|
/// Returns the FGBuoyantForces pointer.
|
|
|
|
|
inline FGBuoyantForces* GetBuoyantForces(void) {return BuoyantForces;}
|
2001-06-05 20:58:48 +00:00
|
|
|
|
/// Returns the FGAircraft pointer.
|
2001-04-02 03:12:38 +00:00
|
|
|
|
inline FGAircraft* GetAircraft(void) {return Aircraft;}
|
2004-06-14 11:40:45 +00:00
|
|
|
|
/// Returns the FGPropagate pointer.
|
2005-05-22 08:06:47 +00:00
|
|
|
|
inline FGPropagate* GetPropagate(void) {return Propagate;}
|
2001-04-02 03:12:38 +00:00
|
|
|
|
/// Returns the FGAuxiliary pointer.
|
|
|
|
|
inline FGAuxiliary* GetAuxiliary(void) {return Auxiliary;}
|
2006-01-12 15:04:22 +00:00
|
|
|
|
/// Returns the FGInput pointer.
|
|
|
|
|
inline FGInput* GetInput(void) {return Input;}
|
|
|
|
|
/// Returns the FGGroundCallback pointer.
|
|
|
|
|
inline FGGroundCallback* GetGroundCallback(void) {return GroundCallback;}
|
|
|
|
|
/// Returns the FGState pointer.
|
|
|
|
|
inline FGState* GetState(void) {return State;}
|
2008-07-10 17:23:02 +00:00
|
|
|
|
/// Retrieves the script object
|
|
|
|
|
inline FGScript* GetScript(void) {return Script;}
|
2002-09-22 15:31:09 +00:00
|
|
|
|
// Returns a pointer to the FGInitialCondition object
|
|
|
|
|
inline FGInitialCondition* GetIC(void) {return IC;}
|
|
|
|
|
// Returns a pointer to the FGTrim object
|
2008-07-10 17:23:02 +00:00
|
|
|
|
FGTrim* GetTrim(void);
|
2001-04-02 03:12:38 +00:00
|
|
|
|
//@}
|
2004-06-14 11:40:45 +00:00
|
|
|
|
|
2001-04-02 03:12:38 +00:00
|
|
|
|
/// Retrieves the engine path.
|
|
|
|
|
inline string GetEnginePath(void) {return EnginePath;}
|
|
|
|
|
/// Retrieves the aircraft path.
|
|
|
|
|
inline string GetAircraftPath(void) {return AircraftPath;}
|
2008-07-10 17:23:02 +00:00
|
|
|
|
/// Retrieves the systems path.
|
|
|
|
|
inline string GetSystemsPath(void) {return SystemsPath;}
|
2007-01-15 12:48:54 +00:00
|
|
|
|
/// Retrieves the full aircraft path name.
|
|
|
|
|
inline 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(string property) {return instance->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(string property, double value) {
|
|
|
|
|
instance->SetDouble(property, value);
|
|
|
|
|
}
|
2004-06-14 11:40:45 +00:00
|
|
|
|
|
2006-01-12 15:04:22 +00:00
|
|
|
|
/// Returns the model name.
|
2002-09-22 15:31:09 +00:00
|
|
|
|
string GetModelName(void) { return modelName; }
|
2004-06-14 11:40:45 +00:00
|
|
|
|
|
2007-01-15 12:48:54 +00:00
|
|
|
|
/// Returns the current time.
|
|
|
|
|
double GetSimTime(void);
|
|
|
|
|
|
|
|
|
|
/// Returns the current frame time (delta T).
|
|
|
|
|
double GetDeltaT(void);
|
2008-07-10 17:23:02 +00:00
|
|
|
|
|
2006-01-12 15:04:22 +00:00
|
|
|
|
/// Returns a pointer to the property manager object.
|
2002-03-20 12:45:02 +00:00
|
|
|
|
FGPropertyManager* GetPropertyManager(void);
|
2006-01-12 15:04:22 +00:00
|
|
|
|
/// Returns a vector of strings representing the names of all loaded models (future)
|
2002-03-23 00:29:21 +00:00
|
|
|
|
vector <string> EnumerateFDMs(void);
|
2006-01-12 15:04:22 +00:00
|
|
|
|
/// Marks this instance of the Exec object as a "slave" object.
|
2007-01-15 12:48:54 +00:00
|
|
|
|
void SetSlave(bool s) {IsSlave = s;}
|
|
|
|
|
|
|
|
|
|
/** Sets the output (logging) mechanism for this run.
|
|
|
|
|
Calling this function passes the name of an output directives file to
|
|
|
|
|
the FGOutput object associated with this run. The call to this function
|
|
|
|
|
should be made prior to loading an aircraft model. This call results in an
|
|
|
|
|
FGOutput object being built as the first Output object in the FDMExec-managed
|
|
|
|
|
list of Output objects that may be created for an aircraft model. If this call
|
|
|
|
|
is made after an aircraft model is loaded, there is no effect. Any Output
|
|
|
|
|
objects added by the aircraft model itself (in an <output> element) will be
|
|
|
|
|
added after this one. Care should be taken not to refer to the same file
|
|
|
|
|
name.
|
|
|
|
|
An output directives file contains an <output> </output> element, within
|
|
|
|
|
which should be specified the parameters or parameter groups that should
|
|
|
|
|
be logged.
|
|
|
|
|
@param fname the filename of an output directives file.
|
|
|
|
|
*/
|
|
|
|
|
bool SetOutputDirectives(string fname);
|
|
|
|
|
|
|
|
|
|
/** 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(string fname) {
|
|
|
|
|
if (Outputs.size() > 0) Outputs[0]->SetOutputFileName(fname);
|
|
|
|
|
else return false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 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("");
|
|
|
|
|
}
|
2004-06-14 11:40:45 +00:00
|
|
|
|
|
2006-01-12 15:04:22 +00:00
|
|
|
|
/** Executes trimming in the selected mode.
|
|
|
|
|
* @param mode Specifies how to trim:
|
|
|
|
|
* - tLongitudinal=0
|
|
|
|
|
* - tFull
|
|
|
|
|
* - tGround
|
|
|
|
|
* - tPullup
|
|
|
|
|
* - tCustom
|
|
|
|
|
* - tTurn
|
2006-01-20 17:50:45 +00:00
|
|
|
|
* - tNone */
|
2006-01-12 15:04:22 +00:00
|
|
|
|
void DoTrim(int mode);
|
2008-07-10 17:23:02 +00:00
|
|
|
|
// void DoTrimAnalysis(int mode);
|
2006-01-12 15:04:22 +00:00
|
|
|
|
|
|
|
|
|
/// Disables data logging to all outputs.
|
|
|
|
|
void DisableOutput(void);
|
|
|
|
|
/// Enables data logging to all outputs.
|
|
|
|
|
void EnableOutput(void);
|
|
|
|
|
/// Pauses execution by preventing time from incrementing.
|
|
|
|
|
void Hold(void) {holding = true;}
|
|
|
|
|
/// Resumes execution from a "Hold".
|
|
|
|
|
void Resume(void) {holding = false;}
|
|
|
|
|
/// Returns true if the simulation is Holding (i.e. simulation time is not moving).
|
|
|
|
|
bool Holding(void) {return holding;}
|
2008-07-10 17:23:02 +00:00
|
|
|
|
/// Resets the initial conditions object and prepares the simulation to run again.
|
|
|
|
|
void ResetToInitialConditions(void);
|
2007-01-15 12:48:54 +00:00
|
|
|
|
/// Sets the debug level.
|
|
|
|
|
void SetDebugLevel(int level) {debug_lvl = level;}
|
2006-01-12 15:04:22 +00:00
|
|
|
|
|
|
|
|
|
struct PropertyCatalogStructure {
|
|
|
|
|
/// Name of the property.
|
|
|
|
|
string base_string;
|
|
|
|
|
/// The node for the property.
|
|
|
|
|
FGPropertyManager *node;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** Builds a catalog of properties.
|
|
|
|
|
* This function descends the property tree and creates a list (an STL vector)
|
|
|
|
|
* containing the name and node for all properties.
|
|
|
|
|
* @param pcs The "root" property catalog structure pointer. */
|
|
|
|
|
void BuildPropertyCatalog(struct PropertyCatalogStructure* pcs);
|
|
|
|
|
|
|
|
|
|
/** Retrieves property or properties matching the supplied string.
|
|
|
|
|
* A string is returned that contains a carriage return delimited list of all
|
2006-01-20 17:50:45 +00:00
|
|
|
|
* strings in the property catalog that matches the supplied check string.
|
2006-01-12 15:04:22 +00:00
|
|
|
|
* @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(string check);
|
|
|
|
|
|
2007-01-15 12:48:54 +00:00
|
|
|
|
// Print the contents of the property catalog for the loaded aircraft.
|
|
|
|
|
void PrintPropertyCatalog(void);
|
|
|
|
|
|
2006-01-12 15:04:22 +00:00
|
|
|
|
/// Use the MSIS atmosphere model.
|
|
|
|
|
void UseAtmosphereMSIS(void);
|
|
|
|
|
|
|
|
|
|
/// Use the Mars atmosphere model. (Not operative yet.)
|
2006-01-20 17:50:45 +00:00
|
|
|
|
void UseAtmosphereMars(void);
|
2006-01-12 15:04:22 +00:00
|
|
|
|
|
2008-07-10 17:23:02 +00:00
|
|
|
|
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; }
|
|
|
|
|
|
2001-04-02 03:12:38 +00:00
|
|
|
|
private:
|
2007-01-15 12:48:54 +00:00
|
|
|
|
static unsigned int FDMctr;
|
|
|
|
|
int Error;
|
2001-11-12 16:06:29 +00:00
|
|
|
|
unsigned int Frame;
|
|
|
|
|
unsigned int IdFDM;
|
2007-06-03 09:37:02 +00:00
|
|
|
|
unsigned short Terminate;
|
2007-01-15 12:48:54 +00:00
|
|
|
|
bool holding;
|
|
|
|
|
bool Constructing;
|
2001-04-02 03:12:38 +00:00
|
|
|
|
bool modelLoaded;
|
2002-03-23 00:29:21 +00:00
|
|
|
|
bool IsSlave;
|
2007-01-15 12:48:54 +00:00
|
|
|
|
string modelName;
|
|
|
|
|
string AircraftPath;
|
|
|
|
|
string FullAircraftPath;
|
|
|
|
|
string EnginePath;
|
2008-07-10 17:23:02 +00:00
|
|
|
|
string SystemsPath;
|
2007-01-15 12:48:54 +00:00
|
|
|
|
string CFGVersion;
|
|
|
|
|
string Release;
|
2004-06-14 11:40:45 +00:00
|
|
|
|
|
2008-07-10 17:23:02 +00:00
|
|
|
|
bool trim_status;
|
|
|
|
|
int ta_mode;
|
|
|
|
|
|
|
|
|
|
|
2002-03-23 00:29:21 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2007-01-15 12:48:54 +00:00
|
|
|
|
static FGPropertyManager *master;
|
2004-06-14 11:40:45 +00:00
|
|
|
|
|
2007-01-15 12:48:54 +00:00
|
|
|
|
FGModel* FirstModel;
|
|
|
|
|
FGGroundCallback* GroundCallback;
|
|
|
|
|
FGState* State;
|
|
|
|
|
FGAtmosphere* Atmosphere;
|
|
|
|
|
FGFCS* FCS;
|
|
|
|
|
FGPropulsion* Propulsion;
|
|
|
|
|
FGMassBalance* MassBalance;
|
|
|
|
|
FGAerodynamics* Aerodynamics;
|
|
|
|
|
FGInertial* Inertial;
|
|
|
|
|
FGGroundReactions* GroundReactions;
|
2008-07-10 17:23:02 +00:00
|
|
|
|
FGExternalReactions* ExternalReactions;
|
|
|
|
|
FGBuoyantForces* BuoyantForces;
|
2007-01-15 12:48:54 +00:00
|
|
|
|
FGAircraft* Aircraft;
|
|
|
|
|
FGPropagate* Propagate;
|
|
|
|
|
FGAuxiliary* Auxiliary;
|
|
|
|
|
FGInput* Input;
|
|
|
|
|
FGScript* Script;
|
2002-09-22 15:31:09 +00:00
|
|
|
|
FGInitialCondition* IC;
|
2007-01-15 12:48:54 +00:00
|
|
|
|
FGTrim* Trim;
|
2001-04-02 03:12:38 +00:00
|
|
|
|
|
2007-01-15 12:48:54 +00:00
|
|
|
|
FGPropertyManager* Root;
|
|
|
|
|
FGPropertyManager* instance;
|
|
|
|
|
|
|
|
|
|
vector <string> PropertyCatalog;
|
|
|
|
|
vector <FGOutput*> Outputs;
|
2002-03-23 00:29:21 +00:00
|
|
|
|
vector <slaveData*> SlaveFDMList;
|
|
|
|
|
|
2006-01-12 15:04:22 +00:00
|
|
|
|
bool ReadFileHeader(Element*);
|
|
|
|
|
bool ReadSlave(Element*);
|
|
|
|
|
bool ReadPrologue(Element*);
|
2009-03-25 10:00:46 +00:00
|
|
|
|
void ResetToInitialConditions(int mode);
|
2001-04-02 03:12:38 +00:00
|
|
|
|
bool Allocate(void);
|
|
|
|
|
bool DeAllocate(void);
|
2007-01-15 12:48:54 +00:00
|
|
|
|
|
2001-12-13 04:48:34 +00:00
|
|
|
|
void Debug(int from);
|
2001-04-02 03:12:38 +00:00
|
|
|
|
};
|
2003-01-24 12:55:28 +00:00
|
|
|
|
}
|
2001-04-02 03:12:38 +00:00
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
#endif
|