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