]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGTank.cpp
JSBSim tweaks.
[flightgear.git] / src / FDM / JSBSim / FGTank.cpp
index 922ff8d0daec313b42298bbffd051a584300ddf2..7162dd88ec48e9131c28ebddee3737abea84e87a 100644 (file)
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
  Module:       FGTank.cpp
  Author:       Jon Berndt
@@ -32,35 +32,45 @@ HISTORY
 --------------------------------------------------------------------------------
 01/21/99   JSB   Created
 
-********************************************************************************
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 INCLUDES
-*******************************************************************************/
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #include "FGTank.h"
 
-static const char *IdSrc = "$Header$";
+static const char *IdSrc = "$Id$";
 static const char *IdHdr = ID_TANK;
 
-/*******************************************************************************
-************************************ CODE **************************************
-*******************************************************************************/
+extern short debug_lvl;
 
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS IMPLEMENTATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+using std::cerr;
+using std::endl;
+using std::cout;
 
 FGTank::FGTank(FGConfigFile* AC_cfg)
 {
-  string type;
-
-  *AC_cfg >> type;                              // Type = 0: fuel, 1: oxidizer
-
-  if (type == "FUEL") Type = ttFUEL;
+  string type = AC_cfg->GetValue("TYPE");
+  string token;
+  
+  if      (type == "FUEL")     Type = ttFUEL;
   else if (type == "OXIDIZER") Type = ttOXIDIZER;
-  else Type = ttUNKNOWN;
-  *AC_cfg >> X;                                 // inches
-  *AC_cfg >> Y;                                 // "
-  *AC_cfg >> Z;                                 // "
-  *AC_cfg >> Radius;                            // "
-  *AC_cfg >> Capacity;                          // pounds (amount it can hold)
-  *AC_cfg >> Contents;                          // pounds  (amount it is holding)
+  else                         Type = ttUNKNOWN;
+  
+  AC_cfg->GetNextConfigLine();
+  while ((token = AC_cfg->GetValue()) != "/AC_TANK") {
+    if (token == "XLOC") *AC_cfg >> X;
+    else if (token == "YLOC") *AC_cfg >> Y;
+    else if (token == "ZLOC") *AC_cfg >> Z;
+    else if (token == "RADIUS") *AC_cfg >> Radius;
+    else if (token == "CAPACITY") *AC_cfg >> Capacity;
+    else if (token == "CONTENTS") *AC_cfg >> Contents;
+    else cerr << "Unknown identifier: " << token << " in tank definition." << endl;
+  }
+  
   Selected = true;
 
   if (Capacity != 0) {
@@ -69,13 +79,25 @@ FGTank::FGTank(FGConfigFile* AC_cfg)
     Contents = 0;
     PctFull  = 0;
   }     
+
+  if (debug_lvl > 0) {
+    cout << "      " << type << " tank holds " << Capacity << " lbs. " << type << endl;
+    cout << "      currently at " << PctFull << "% of maximum capacity" << endl;
+    cout << "      Tank location (X, Y, Z): " << X << ", " << Y << ", " << Z << endl;
+    cout << "      Effective radius: " << Radius << " inches" << endl;
+  }
+
+  if (debug_lvl & 2) cout << "Instantiated: FGTank" << endl;
 }
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-FGTank::~FGTank(void)
+FGTank::~FGTank()
 {
+  if (debug_lvl & 2) cout << "Destroyed:    FGTank" << endl;
 }
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 float FGTank::Reduce(float used)
 {
@@ -84,7 +106,7 @@ float FGTank::Reduce(float used)
   if (used < Contents) {
     Contents -= used;
     PctFull = 100.0*Contents/Capacity;
-    return Contents;
+    return 0.0;
   } else {
     shortage = Contents - used;
     Contents = 0.0;
@@ -94,3 +116,10 @@ float FGTank::Reduce(float used)
   }
 }
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGTank::Debug(void)
+{
+    //TODO: Add your source code here
+}
+