]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/propulsion/FGEngine.h
Sync w. JSBSim CVS (merge from PRE_OSG_PLIB_20061029 branch)
[flightgear.git] / src / FDM / JSBSim / models / propulsion / 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 Lesser 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 Lesser General Public License for more details.
17
18  You should have received a copy of the GNU Lesser General Public License along with
19  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20  Place - Suite 330, Boston, MA  02111-1307, USA.
21
22  Further information about the GNU Lesser General Public License can also be found on
23  the world wide web at http://www.gnu.org.
24
25 FUNCTIONAL DESCRIPTION
26 --------------------------------------------------------------------------------
27
28 Based on Flightgear code, which is based on LaRCSim. This class simulates
29 a generic engine.
30
31 HISTORY
32 --------------------------------------------------------------------------------
33 01/21/99   JSB   Created
34
35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36 SENTRY
37 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
38
39 #ifndef FGENGINE_H
40 #define FGENGINE_H
41
42 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43 INCLUDES
44 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
45
46 #ifdef FGFS
47 #  include <simgear/compiler.h>
48 #  include STL_STRING
49    SG_USING_STD(string);
50 #  ifdef SG_HAVE_STD_INCLUDES
51 #    include <vector>
52 #  else
53 #    include <vector.h>
54 #  endif
55 #else
56 #  include <vector>
57 #  include <string>
58 #endif
59
60 #include <FGJSBBase.h>
61 #include "FGThruster.h"
62 #include <input_output/FGPropertyManager.h>
63 #include <input_output/FGXMLFileRead.h>
64
65 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66 DEFINITIONS
67 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
68
69 #define ID_ENGINE "$Id$"
70
71 using std::string;
72 using std::vector;
73
74 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75 FORWARD DECLARATIONS
76 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
77
78 namespace JSBSim {
79
80 class FGFDMExec;
81 class FGState;
82 class FGAtmosphere;
83 class FGFCS;
84 class FGAircraft;
85 class FGPropagate;
86 class FGPropulsion;
87 class FGAuxiliary;
88 class FGThruster;
89 class Element;
90
91 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
92 CLASS DOCUMENTATION
93 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
94
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.
98     @author Jon S. Berndt
99     @version $Id$
100 */
101
102 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
103 CLASS DECLARATION
104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
105
106 class FGEngine : public FGJSBBase, public FGXMLFileRead
107 {
108 public:
109   FGEngine(FGFDMExec* exec, Element* el, int engine_number);
110   virtual ~FGEngine();
111
112   enum EngineType {etUnknown, etRocket, etPiston, etTurbine, etTurboprop, etElectric};
113
114   EngineType      GetType(void) { return Type; }
115   virtual string  GetName(void) { return Name; }
116
117   // Engine controls
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; }
123
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; }
130
131   virtual void SetStarved(bool tt) { Starved = tt; }
132   virtual void SetStarved(void)    { Starved = true; }
133
134   virtual void SetRunning(bool bb) { Running=bb; }
135   virtual void SetName(string name) { Name = name; }
136   virtual void AddFeedTank(int tkID);
137   virtual void SetFuelFreeze(bool f) { FuelFreeze = f; }
138
139   virtual void SetStarter(bool s) { Starter = s; }
140
141   /** Calculates the thrust of the engine, and other engine functions.
142       @return Thrust in pounds */
143   virtual double Calculate(void) {return 0.0;}
144
145   /** Reduces the fuel in the active tanks by the amount required.
146       This function should be called from within the
147       derived class' Calculate() function before any other calculations are
148       done. This base class method removes fuel from the fuel tanks as
149       appropriate, and sets the starved flag if necessary. */
150   virtual void ConsumeFuel(void);
151
152   /** The fuel need is calculated based on power levels and flow rate for that
153       power level. It is also turned from a rate into an actual amount (pounds)
154       by multiplying it by the delta T and the rate.
155       @return Total fuel requirement for this engine in pounds. */
156   virtual double CalcFuelNeed(void);
157
158   /** The oxidizer need is calculated based on power levels and flow rate for that
159       power level. It is also turned from a rate into an actual amount (pounds)
160       by multiplying it by the delta T and the rate.
161       @return Total oxidizer requirement for this engine in pounds. */
162   virtual double CalcOxidizerNeed(void);
163
164   /// Sets engine placement information
165   virtual void SetPlacement(FGColumnVector3& location, FGColumnVector3& orientation);
166
167   virtual double GetPowerAvailable(void) {return 0.0;};
168
169   virtual bool GetTrimMode(void) {return TrimMode;}
170   virtual void SetTrimMode(bool state) {TrimMode = state;}
171
172   virtual FGColumnVector3& GetBodyForces(void);
173   virtual FGColumnVector3& GetMoments(void);
174
175   bool LoadThruster(Element *el);
176   FGThruster* GetThruster(void) {return Thruster;}
177
178   virtual string GetEngineLabels(string delimeter) = 0;
179   virtual string GetEngineValues(string delimeter) = 0;
180
181 protected:
182   FGPropertyManager* PropertyManager;
183   string Name;
184   const int   EngineNumber;
185   EngineType Type;
186   double X, Y, Z;
187   double EnginePitch;
188   double EngineYaw;
189   double SLFuelFlowMax;
190   double SLOxiFlowMax;
191   double MaxThrottle;
192   double MinThrottle;
193
194   double Thrust;
195   double Throttle;
196   double Mixture;
197   double FuelNeed;
198   double OxidizerNeed;
199   double PctPower;
200   bool  Starter;
201   bool  Starved;
202   bool  Running;
203   bool  Cranking;
204   bool  TrimMode;
205   bool  FuelFreeze;
206
207   double FuelFlow_gph;
208   double FuelFlow_pph;
209
210   FGFDMExec*      FDMExec;
211   FGState*        State;
212   FGAtmosphere*   Atmosphere;
213   FGFCS*          FCS;
214   FGPropulsion*   Propulsion;
215   FGAircraft*     Aircraft;
216   FGPropagate*    Propagate;
217   FGAuxiliary*    Auxiliary;
218   FGThruster*     Thruster;
219
220   vector <int> SourceTanks;
221   void Debug(int from);
222 };
223 }
224 #include <FGState.h>
225 #include <FGFDMExec.h>
226 #include <models/FGAtmosphere.h>
227 #include <models/FGFCS.h>
228 #include <models/FGAircraft.h>
229 #include <models/FGPropagate.h>
230 #include <models/FGPropulsion.h>
231 #include <models/FGAuxiliary.h>
232 #include <models/propulsion/FGThruster.h>
233 #include <input_output/FGXMLElement.h>
234
235 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
236 #endif
237