]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGPropulsion.cpp
Make yasim accept the launchbar and hook properties. They are not tied to anything...
[flightgear.git] / src / FDM / JSBSim / FGPropulsion.cpp
index a7a31a38b4f4e7415863a55098ab4f261f6fe84b..bdb0a211bf3af0d128488b844449d192121d3f93 100644 (file)
@@ -50,6 +50,7 @@ INCLUDES
 #include "FGPiston.h"
 #include "FGElectric.h"
 #include "FGPropertyManager.h"
+#include <sstream>
 
 namespace JSBSim {
 
@@ -73,6 +74,7 @@ FGPropulsion::FGPropulsion(FGFDMExec* exec) : FGModel(exec)
   ActiveEngine = -1; // -1: ALL, 0: Engine 1, 1: Engine 2 ...
   tankJ.InitMatrix();
   refuel = false;
+  fuel_freeze = false;
 
   bind();
 
@@ -93,6 +95,8 @@ FGPropulsion::~FGPropulsion()
 
 bool FGPropulsion::Run(void)
 {
+  unsigned int i;
+
   if (FGModel::Run()) return true;
 
   double dt = State->Getdt();
@@ -100,18 +104,18 @@ bool FGPropulsion::Run(void)
   vForces.InitMatrix();
   vMoments.InitMatrix();
 
-  for (unsigned int i=0; i<numEngines; i++) {
+  for (i=0; i<numEngines; i++) {
     Engines[i]->Calculate();
     vForces  += Engines[i]->GetBodyForces();  // sum body frame forces
     vMoments += Engines[i]->GetMoments();     // sum body frame moments
   }
 
-  for (unsigned int i=0; i<numTanks; i++) {
+  for (i=0; i<numTanks; i++) {
     Tanks[i]->Calculate( dt * rate );
-  }     
+  }
 
   if (refuel) DoRefuel( dt * rate );
-
+  
   return false;
 }
 
@@ -231,20 +235,20 @@ bool FGPropulsion::Load(FGConfigFile* AC_cfg)
         ThrottleAdded = true;
 
         if (engType == "FG_ROCKET") {
-          Engines.push_back(new FGRocket(FDMExec, Cfg_ptr));
+          Engines.push_back(new FGRocket(FDMExec, Cfg_ptr, numEngines));
         } else if (engType == "FG_PISTON") {
-          Engines.push_back(new FGPiston(FDMExec, Cfg_ptr));
+          Engines.push_back(new FGPiston(FDMExec, Cfg_ptr, numEngines));
         } else if (engType == "FG_TURBINE") {
-          Engines.push_back(new FGTurbine(FDMExec, Cfg_ptr));
+          Engines.push_back(new FGTurbine(FDMExec, Cfg_ptr, numEngines));
         } else if (engType == "FG_SIMTURBINE") {
           cerr << endl;
           cerr << "The FG_SIMTURBINE engine type has been renamed to FG_TURBINE." << endl;
           cerr << "To fix this problem, simply replace the FG_SIMTURBINE name " << endl;
           cerr << "in your engine file to FG_TURBINE." << endl;
           cerr << endl;
-          Engines.push_back(new FGTurbine(FDMExec, Cfg_ptr));
+          Engines.push_back(new FGTurbine(FDMExec, Cfg_ptr, numEngines));
         } else if (engType == "FG_ELECTRIC") {
-          Engines.push_back(new FGElectric(FDMExec, Cfg_ptr));
+          Engines.push_back(new FGElectric(FDMExec, Cfg_ptr, numEngines));
         } else {
           cerr << fgred << "    Unrecognized engine type: " << underon << engType
                     << underoff << " found in config file." << fgdef << endl;
@@ -281,7 +285,6 @@ bool FGPropulsion::Load(FGConfigFile* AC_cfg)
         }
 
         Engines[numEngines]->SetPlacement(xLoc, yLoc, zLoc, Pitch, Yaw);
-        Engines[numEngines]->SetEngineNumber(numEngines);
         numEngines++;
 
       } else {
@@ -319,16 +322,23 @@ bool FGPropulsion::Load(FGConfigFile* AC_cfg)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-string FGPropulsion::GetPropulsionStrings(void)
+string FGPropulsion::GetPropulsionStrings(string delimeter)
 {
+  unsigned int i;
+
   string PropulsionStrings = "";
   bool firstime = true;
+  stringstream buf;
 
-  for (unsigned int i=0;i<Engines.size();i++) {
+  for (i=0; i<Engines.size(); i++) {
     if (firstime)  firstime = false;
-    else           PropulsionStrings += ", ";
+    else           PropulsionStrings += delimeter;
 
-    PropulsionStrings += Engines[i]->GetEngineLabels() + ", ";
+    PropulsionStrings += Engines[i]->GetEngineLabels(delimeter);
+  }
+  for (i=0; i<Tanks.size(); i++) {
+    if (Tanks[i]->GetType() == FGTank::ttFUEL) buf << delimeter << "Fuel Tank " << i;
+    else if (Tanks[i]->GetType() == FGTank::ttOXIDIZER) buf << delimeter << "Oxidizer Tank " << i;
   }
 
   return PropulsionStrings;
@@ -336,16 +346,23 @@ string FGPropulsion::GetPropulsionStrings(void)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-string FGPropulsion::GetPropulsionValues(void)
+string FGPropulsion::GetPropulsionValues(string delimeter)
 {
+  unsigned int i;
+
   string PropulsionValues = "";
   bool firstime = true;
+  stringstream buf;
 
-  for (unsigned int i=0;i<Engines.size();i++) {
+  for (i=0; i<Engines.size(); i++) {
     if (firstime)  firstime = false;
-    else           PropulsionValues += ", ";
+    else           PropulsionValues += delimeter;
 
-    PropulsionValues += Engines[i]->GetEngineValues() + ", ";
+    PropulsionValues += Engines[i]->GetEngineValues(delimeter);
+  }
+  for (i=0; i<Tanks.size(); i++) {
+    buf << delimeter;
+    buf << Tanks[i]->GetContents();
   }
 
   return PropulsionValues;
@@ -494,11 +511,21 @@ void FGPropulsion::DoRefuel(double time_slice)
       if (Tanks[i]->GetPctFull() < 99.99)
           Transfer(-1, i, fillrate/TanksNotFull);
     }
-  }      
+  }
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
+void FGPropulsion::SetFuelFreeze(bool f) 
+{
+  fuel_freeze = f;
+  for (unsigned int i=0; i<numEngines; i++) {
+    Engines[i]->SetFuelFreeze(f);
+  }
+}  
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 void FGPropulsion::bind(void)
 {
   typedef double (FGPropulsion::*PMF)(int) const;