TrimMode = false;
FuelFlow_gph = 0.0;
FuelFlow_pph = 0.0;
+ FuelFreeze = false;
FDMExec = exec;
State = FDMExec->GetState();
Output = FDMExec->GetOutput();
PropertyManager = FDMExec->GetPropertyManager();
-
+
+ char property_name[80];
+ snprintf(property_name, 80, "propulsion/engine[%u]/thrust", EngineNumber);
+ PropertyManager->Tie( property_name, &Thrust);
+
Debug(0);
}
FGEngine::~FGEngine()
{
- if (Thruster)
- delete Thruster;
+ if (Thruster) delete Thruster;
+ char property_name[80];
+ snprintf(property_name, 80, "propulsion/engine[%u]/thrust", EngineNumber);
+ PropertyManager->Untie( property_name);
+
Debug(1);
}
void FGEngine::ConsumeFuel(void)
{
- double Fshortage, Oshortage, TanksWithFuel;
+ if (FuelFreeze) return;
+ unsigned int i;
+ double Fshortage, Oshortage, TanksWithFuel, TanksWithOxidizer;
FGTank* Tank;
+ bool haveOxTanks = false;
if (TrimMode) return;
- Fshortage = Oshortage = TanksWithFuel = 0.0;
+ Fshortage = Oshortage = TanksWithFuel = TanksWithOxidizer = 0.0;
- // count how many assigned tanks have fuel
- for (unsigned int i=0; i<SourceTanks.size(); i++) {
+ // count how many assigned tanks have fuel or oxidizer
+ for (i=0; i<SourceTanks.size(); i++) {
Tank = Propulsion->GetTank(SourceTanks[i]);
- if (Tank->GetContents() > 0.0) {
- ++TanksWithFuel;
+ if (Tank->GetType() == FGTank::ttFUEL){
+ if (Tank->GetContents() > 0.0) {
+ ++TanksWithFuel;
+ }
+ } else if (Tank->GetType() == FGTank::ttOXIDIZER) {
+ haveOxTanks = true;
+ if (Tank->GetContents() > 0.0) {
+ ++TanksWithOxidizer;
+ }
}
}
- if (!TanksWithFuel) return;
+ if (!TanksWithFuel || (haveOxTanks && !TanksWithOxidizer)) return;
- for (unsigned int i=0; i<SourceTanks.size(); i++) {
+ for (i=0; i<SourceTanks.size(); i++) {
Tank = Propulsion->GetTank(SourceTanks[i]);
if (Tank->GetType() == FGTank::ttFUEL) {
Fshortage += Tank->Drain(CalcFuelNeed()/TanksWithFuel);
- } else {
- Oshortage += Tank->Drain(CalcOxidizerNeed()/TanksWithFuel);
+ } else if (Tank->GetType() == FGTank::ttOXIDIZER) {
+ Oshortage += Tank->Drain(CalcOxidizerNeed()/TanksWithOxidizer);
}
}
bool FGEngine::LoadThruster(FGConfigFile* AC_cfg)
{
string token, fullpath, localpath;
- string thrusterFileName, thrType, engineFileName;
+ string thrType, engineFileName;
FGConfigFile* Cfg_ptr = 0;
double xLoc, yLoc, zLoc, Pitch, Yaw;
double P_Factor = 0, Sense = 0.0;