Jump to content
Sign in to follow this  
Guest Ron Freimuth

TIP: FS2004 XML L:Var units functionality

Recommended Posts

Hi,Maybe this is familiar to many of you, but I think it's worth to clarify the concept:Local (L:type) vars may accept units like FS's own vars (A:type) and even more, they support conversions as well!For instance, you may assign (A:XXXX, feet) to (L:MyVar, feet)Or you can assign 15 (>L:MyVar, celsius) or 30 (>L:MyVar, degrees)Then if you read those Lvars using COMPATIBLE units, FS will make the conversion automatically. So you will get proper values for(L:MyVar, meters), (L:MyVar, farenheit) or (L:MyVar, radians)There is no need to be limited by "number", "bool", "enum", etc.NOTE: Only tested in FS2004, and for the most common units like those stated, but I guess should work for the rest.Hope this helps,Tom

Share this post


Link to post
Share on other sites

Hi Tom,Allthough I wasn't aware of this (probably because I've never needed it), it's good to know.So thanks for posting it.As a sidenote, conversions in FS2004 are NOT always as trivial as you would expect.Example:(A:FUEL TANK LEFT MAIN QUANTITY,gallon)Now if you read(A:FUEL TANK LEFT MAIN QUANTITY,pounds)you would expect FS2004 to use a conversion factor gallon-to-pounds.(that is: I would :-) )But it doesn't ...Instead of the expected gallon-to-pounds conversion of appr. 6.7, FS uses a factor of 8.4. (beats me where that comes from, it's not even the same as the difference between Liquid Gallon and Imperial Gallon)Cheers, Rob

Share this post


Link to post
Share on other sites

Rob,I think FS considers water as the fluid to use in gallons to pounds conversion, which has a gravity of 1. Jet fuel has a lower gravity value, therefore the difference.Cheers,Tom

Share this post


Link to post
Share on other sites

Hi Tom,Yes, I can explain WHY there is a difference (although I would have expected FS to handle that for me, given the type of parameter which appies to FUEL, not WATER in the tanks :-)), but NOT the difference between factor 6.7 and 8.4 ... I just can't figure out where the 8.4 comes from :-)But again, it was just an example of non-trivial conversion.. nothing more...Cheers, Rob

Share this post


Link to post
Share on other sites

>Hi Tom,>>Yes, I can explain WHY there is a difference (although I would>have expected FS to handle that for me, given the type of>parameter which appies to FUEL, not WATER in the tanks :-)),>but NOT the difference between factor 6.7 and 8.4 ... I just>can't figure out where the 8.4 comes from :-)That becomes even more curious when you consider that the calculation in the Fuel Menu uses the correct 6.7 lb/gal factor... ???


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites

"..I just can't figure out where the 8.4 comes from" 1 US water gallon = 8.4 * Water Density(1.0000) = 8.4 pounds (the value you get)1 US Jet Fuel gallon = 8.4 * JF Density(aprox 0.8029) = 6.74 pounds I agree FS should take JFuel on account instead of water. It seems that uses only direct conversions ie formulas with standard constants only.Tom

Share this post


Link to post
Share on other sites

Yes, that explains it...But I'll still stick to my original point: It's not what I would expect when using these conversion functions :-)Cheers, Rob

Share this post


Link to post
Share on other sites
Guest Ron Freimuth

>Local (L:type) vars may accept units like FS's own vars>(A:type) and even more, they support conversions as well!>>For instance, you may assign (A:XXXX, feet) to (L:MyVar,>feet)>Or you can assign 15 (>L:MyVar, celsius) or 30 (>L:MyVar,>degrees) You don't need to use the same units in the L: Parmaeters above. I use 'float' for FP values, letting the unit in the A: variable do the conversion. Though, if A: is bool or enum then L: should be the same. While I think using 'enum' in the L: variable will simply change a FP value to an integer value.>NOTE: Only tested in FS2004, and for the most common units>like those stated, but I guess should work for the rest.>Tom Sure, works in FS2K2 also.Ron

Share this post


Link to post
Share on other sites

> You don't need to use the same units in the L: Parmaeters>above. I use 'float' for FP values, letting the unit in the>A: variable do the conversion.Hi Ron,Yes you do if you need to read an L:Var with different units, because automatic conversion between L:Var units only works when they are COMPATIBLE. Using your example,if you assign (A:XXX,knots) to (L:MyVar,float), you will get proper values for (L:MyVar,knots) BUT NOT for (L:MyVar,kilometers/hour). Instead, if you assign (A:XXX,knots) to (L:MyVar,knots), you will have right values for (L:MyVar,knots) AND (L:MyVar,kilometers/hour).Best regards,Tom

Share this post


Link to post
Share on other sites
Guest Ron Freimuth

>> You don't need to use the same units in the L: Parmaeters>>above. I use 'float' for FP values, letting the unit in the>>A: variable do the conversion.>>Hi Ron,>>Yes you do if you need to read an L:Var with different units,>because automatic conversion between L:Var units only works>when they are COMPATIBLE. ...........>Tom Ah. I never expected automatic conversion to work with 'floats', if I wanted to convert them I used my own conversion factors. L: Parameters set once in an initialization block. However, I'll keep your comment in mind. Ron

Share this post


Link to post
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
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...