1
0
Fork 0
flightgear/src/FDM/JSBSim/FGEngine.h

217 lines
6.8 KiB
C
Raw Normal View History

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
#ifdef FGFS
2000-02-15 03:30:01 +00:00
# include <simgear/compiler.h>
# include STL_STRING
2001-03-30 01:04:50 +00:00
SG_USING_STD(string);
# ifdef SG_HAVE_STD_INCLUDES
2001-03-30 01:04:50 +00:00
# include <vector>
# else
# include <vector.h>
# endif
#else
2001-03-30 01:04:50 +00:00
# include <vector>
# 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$"
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
class FGFDMExec;
class FGState;
class FGAtmosphere;
class FGFCS;
class FGAircraft;
class FGTranslation;
class FGRotation;
2001-03-30 01:04:50 +00:00
class FGPropulsion;
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
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};
2001-03-30 01:04:50 +00:00
virtual float GetThrottleMin(void) { return MinThrottle; }
virtual float GetThrottleMax(void) { return MaxThrottle; }
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; }
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:
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;
int EngineNumber;
2001-03-30 01:04:50 +00:00
bool TrimMode;
FGFDMExec* FDMExec;
FGState* State;
FGAtmosphere* Atmosphere;
FGFCS* FCS;
2001-03-30 01:04:50 +00:00
FGPropulsion* Propulsion;
FGAircraft* Aircraft;
FGTranslation* Translation;
FGRotation* Rotation;
FGPosition* Position;
FGAuxiliary* Auxiliary;
FGOutput* Output;
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
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#endif
2001-03-30 01:04:50 +00:00