#include "FGPiston.h"
#include "FGElectric.h"
#include "FGPropertyManager.h"
+#include <sstream>
namespace JSBSim {
ActiveEngine = -1; // -1: ALL, 0: Engine 1, 1: Engine 2 ...
tankJ.InitMatrix();
refuel = false;
+ fuel_freeze = false;
bind();
bool FGPropulsion::Run(void)
{
+ unsigned int i;
+
if (FGModel::Run()) return true;
double dt = State->Getdt();
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;
}
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;
}
Engines[numEngines]->SetPlacement(xLoc, yLoc, zLoc, Pitch, Yaw);
- Engines[numEngines]->SetEngineNumber(numEngines);
numEngines++;
} else {
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-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;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-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;
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;