XML: Units: How FS handles Units

From FSDeveloper Wiki
Jump to: navigation, search

Thanks go to Tom Aguilo for providing the following information on Units:


A:Vars

Simulation Variables (A: type) have values saved together with their units' flag. The numerical value saved is always that associated with the default unit of measurement for the appropriate measurement category. The default is what is considered by Flight Simulator as the reference unit in the Metric system.

Units grouped within the same category maintain a given relationship, or conversion factor, for its reciprocal conversion except Miscellaneous, which generally maintains a 1:1 factor (ie: (A:Light Landing, bool/number/part/enum,etc) all return the same value, 0 or 1 )

If an ( A: ) variable is written without a unit (ie: (A:Fuel weight per gallon) ) a 0 is returned as the relationship of nothing is of course 0.

If an ( A: ) variable is written with a unit not corresponding with its category, the value returned means a conversion between the unit defined and the default unit of the category that unit belongs to.


A:Var Example 1

Suppose an aircraft is holding on Rwy 32L at Chicago O’Hare International Airport. The aircraft altimeter will indicate about 673 feet and (A:PLANE ALTITUDE, feet) will return 672.9. However, the numerical value actually saved is 205.1 which is the value of the altitude measured in the default units for the Distance Category, meters.

If the unit of measurement is changed to a unit not corresponding to the Distance category, for example, (A:PLANE ALTITUDE, Kelvin), then the number 205.1 is returned because Kelvin is the default unit of measurement in the Temperature Category. On the other hand, (A:PLANE ALTITUDE, Fahrenheit) will return -90.5 because that is the degrees Fahrenheit equivalent of 205.1 degrees Kelvin.


A:Var Example 2

A:FUEL TANK LEFT MAIN QUANTITY is a volume variable, and the default unit of measurement for volume is cubic meter. For some Cessna 421 sim models, a full left main tank contains 121 gallons (U.S. liquid gallons), so, for that aircraft, with a full left main tank, Flight Sim stores the value 0.458038 into memory (121 gallons=0.458038 cubic meters), together with a flag that says its a volume type of unit. When Flight Sim is asked to display (A:FUEL TANK LEFT MAIN QUANTITY, gallons), then it recognizes gallons as a volume type unit, applies the cubic meter to gallons conversion, and returns 121.

However, if Flight Sim is asked to display (A:FUEL TANK LEFT MAIN QUANTITY, pounds), then it assumes this is a weight variable. The default weight unit is kilogram, so Flight Sim assumes that the 0.458038 stored in memory represents 0.458038 kg. When it is asked to covert that to pounds, it returns 1.0098 (0.458038 kg=1.0098 pounds), or in other words, (A:FUEL TANK LEFT MAIN QUANTITY, pounds) = 1.0098. This value isn't intuitive and has no meaning because A:FUEL TANK LEFT MAIN QUANTITY is a volume variable, not a weight variable.


L:Vars

Local Variables (L:type) follow the same logic, although when expressed without a unit, or if expressed using a unit that is not defined by Flight Simulator, no conversion occurs and their values return as literal, taking by default a 1:1 relationship.

L:Var Example:

1 (>L:Test) or 1 (>L:Test, dogs) then 
(L:Test, seconds/minutes/cu meter/number,etc) returns 1
2 (>L:Test, number) then 
(L:Test, seconds) returns 2 because seconds is the default unit in the Time Category
(L:Test, minutes) returns 0.03333 because seconds is the default unit in the Time Category and there are 0.03333 minutes in two seconds.
(L:Test, liters) returns 2000 because cu meter is the default unit in Volume Category and there are 2000 liters in two cubic meters.
1 (>L:Test, minutes) then 
(L:Test, seconds) returns 60
(L:Test, number) returns 60
(L:Test, liters) returns 60000
(L:Test) or (L:Test, dogs) returns 1


Default Unit of Measurement

DISTANCE: meter
AREA: sq m
VOLUME: cubic meter
TEMPERATURE: kelvin
ANGLE: radian
ANGULAR VELOCITY: radian per second
SPEED: meter per second
ACCELERATION: meter per second squared
TIME: second
POWER: watt
VOLUME RATE: meter cubed per second
WEIGHT: kilogram
WEIGHT RATE: kilogram per second
ELECTRICAL CURRENT: ampere
ELECTRICAL POTENTIAL: volt
FREQUENCY: hertz
DENSITY: kilogram per cubic meter
PRESSURE: pascal = newton per square meter
TORQUE: newton meter

No conversion applied

SPEED: mach
TIME: year

Not a Pressure Unit

PRESSURE: slug feet squared

1 : 1

MISCELLANEOUS: part
MISCELLANEOUS: percent over 100
MISCELLANEOUS: times
MISCELLANEOUS: ratio
MISCELLANEOUS: number
MISCELLANEOUS: scaler
MISCELLANEOUS: position
MISCELLANEOUS: enum
MISCELLANEOUS: bool
MISCELLANEOUS: mask
MISCELLANEOUS: flags
MISCELLANEOUS: per radian

Conversion is applied

MISCELLANEOUS: per degree
MISCELLANEOUS: half
MISCELLANEOUS: third
MISCELLANEOUS: percent
MISCELLANEOUS: bel
MISCELLANEOUS: decibel
MISCELLANEOUS: more_than_a_half
MISCELLANEOUS: bco16

Non-functional Unit of Measurement (in FSX)

DENSITY: pound per gallon

The system variable (A:Fuel weight per gallon, pounds per gallon) returns 6 in FS9, but the units are not valid in FSX, so the variable returns 0. This is a handy phenomenon, in that the difference can be exploited to distinguish between FS9 and FSX simulations. See wiki

XML: Refreshing Panels in FS9 & FSX

for an example application.


Non-Numerical value

MISCELLANEOUS: string

- rpmc