2000-11-03 23:02:47 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2001-03-30 01:04:50 +00:00
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
Header: FGEngine.h
|
|
|
|
Author: Jon S. Berndt
|
|
|
|
Date started: 01/21/99
|
2001-03-30 01:04:50 +00:00
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
|
2001-03-30 01:04:50 +00:00
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
This program is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU General Public License as published by the Free Software
|
|
|
|
Foundation; either version 2 of the License, or (at your option) any later
|
|
|
|
version.
|
2001-03-30 01:04:50 +00:00
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
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
|
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
details.
|
2001-03-30 01:04:50 +00:00
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
|
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|
|
|
Place - Suite 330, Boston, MA 02111-1307, USA.
|
2001-03-30 01:04:50 +00:00
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
Further information about the GNU General Public License can also be found on
|
|
|
|
the world wide web at http://www.gnu.org.
|
2001-03-30 01:04:50 +00:00
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
FUNCTIONAL DESCRIPTION
|
|
|
|
--------------------------------------------------------------------------------
|
2001-03-30 01:04:50 +00:00
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
Based on Flightgear code, which is based on LaRCSim. This class simulates
|
|
|
|
a generic engine.
|
2001-03-30 01:04:50 +00:00
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
HISTORY
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
01/21/99 JSB Created
|
2001-03-30 01:04:50 +00:00
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
1999-02-05 21:26:01 +00:00
|
|
|
SENTRY
|
2000-11-03 23:02:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
1999-02-05 21:26:01 +00:00
|
|
|
|
2001-03-30 01:04:50 +00:00
|
|
|
#ifndef FGENGINE_H
|
|
|
|
#define FGENGINE_H
|
1999-02-05 21:26:01 +00:00
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
1999-02-05 21:26:01 +00:00
|
|
|
INCLUDES
|
2000-11-03 23:02:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
1999-02-05 21:26:01 +00:00
|
|
|
|
1999-02-26 22:09:10 +00:00
|
|
|
#ifdef FGFS
|
2000-02-15 03:30:01 +00:00
|
|
|
# include <simgear/compiler.h>
|
1999-02-26 22:09:10 +00:00
|
|
|
# include STL_STRING
|
2001-03-30 01:04:50 +00:00
|
|
|
SG_USING_STD(string);
|
|
|
|
# ifdef FG_HAVE_STD_INCLUDES
|
|
|
|
# include <vector>
|
|
|
|
# else
|
|
|
|
# include <vector.h>
|
|
|
|
# endif
|
1999-02-26 22:09:10 +00:00
|
|
|
#else
|
2001-03-30 01:04:50 +00:00
|
|
|
# include <vector>
|
1999-02-26 22:09:10 +00:00
|
|
|
# include <string>
|
|
|
|
#endif
|
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2001-03-30 01:04:50 +00:00
|
|
|
DEFINITIONS
|
2000-11-03 23:02:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
1999-02-05 21:26:01 +00:00
|
|
|
|
2001-03-30 01:04:50 +00:00
|
|
|
#define ID_ENGINE "$Id$"
|
2000-10-14 02:10:10 +00:00
|
|
|
|
Updates from the Jon and Tony show.
Tony submitted:
JSBsim:
Added trimming routine, it is longitudinal & in-air only at this point
Added support for taking wind & weather data from external source
Added support for flaps.
Added independently settable pitch trim
Added alphamin and max to config file, stall modeling and warning to
follow
c172.cfg:
Flaps!
Adjusted Cmo, model should be speed stable now
FG:
Hooked up Christian's weather code, should be using it soon.
Hooked up the trimming routine. Note that the X-15 will not trim.
This is not a model or trimming routine deficiency, just the
nature of the X-15
The trimming routine sets the pitch trim and and throttle at startup.
The throttle is set using Norman's code for the autothrottle so the
autothrottle is on by default. --notrim will turn it off.
Added --vc, --mach, and --notrim switches
(vc is airspeed in knots)
uBody, vBody, and wBody are still supported, last one entered
on the command line counts, i.e. you can set vc or mach or u,v,
and w but any combination will be ignored.
2000-05-16 21:35:11 +00:00
|
|
|
using std::string;
|
1999-05-08 03:19:08 +00:00
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2001-03-30 01:04:50 +00:00
|
|
|
FORWARD DECLARATIONS
|
2000-11-03 23:02:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
1999-02-05 21:26:01 +00:00
|
|
|
|
1999-02-11 21:05:34 +00:00
|
|
|
class FGFDMExec;
|
|
|
|
class FGState;
|
|
|
|
class FGAtmosphere;
|
|
|
|
class FGFCS;
|
|
|
|
class FGAircraft;
|
|
|
|
class FGTranslation;
|
|
|
|
class FGRotation;
|
2001-03-30 01:04:50 +00:00
|
|
|
class FGPropulsion;
|
1999-02-11 21:05:34 +00:00
|
|
|
class FGPosition;
|
|
|
|
class FGAuxiliary;
|
|
|
|
class FGOutput;
|
|
|
|
|
2001-03-30 01:04:50 +00:00
|
|
|
using std::vector;
|
|
|
|
|
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
CLASS DOCUMENTATION
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
|
|
|
/** Base class for all engines.
|
|
|
|
This base class contains methods and members common to all engines, such as
|
|
|
|
logic to drain fuel from the appropriate tank, etc.
|
|
|
|
@author Jon S. Berndt
|
|
|
|
@version $Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
CLASS DECLARATION
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
Updates from the Jon and Tony show.
Tony submitted:
JSBsim:
Added trimming routine, it is longitudinal & in-air only at this point
Added support for taking wind & weather data from external source
Added support for flaps.
Added independently settable pitch trim
Added alphamin and max to config file, stall modeling and warning to
follow
c172.cfg:
Flaps!
Adjusted Cmo, model should be speed stable now
FG:
Hooked up Christian's weather code, should be using it soon.
Hooked up the trimming routine. Note that the X-15 will not trim.
This is not a model or trimming routine deficiency, just the
nature of the X-15
The trimming routine sets the pitch trim and and throttle at startup.
The throttle is set using Norman's code for the autothrottle so the
autothrottle is on by default. --notrim will turn it off.
Added --vc, --mach, and --notrim switches
(vc is airspeed in knots)
uBody, vBody, and wBody are still supported, last one entered
on the command line counts, i.e. you can set vc or mach or u,v,
and w but any combination will be ignored.
2000-05-16 21:35:11 +00:00
|
|
|
class FGEngine {
|
1999-02-05 21:26:01 +00:00
|
|
|
public:
|
2001-03-30 01:04:50 +00:00
|
|
|
FGEngine(FGFDMExec* exec);
|
|
|
|
virtual ~FGEngine();
|
1999-02-05 21:26:01 +00:00
|
|
|
|
2001-04-06 22:59:31 +00:00
|
|
|
enum EngineType {etUnknown, etRocket, etPiston, etTurboProp, etTurboJet, etTurboShaft};
|
1999-02-26 22:09:10 +00:00
|
|
|
|
2001-03-30 01:04:50 +00:00
|
|
|
virtual float GetThrottleMin(void) { return MinThrottle; }
|
|
|
|
virtual float GetThrottleMax(void) { return MaxThrottle; }
|
Updates from the Jon and Tony show.
Tony submitted:
JSBsim:
Added trimming routine, it is longitudinal & in-air only at this point
Added support for taking wind & weather data from external source
Added support for flaps.
Added independently settable pitch trim
Added alphamin and max to config file, stall modeling and warning to
follow
c172.cfg:
Flaps!
Adjusted Cmo, model should be speed stable now
FG:
Hooked up Christian's weather code, should be using it soon.
Hooked up the trimming routine. Note that the X-15 will not trim.
This is not a model or trimming routine deficiency, just the
nature of the X-15
The trimming routine sets the pitch trim and and throttle at startup.
The throttle is set using Norman's code for the autothrottle so the
autothrottle is on by default. --notrim will turn it off.
Added --vc, --mach, and --notrim switches
(vc is airspeed in knots)
uBody, vBody, and wBody are still supported, last one entered
on the command line counts, i.e. you can set vc or mach or u,v,
and w but any combination will be ignored.
2000-05-16 21:35:11 +00:00
|
|
|
float GetThrottle(void) { return Throttle; }
|
|
|
|
float GetThrust(void) { return Thrust; }
|
|
|
|
bool GetStarved(void) { return Starved; }
|
|
|
|
bool GetFlameout(void) { return Flameout; }
|
2000-10-02 23:07:30 +00:00
|
|
|
bool GetRunning(void) { return Running; }
|
Updates from the Jon and Tony show.
Tony submitted:
JSBsim:
Added trimming routine, it is longitudinal & in-air only at this point
Added support for taking wind & weather data from external source
Added support for flaps.
Added independently settable pitch trim
Added alphamin and max to config file, stall modeling and warning to
follow
c172.cfg:
Flaps!
Adjusted Cmo, model should be speed stable now
FG:
Hooked up Christian's weather code, should be using it soon.
Hooked up the trimming routine. Note that the X-15 will not trim.
This is not a model or trimming routine deficiency, just the
nature of the X-15
The trimming routine sets the pitch trim and and throttle at startup.
The throttle is set using Norman's code for the autothrottle so the
autothrottle is on by default. --notrim will turn it off.
Added --vc, --mach, and --notrim switches
(vc is airspeed in knots)
uBody, vBody, and wBody are still supported, last one entered
on the command line counts, i.e. you can set vc or mach or u,v,
and w but any combination will be ignored.
2000-05-16 21:35:11 +00:00
|
|
|
int GetType(void) { return Type; }
|
2001-03-30 01:04:50 +00:00
|
|
|
string GetName(void) { return Name; }
|
|
|
|
|
|
|
|
void SetStarved(bool tt) {Starved = tt;}
|
|
|
|
void SetStarved(void) {Starved = true;}
|
|
|
|
|
2000-10-02 23:07:30 +00:00
|
|
|
void SetRunning(bool bb) { Running=bb; }
|
2001-03-30 01:04:50 +00:00
|
|
|
void SetName(string name) {Name = name;}
|
|
|
|
void AddFeedTank(int tkID);
|
|
|
|
|
|
|
|
/** Calculates the thrust of the engine, and other engine functions.
|
|
|
|
@param PowerRequired this is the power required to run the thrusting device
|
|
|
|
such as a propeller. This resisting effect must be provided to the
|
|
|
|
engine model.
|
|
|
|
@return Thrust in pounds */
|
|
|
|
virtual float Calculate(float PowerRequired) {return 0.0;};
|
|
|
|
|
|
|
|
/** Reduces the fuel in the active tanks by the amount required.
|
|
|
|
This function should be called from within the
|
|
|
|
derived class' Calculate() function before any other calculations are
|
|
|
|
done. This base class method removes fuel from the fuel tanks as
|
|
|
|
appropriate, and sets the starved flag if necessary. */
|
|
|
|
void ConsumeFuel(void);
|
|
|
|
|
|
|
|
/** The fuel need is calculated based on power levels and flow rate for that
|
|
|
|
power level. It is also turned from a rate into an actual amount (pounds)
|
|
|
|
by multiplying it by the delta T and the rate.
|
|
|
|
@return Total fuel requirement for this engine in pounds. */
|
1999-02-05 21:26:01 +00:00
|
|
|
float CalcFuelNeed(void);
|
2001-03-30 01:04:50 +00:00
|
|
|
|
|
|
|
/** The oxidizer need is calculated based on power levels and flow rate for that
|
|
|
|
power level. It is also turned from a rate into an actual amount (pounds)
|
|
|
|
by multiplying it by the delta T and the rate.
|
|
|
|
@return Total oxidizer requirement for this engine in pounds. */
|
1999-02-05 21:26:01 +00:00
|
|
|
float CalcOxidizerNeed(void);
|
|
|
|
|
2001-03-30 01:04:50 +00:00
|
|
|
/// Sets engine placement information
|
|
|
|
void SetPlacement(float x, float y, float z, float pitch, float yaw);
|
|
|
|
|
|
|
|
virtual float GetPowerAvailable(void) {return 0.0;};
|
|
|
|
|
|
|
|
bool GetTrimMode(void) {return TrimMode;}
|
|
|
|
void SetTrimMode(bool state) {TrimMode = state;}
|
|
|
|
|
|
|
|
protected:
|
1999-02-26 22:09:10 +00:00
|
|
|
string Name;
|
|
|
|
EngineType Type;
|
1999-02-05 21:26:01 +00:00
|
|
|
float X, Y, Z;
|
2000-07-06 21:02:46 +00:00
|
|
|
float EnginePitch;
|
|
|
|
float EngineYaw;
|
1999-02-05 21:26:01 +00:00
|
|
|
float SLFuelFlowMax;
|
|
|
|
float SLOxiFlowMax;
|
|
|
|
float MaxThrottle;
|
|
|
|
float MinThrottle;
|
|
|
|
|
|
|
|
float Thrust;
|
|
|
|
float Throttle;
|
|
|
|
float FuelNeed, OxidizerNeed;
|
|
|
|
bool Starved;
|
|
|
|
bool Flameout;
|
2000-10-02 23:07:30 +00:00
|
|
|
bool Running;
|
1999-02-05 21:26:01 +00:00
|
|
|
float PctPower;
|
1999-02-11 21:05:34 +00:00
|
|
|
int EngineNumber;
|
2001-03-30 01:04:50 +00:00
|
|
|
bool TrimMode;
|
1999-02-11 21:05:34 +00:00
|
|
|
|
|
|
|
FGFDMExec* FDMExec;
|
|
|
|
FGState* State;
|
|
|
|
FGAtmosphere* Atmosphere;
|
|
|
|
FGFCS* FCS;
|
2001-03-30 01:04:50 +00:00
|
|
|
FGPropulsion* Propulsion;
|
1999-02-11 21:05:34 +00:00
|
|
|
FGAircraft* Aircraft;
|
|
|
|
FGTranslation* Translation;
|
|
|
|
FGRotation* Rotation;
|
|
|
|
FGPosition* Position;
|
|
|
|
FGAuxiliary* Auxiliary;
|
|
|
|
FGOutput* Output;
|
1999-02-26 22:09:10 +00:00
|
|
|
|
2001-03-30 01:04:50 +00:00
|
|
|
vector <int> SourceTanks;
|
|
|
|
void Debug(void);
|
1999-02-05 21:26:01 +00:00
|
|
|
};
|
|
|
|
|
2001-03-30 01:04:50 +00:00
|
|
|
#include "FGState.h"
|
|
|
|
#include "FGFDMExec.h"
|
|
|
|
#include "FGAtmosphere.h"
|
|
|
|
#include "FGFCS.h"
|
|
|
|
#include "FGAircraft.h"
|
|
|
|
#include "FGTranslation.h"
|
|
|
|
#include "FGRotation.h"
|
|
|
|
#include "FGPropulsion.h"
|
|
|
|
#include "FGPosition.h"
|
|
|
|
#include "FGAuxiliary.h"
|
|
|
|
#include "FGOutput.h"
|
|
|
|
#include "FGDefs.h"
|
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
1999-02-26 22:09:10 +00:00
|
|
|
#endif
|
2001-03-30 01:04:50 +00:00
|
|
|
|