]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBsim/FGTank.cpp
ea118069547dfd3046e5f94f5b4d7b8b6894d993
[flightgear.git] / src / FDM / JSBsim / FGTank.cpp
1 /*******************************************************************************
2
3  Module:       FGTank.cpp
4  Author:       Jon Berndt
5  Date started: 01/21/99
6  Called by:    FGAircraft
7
8  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
9
10  This program is free software; you can redistribute it and/or modify it under
11  the terms of the GNU General Public License as published by the Free Software
12  Foundation; either version 2 of the License, or (at your option) any later
13  version.
14
15  This program is distributed in the hope that it will be useful, but WITHOUT
16  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
18  details.
19
20  You should have received a copy of the GNU General Public License along with
21  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22  Place - Suite 330, Boston, MA  02111-1307, USA.
23
24  Further information about the GNU General Public License can also be found on
25  the world wide web at http://www.gnu.org.
26
27 FUNCTIONAL DESCRIPTION
28 --------------------------------------------------------------------------------
29 See header file.
30
31 HISTORY
32 --------------------------------------------------------------------------------
33 01/21/99   JSB   Created
34
35 ********************************************************************************
36 INCLUDES
37 *******************************************************************************/
38 #include "FGTank.h"
39
40 /*******************************************************************************
41 ************************************ CODE **************************************
42 *******************************************************************************/
43
44
45 FGTank::FGTank(ifstream& acfile)
46 {
47   string type;
48
49   acfile >> type;                              // Type = 0: fuel, 1: oxidizer
50   if (type == "FUEL") Type = ttFUEL;
51   else if (type == "OXIDIZER") Type = ttOXIDIZER;
52   else Type = ttUNKNOWN;
53   acfile >> X;                                 // inches
54   acfile >> Y;                                 // "
55   acfile >> Z;                                 // "
56   acfile >> Radius;                            // "
57   acfile >> Capacity;                          // pounds (amount it can hold)
58   acfile >> Contents;                          // pounds  (amount it is holding)
59   Selected = true;
60   PctFull = 100.0*Contents/Capacity;           // percent full; 0 to 100.0
61 }
62
63
64 FGTank::~FGTank(void)
65 {
66 }
67
68
69 float FGTank::Reduce(float used)
70 {
71   float shortage;
72
73   if (used < Contents) {
74     Contents -= used;
75     PctFull = 100.0*Contents/Capacity;
76     return Contents;
77   } else {
78     shortage = Contents - used;
79     Contents = 0.0;
80     PctFull = 0.0;
81     Selected = false;
82     return shortage;
83   }
84 }
85