• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

XML Gauge problem

Messages
110
Country
unitedkingdom
Hi,

I'm new to creating gauges and have probably made a basic mistake but here goes.

I am creating a fuel quantity gauge using ace.exe and a background.bmp and needle.bmp.

I cannot get the gauage to register any fuel quantity, 800 gallons is loaded in the setup screen for, in this example, the 'left tank'.

I am using the following code generated through ace.exe:

=======================================
<?xml version="1.0" encoding="UTF-8"?>

<SimBase.Document
Type="AceXML"
version="1,0"
id="FuelQuantityLeftMain">
<Descr>AceXML Document</Descr>
<Filename>FuelQuantityLeftMain.xml</Filename>
<SimGauge.Gauge id="FuelQuantityLeftMain" ArtDirectory="D:\Program Files\FS Design Tools\New Gauges\EE_Lightning\">
<FloatPosition>30.000,30.000</FloatPosition>
<Image id="FuelQuantity_BG.bmp" Name="FuelQuantity_BG.bmp">
<Transparent>True</Transparent>
</Image>
<Element id="Needle_113_17">
<FloatPosition>100.000,100.000</FloatPosition>
<SizeScale>0.900</SizeScale>
<Image id="Needle_113_17.bmp" Name="Needle_113_17.bmp">
<Transparent>True</Transparent>
<Axis>13.000,8.500</Axis>
</Image>
<Rotation id="Rotation">
<Expression id="Rotation through max of 6.28318 minus ~1.04 radians">
<Script>(A:FUEL TANK LEFT MAIN LEVEL) 5.25 * 2.098 +</Script>
</Expression>
</Rotation>
</Element>
</SimGauge.Gauge>
</SimBase.Document>
============================

in (A:FUEL TANK LEFT MAIN LEVEL) 5.25 * 2.098 +
the 5.25 is the radians between enpty and full and the 2.098 is the radians offset to bring the needle from it's EAST direction to the empty position. (Needle is horizontal, sharp end to the right).

I believe that (A:FUEL TANK LEFT MAIN LEVEL) is a percentage output from FSX.

When I replace (A:FUEL TANK LEFT MAIN LEVEL) with a value 1 in the expression the needle drives round to Full in ace.exe but it doesn't respond to the (A:FUEL TANK LEFT MAIN LEVEL) data in the cockpit.

Any thoughts?

klem
 
This is incomplete:

<Script>(A:FUEL TANK LEFT MAIN LEVEL) 5.25 * 2.098 +</Script>

All variables MUST have their "units" specified, such as:

<Script>(A:FUEL TANK LEFT MAIN LEVEL,percent) 5.25 * 2.098 +</Script>

-or-

<Script>(A:FUEL TANK LEFT MAIN LEVEL,gallons) 5.25 * 2.098 +</Script>
 
Many thanks Bill, I just realised what the problem was after re-reading some of the SDK notes - well, realised = guessed !

I had thought I would automatically get a percent output as the Variables describe it as a percent. Anyway, thanks to your reply I have also learned that it can be gallons too.



Thanks again

klem
 
Last edited:
The SDK lists all of the possible "units" that're available, but of course we need to specify only those that make sense... ;)

Frankly, this is one reason why I often will use the XML variables even when coding a C++ gauge. Instead of me having to code a conversion (or use one of the macro conversions), I can simply ask for the sim to return the value with the units I require! :D
 
Thanks Bill

Still got some work to do as 5.35 radians doesn't equal 100% for some reason, the gauge goes round and round... and round.... about 30 degrees for every gallon of fuel used as read on a fuel quantity readout. :(
Total gallons = 800, 8 gallons = 1%.

Doesn't 1% * 5.25 radians = .0525 radians or 3 degrees? I seem to be getting about 240 degrees for 8 gallons, well something large anyway.


klem
 
Try this:

<Script>(A:FUEL TANK LEFT MAIN LEVEL,percent) 100 / 5.25 * 2.098 +</Script>
 
Many thanks Bill, that solved the problem - and my understanding.

In fact I was able to go on and scale the fuel level for my 345 gallon capacity tank (~2400lbs) to the 3200lb background scale using:-

<Script>(A:FUEL TANK LEFT MAIN LEVEL, percent) 100 / (A:FUEL TANK LEFT MAIN CAPACITY, gallons) 6.84 * * 3200 / 5.25 * 2.098 +</Script>

( yes, I'm very pleased with myself :) ! )

But I think I'll build a new background with a more appropriate scale.

Thanks again

klem
 
Or you could have used this:

<Script>(A:FUEL TANK LEFT MAIN LEVEL,percent) .00525 * 2.098 +</Script>

Either way will reach the same result... ;)
 
I did something like that when I was testing it but after years of writing Visual Basic code for databases I got into the habit of re-useable code so my expression would work for any tank using the 3200lb gauge. Mind you that's pretty unlikely so I think I'll cut the processor overhead and simplify it to yours or whatever suits the gauge scale. :)

Cheers

klem
 
Back
Top