1
0
Fork 0
flightgear/src/FDM/JSBSim/models/FGPropulsion.h

229 lines
7.8 KiB
C
Raw Normal View History

2002-08-26 22:04:10 +00:00
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Header: FGPropulsion.h
Author: Jon S. Berndt
Date started: 08/20/00
2004-03-14 14:57:07 +00:00
2009-08-30 08:22:03 +00:00
------------- Copyright (C) 1999 Jon S. Berndt (jon@jsbsim.org) -------------
2004-03-14 14:57:07 +00:00
2002-08-26 22:04:10 +00:00
This program is free software; you can redistribute it and/or modify it under
2007-01-15 12:48:54 +00:00
the terms of the GNU Lesser General Public License as published by the Free Software
2002-08-26 22:04:10 +00:00
Foundation; either version 2 of the License, or (at your option) any later
version.
2004-03-14 14:57:07 +00:00
2002-08-26 22:04:10 +00:00
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
2007-01-15 12:48:54 +00:00
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
2002-08-26 22:04:10 +00:00
details.
2004-03-14 14:57:07 +00:00
2007-01-15 12:48:54 +00:00
You should have received a copy of the GNU Lesser General Public License along with
2002-08-26 22:04:10 +00:00
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
2004-03-14 14:57:07 +00:00
2007-01-15 12:48:54 +00:00
Further information about the GNU Lesser General Public License can also be found on
2002-08-26 22:04:10 +00:00
the world wide web at http://www.gnu.org.
2004-03-14 14:57:07 +00:00
2002-08-26 22:04:10 +00:00
HISTORY
--------------------------------------------------------------------------------
08/20/00 JSB Created
2004-03-14 14:57:07 +00:00
2002-08-26 22:04:10 +00:00
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SENTRY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#ifndef FGPROPULSION_H
#define FGPROPULSION_H
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <vector>
#include <fstream>
2002-08-26 22:04:10 +00:00
#include "FGModel.h"
2009-10-12 07:24:41 +00:00
#include "models/propulsion/FGEngine.h"
#include "models/propulsion/FGTank.h"
#include "math/FGMatrix33.h"
#include "input_output/FGXMLFileRead.h"
2002-08-26 22:04:10 +00:00
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_PROPULSION "$Id$"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
2003-06-03 08:46:15 +00:00
namespace JSBSim {
2002-08-26 22:04:10 +00:00
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DOCUMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/** Propulsion management class.
The Propulsion class is the container for the entire propulsion system, which is
2004-06-14 11:40:45 +00:00
comprised of engines, and tanks. Once the Propulsion class gets the config file,
it reads in the \<propulsion> section. Then:
-# The appropriate engine type instance is created
-# At least one tank object is created, and is linked to an engine.
At Run time each engine's Calculate() method is called.
<h3>Configuration File Format:</h3>
@code
<propulsion>
<engine file="{string}">
... see FGEngine, FGThruster, and class for engine type ...
</engine>
... more engines ...
<tank type="{FUEL | OXIDIZER}">
... see FGTank ...
</tank>
... more tanks ...
<dump-rate unit="{LBS/MIN | KG/MIN}"> {number} </dump-rate>
</propulsion>
@endcode
2002-08-26 22:04:10 +00:00
@author Jon S. Berndt
@version $Id$
@see
FGEngine
FGTank
2002-08-26 22:04:10 +00:00
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DECLARATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
class FGPropulsion : public FGModel, public FGXMLFileRead
2002-08-26 22:04:10 +00:00
{
public:
/// Constructor
FGPropulsion(FGFDMExec*);
/// Destructor
~FGPropulsion();
/** Executes the propulsion model.
The initial plan for the FGPropulsion class calls for Run() to be executed,
2004-06-14 11:40:45 +00:00
calculating the power available from the engine.
2002-08-26 22:04:10 +00:00
[Note: Should we be checking the Starved flag here?] */
bool Run(void);
bool InitModel(void);
2004-06-14 11:40:45 +00:00
/** Loads the propulsion system (engine[s] and tank[s]).
2002-08-26 22:04:10 +00:00
Characteristics of the propulsion system are read in from the config file.
2006-01-12 15:04:22 +00:00
@param el pointer to an XML element that contains the engine information.
2002-08-26 22:04:10 +00:00
@return true if successfully loaded, otherwise false */
2006-01-12 15:04:22 +00:00
bool Load(Element* el);
2002-08-26 22:04:10 +00:00
/// Retrieves the number of engines defined for the aircraft.
2007-01-15 12:48:54 +00:00
inline unsigned int GetNumEngines(void) const {return (unsigned int)Engines.size();}
2002-08-26 22:04:10 +00:00
/** Retrieves an engine object pointer from the list of engines.
@param index the engine index within the vector container
@return the address of the specific engine, or zero if no such engine is
available */
inline FGEngine* GetEngine(unsigned int index) {
if (index <= Engines.size()-1) return Engines[index];
else return 0L; }
/// Retrieves the number of tanks defined for the aircraft.
2007-01-15 12:48:54 +00:00
inline unsigned int GetNumTanks(void) const {return (unsigned int)Tanks.size();}
2002-08-26 22:04:10 +00:00
/** Retrieves a tank object pointer from the list of tanks.
@param index the tank index within the vector container
@return the address of the specific tank, or zero if no such tank is
available */
inline FGTank* GetTank(unsigned int index) {
if (index <= Tanks.size()-1) return Tanks[index];
else return 0L; }
/** Returns the number of fuel tanks currently actively supplying fuel */
inline int GetnumSelectedFuelTanks(void) const {return numSelectedFuelTanks;}
/** Returns the number of oxidizer tanks currently actively supplying oxidizer */
inline int GetnumSelectedOxiTanks(void) const {return numSelectedOxiTanks;}
2004-06-14 11:40:45 +00:00
/** Loops the engines until thrust output steady (used for trimming) */
2002-08-26 22:04:10 +00:00
bool GetSteadyState(void);
2004-03-14 14:57:07 +00:00
/** Sets up the engines as running */
void InitRunning(int n);
2004-03-14 14:57:07 +00:00
string GetPropulsionStrings(string delimeter);
string GetPropulsionValues(string delimeter);
2002-08-26 22:04:10 +00:00
inline FGColumnVector3& GetForces(void) {return vForces; }
inline double GetForces(int n) const { return vForces(n);}
inline FGColumnVector3& GetMoments(void) {return vMoments;}
inline double GetMoments(int n) const {return vMoments(n);}
2004-03-14 14:57:07 +00:00
inline bool GetRefuel(void) const {return refuel;}
2006-01-12 15:04:22 +00:00
inline void SetRefuel(bool setting) {refuel = setting;}
inline bool GetFuelDump(void) const {return dump;}
inline void SetFuelDump(bool setting) {dump = setting;}
2004-06-14 11:40:45 +00:00
double Transfer(int source, int target, double amount);
void DoRefuel(double time_slice);
void DumpFuel(double time_slice);
2004-06-14 11:40:45 +00:00
2002-08-26 22:04:10 +00:00
FGColumnVector3& GetTanksMoment(void);
double GetTanksWeight(void);
ifstream* FindEngineFile(string filename);
string FindEngineFullPathname(string engine_filename);
2006-01-12 15:04:22 +00:00
inline int GetActiveEngine(void) const {return ActiveEngine;}
2004-12-16 12:47:20 +00:00
inline bool GetFuelFreeze(void) {return fuel_freeze;}
2006-01-12 15:04:22 +00:00
double GetTotalFuelQuantity(void) const {return TotalFuelQuantity;}
2002-08-26 22:04:10 +00:00
void SetMagnetos(int setting);
void SetStarter(int setting);
void SetCutoff(int setting=0);
2002-08-26 22:04:10 +00:00
void SetActiveEngine(int engine);
2006-01-12 15:04:22 +00:00
void SetFuelFreeze(bool f);
2004-03-14 14:57:07 +00:00
FGMatrix33& CalculateTankInertias(void);
2002-08-26 22:04:10 +00:00
private:
vector <FGEngine*> Engines;
vector <FGTank*> Tanks;
2002-08-26 22:04:10 +00:00
unsigned int numSelectedFuelTanks;
unsigned int numSelectedOxiTanks;
unsigned int numFuelTanks;
unsigned int numOxiTanks;
unsigned int numEngines;
unsigned int numTanks;
int ActiveEngine;
FGColumnVector3 vForces;
FGColumnVector3 vMoments;
2004-03-14 14:57:07 +00:00
FGColumnVector3 vTankXYZ;
FGColumnVector3 vXYZtank_arm;
FGMatrix33 tankJ;
2004-06-14 11:40:45 +00:00
bool refuel;
bool dump;
2004-12-16 12:47:20 +00:00
bool fuel_freeze;
2006-01-12 15:04:22 +00:00
double TotalFuelQuantity;
double DumpRate;
2006-01-12 15:04:22 +00:00
bool IsBound;
bool HavePistonEngine;
bool HaveTurbineEngine;
bool HaveTurboPropEngine;
bool HaveRocketEngine;
bool HaveElectricEngine;
2004-06-14 11:40:45 +00:00
int InitializedEngines;
bool HasInitializedEngines;
void bind();
2002-08-26 22:04:10 +00:00
void Debug(int from);
};
}
2002-08-26 22:04:10 +00:00
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#endif