Hi,

I am using the following piece of code to read the fuel levels:
double fueln = 0;
// get the fuel levels;
for( int count = 0; count < 7; count++ )
  {
    string tank = "/consumables/fuel/tank["+
      su->intTostring(count)+"]/level-gal_us";
    cout << setprecision(6) << "tank " << count << ": "
         << setw(10) << fgGetDouble( tank.c_str() ) << endl;
    fueln = fueln + fgGetDouble( tank.c_str() );
  }

The fuel levels seem to retrieve correctly.
I then added the following code to set the fuel levels for when the c172 aircraft starts:
fgSetDouble( "/consumables/fuel/tank[0]/level-gal_us", tank1 );
fgSetDouble( "/consumables/fuel/tank[1]/level-gal_us", tank2 );


Now when i read the fuel levels strange things start to happen.
At time 21 seconds the tanks read as:
tank 0:   2.624356
tank 1:   2.624356
tank 2:   0.000000
tank 3:   0.000000
tank 4:   0.000000
tank 5:   0.000000
tank 6:   0.000000

At time 25 seconds the tanks read as:
tank 0:   2.641097
tank 1:   2.641097
tank 2:   0.000000
tank 3:   0.000000
tank 4:   0.000000
tank 5:   0.000000
tank 6:   0.000000

There his more fuel at time 25 then at time 21. I assume i must be setting the fuels levels incorrectly.

Does anyone know of a different method?

Thanks,

Seamus

On Fri, 4 Feb 2005, Andy Ross wrote:

I found time this afternoon to refresh my memory about how the fuel
stuff works.

The FDM reads these properties to determine the amount of fuel in each
tank.  YASim uses this only for computing the inertia tensor and total
aircraft mass, it doesn't care about "fuel" per se.

 /consumables/fuel/tank[n]/level-lbs

The FDM reads the following boolean property to determine whether to
kill an engine:

 /engines/engine[n]/out-of-fuel

The FDM *adds* to this property to contain a running total of fuel
consumed for each engine.  If it currently has a value of 7, and this
timestep 4.2 lbs of fuel were consumed by this engine, then it should
be set to 11.2.

 /engines/engine[n]/fuel-consumed-lbs

And that's it.  Everything else related to fuel, including
user-configurability of tank selection and/or filling, is handled by
the nasal script/gui for you.  IMHO, it's really about as simple for
the FDM as is possible.

Andy

_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@flightgear.org
http://mail.flightgear.org/mailman/listinfo/flightgear-devel
2f585eeea02e2c79d7b1d8c4963bae2d


_______________________________________________ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d

Reply via email to