1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\r
4 Author: Jon S. Berndt
\r
5 Date started: 01/21/99
\r
7 ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
\r
9 This program is free software; you can redistribute it and/or modify it under
\r
10 the terms of the GNU General Public License as published by the Free Software
\r
11 Foundation; either version 2 of the License, or (at your option) any later
\r
14 This program is distributed in the hope that it will be useful, but WITHOUT
\r
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
\r
16 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
\r
19 You should have received a copy of the GNU General Public License along with
\r
20 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
\r
21 Place - Suite 330, Boston, MA 02111-1307, USA.
\r
23 Further information about the GNU General Public License can also be found on
\r
24 the world wide web at http://www.gnu.org.
\r
26 FUNCTIONAL DESCRIPTION
\r
27 --------------------------------------------------------------------------------
\r
29 Based on Flightgear code, which is based on LaRCSim. This class simulates
\r
33 --------------------------------------------------------------------------------
\r
34 01/21/99 JSB Created
\r
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\r
38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
\r
43 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\r
45 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
\r
48 # include <simgear/compiler.h>
\r
49 # include STL_STRING
\r
50 SG_USING_STD(string);
\r
51 # ifdef SG_HAVE_STD_INCLUDES
\r
54 # include <vector.h>
\r
61 #include "FGJSBBase.h"
\r
63 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\r
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
\r
67 #define ID_ENGINE "$Id$"
\r
71 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\r
72 FORWARD DECLARATIONS
\r
73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
\r
80 class FGTranslation;
\r
89 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\r
90 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
\r
91 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
\r
93 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\r
95 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
\r
97 /** Base class for all engines.
\r
98 This base class contains methods and members common to all engines, such as
\r
99 logic to drain fuel from the appropriate tank, etc.
\r
100 @author Jon S. Berndt
\r
104 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\r
106 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
\r
108 class FGEngine : public FGJSBBase
\r
111 FGEngine(FGFDMExec* exec);
\r
112 virtual ~FGEngine();
\r
114 enum EngineType {etUnknown, etRocket, etPiston, etTurboProp, etTurboJet, etTurboShaft};
\r
116 virtual float GetThrottleMin(void) { return MinThrottle; }
\r
117 virtual float GetThrottleMax(void) { return MaxThrottle; }
\r
118 float GetThrottle(void) { return Throttle; }
\r
119 float GetMixture(void) { return Mixture; }
\r
120 float GetThrust(void) { return Thrust; }
\r
121 bool GetStarved(void) { return Starved; }
\r
122 bool GetFlameout(void) { return Flameout; }
\r
123 bool GetRunning(void) { return Running; }
\r
124 int GetType(void) { return Type; }
\r
125 string GetName(void) { return Name; }
\r
127 virtual float getManifoldPressure_inHg () const {
\r
128 return ManifoldPressure_inHg;
\r
130 virtual float getExhaustGasTemp_degF () const {
\r
131 return (ExhaustGasTemp_degK - 273) * (9.0 / 5.0) + 32.0;
\r
133 virtual float getCylinderHeadTemp_degF () const {
\r
134 return (CylinderHeadTemp_degK - 273) * (9.0 / 5.0) + 32.0;
\r
136 virtual float getOilPressure_psi () const {
\r
137 return OilPressure_psi;
\r
139 virtual float getOilTemp_degF () const {
\r
140 return (OilTemp_degK - 273.0) * (9.0 / 5.0) + 32.0;
\r
143 void SetStarved(bool tt) {Starved = tt;}
\r
144 void SetStarved(void) {Starved = true;}
\r
146 void SetRunning(bool bb) { Running=bb; }
\r
147 void SetName(string name) {Name = name;}
\r
148 void AddFeedTank(int tkID);
\r
150 /** Calculates the thrust of the engine, and other engine functions.
\r
151 @param PowerRequired this is the power required to run the thrusting device
\r
152 such as a propeller. This resisting effect must be provided to the
\r
154 @return Thrust in pounds */
\r
155 virtual float Calculate(float PowerRequired) {return 0.0;};
\r
157 /** Reduces the fuel in the active tanks by the amount required.
\r
158 This function should be called from within the
\r
159 derived class' Calculate() function before any other calculations are
\r
160 done. This base class method removes fuel from the fuel tanks as
\r
161 appropriate, and sets the starved flag if necessary. */
\r
162 void ConsumeFuel(void);
\r
164 /** The fuel need is calculated based on power levels and flow rate for that
\r
165 power level. It is also turned from a rate into an actual amount (pounds)
\r
166 by multiplying it by the delta T and the rate.
\r
167 @return Total fuel requirement for this engine in pounds. */
\r
168 float CalcFuelNeed(void);
\r
170 /** The oxidizer need is calculated based on power levels and flow rate for that
\r
171 power level. It is also turned from a rate into an actual amount (pounds)
\r
172 by multiplying it by the delta T and the rate.
\r
173 @return Total oxidizer requirement for this engine in pounds. */
\r
174 float CalcOxidizerNeed(void);
\r
176 /// Sets engine placement information
\r
177 void SetPlacement(float x, float y, float z, float pitch, float yaw);
\r
179 virtual float GetPowerAvailable(void) {return 0.0;};
\r
181 bool GetTrimMode(void) {return TrimMode;}
\r
182 void SetTrimMode(bool state) {TrimMode = state;}
\r
190 float SLFuelFlowMax;
\r
191 float SLOxiFlowMax;
\r
198 float FuelNeed, OxidizerNeed;
\r
206 float ManifoldPressure_inHg;
\r
207 float ExhaustGasTemp_degK;
\r
208 float CylinderHeadTemp_degK;
\r
209 float OilPressure_psi;
\r
210 float OilTemp_degK;
\r
212 FGFDMExec* FDMExec;
\r
214 FGAtmosphere* Atmosphere;
\r
216 FGPropulsion* Propulsion;
\r
217 FGAircraft* Aircraft;
\r
218 FGTranslation* Translation;
\r
219 FGRotation* Rotation;
\r
220 FGPosition* Position;
\r
221 FGAuxiliary* Auxiliary;
\r
224 vector <int> SourceTanks;
\r
228 #include "FGState.h"
\r
229 #include "FGFDMExec.h"
\r
230 #include "FGAtmosphere.h"
\r
232 #include "FGAircraft.h"
\r
233 #include "FGTranslation.h"
\r
234 #include "FGRotation.h"
\r
235 #include "FGPropulsion.h"
\r
236 #include "FGPosition.h"
\r
237 #include "FGAuxiliary.h"
\r
238 #include "FGOutput.h"
\r
239 #include "FGDefs.h"
\r
241 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\r