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 FG_HAVE_STD_INCLUDES
61 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
65 #define ID_ENGINE "$Id$"
69 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
87 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
88 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
89 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
108 FGEngine(FGFDMExec* exec);
111 enum EngineType {etUnknown, etRocket, etPiston, etTurboProp, etTurboJet, etTurboShaft};
113 virtual float GetThrottleMin(void) { return MinThrottle; }
114 virtual float GetThrottleMax(void) { return MaxThrottle; }
115 float GetThrottle(void) { return Throttle; }
116 float GetThrust(void) { return Thrust; }
117 bool GetStarved(void) { return Starved; }
118 bool GetFlameout(void) { return Flameout; }
119 bool GetRunning(void) { return Running; }
120 int GetType(void) { return Type; }
121 string GetName(void) { return Name; }
123 void SetStarved(bool tt) {Starved = tt;}
124 void SetStarved(void) {Starved = true;}
126 void SetRunning(bool bb) { Running=bb; }
127 void SetName(string name) {Name = name;}
128 void AddFeedTank(int tkID);
130 /** Calculates the thrust of the engine, and other engine functions.
131 @param PowerRequired this is the power required to run the thrusting device
132 such as a propeller. This resisting effect must be provided to the
134 @return Thrust in pounds */
135 virtual float Calculate(float PowerRequired) {return 0.0;};
137 /** Reduces the fuel in the active tanks by the amount required.
138 This function should be called from within the
139 derived class' Calculate() function before any other calculations are
140 done. This base class method removes fuel from the fuel tanks as
141 appropriate, and sets the starved flag if necessary. */
142 void ConsumeFuel(void);
144 /** The fuel need is calculated based on power levels and flow rate for that
145 power level. It is also turned from a rate into an actual amount (pounds)
146 by multiplying it by the delta T and the rate.
147 @return Total fuel requirement for this engine in pounds. */
148 float CalcFuelNeed(void);
150 /** The oxidizer need is calculated based on power levels and flow rate for that
151 power level. It is also turned from a rate into an actual amount (pounds)
152 by multiplying it by the delta T and the rate.
153 @return Total oxidizer requirement for this engine in pounds. */
154 float CalcOxidizerNeed(void);
156 /// Sets engine placement information
157 void SetPlacement(float x, float y, float z, float pitch, float yaw);
159 virtual float GetPowerAvailable(void) {return 0.0;};
161 bool GetTrimMode(void) {return TrimMode;}
162 void SetTrimMode(bool state) {TrimMode = state;}
177 float FuelNeed, OxidizerNeed;
187 FGAtmosphere* Atmosphere;
189 FGPropulsion* Propulsion;
190 FGAircraft* Aircraft;
191 FGTranslation* Translation;
192 FGRotation* Rotation;
193 FGPosition* Position;
194 FGAuxiliary* Auxiliary;
197 vector <int> SourceTanks;
202 #include "FGFDMExec.h"
203 #include "FGAtmosphere.h"
205 #include "FGAircraft.h"
206 #include "FGTranslation.h"
207 #include "FGRotation.h"
208 #include "FGPropulsion.h"
209 #include "FGPosition.h"
210 #include "FGAuxiliary.h"
211 #include "FGOutput.h"
214 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%