Fix use of properties for fuel-tank levels.
This commit is contained in:
parent
47772b9853
commit
451ebabe95
2 changed files with 19 additions and 7 deletions
|
@ -124,6 +124,14 @@ FGJSBsim::FGJSBsim( double dt )
|
|||
|
||||
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/throttle", FCS->GetThrottleCmd(0));
|
||||
fgSetDouble("/fdm/trim/aileron", FCS->GetDaCmd());
|
||||
|
@ -327,9 +335,10 @@ bool FGJSBsim::copy_to_JSBsim() {
|
|||
// << get_V_down_airmass() );
|
||||
|
||||
for (i = 0; i < Propulsion->GetNumTanks(); i++) {
|
||||
SGPropertyNode * node = fgGetNode("/consumables/fuel/tank", i, true);
|
||||
FGTank * tank = Propulsion->GetTank(i);
|
||||
tank->SetContents(fgGetNode("consumables/fuel/tank", i, true)
|
||||
->getDoubleValue());
|
||||
tank->SetContents(node->getDoubleValue("level-gal_us") * 6.6);
|
||||
// tank->SetContents(node->getDoubleValue("level-lb"));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -455,9 +464,12 @@ bool FGJSBsim::copy_from_JSBsim() {
|
|||
}
|
||||
|
||||
// Copy the fuel levels from JSBSim.
|
||||
for (i = 0; i < Propulsion->GetNumTanks(); i++)
|
||||
fgGetNode("consumables/fuel/tank", i, true)
|
||||
->setDoubleValue(Propulsion->GetTank(i)->GetContents());
|
||||
for (i = 0; i < Propulsion->GetNumTanks(); i++) {
|
||||
SGPropertyNode * node = fgGetNode("/consumables/fuel/tank", i, true);
|
||||
double contents = Propulsion->GetTank(i)->GetContents();
|
||||
node->setDoubleValue("level-gal_us", contents/6.6);
|
||||
// node->setDoubleValue("level-lb", contents);
|
||||
}
|
||||
|
||||
update_gear();
|
||||
|
||||
|
|
|
@ -120,11 +120,11 @@ void FGLaRCsim::update( int multiloop ) {
|
|||
fgSetDouble("/engines/engine/cranking", eng.getCrankingFlag());
|
||||
|
||||
//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]")
|
||||
- (eng.get_fuel_flow_gals_hr() / (2 * 3600))
|
||||
* get_delta_t());
|
||||
fgSetDouble("/consumables/fuel/tank[1]",
|
||||
fgSetDouble("/consumables/fuel/tank[1]/level-gal_us",
|
||||
fgGetDouble("/consumables/fuel/tank[1]")
|
||||
- (eng.get_fuel_flow_gals_hr() / (2 * 3600))
|
||||
* get_delta_t());
|
||||
|
|
Loading…
Reference in a new issue