]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGPropulsion.cpp
Oct 2, 2000 JSBSim sync.
[flightgear.git] / src / FDM / JSBSim / FGPropulsion.cpp
1 /*******************************************************************************
2
3  Module:       FGPropulsion.cpp
4  Author:       Jon S. Berndt
5  Date started: 08/20/00
6  Purpose:      Encapsulates the set of engines, tanks, and thrusters associated
7                with this aircraft
8
9  ------------- Copyright (C) 2000  Jon S. Berndt (jsb@hal-pc.org) -------------
10
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
14  version.
15
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
19  details.
20
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.
24
25  Further information about the GNU General Public License can also be found on
26  the world wide web at http://www.gnu.org.
27
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:
35
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.
39
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.
43
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.
50
51 HISTORY
52 --------------------------------------------------------------------------------
53 08/20/00   JSB   Created
54
55 ********************************************************************************
56 INCLUDES
57 *******************************************************************************/
58
59 #include "FGPropulsion.h"
60
61 /*******************************************************************************
62 ************************************ CODE **************************************
63 *******************************************************************************/
64
65
66 FGPropulsion::FGPropulsion(FGFDMExec* fgex) : FGModel(fgex)
67 {
68
69 }
70
71
72 bool FGPropulsion:: Run(void) {
73
74   if (!FGModel::Run()) {
75
76     return false;
77   } else {
78     return true;
79   }
80 }
81
82
83 bool FGPropulsion::LoadPropulsion(FGConfigFile* AC_cfg)
84 {
85   string token;
86   string engine_name;
87   string parameter;
88
89   AC_cfg->GetNextConfigLine();
90
91   while ((token = AC_cfg->GetValue()) != "/PROPULSION") {
92     *AC_cfg >> parameter;
93
94     if (parameter == "AC_ENGINE") {
95
96       *AC_cfg >> engine_name;
97       Engine[numEngines] = new FGEngine(FDMExec, EnginePath, engine_name, numEngines);
98       numEngines++;
99
100     } else if (parameter == "AC_TANK") {
101
102       Tank[numTanks] = new FGTank(AC_cfg);
103       switch(Tank[numTanks]->GetType()) {
104       case FGTank::ttFUEL:
105         numSelectedFuelTanks++;
106         break;
107       case FGTank::ttOXIDIZER:
108         numSelectedOxiTanks++;
109         break;
110       }
111       numTanks++;
112     }
113   }
114 }
115