1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7 ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
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
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
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.
23 Further information about the GNU General Public License can also be found on
24 the world wide web at http://www.gnu.org.
27 --------------------------------------------------------------------------------
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
34 #ifndef FGPROPULSION_H
35 #define FGPROPULSION_H
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
42 # include <simgear/compiler.h>
43 # ifdef SG_HAVE_STD_INCLUDES
48 # include <iterator.h>
58 #include "FGMatrix33.h"
60 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
64 #define ID_PROPULSION "$Id$"
66 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
68 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
72 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
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:
81 -# The appropriate engine type instance is created
82 -# At least one tank object is created, and is linked to an engine.
84 At Run time each engines Calculate() method is called.
92 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
94 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
96 class FGPropulsion : public FGModel
100 FGPropulsion(FGFDMExec*);
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.
108 [Note: Should we be checking the Starved flag here?] */
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);
118 /// Retrieves the number of engines defined for the aircraft.
119 inline unsigned int GetNumEngines(void) const {return Engines.size();}
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
125 inline FGEngine* GetEngine(unsigned int index) {
126 if (index <= Engines.size()-1) return Engines[index];
129 /// Retrieves the number of tanks defined for the aircraft.
130 inline unsigned int GetNumTanks(void) const {return Tanks.size();}
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
136 inline FGTank* GetTank(unsigned int index) {
137 if (index <= Tanks.size()-1) return Tanks[index];
140 /** Returns the number of fuel tanks currently actively supplying fuel */
141 inline int GetnumSelectedFuelTanks(void) const {return numSelectedFuelTanks;}
143 /** Returns the number of oxidizer tanks currently actively supplying oxidizer */
144 inline int GetnumSelectedOxiTanks(void) const {return numSelectedOxiTanks;}
146 /** Loops the engines until thrust output steady (used for trimming) */
147 bool GetSteadyState(void);
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);
153 string GetPropulsionStrings(string delimeter);
154 string GetPropulsionValues(string delimeter);
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);}
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);
166 FGColumnVector3& GetTanksMoment(void);
167 double GetTanksWeight(void);
169 inline int GetActiveEngine(void) const
174 inline int GetActiveEngine(void);
175 inline bool GetFuelFreeze(void) {return fuel_freeze;}
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);
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;
198 FGColumnVector3 vForces;
199 FGColumnVector3 vMoments;
200 FGColumnVector3 vTankXYZ;
201 FGColumnVector3 vXYZtank_arm;
206 void Debug(int from);
209 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%