1
0
Fork 0

Fix use of properties for fuel-tank levels.

This commit is contained in:
david 2002-01-19 18:26:30 +00:00
parent 47772b9853
commit 451ebabe95
2 changed files with 19 additions and 7 deletions

View file

@ -124,6 +124,14 @@ FGJSBsim::FGJSBsim( double dt )
init_gear(); init_gear();
// Set initial fuel levels if provided.
for (int i = 0; i < Propulsion->GetNumTanks(); i++) {
SGPropertyNode * node = fgGetNode("/consumables/fuel/tank", i, true);
if (node->getChild("level-gal_us", 0, false) != 0)
Propulsion->GetTank(i)
->SetContents(node->getDoubleValue("level-gal_us") * 6.6);
}
fgSetDouble("/fdm/trim/pitch-trim", FCS->GetPitchTrimCmd()); fgSetDouble("/fdm/trim/pitch-trim", FCS->GetPitchTrimCmd());
fgSetDouble("/fdm/trim/throttle", FCS->GetThrottleCmd(0)); fgSetDouble("/fdm/trim/throttle", FCS->GetThrottleCmd(0));
fgSetDouble("/fdm/trim/aileron", FCS->GetDaCmd()); fgSetDouble("/fdm/trim/aileron", FCS->GetDaCmd());
@ -327,9 +335,10 @@ bool FGJSBsim::copy_to_JSBsim() {
// << get_V_down_airmass() ); // << get_V_down_airmass() );
for (i = 0; i < Propulsion->GetNumTanks(); i++) { for (i = 0; i < Propulsion->GetNumTanks(); i++) {
SGPropertyNode * node = fgGetNode("/consumables/fuel/tank", i, true);
FGTank * tank = Propulsion->GetTank(i); FGTank * tank = Propulsion->GetTank(i);
tank->SetContents(fgGetNode("consumables/fuel/tank", i, true) tank->SetContents(node->getDoubleValue("level-gal_us") * 6.6);
->getDoubleValue()); // tank->SetContents(node->getDoubleValue("level-lb"));
} }
return true; return true;
@ -455,9 +464,12 @@ bool FGJSBsim::copy_from_JSBsim() {
} }
// Copy the fuel levels from JSBSim. // Copy the fuel levels from JSBSim.
for (i = 0; i < Propulsion->GetNumTanks(); i++) for (i = 0; i < Propulsion->GetNumTanks(); i++) {
fgGetNode("consumables/fuel/tank", i, true) SGPropertyNode * node = fgGetNode("/consumables/fuel/tank", i, true);
->setDoubleValue(Propulsion->GetTank(i)->GetContents()); double contents = Propulsion->GetTank(i)->GetContents();
node->setDoubleValue("level-gal_us", contents/6.6);
// node->setDoubleValue("level-lb", contents);
}
update_gear(); update_gear();

View file

@ -120,11 +120,11 @@ void FGLaRCsim::update( int multiloop ) {
fgSetDouble("/engines/engine/cranking", eng.getCrankingFlag()); fgSetDouble("/engines/engine/cranking", eng.getCrankingFlag());
//Assume we are using both tanks equally for now //Assume we are using both tanks equally for now
fgSetDouble("/consumables/fuel/tank[0]", fgSetDouble("/consumables/fuel/tank[0]/level-gal_us",
fgGetDouble("/consumables/fuel/tank[0]") fgGetDouble("/consumables/fuel/tank[0]")
- (eng.get_fuel_flow_gals_hr() / (2 * 3600)) - (eng.get_fuel_flow_gals_hr() / (2 * 3600))
* get_delta_t()); * get_delta_t());
fgSetDouble("/consumables/fuel/tank[1]", fgSetDouble("/consumables/fuel/tank[1]/level-gal_us",
fgGetDouble("/consumables/fuel/tank[1]") fgGetDouble("/consumables/fuel/tank[1]")
- (eng.get_fuel_flow_gals_hr() / (2 * 3600)) - (eng.get_fuel_flow_gals_hr() / (2 * 3600))
* get_delta_t()); * get_delta_t());