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

230 lines
7.9 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>
2009-10-26 13:29:58 +00:00
#include <iosfwd>
2002-08-26 22:04:10 +00:00
#include "FGModel.h"
2009-10-12 07:24:41 +00:00
#include "math/FGMatrix33.h"
#include "input_output/FGXMLFileRead.h"
2002-08-26 22:04:10 +00:00
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
2010-11-28 09:58:47 +00:00
#define ID_PROPULSION "$Id: FGPropulsion.h,v 1.26 2010/11/18 12:38:06 jberndt Exp $"
2002-08-26 22:04:10 +00:00
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
2003-06-03 08:46:15 +00:00
namespace JSBSim {
2009-10-26 13:29:58 +00:00
class FGTank;
class FGEngine;
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
2010-11-28 09:58:47 +00:00
@version $Id: FGPropulsion.h,v 1.26 2010/11/18 12:38:06 jberndt Exp $
@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.
2010-11-28 09:58:47 +00:00
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 */
2010-11-28 09:58:47 +00:00
FGEngine* GetEngine(unsigned int index) const {
2010-07-16 09:05:59 +00:00
if (index < Engines.size()) return Engines[index];
else return 0L; }
2002-08-26 22:04:10 +00:00
/// Retrieves the number of tanks defined for the aircraft.
2010-11-28 09:58:47 +00:00
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 */
2010-11-28 09:58:47 +00:00
FGTank* GetTank(unsigned int index) const {
2010-07-16 09:05:59 +00:00
if (index < Tanks.size()) return Tanks[index];
else return 0L; }
2002-08-26 22:04:10 +00:00
/** Returns the number of fuel tanks currently actively supplying fuel */
2010-11-28 09:58:47 +00:00
int GetnumSelectedFuelTanks(void) const {return numSelectedFuelTanks;}
2002-08-26 22:04:10 +00:00
/** Returns the number of oxidizer tanks currently actively supplying oxidizer */
2010-11-28 09:58:47 +00:00
int GetnumSelectedOxiTanks(void) const {return numSelectedOxiTanks;}
2002-08-26 22:04:10 +00:00
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
2010-11-28 09:58:47 +00:00
std::string GetPropulsionStrings(const std::string& delimiter) const;
std::string GetPropulsionValues(const std::string& delimiter) const;
2002-08-26 22:04:10 +00:00
2010-11-28 09:58:47 +00:00
const FGColumnVector3& GetForces(void) const {return vForces; }
double GetForces(int n) const { return vForces(n);}
const FGColumnVector3& GetMoments(void) const {return vMoments;}
double GetMoments(int n) const {return vMoments(n);}
2004-03-14 14:57:07 +00:00
2010-11-28 09:58:47 +00:00
bool GetRefuel(void) const {return refuel;}
void SetRefuel(bool setting) {refuel = setting;}
bool GetFuelDump(void) const {return dump;}
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);
2009-10-26 13:29:58 +00:00
std::ifstream* FindEngineFile(const std::string& filename);
std::string FindEngineFullPathname(const std::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:
2009-10-26 13:29:58 +00:00
std::vector <FGEngine*> Engines;
std::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