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 "FGThruster.h"
63 #include "FGPropertyManager.h"
65 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
69 #define ID_ENGINE "$Id$"
74 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
92 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
94 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
96 /** Base class for all engines.
97 This base class contains methods and members common to all engines, such as
98 logic to drain fuel from the appropriate tank, etc.
103 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
105 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
107 class FGEngine : public FGJSBBase
110 FGEngine(FGFDMExec* exec, int engine_number);
113 enum EngineType {etUnknown, etRocket, etPiston, etTurbine, etElectric};
115 EngineType GetType(void) { return Type; }
116 virtual string GetName(void) { return Name; }
119 virtual double GetThrottleMin(void) { return MinThrottle; }
120 virtual double GetThrottleMax(void) { return MaxThrottle; }
121 virtual double GetThrottle(void) { return Throttle; }
122 virtual double GetMixture(void) { return Mixture; }
123 virtual bool GetStarter(void) { return Starter; }
125 virtual double getFuelFlow_gph () const {return FuelFlow_gph;}
126 virtual double getFuelFlow_pph () const {return FuelFlow_pph;}
127 virtual double GetThrust(void) { return Thrust; }
128 virtual bool GetStarved(void) { return Starved; }
129 virtual bool GetRunning(void) { return Running; }
130 virtual bool GetCranking(void) { return Cranking; }
132 virtual void SetStarved(bool tt) { Starved = tt; }
133 virtual void SetStarved(void) { Starved = true; }
135 virtual void SetRunning(bool bb) { Running=bb; }
136 virtual void SetName(string name) { Name = name; }
137 virtual void AddFeedTank(int tkID);
138 virtual void SetFuelFreeze(bool f) { FuelFreeze = f; }
140 virtual void SetStarter(bool s) { Starter = s; }
142 /** Calculates the thrust of the engine, and other engine functions.
143 @return Thrust in pounds */
144 virtual double Calculate(void) {return 0.0;}
146 /** Reduces the fuel in the active tanks by the amount required.
147 This function should be called from within the
148 derived class' Calculate() function before any other calculations are
149 done. This base class method removes fuel from the fuel tanks as
150 appropriate, and sets the starved flag if necessary. */
151 virtual void ConsumeFuel(void);
153 /** The fuel need is calculated based on power levels and flow rate for that
154 power level. It is also turned from a rate into an actual amount (pounds)
155 by multiplying it by the delta T and the rate.
156 @return Total fuel requirement for this engine in pounds. */
157 virtual double CalcFuelNeed(void);
159 /** The oxidizer need is calculated based on power levels and flow rate for that
160 power level. It is also turned from a rate into an actual amount (pounds)
161 by multiplying it by the delta T and the rate.
162 @return Total oxidizer requirement for this engine in pounds. */
163 virtual double CalcOxidizerNeed(void);
165 /// Sets engine placement information
166 virtual void SetPlacement(double x, double y, double z, double pitch, double yaw);
168 virtual double GetPowerAvailable(void) {return 0.0;};
170 virtual bool GetTrimMode(void) {return TrimMode;}
171 virtual void SetTrimMode(bool state) {TrimMode = state;}
173 virtual FGColumnVector3& GetBodyForces(void);
174 virtual FGColumnVector3& GetMoments(void);
176 bool LoadThruster(FGConfigFile* AC_cfg);
177 FGThruster* GetThruster(void) {return Thruster;}
179 virtual string GetEngineLabels(string delimeter) = 0;
180 virtual string GetEngineValues(string delimeter) = 0;
183 FGPropertyManager* PropertyManager;
185 const int EngineNumber;
190 double SLFuelFlowMax;
213 FGAtmosphere* Atmosphere;
215 FGPropulsion* Propulsion;
216 FGAircraft* Aircraft;
217 FGPropagate* Propagate;
218 FGAuxiliary* Auxiliary;
220 FGThruster* Thruster;
222 vector <int> SourceTanks;
223 void Debug(int from);
227 #include "FGFDMExec.h"
228 #include "FGAtmosphere.h"
230 #include "FGAircraft.h"
231 #include "FGPropagate.h"
232 #include "FGPropulsion.h"
233 #include "FGAuxiliary.h"
234 #include "FGOutput.h"
235 #include "FGThruster.h"
236 #include "FGConfigFile.h"
238 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%