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