]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGPropulsion.h
Expose the strut compression.
[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 #include "FGEngine.h"
57 #include "FGTank.h"
58 #include "FGMatrix33.h"
59
60 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
61 DEFINITIONS
62 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
63
64 #define ID_PROPULSION "$Id$"
65
66 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67 FORWARD DECLARATIONS
68 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
69
70 namespace JSBSim {
71
72 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73 CLASS DOCUMENTATION
74 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
75
76 /** Propulsion management class.
77     The Propulsion class is the container for the entire propulsion system, which is
78     comprised of engines, and tanks. Once the Propulsion class gets the config file,
79     it reads in information which is specific to a type of engine. Then:
80
81     -# The appropriate engine type instance is created
82     -# At least one tank object is created, and is linked to an engine.
83
84     At Run time each engines Calculate() method is called.
85     @author Jon S. Berndt
86     @version $Id$
87     @see
88     FGEngine
89     FGTank
90 */
91
92 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
93 CLASS DECLARATION
94 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
95
96 class FGPropulsion : public FGModel
97 {
98 public:
99   /// Constructor
100   FGPropulsion(FGFDMExec*);
101   /// Destructor
102   ~FGPropulsion();
103
104   /** Executes the propulsion model.
105       The initial plan for the FGPropulsion class calls for Run() to be executed,
106       calculating the power available from the engine.
107
108       [Note: Should we be checking the Starved flag here?] */
109   bool Run(void);
110
111   /** Loads the propulsion system (engine[s] and tank[s]).
112       Characteristics of the propulsion system are read in from the config file.
113       @param AC_cfg pointer to the config file instance that describes the
114              aircraft being modeled.
115       @return true if successfully loaded, otherwise false */
116   bool Load(FGConfigFile* AC_cfg);
117
118   /// Retrieves the number of engines defined for the aircraft.
119   inline unsigned int GetNumEngines(void) const {return Engines.size();}
120
121   /** Retrieves an engine object pointer from the list of engines.
122       @param index the engine index within the vector container
123       @return the address of the specific engine, or zero if no such engine is
124               available */
125   inline FGEngine* GetEngine(unsigned int index) {
126                       if (index <= Engines.size()-1) return Engines[index];
127                       else                           return 0L;      }
128
129   /// Retrieves the number of tanks defined for the aircraft.
130   inline unsigned int GetNumTanks(void) const {return Tanks.size();}
131
132   /** Retrieves a tank object pointer from the list of tanks.
133       @param index the tank index within the vector container
134       @return the address of the specific tank, or zero if no such tank is
135               available */
136   inline FGTank* GetTank(unsigned int index) {
137                       if (index <= Tanks.size()-1) return Tanks[index];
138                       else                         return 0L;        }
139
140   /** Returns the number of fuel tanks currently actively supplying fuel */
141   inline int GetnumSelectedFuelTanks(void) const {return numSelectedFuelTanks;}
142
143   /** Returns the number of oxidizer tanks currently actively supplying oxidizer */
144   inline int GetnumSelectedOxiTanks(void) const {return numSelectedOxiTanks;}
145
146   /** Loops the engines until thrust output steady (used for trimming) */
147   bool GetSteadyState(void);
148
149   /** starts the engines in IC mode (dt=0).  All engine-specific setup must
150       be done before calling this (i.e. magnetos, starter engage, etc.) */
151   bool ICEngineStart(void);
152
153   string GetPropulsionStrings(string delimeter);
154   string GetPropulsionValues(string delimeter);
155
156   inline FGColumnVector3& GetForces(void)  {return vForces; }
157   inline double GetForces(int n) const { return vForces(n);}
158   inline FGColumnVector3& GetMoments(void) {return vMoments;}
159   inline double GetMoments(int n) const {return vMoments(n);}
160
161   inline bool GetRefuel(void) {return refuel;}
162   inline void SetRefuel(bool setting) {refuel = setting;} 
163   double Transfer(int source, int target, double amount);
164   void DoRefuel(double time_slice);
165
166   FGColumnVector3& GetTanksMoment(void);
167   double GetTanksWeight(void);
168
169   inline int GetActiveEngine(void) const
170   {
171     return ActiveEngine;
172   }
173
174   inline int GetActiveEngine(void);
175   inline bool GetFuelFreeze(void) {return fuel_freeze;}
176
177   void SetMagnetos(int setting);
178   void SetStarter(int setting);
179   void SetCutoff(int setting=0);
180   void SetActiveEngine(int engine);
181   void SetFuelFreeze(bool f);  
182   FGMatrix33& CalculateTankInertias(void);
183
184   void bind();
185   void unbind();
186
187 private:
188   vector <FGEngine*>   Engines;
189   vector <FGTank*>     Tanks;
190   vector <FGTank*>::iterator iTank;
191   unsigned int numSelectedFuelTanks;
192   unsigned int numSelectedOxiTanks;
193   unsigned int numFuelTanks;
194   unsigned int numOxiTanks;
195   unsigned int numEngines;
196   unsigned int numTanks;
197   int ActiveEngine;
198   FGColumnVector3 vForces;
199   FGColumnVector3 vMoments;
200   FGColumnVector3 vTankXYZ;
201   FGColumnVector3 vXYZtank_arm;
202   FGMatrix33 tankJ;
203   bool refuel;
204   bool fuel_freeze;
205
206   void Debug(int from);
207 };
208 }
209 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
210 #endif
211