]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGEngine.h
Remove std::
[flightgear.git] / src / FDM / JSBSim / FGEngine.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Header:       FGEngine.h
4  Author:       Jon S. Berndt
5  Date started: 01/21/99
6
7  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
8
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
12  version.
13
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
17  details.
18
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.
22
23  Further information about the GNU General Public License can also be found on
24  the world wide web at http://www.gnu.org.
25
26 FUNCTIONAL DESCRIPTION
27 --------------------------------------------------------------------------------
28
29 Based on Flightgear code, which is based on LaRCSim. This class simulates
30 a generic engine.
31
32 HISTORY
33 --------------------------------------------------------------------------------
34 01/21/99   JSB   Created
35
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37 SENTRY
38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
39
40 #ifndef FGENGINE_H
41 #define FGENGINE_H
42
43 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44 INCLUDES
45 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
46
47 #ifdef FGFS
48 #  include <simgear/compiler.h>
49 #  include STL_STRING
50    SG_USING_STD(string);
51 #  ifdef SG_HAVE_STD_INCLUDES
52 #    include <vector>
53 #  else
54 #    include <vector.h>
55 #  endif
56 #else
57 #  include <vector>
58 #  include <string>
59 #endif
60
61 #include "FGJSBBase.h"
62
63 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
64 DEFINITIONS
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
66
67 #define ID_ENGINE "$Id$"
68
69 using std::string;
70 using std::vector;
71
72 namespace JSBSim {
73
74 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75 FORWARD DECLARATIONS
76 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
77
78 class FGFDMExec;
79 class FGState;
80 class FGAtmosphere;
81 class FGFCS;
82 class FGAircraft;
83 class FGTranslation;
84 class FGRotation;
85 class FGPropulsion;
86 class FGPosition;
87 class FGAuxiliary;
88 class FGOutput;
89
90 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
91 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
92 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
93
94 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95 CLASS DOCUMENTATION
96 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
97
98 /** Base class for all engines.
99     This base class contains methods and members common to all engines, such as
100     logic to drain fuel from the appropriate tank, etc.
101     @author Jon S. Berndt
102     @version $Id$ 
103 */
104
105 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
106 CLASS DECLARATION
107 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
108
109 class FGEngine : public FGJSBBase
110 {
111 public:
112   FGEngine(FGFDMExec* exec);
113   virtual ~FGEngine();
114
115   enum EngineType {etUnknown, etRocket, etPiston, etTurbine};
116
117   virtual double  GetThrottleMin(void) { return MinThrottle; }
118   virtual double  GetThrottleMax(void) { return MaxThrottle; }
119   virtual double  GetThrottle(void) { return Throttle; }
120   virtual double  GetMixture(void) { return Mixture; }
121   virtual int     GetMagnetos(void) { return Magnetos; }
122   virtual bool    GetStarter(void) { return Starter; }
123   virtual double  GetThrust(void) { return Thrust; }
124   virtual bool    GetStarved(void) { return Starved; }
125   virtual bool    GetFlameout(void) { return Flameout; }
126   virtual bool    GetRunning(void) { return Running; }
127   virtual bool    GetCranking(void) { return Cranking; }
128   virtual int     GetType(void) { return Type; }
129   virtual string  GetName(void) { return Name; }
130
131   virtual double getFuelFlow_gph () const {
132     return FuelFlow_gph;
133   }
134
135   virtual double getManifoldPressure_inHg () const {
136     return ManifoldPressure_inHg;
137   }
138   virtual double getExhaustGasTemp_degF () const {
139     return (ExhaustGasTemp_degK - 273) * (9.0 / 5.0) + 32.0;
140   }
141   virtual double getCylinderHeadTemp_degF () const {
142     return (CylinderHeadTemp_degK - 273) * (9.0 / 5.0) + 32.0;
143   }
144   virtual double getOilPressure_psi () const {
145     return OilPressure_psi;
146   }
147   virtual double getOilTemp_degF () const {
148     return (OilTemp_degK - 273.0) * (9.0 / 5.0) + 32.0;
149   }
150
151   virtual void SetStarved(bool tt) {Starved = tt;}
152   virtual void SetStarved(void)    {Starved = true;}
153
154   virtual void SetRunning(bool bb) { Running=bb; }
155   virtual void SetName(string name) {Name = name;}
156   virtual void AddFeedTank(int tkID);
157
158   virtual void SetMagnetos(int m) { Magnetos = m; }
159   virtual void SetStarter(bool s) { Starter = s;}
160
161   /** Calculates the thrust of the engine, and other engine functions.
162       @param PowerRequired this is the power required to run the thrusting device
163              such as a propeller. This resisting effect must be provided to the 
164              engine model.
165       @return Thrust in pounds */
166   virtual double Calculate(double PowerRequired) {return 0.0;};
167
168   /** Reduces the fuel in the active tanks by the amount required.
169       This function should be called from within the
170       derived class' Calculate() function before any other calculations are
171       done. This base class method removes fuel from the fuel tanks as
172       appropriate, and sets the starved flag if necessary. */
173   virtual void ConsumeFuel(void);
174
175   /** The fuel need is calculated based on power levels and flow rate for that
176       power level. It is also turned from a rate into an actual amount (pounds)
177       by multiplying it by the delta T and the rate.
178       @return Total fuel requirement for this engine in pounds. */
179   virtual double CalcFuelNeed(void);
180
181   /** The oxidizer need is calculated based on power levels and flow rate for that
182       power level. It is also turned from a rate into an actual amount (pounds)
183       by multiplying it by the delta T and the rate.
184       @return Total oxidizer requirement for this engine in pounds. */
185   virtual double CalcOxidizerNeed(void);
186
187   /// Sets engine placement information
188   virtual void SetPlacement(double x, double y, double z, double pitch, double yaw);
189
190   /// Sets the engine number
191   virtual void SetEngineNumber(int nn) {EngineNumber = nn;}
192
193   virtual double GetPowerAvailable(void) {return 0.0;};
194
195   virtual bool GetTrimMode(void) {return TrimMode;}
196   virtual void SetTrimMode(bool state) {TrimMode = state;}
197
198 protected:
199   string Name;
200   EngineType Type;
201   double X, Y, Z;
202   double EnginePitch;
203   double EngineYaw;
204   double SLFuelFlowMax;
205   double SLOxiFlowMax;
206   double MaxThrottle;
207   double MinThrottle;
208
209   double Thrust;
210   double Throttle;
211   double Mixture;
212   int   Magnetos;
213   bool  Starter;
214   double FuelNeed, OxidizerNeed;
215   bool  Starved;
216   bool  Flameout;
217   bool  Running;
218   bool  Cranking;
219   double PctPower;
220   int   EngineNumber;
221   bool  TrimMode;
222
223   double FuelFlow_gph;
224   double ManifoldPressure_inHg;
225   double ExhaustGasTemp_degK;
226   double CylinderHeadTemp_degK;
227   double OilPressure_psi;
228   double OilTemp_degK;
229
230   FGFDMExec*      FDMExec;
231   FGState*        State;
232   FGAtmosphere*   Atmosphere;
233   FGFCS*          FCS;
234   FGPropulsion*   Propulsion;
235   FGAircraft*     Aircraft;
236   FGTranslation*  Translation;
237   FGRotation*     Rotation;
238   FGPosition*     Position;
239   FGAuxiliary*    Auxiliary;
240   FGOutput*       Output;
241
242   vector <int> SourceTanks;
243   virtual void Debug(int from);
244 };
245 }
246 #include "FGState.h"
247 #include "FGFDMExec.h"
248 #include "FGAtmosphere.h"
249 #include "FGFCS.h"
250 #include "FGAircraft.h"
251 #include "FGTranslation.h"
252 #include "FGRotation.h"
253 #include "FGPropulsion.h"
254 #include "FGPosition.h"
255 #include "FGAuxiliary.h"
256 #include "FGOutput.h"
257
258 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
259 #endif
260