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

255 lines
7.9 KiB
C
Raw Normal View History

2001-11-09 04:38:53 +00:00
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Header: FGEngine.h
Author: Jon S. Berndt
Date started: 01/21/99
------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
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.
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.
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.
Further information about the GNU General Public License can also be found on
the world wide web at http://www.gnu.org.
FUNCTIONAL DESCRIPTION
--------------------------------------------------------------------------------
Based on Flightgear code, which is based on LaRCSim. This class simulates
a generic engine.
HISTORY
--------------------------------------------------------------------------------
01/21/99 JSB Created
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SENTRY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#ifndef FGENGINE_H
#define FGENGINE_H
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#ifdef FGFS
# include <simgear/compiler.h>
# include STL_STRING
SG_USING_STD(string);
# ifdef SG_HAVE_STD_INCLUDES
# include <vector>
# else
# include <vector.h>
# endif
#else
# include <vector>
# include <string>
#endif
#include "FGJSBBase.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_ENGINE "$Id$"
using std::string;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
class FGFDMExec;
class FGState;
class FGAtmosphere;
class FGFCS;
class FGAircraft;
class FGTranslation;
class FGRotation;
class FGPropulsion;
class FGPosition;
class FGAuxiliary;
class FGOutput;
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 : public FGJSBBase
{
public:
FGEngine(FGFDMExec* exec);
virtual ~FGEngine();
enum EngineType {etUnknown, etRocket, etPiston, etTurboProp, etTurboJet, etTurboShaft};
2001-11-20 22:34:24 +00:00
virtual double GetThrottleMin(void) { return MinThrottle; }
virtual double GetThrottleMax(void) { return MaxThrottle; }
double GetThrottle(void) { return Throttle; }
double GetMixture(void) { return Mixture; }
2001-11-30 17:49:37 +00:00
int GetMagnetos(void) { return Magnetos; }
2001-11-09 04:38:53 +00:00
bool GetStarter(void) { return Starter; }
2001-11-20 22:34:24 +00:00
double GetThrust(void) { return Thrust; }
2001-11-30 17:49:37 +00:00
bool GetStarved(void) { return Starved; }
bool GetFlameout(void) { return Flameout; }
bool GetRunning(void) { return Running; }
bool GetCranking(void) { return Cranking; }
int GetType(void) { return Type; }
string GetName(void) { return Name; }
2001-11-09 04:38:53 +00:00
2001-11-20 22:34:24 +00:00
virtual double getManifoldPressure_inHg () const {
2001-11-09 04:38:53 +00:00
return ManifoldPressure_inHg;
}
2001-11-20 22:34:24 +00:00
virtual double getExhaustGasTemp_degF () const {
2001-11-09 04:38:53 +00:00
return (ExhaustGasTemp_degK - 273) * (9.0 / 5.0) + 32.0;
}
2001-11-20 22:34:24 +00:00
virtual double getCylinderHeadTemp_degF () const {
2001-11-09 04:38:53 +00:00
return (CylinderHeadTemp_degK - 273) * (9.0 / 5.0) + 32.0;
}
2001-11-20 22:34:24 +00:00
virtual double getOilPressure_psi () const {
2001-11-09 04:38:53 +00:00
return OilPressure_psi;
}
2001-11-20 22:34:24 +00:00
virtual double getOilTemp_degF () const {
2001-11-09 04:38:53 +00:00
return (OilTemp_degK - 273.0) * (9.0 / 5.0) + 32.0;
}
void SetStarved(bool tt) {Starved = tt;}
void SetStarved(void) {Starved = true;}
void SetRunning(bool bb) { Running=bb; }
void SetName(string name) {Name = name;}
void AddFeedTank(int tkID);
void SetMagnetos(int m) { Magnetos = m; }
void SetStarter(bool s) { Starter = s;}
/** 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 */
2001-11-20 22:34:24 +00:00
virtual double Calculate(double PowerRequired) {return 0.0;};
2001-11-09 04:38:53 +00:00
/** 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. */
2001-11-20 22:34:24 +00:00
double CalcFuelNeed(void);
2001-11-09 04:38:53 +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. */
2001-11-20 22:34:24 +00:00
double CalcOxidizerNeed(void);
2001-11-09 04:38:53 +00:00
/// Sets engine placement information
2001-11-20 22:34:24 +00:00
void SetPlacement(double x, double y, double z, double pitch, double yaw);
2001-11-09 04:38:53 +00:00
2001-11-30 17:49:37 +00:00
/// Sets the engine number
void SetEngineNumber(int nn) {EngineNumber = nn;}
2001-11-20 22:34:24 +00:00
virtual double GetPowerAvailable(void) {return 0.0;};
2001-11-09 04:38:53 +00:00
bool GetTrimMode(void) {return TrimMode;}
void SetTrimMode(bool state) {TrimMode = state;}
protected:
string Name;
EngineType Type;
2001-11-20 22:34:24 +00:00
double X, Y, Z;
double EnginePitch;
double EngineYaw;
double SLFuelFlowMax;
double SLOxiFlowMax;
double MaxThrottle;
double MinThrottle;
double Thrust;
double Throttle;
double Mixture;
2001-11-09 04:38:53 +00:00
int Magnetos;
bool Starter;
2001-11-20 22:34:24 +00:00
double FuelNeed, OxidizerNeed;
2001-11-09 04:38:53 +00:00
bool Starved;
bool Flameout;
bool Running;
bool Cranking;
2001-11-20 22:34:24 +00:00
double PctPower;
2001-11-09 04:38:53 +00:00
int EngineNumber;
bool TrimMode;
2001-11-20 22:34:24 +00:00
double ManifoldPressure_inHg;
double ExhaustGasTemp_degK;
double CylinderHeadTemp_degK;
double OilPressure_psi;
double OilTemp_degK;
2001-11-09 04:38:53 +00:00
FGFDMExec* FDMExec;
FGState* State;
FGAtmosphere* Atmosphere;
FGFCS* FCS;
FGPropulsion* Propulsion;
FGAircraft* Aircraft;
FGTranslation* Translation;
FGRotation* Rotation;
FGPosition* Position;
FGAuxiliary* Auxiliary;
FGOutput* Output;
vector <int> SourceTanks;
2001-12-13 04:48:34 +00:00
virtual void Debug(int from);
2001-11-09 04:38:53 +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"
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#endif