1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7 ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free Software
11 Foundation; either version 2 of the License, or (at your option) any later
14 This program is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19 You should have received a copy of the GNU General Public License along with
20 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21 Place - Suite 330, Boston, MA 02111-1307, USA.
23 Further information about the GNU General Public License can also be found on
24 the world wide web at http://www.gnu.org.
26 FUNCTIONAL DESCRIPTION
27 --------------------------------------------------------------------------------
29 Based on Flightgear code, which is based on LaRCSim. This class simulates
33 --------------------------------------------------------------------------------
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
43 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
45 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
48 # include <simgear/compiler.h>
51 # ifdef SG_HAVE_STD_INCLUDES
61 #include "FGJSBBase.h"
62 #include "FGPropertyManager.h"
64 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
68 #define ID_ENGINE "$Id$"
73 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
91 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
93 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
95 /** Base class for all engines.
96 This base class contains methods and members common to all engines, such as
97 logic to drain fuel from the appropriate tank, etc.
102 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
106 class FGEngine : public FGJSBBase
109 FGEngine(FGFDMExec* exec);
112 enum EngineType {etUnknown, etRocket, etPiston, etTurbine, etSimTurbine};
114 EngineType GetType(void) { return Type; }
115 virtual string GetName(void) { return Name; }
118 virtual double GetThrottleMin(void) { return MinThrottle; }
119 virtual double GetThrottleMax(void) { return MaxThrottle; }
120 virtual double GetThrottle(void) { return Throttle; }
121 virtual double GetMixture(void) { return Mixture; }
122 virtual bool GetStarter(void) { return Starter; }
124 virtual double getFuelFlow_gph () const {return FuelFlow_gph;}
125 virtual double getFuelFlow_pph () const {return FuelFlow_pph;}
126 virtual double GetThrust(void) { return Thrust; }
127 virtual bool GetStarved(void) { return Starved; }
128 virtual bool GetRunning(void) { return Running; }
129 virtual bool GetCranking(void) { return Cranking; }
131 virtual void SetStarved(bool tt) { Starved = tt; }
132 virtual void SetStarved(void) { Starved = true; }
134 virtual void SetRunning(bool bb) { Running=bb; }
135 virtual void SetName(string name) { Name = name; }
136 virtual void AddFeedTank(int tkID);
138 virtual void SetStarter(bool s) { Starter = s; }
140 /** Calculates the thrust of the engine, and other engine functions.
141 @param PowerRequired this is the power required to run the thrusting device
142 such as a propeller. This resisting effect must be provided to the
144 @return Thrust in pounds */
145 virtual double Calculate(double PowerRequired) {return 0.0;};
147 /** Reduces the fuel in the active tanks by the amount required.
148 This function should be called from within the
149 derived class' Calculate() function before any other calculations are
150 done. This base class method removes fuel from the fuel tanks as
151 appropriate, and sets the starved flag if necessary. */
152 virtual void ConsumeFuel(void);
154 /** The fuel need is calculated based on power levels and flow rate for that
155 power level. It is also turned from a rate into an actual amount (pounds)
156 by multiplying it by the delta T and the rate.
157 @return Total fuel requirement for this engine in pounds. */
158 virtual double CalcFuelNeed(void);
160 /** The oxidizer need is calculated based on power levels and flow rate for that
161 power level. It is also turned from a rate into an actual amount (pounds)
162 by multiplying it by the delta T and the rate.
163 @return Total oxidizer requirement for this engine in pounds. */
164 virtual double CalcOxidizerNeed(void);
166 /// Sets engine placement information
167 virtual void SetPlacement(double x, double y, double z, double pitch, double yaw);
169 /// Sets the engine number
170 virtual void SetEngineNumber(int nn) {EngineNumber = nn;}
172 virtual double GetPowerAvailable(void) {return 0.0;};
174 virtual bool GetTrimMode(void) {return TrimMode;}
175 virtual void SetTrimMode(bool state) {TrimMode = state;}
178 FGPropertyManager* PropertyManager;
184 double SLFuelFlowMax;
207 FGAtmosphere* Atmosphere;
209 FGPropulsion* Propulsion;
210 FGAircraft* Aircraft;
211 FGTranslation* Translation;
212 FGRotation* Rotation;
213 FGPosition* Position;
214 FGAuxiliary* Auxiliary;
217 vector <int> SourceTanks;
218 void Debug(int from);
222 #include "FGFDMExec.h"
223 #include "FGAtmosphere.h"
225 #include "FGAircraft.h"
226 #include "FGTranslation.h"
227 #include "FGRotation.h"
228 #include "FGPropulsion.h"
229 #include "FGPosition.h"
230 #include "FGAuxiliary.h"
231 #include "FGOutput.h"
233 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%