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

212 lines
7.1 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
2002-08-26 22:04:10 +00:00
------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.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
the terms of the GNU General Public License as published by the Free Software
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
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
2004-03-14 14:57:07 +00:00
2002-08-26 22:04:10 +00:00
You should have received a copy of the GNU General Public License along with
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
2002-08-26 22:04:10 +00:00
Further information about the GNU General Public License can also be found on
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#ifdef FGFS
# include <simgear/compiler.h>
# ifdef SG_HAVE_STD_INCLUDES
# include <vector>
# include <iterator>
# else
# include <vector.h>
# include <iterator.h>
# endif
#else
# include <vector>
# include <iterator>
#endif
#include "FGModel.h"
2004-03-14 14:57:07 +00:00
#include "FGEngine.h"
2002-08-26 22:04:10 +00:00
#include "FGTank.h"
2004-03-14 14:57:07 +00:00
#include "FGMatrix33.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 information which is specific to a type of engine. Then:
-# The appropriate engine type instance is created
-# At least one tank object is created, and is linked to an engine.
2004-06-14 11:40:45 +00:00
At Run time each engines Calculate() method is called.
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:
/// 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);
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.
@param AC_cfg pointer to the config file instance that describes the
aircraft being modeled.
@return true if successfully loaded, otherwise false */
bool Load(FGConfigFile* AC_cfg);
/// Retrieves the number of engines defined for the aircraft.
inline unsigned int GetNumEngines(void) const {return Engines.size();}
/** 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.
2002-08-26 22:04:10 +00:00
inline unsigned int GetNumTanks(void) const {return Tanks.size();}
/** 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
2002-08-26 22:04:10 +00:00
/** starts the engines in IC mode (dt=0). All engine-specific setup must
be done before calling this (i.e. magnetos, starter engage, etc.) */
bool ICEngineStart(void);
2004-03-14 14:57:07 +00:00
2004-12-16 12:47:20 +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
2004-06-14 11:40:45 +00:00
inline bool GetRefuel(void) {return refuel;}
inline void SetRefuel(bool setting) {refuel = setting;}
double Transfer(int source, int target, double amount);
void DoRefuel(double time_slice);
2002-08-26 22:04:10 +00:00
FGColumnVector3& GetTanksMoment(void);
double GetTanksWeight(void);
inline int GetActiveEngine(void) const
{
return ActiveEngine;
}
inline int GetActiveEngine(void);
2004-12-16 12:47:20 +00:00
inline bool GetFuelFreeze(void) {return fuel_freeze;}
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);
2004-12-16 12:47:20 +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
void bind();
void unbind();
2004-03-14 14:57:07 +00:00
2002-08-26 22:04:10 +00:00
private:
vector <FGEngine*> Engines;
vector <FGTank*> Tanks;
vector <FGTank*>::iterator iTank;
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;
2004-12-16 12:47:20 +00:00
bool fuel_freeze;
2004-06-14 11:40:45 +00:00
2002-08-26 22:04:10 +00:00
void Debug(int from);
};
}
2002-08-26 22:04:10 +00:00
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#endif