FlightGear next
FGPropulsion.h
Go to the documentation of this file.
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 (jon@jsbsim.org) -------------
8
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU Lesser 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 Lesser General Public License for more
17 details.
18
19 You should have received a copy of the GNU Lesser 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 Lesser General Public License can also be found on
24 the world wide web at http://www.gnu.org.
25
26HISTORY
27--------------------------------------------------------------------------------
2808/20/00 JSB Created
29
30%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31SENTRY
32%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
33
34#ifndef FGPROPULSION_H
35#define FGPROPULSION_H
36
37/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38INCLUDES
39%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40
41#include <vector>
42#include <iosfwd>
43
44#include "simgear/props/propertyObject.hxx"
45#include "FGModel.h"
46#include "propulsion/FGEngine.h"
47#include "math/FGMatrix33.h"
48
49/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50FORWARD DECLARATIONS
51%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
52
53namespace JSBSim {
54
55class FGTank;
56class FGEngine;
57
58/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59CLASS DOCUMENTATION
60%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
61
94
95/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
96CLASS DECLARATION
97%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
98
99class FGPropulsion : public FGModel
100{
101public:
105 ~FGPropulsion() override;
106
116 bool Run(bool Holding) override;
117
118 bool InitModel(void) override;
119
124 bool Load(Element* el) override;
125
127 unsigned int GetNumEngines(void) const {return (unsigned int)Engines.size();}
128
133 FGEngine* GetEngine(unsigned int index) const {
134 if (index < Engines.size()) return Engines[index];
135 else return 0L; }
136
138 unsigned int GetNumTanks(void) const {return (unsigned int)Tanks.size();}
139
144 FGTank* GetTank(unsigned int index) const {
145 if (index < Tanks.size()) return Tanks[index];
146 else return 0L; }
147
149 int GetnumSelectedFuelTanks(void) const {return numSelectedFuelTanks;}
150
152 int GetnumSelectedOxiTanks(void) const {return numSelectedOxiTanks;}
153
155 bool GetSteadyState(void);
156
158 void InitRunning(int n);
159
160 std::string GetPropulsionStrings(const std::string& delimiter) const;
161 std::string GetPropulsionValues(const std::string& delimiter) const;
162 std::string GetPropulsionTankReport();
163
164 const FGColumnVector3& GetForces(void) const {return vForces; }
165 double GetForces(int n) const { return vForces(n);}
166 const FGColumnVector3& GetMoments(void) const {return vMoments;}
167 double GetMoments(int n) const {return vMoments(n);}
168
169 double Transfer(int source, int target, double amount);
170 void DoRefuel(double time_slice);
171 void DumpFuel(double time_slice);
172
173 const FGColumnVector3& GetTanksMoment(void);
174 double GetTanksWeight(void) const;
175
176 SGPath FindFullPathName(const SGPath& path) const override;
177 inline int GetActiveEngine(void) const {return ActiveEngine;}
178 inline bool GetFuelFreeze(void) const {return FuelFreeze;}
179
180 void SetMagnetos(int setting);
181 void SetStarter(int setting);
182 int GetStarter(void) const;
183 void SetCutoff(int setting=0);
184 int GetCutoff(void) const;
185 void SetActiveEngine(int engine);
186 void SetFuelFreeze(bool f);
188
190
191private:
192 std::vector <FGEngine*> Engines;
193 std::vector <FGTank*> Tanks;
194 unsigned int numSelectedFuelTanks;
195 unsigned int numSelectedOxiTanks;
196 unsigned int numFuelTanks;
197 unsigned int numOxiTanks;
198 unsigned int numEngines;
199 unsigned int numTanks;
200 int ActiveEngine;
201 FGColumnVector3 vForces;
202 FGColumnVector3 vMoments;
203 FGColumnVector3 vTankXYZ;
204 FGColumnVector3 vXYZtank_arm;
205 FGMatrix33 tankJ;
206 simgear::PropertyObject<bool> refuel;
207 simgear::PropertyObject<bool> dump;
208 bool FuelFreeze;
209 simgear::PropertyObject<double> TotalFuelQuantity;
210 simgear::PropertyObject<double> TotalOxidizerQuantity;
211 double DumpRate;
212 double RefuelRate;
213 bool IsBound;
214 bool HavePistonEngine;
215 bool HaveTurbineEngine;
216 bool HaveTurboPropEngine;
217 bool HaveRocketEngine;
218 bool HaveElectricEngine;
219 void ConsumeFuel(FGEngine* engine);
220
221 bool ReadingEngine;
222
223 void bind();
224 void Debug(int from) override;
225};
226}
227//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
228#endif
This class implements a 3 element column vector.
Base class for all engines.
Definition FGEngine.h:104
Handles matrix math operations.
Definition FGMatrix33.h:70
FGModel(FGFDMExec *)
Constructor.
Definition FGModel.cpp:57
struct FGEngine::Inputs in
const FGColumnVector3 & GetForces(void) const
~FGPropulsion() override
Destructor.
void SetFuelFreeze(bool f)
std::string GetPropulsionStrings(const std::string &delimiter) const
int GetCutoff(void) const
FGTank * GetTank(unsigned int index) const
Retrieves a tank object pointer from the list of tanks.
int GetnumSelectedOxiTanks(void) const
Returns the number of oxidizer tanks currently actively supplying oxidizer.
double GetTanksWeight(void) const
double Transfer(int source, int target, double amount)
void SetCutoff(int setting=0)
void DumpFuel(double time_slice)
double GetMoments(int n) const
unsigned int GetNumEngines(void) const
Retrieves the number of engines defined for the aircraft.
double GetForces(int n) const
const FGColumnVector3 & GetMoments(void) const
void SetActiveEngine(int engine)
int GetnumSelectedFuelTanks(void) const
Returns the number of fuel tanks currently actively supplying fuel.
int GetActiveEngine(void) const
SGPath FindFullPathName(const SGPath &path) const override
bool Load(Element *el) override
Loads the propulsion system (engine[s] and tank[s]).
void SetStarter(int setting)
bool GetFuelFreeze(void) const
void DoRefuel(double time_slice)
const FGColumnVector3 & GetTanksMoment(void)
void InitRunning(int n)
Sets up the engines as running.
const FGMatrix33 & CalculateTankInertias(void)
bool Run(bool Holding) override
Executes the propulsion model.
bool InitModel(void) override
std::string GetPropulsionValues(const std::string &delimiter) const
void SetMagnetos(int setting)
unsigned int GetNumTanks(void) const
Retrieves the number of tanks defined for the aircraft.
std::string GetPropulsionTankReport()
FGPropulsion(FGFDMExec *)
Constructor.
bool GetSteadyState(void)
Loops the engines until thrust output steady (used for trimming)
FGEngine * GetEngine(unsigned int index) const
Retrieves an engine object pointer from the list of engines.
int GetStarter(void) const
Models a fuel tank.
Definition FGTank.h:202