]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGPropulsion.h
Latest JSBSim updates.
[flightgear.git] / src / FDM / JSBSim / FGPropulsion.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
2 \r
3  Header:       FGPropulsion.h\r
4  Author:       Jon S. Berndt\r
5  Date started: 08/20/00\r
6  \r
7  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------\r
8  \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
12  version.\r
13  \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
17  details.\r
18  \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
22  \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
25  \r
26 HISTORY\r
27 --------------------------------------------------------------------------------\r
28 08/20/00   JSB   Created\r
29  \r
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
31 SENTRY\r
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/\r
33 \r
34 #ifndef FGPROPULSION_H\r
35 #define FGPROPULSION_H\r
36 \r
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
38 INCLUDES\r
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/\r
40 \r
41 #ifdef FGFS\r
42 #  include <simgear/compiler.h>\r
43 #  ifdef SG_HAVE_STD_INCLUDES\r
44 #    include <vector>\r
45 #    include <iterator>\r
46 #  else\r
47 #    include <vector.h>\r
48 #    include <iterator.h>\r
49 #  endif\r
50 #else\r
51 #  include <vector>\r
52 #  include <iterator>\r
53 #endif\r
54 \r
55 #include "FGModel.h"\r
56 \r
57 #include "FGRocket.h"\r
58 #include "FGPiston.h"\r
59 #include "FGTurboShaft.h"\r
60 #include "FGTurboJet.h"\r
61 #include "FGTurboProp.h"\r
62 #include "FGTank.h"\r
63 #include "FGPropeller.h"\r
64 #include "FGNozzle.h"\r
65 \r
66 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
67 DEFINITIONS\r
68 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/\r
69 \r
70 #define ID_PROPULSION "$Id$"\r
71 \r
72 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
73 FORWARD DECLARATIONS\r
74 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/\r
75 \r
76 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
77 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]\r
78 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/\r
79 \r
80 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
81 CLASS DOCUMENTATION\r
82 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/\r
83 \r
84 /** Propulsion management class.\r
85     FGPropulsion manages all aspects of propulsive force generation, including\r
86     containment of engines, tanks, and thruster class instances in STL vectors,\r
87     and the interaction and communication between them.\r
88     @author Jon S. Berndt\r
89     @version $Id$\r
90     @see FGEngine\r
91     @see FGTank\r
92     @see FGThruster\r
93     @see <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jsbsim/JSBSim/FGPropulsion.h?rev=HEAD&content-type=text/vnd.viewcvs-markup">\r
94          Header File </a>\r
95     @see <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jsbsim/JSBSim/FGPropulsion.cpp?rev=HEAD&content-type=text/vnd.viewcvs-markup">\r
96          Source File </a>\r
97 */\r
98 \r
99 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
100 CLASS DECLARATION\r
101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/\r
102 \r
103 class FGPropulsion : public FGModel\r
104 {\r
105 public:\r
106   /// Constructor\r
107   FGPropulsion(FGFDMExec*);\r
108   /// Destructor\r
109   ~FGPropulsion();\r
110 \r
111   /** Executes the propulsion model.\r
112       The initial plan for the FGPropulsion class calls for Run() to be executed,\r
113       performing the following tasks:\r
114       <ol>\r
115   <li>Determine the drag - or power required - for the attached thrust effector\r
116       for this engine so that any feedback to the engine can be performed. This\r
117       is done by calling FGThruster::CalculatePReq()</li>\r
118   <li>Given 1, above, calculate the power available from the engine. This is\r
119       done by calling FGEngine::CalculatePAvail()</li>\r
120   <li>Next, calculate the thrust output from the thruster model given the power\r
121       available and the power required. This may also result in new performance\r
122       numbers for the thruster in the case of the propeller, at least. This\r
123       result is returned from a call to Calculate().</li></ol>\r
124 \r
125       [Note: Should we be checking the Starved flag here?] */\r
126   bool Run(void);\r
127 \r
128   /** Loads the propulsion system (engine[s], tank[s], thruster[s]).\r
129       Characteristics of the propulsion system are read in from the config file.\r
130       @param AC_cfg pointer to the config file instance that describes the\r
131              aircraft being modeled.\r
132       @return true if successfully loaded, otherwise false */\r
133   bool Load(FGConfigFile* AC_cfg);\r
134 \r
135   /// Retrieves the number of engines defined for the aircraft.\r
136   inline unsigned int GetNumEngines(void) const {return Engines.size();}\r
137 \r
138   /** Retrieves an engine object pointer from the list of engines.\r
139       @param index the engine index within the vector container\r
140       @return the address of the specific engine, or zero if no such engine is\r
141               available */\r
142   inline FGEngine* GetEngine(unsigned int index) {\r
143                       if (index <= Engines.size()-1) return Engines[index];\r
144                       else                           return 0L;      }\r
145 \r
146   // Retrieves the number of tanks defined for the aircraft.\r
147   inline unsigned int GetNumTanks(void) const {return Tanks.size();}\r
148 \r
149   /** Retrieves a tank object pointer from the list of tanks.\r
150       @param index the tank index within the vector container\r
151       @return the address of the specific tank, or zero if no such tank is\r
152               available */\r
153   inline FGTank* GetTank(unsigned int index) {\r
154                       if (index <= Tanks.size()-1) return Tanks[index];\r
155                       else                         return 0L;        }\r
156 \r
157   /** Retrieves a thruster object pointer from the list of thrusters.\r
158       @param index the thruster index within the vector container\r
159       @return the address of the specific thruster, or zero if no such thruster is\r
160               available */\r
161   inline FGThruster* GetThruster(unsigned int index) {\r
162                       if (index <= Thrusters.size()-1) return Thrusters[index];\r
163                       else                             return 0L;    }\r
164 \r
165   /** Returns the number of fuel tanks currently actively supplying fuel */\r
166   inline int GetnumSelectedFuelTanks(void) const {return numSelectedFuelTanks;}\r
167 \r
168   /** Returns the number of oxidizer tanks currently actively supplying oxidizer */\r
169   inline int GetnumSelectedOxiTanks(void) const {return numSelectedOxiTanks;}\r
170 \r
171   /** Loops the engines/thrusters until thrust output steady (used for trimming) */\r
172   bool GetSteadyState(void);\r
173   \r
174   /** starts the engines in IC mode (dt=0).  All engine-specific setup must\r
175       be done before calling this (i.e. magnetos, starter engage, etc.) */\r
176   bool ICEngineStart(void);\r
177   \r
178   string GetPropulsionStrings(void);\r
179   string GetPropulsionValues(void);\r
180 \r
181   inline FGColumnVector3& GetForces(void)  {return vForces; }\r
182   inline double GetForces(int n) const { return vForces(n);}\r
183   inline FGColumnVector3& GetMoments(void) {return vMoments;}\r
184   inline double GetMoments(int n) const {return vMoments(n);}\r
185   \r
186   FGColumnVector3& GetTanksMoment(void);\r
187   double GetTanksWeight(void);\r
188 \r
189   double GetTanksIxx(const FGColumnVector3& vXYZcg);\r
190   double GetTanksIyy(const FGColumnVector3& vXYZcg);\r
191   double GetTanksIzz(const FGColumnVector3& vXYZcg);\r
192   double GetTanksIxz(const FGColumnVector3& vXYZcg);\r
193   double GetTanksIxy(const FGColumnVector3& vXYZcg);\r
194   \r
195   void SetMagnetos(int setting);\r
196   void SetStarter(int setting);\r
197   void SetActiveEngine(int engine);\r
198   \r
199   void bind();\r
200   void unbind();\r
201    \r
202 private:\r
203   vector <FGEngine*>   Engines;\r
204   vector <FGTank*>     Tanks;\r
205   vector <FGTank*>::iterator iTank;\r
206   vector <FGThruster*> Thrusters;\r
207   unsigned int numSelectedFuelTanks;\r
208   unsigned int numSelectedOxiTanks;\r
209   unsigned int numFuelTanks;\r
210   unsigned int numOxiTanks;\r
211   unsigned int numEngines;\r
212   unsigned int numTanks;\r
213   unsigned int numThrusters;\r
214   int ActiveEngine;\r
215   double dt;\r
216   FGColumnVector3 vForces;\r
217   FGColumnVector3 vMoments;\r
218   FGColumnVector3 vXYZtank;\r
219   void Debug(int from);\r
220 };\r
221 \r
222 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
223 #endif\r
224 \r