1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 Module: FGPropulsion.cpp
6 Purpose: Encapsulates the set of engines, tanks, and thrusters associated
9 ------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) -------------
11 This program is free software; you can redistribute it and/or modify it under
12 the terms of the GNU General Public License as published by the Free Software
13 Foundation; either version 2 of the License, or (at your option) any later
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
23 Place - Suite 330, Boston, MA 02111-1307, USA.
25 Further information about the GNU General Public License can also be found on
26 the world wide web at http://www.gnu.org.
28 FUNCTIONAL DESCRIPTION
29 --------------------------------------------------------------------------------
30 The Propulsion class is the container for the entire propulsion system, which is
31 comprised of engines, tanks, and "thrusters" (the device that transforms the
32 engine power into a force that acts on the aircraft, such as a nozzle or
33 propeller). Once the Propulsion class gets the config file, it reads in
34 information which is specific to a type of engine. Then:
36 1) The appropriate engine type instance is created
37 2) At least one thruster object is instantiated, and is linked to the engine
38 3) At least one tank object is created, and is linked to an engine.
40 Note: Thusters can be linked to more than one engine and engines can be linked
41 to more than one thruster. It is the same with tanks - a many to many
42 relationship can be established.
44 At Run time each engines Calculate() method is called to return the excess power
45 generated during that iteration. The drag from the previous iteration is sub-
46 tracted to give the excess power available for thrust this pass. That quantity
47 is passed to the thrusters associated with a particular engine - perhaps with a
48 scaling mechanism (gearing?) to allow the engine to give its associated thrust-
49 ers specific distributed portions of the excess power.
52 --------------------------------------------------------------------------------
55 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
59 #include "FGPropulsion.h"
61 static const char *IdSrc = "$Header$";
62 static const char *IdHdr = ID_PROPULSION;
64 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
69 FGPropulsion::FGPropulsion(FGFDMExec* fgex) : FGModel(fgex)
75 bool FGPropulsion:: Run(void) {
77 if (!FGModel::Run()) {
86 bool FGPropulsion::LoadPropulsion(FGConfigFile* AC_cfg)
91 int numEngines=0, numTanks=0;
93 AC_cfg->GetNextConfigLine();
95 while ((token = AC_cfg->GetValue()) != "/PROPULSION") {
98 if (parameter == "AC_ENGINE") {
100 *AC_cfg >> engine_name;
101 Engines[numEngines] = *(new FGEngine(FDMExec, FDMExec->GetEnginePath(), engine_name, numEngines));
104 } else if (parameter == "AC_TANK") {
106 Tanks[numTanks] = *(new FGTank(AC_cfg));
107 switch(Tanks[numTanks].GetType()) {
109 // numSelectedFuelTanks++;
111 case FGTank::ttOXIDIZER:
112 // numSelectedOxiTanks++;