Jump to content
The simFlight Network Forums

How to determine Fuel Type


Recommended Posts

Good morning,

 

I am in the process of revamping a client that uses FSUIPC over at FSEconomy and had a quick questions.

 

I have searched for this, but apparently haven't hit the right keywords.

 

Is there a way to determine the Loaded Aircrafts Fuel Type?

 

I have searched the Offset PDF (I think I have the latest) and couldn't determine if that was available or not.

 

I have looked in different aircraft.cfg files for FSX and see an entry there for that.

 

As an example the fuel section for a B737-800:

 

[fuel]
Center1   = -5.9,   0.0, -3.2, 4299, 0 
LeftMain  = -9.7, -17.2, -3.2, 1288, 0
RightMain = -9.7,  17.2, -3.2, 1288, 0
fuel_type = 2                                   //Fuel type: 1 = Avgas, 2 = JetA
number_of_tank_selectors = 1                   
electric_pump=1
fuel_dump_rate = 0.0167

 

For the default Aircreation 582SL:

 

[fuel]
Center1= -2.70, 0.00, -3.80, 10.00, 0.00
fuel_type=1.000000
number_of_tank_selectors=1
electric_pump=0
engine_driven_pump=0

 

I figured I could use the current weight per gallon (0xAF4) that is calculated to get a rough estimate as 100ll is generally right at 6lbs, whereas JetA is a bit heavier at 6.5+lbs, but if it is already available no use guessing.

 

 

Thanks for a great product btw, I have personally been a silent paid user for a number of years now.

 

(Just started using Mister Henty's .net wrapper as well, and another great piece of work that helps to simplify integration for those of us that like a managed environment.)

 

Link to comment
Share on other sites

Is there a way to determine the Loaded Aircrafts Fuel Type?

 

I have searched the Offset PDF (I think I have the latest) and couldn't determine if that was available or not.

 

I have looked in different aircraft.cfg files for FSX and see an entry there for that.

 

As an example the fuel section for a B737-800:

 

[fuel]

Center1   = -5.9,   0.0, -3.2, 4299, 0 

LeftMain  = -9.7, -17.2, -3.2, 1288, 0

RightMain = -9.7,  17.2, -3.2, 1288, 0

fuel_type = 2                                   //Fuel type: 1 = Avgas, 2 = JetA

number_of_tank_selectors = 1                   

electric_pump=1

fuel_dump_rate = 0.0167

 

For the default Aircreation 582SL:

 

[fuel]

Center1= -2.70, 0.00, -3.80, 10.00, 0.00

fuel_type=1.000000

number_of_tank_selectors=1

electric_pump=0

engine_driven_pump=0

 

I figured I could use the current weight per gallon (0xAF4) that is calculated to get a rough estimate as 100ll is generally right at 6lbs, whereas JetA is a bit heavier at 6.5+lbs, but if it is already available no use guessing.

 

I just checked, and it doesn't look like the SimConnect interface (which is what FSUIPC relies upon) provides that value at all.

 

Doesn't the weight per gallon vary with altitude, due to pressure differences affecting volume?

 

Pete

Link to comment
Share on other sites

Hi Pete,

 

Thanks for the quick response.

 

JetA does have quite a bit of variation, but it is always greater then 6.4lbs per gallon.

100ll stays pretty consistent at a hair over 6lbs.

 

I am not sure my work around now will actually work as I am unsure that offset 0XAF4 will return anything but an integer value.

I am testing that now.

Link to comment
Share on other sites

Apparently that offset is just integers. So my weight trick is non-functional, everything returns as 100LL.

 

Its not a game breaker, more of a nice to have as I am providing a comparison of the FSE Model to the Loaded Aircraft in the Sim to try and help prevent end of flight errors due to incompatibilities.

 

Just to make sure I am not doing anything wrong here are the code snippets I am using:

 

Offset<short> _fuelWeight = new Offset<short>("AircraftInfo", 0x0AF4);

 

public double FuelWeightPerGal

{

get { return _fuelWeight.Value / 256.0; }

}

 

It always returns 6.0

Edited by Airboss001
Link to comment
Share on other sites

Apparently that offset is just integers. So my weight trick is non-functional, everything returns as 100LL.

 

Its not a game breaker, more of a nice to have as I am providing a comparison of the FSE Model to the Loaded Aircraft in the Sim to try and help prevent end of flight errors due to incompatibilities.

 

Strange. I'm just checking ...

... no. Here I get 0AF4 = 1715 (decimal), making the value 6.6992.

 

Just check the value in 0AF4. You can monitor it with FSUIPC's logging-tab monitor, very easily.

 

Just to make sure I am not doing anything wrong here are the code snippets I am using:

 

Offset<short> _fuelWeight = new Offset<short>("AircraftInfo", 0x0AF4);

 

public double FuelWeightPerGal

{

get { return _fuelWeight.Value / 256.0; }

}

 

I'm not familiar with this way of coding, sorry. But if the variable _fuelWeight.Value is defined as a "short" then it cannot handle fractions in any case. The division by 256.0 should convert the end result into floating point (it would do so in C/C++), but try copying it to a declared floating point variable before dividing.

 

Pete

Link to comment
Share on other sites

My bad, I thought there would be an auto conversion to double for the returned value since I was dividing by a double.

 

I just split out the pieces and got it to work just fine getting the same retuned value in the offset you did sitting on the ground.

 

Thanks for the touchback as I would have just moved on!

Link to comment
Share on other sites

Instead of splitting it out you can do the calculation in one line by casting the short to a double:

public double FuelWeightPerGal
{
get { return (double)_fuelWeight.Value / 256d; }
}

Note also that in C# 256.0 is a float (Single) literal. Doubles need a 'd' at the end.

 

Paul

Link to comment
Share on other sites

Thanks Paul, I had seen a couple of your other posts showing that as well.

 

It is interesting to note that using

 

return offset.Value / 256.0;

Does not implicitly convert the value to a float before division without the explicit cast.

 

return offset.Value / 256d

Does however do the implicit cast, and returns the right value

 

Edit: just to complete this I did go back and try:

return offset.Value / 256f;

 

And it worked as well...

That is really odd and either operand should force the other to the same precision.

I would think that 256.0 should be considered a float, but apparently its not.

 

Edit 2: I when back to 256.0 to do some more testing and now its working correctly?!

Gah, sometimes you just can't win.

And yes, I really had that in the code, I copy/pasted directly from the code above so I am not crazy...much.

(I am checking to see if a selected aircraft has the wrong fuel type in the configuration, but don't remember what I was using now)

Link to comment
Share on other sites

Yes that is odd.

 

I ran this code and seems it works as stated (one operand being a double is enough to force the other):

public void test()
{
      short myInt = 1715;
      double result1 = myInt / 256;
      double result2 = (double)myInt / 256;
      double result3 = myInt / 256.0;
      double result4 = myInt / 256d;
      double result5 = myInt / 256f;
      double result6 = divTest();
}

public double divTest()
{
      short myInt = 1715;
      return myInt / 256.0;
}

All the results are fine (6.69921875) except Result1 which is rounded to 6 because it's the only one where both operands are integers.

 

Result3 and Result6 are the same as you were trying in your original code.

 

Also, writing 256.0 is seen by the compiler as a double, not a single as I wrote in my last post.

 

Paul

Link to comment
Share on other sites

I have gone back and tried every plane I thought I had loaded and can't repeat it...

So one of two things occurred most likely.

 

An aircraft had fuel-type miss-set (I can't seem to duplicate)

Or I loaded another 100LL aircraft thinking I had a JetA aircraft (Maybe I am crazy after all! :oops: )

Sorry for the churn.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.