• 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.

FSX IS this possible with a 2d pop-up XML gauge?

The whole idea of efficient coding is to have code run as little as possible, thus saving computer time for other things (like frame rate). So if code does not need to be running all the time and there is an alternative to that, why not use it? That said, setting the value of L: variables over and over again takes VERY little computing power and you would need an awful lot of them to affect things by even a little. BTW, this is NOT true with K: commands, which DO use a lot of FS resources and should be run as little as possible.

You have said that when the FLD State variable goes to 0, then you want the load action to occur. For this to happen properly we need to set our flag variable (TankSub) to 1 at the same time. You can do this two ways:

1. The way you do it now, is:
a. Somewhere in a Click statement you change the value of the FLD State variable to 0.
b. The code above then senses this and changes the TankSub variable to 1. You run this code over and over and over again, slowing down your panel.

2. The more efficient way:
a. Somewhere in a Click statement you change the value of the FLD State variable to 0.
b. In that same Click statement you can ALSO change the value of the TankSub variable to 1. Now that code is only run once, when you click. Yes, it would be run more often if you clicked more, but not 18 times per second like in #1!

As for going into negative values, just check that the result of the subtraction is less than 0, and then reset it to 0.

XML:
<Element>
<Select>
<Value> (L:FLD_State,enum) 0 == (L:TankSub, number) 2 == &amp;&amp; if{ (L:EAFS, enum) (A:FUEL TOTAL QUANTITY,gallon) - (>L:EAFS, enum)  0 (>L:TankSub, number) (L:EAFS, enum) 0 &lt; if{ 0 (>L:EAFS, enum) } } </Value>
</Select>
</Element>

Hope this helps,
 
The whole idea of efficient coding is to have code run as little as possible, thus saving computer time for other things (like frame rate). So if code does not need to be running all the time and there is an alternative to that, why not use it? That said, setting the value of L: variables over and over again takes VERY little computing power and you would need an awful lot of them to affect things by even a little. BTW, this is NOT true with K: commands, which DO use a lot of FS resources and should be run as little as possible.

You have said that when the FLD State variable goes to 0, then you want the load action to occur. For this to happen properly we need to set our flag variable (TankSub) to 1 at the same time. You can do this two ways:

1. The way you do it now, is:
a. Somewhere in a Click statement you change the value of the FLD State variable to 0.
b. The code above then senses this and changes the TankSub variable to 1. You run this code over and over and over again, slowing down your panel.

2. The more efficient way:
a. Somewhere in a Click statement you change the value of the FLD State variable to 0.
b. In that same Click statement you can ALSO change the value of the TankSub variable to 1. Now that code is only run once, when you click. Yes, it would be run more often if you clicked more, but not 18 times per second like in #1!

As for going into negative values, just check that the result of the subtraction is less than 0, and then reset it to 0.

XML:
<Element>
<Select>
<Value> (L:FLD_State,enum) 0 == (L:TankSub, number) 2 == &amp;&amp; if{ (L:EAFS, enum) (A:FUEL TOTAL QUANTITY,gallon) - (>L:EAFS, enum)  0 (>L:TankSub, number) (L:EAFS, enum) 0 &lt; if{ 0 (>L:EAFS, enum) } } </Value>
</Select>
</Element>

Hope this helps,
awesome stuff Tom, thanks - copied to notes :)

OK...so...this was actually going to be my first approach. As i started playing with someone else's work i didn't feel morally right, so i asked the gauge builder if this would be OK. I didn't get a response so thought i would take option 1.
After re-reading the readMe it does already state that permission for modification for personal use is OK / granted. Perfect.

So i got to work, failed a couple times..but eventually got the following which is working as intended.

The click statement in the Gauge

XML:
<Mouse>

  <Area Left="2" Top="10" Right="37" Bottom="25">
    <Cursor Type="Hand"/>
    <Tooltip ID="">%('Loading Fuel ...' 'Tanks Full' 'Set Fuel Load On (RightClick: Change Units)' 'Set Fuel Dump Off' 'Set Fuel Dump Off' 5 (L:FLD_State,enum) 2 + case)%!s!</Tooltip>
    <Click Kind="LeftSingle+RightSingle" Repeat="No">
      (M:Event) 'LeftSingle' scmp ! (L:FLD_State,enum) 0 &lt;= &amp;&amp;
      if{ (L:FLD_State,enum) 0 == if{ 2 } els{ 0 } (&gt;L:FLD_State,enum) (L:FLD_State,enum) 2  == if{ 1 (>L:TankSub, number) } <<<ADDED
      (M:Event) 'RightSingle' scmp !
      if{
        (L:FLD_Unit,enum) ++ (&gt;L:FLD_Unit,enum)
        (L:FLD_Unit,enum) 4 == if{ 0 (&gt;L:FLD_Unit,enum) }
      }
    </Click>
  </Area>

And in MY XML for the fuel level gauge :

XML:
<Element>
<Select>
<Value> (L:FLD_State,enum) 0 == (L:TankSub, number) 1 == &amp;&amp; if{ (L:EAFS, enum) (A:FUEL TOTAL QUANTITY,gallon) - (>L:EAFS, enum) 0 (>L:TankSub, number) (L:EAFS, enum) 0 &lt; if{ 0 (>L:EAFS, enum) } } </Value>
</Select>
</Element>

So with the above, after filling the aircraft tanks, when loading turned off, amount in aircraft is subtracted from fuel stored in storage tank at the airport. Will not go below '0' ***( needs coding for switch to be turned off if tank reached 0)


And for dumping the fuel in the aircraft to the storage tank, i needed to take a slightly different approach :
I had to add to the click statement - so it would read the fuel in the aircraft and ADD to the storage tank when it was first clicked, instead of when the flag was reset/ switch back to '0' otherwise adding after the dump is complete obviously adds nothing.(or the lowest amount when switch is '0')

XML:
<Area Left="2" Top="26" Right="37" Bottom="41">
    <Cursor Type="Hand"/>
    <Tooltip ID="">%('Set Fuel Load Off' 'Set Fuel Load Off' 'Set Fuel Dump On (RightClick: Change Units)' 'Tanks Nearly Empty' 'Dumping Fuel ...' 5 (L:FLD_State,enum) 2 + case)%!s!</Tooltip>
    <Click Kind="LeftSingle+RightSingle" Repeat="No">
      (M:Event) 'LeftSingle' scmp ! (L:FLD_State,enum) 0 &gt;= &amp;&amp;
      if{ (L:FLD_State,enum) 0 == if{ -2 } els{ 0 } (&gt;L:FLD_State,enum) (L:FLD_State,enum) -2  == if{ (L:EAFS, enum) (A:FUEL TOTAL QUANTITY,gallon) + (>L:EAFS, enum) }  <<<ADDED
      (M:Event) 'RightSingle' scmp !
      if{
        (L:FLD_Unit,enum) ++ (&gt;L:FLD_Unit,enum)
        (L:FLD_Unit,enum) 4 == if{ 0 (&gt;L:FLD_Unit,enum) }
      }
    </Click>
  </Area>

And again in MY XML for the fuel gauge, added element to stop going over ''10,000''

XML:
<Element>
<Select>
<Value>(L:EAFS, enum) 10000 &gt; if{ 10000 (>L:EAFS, enum) } </Value>
</Select>
</Element>


With this i'm getting good results....but still very qwerky ; for example if the there are 2000gals in the aircraft tank, and i add 1000, it will subtract 3000 (which is the total fuel amount) from storage, instead of 1000.

1) Can you see any errors in my technique here in the way i've done it and have i followed your instructions correctly ?

2) Can you suggest a way around the qwerky function ?
 
I don't see any obvious problems in the code you posted. The odd result might be due to some other code? Check each instance of (>L:EAFS, enum) and make sure that there isn't one that shouldn't be there, or is doing the wrong thing.
 
Thanks Tom

so I have been thinking about the odd qwerty behaviour with the filling.

… bear with me I’m on a phone in work ….
I’m thinking if the value of total fuel was past to another Lvar and used to subtract the correct amount
The idea:
In an element or click
Total fuel > currentAmount ( 2000 )

After loading: ( 1000 )
Total fuel ( now 3000)
So total fuel - current amount ( back to 1000) - L:EAFS

Now only 1000 has been subtracted instead of the total 3000

sound good?
 
Perhaps, but this shouldn't be happening in the first place.
Hi Tom.

The dump side is working fine, adding the amount to storage as expected.

Its the loading. The code is a reverse of the dump code, but as above, it can’t work like that unless the aircraft is loaded with zero fuel. In that Scenario it’s ok.
but if the aircraft has an amount of fuel already in the tank, and then i load more, the way it’s coded right now takes the total aircraft fuel and subtracts from the storage. Hence taking more than what was loaded.
if it has 2000 in the tank and load 1000, it subtracts 3000. It should only subtract 1000.

To get around that I was going to try to take the amount what is in the tank before any loading happens, what’s in the tank after loading, subtract the two, and the remainder subtracted from the storage tank.

Hope that makes the problem more clear.
 
Yes, that should work. But probably simpler, you could calculate that result directly as fuel capacity - fuel quantity.
 
Tom, just brain storming, when the fuel quantity goes up, does the capacity come down in the sim?
 
No. Capacity always remains the same as it signifies the maximum fuel that the tank can hold, not an amount that is in it.
 
Im unable to get on the PC right now to try this. But I must admit Im struggling to figure out how to achieve this with capacity and quantit. The sums I’ve tried don’t add up.
 
I agree, use your original logic. Amount after loading minus amount before loading equals amount added. The other way to do this is keep track of the amount added as you do it. Add 1000 gal to the plane, immediately subtract 1000 gal from the airport tank.
 
Thanks Tom, original logic used and working :

XML:
<Element>
<Select>
<Value> (L:FLD_State,enum) 0 == (L:TankSub, number) 1 == &amp;&amp; if{ (A:FUEL TOTAL QUANTITY,gallon) (L:CurrentAmount,enum) - (>L:Loadsub, enum) (L:EAFS, enum) (L:Loadsub, enum) - (>L:EAFS, enum)  0 (>L:TankSub, number) (L:EAFS, enum) 0 &lt; if{ 0 (>L:EAFS, enum) } } </Value>
</Select>
</Element>

Amount in tank : [L] LVar: EAFS = 3377.96
Amount loaded : [L] LVar: Loadsub = 3376.67
Amount remaining : [L] LVar: EAFS = 1.29
[L] LVar: FLD_State = 0
[L] LVar: FLD_State = 2
[L] LVar: FLD_State = 0

:)
 
WEEKEND RECAP:
initially we want to end up with something like this :

fuel_storage_monitoring-001.(FSM).jpg


The internet/PC will be replaced with a unit in the aircraft.

Whilst in need of some inspiration of what kind of unit to make, i popped down to the boneyard (Kemble) and gathered some items to test some ideas: :stirthepo

Couple' tubes of super glue and a zippy tie later, i came up with eyesore contraption:

RemoteFuelGauge.jpg


Concentrating on the fuel gauge selector, i wanted it to display the amount at each airport ( remember this is just to test the idea..the graphics are shocking ATM)
So i gave the fuel gauge its value based off the switch position :

XML:
<Gauge Name="Remote_Fuel_Unit" Version="1.0">
<Image Name="background.bmp"/>

<Element>
<Position X="98" Y="494" />
<Select>
<Value>(L:Fuel Gauge Switch, enum)</Value>
<Case Value="0">
<Image Name="Airport_selector_switch_EAFS_B.bmp">
<Axis X="37" Y="25" />
</Image>
</Case>
<Case Value="1">
<Image Name="Airport_selector_switch_UKBA_B.bmp">
<Axis X="23" Y="35" />
</Image>
</Case>
<Case Value="2">
<Image Name="Airport_selector_switch_LSGS_B.bmp">
<Axis X="37" Y="25" />
</Image>
</Case>
</Select>
</Element>

<!-- ========================= Fuel Gauge ======================== -->
    <Element>
        <Position X="101" Y="334" />
        <Image Name="needle.bmp" PointsTo="North">
            <Axis X="2" Y="55" />
        </Image>
        <Rotate>
            <Value>(L:Fuel Gauge Switch, enum) 0 ==
      if{ (L:EAFS, enum) }
      els{ (L:Fuel Gauge Switch, enum) 1 ==
          if{ (L:LSGS, enum) }
          els{ (L:UKBA, enum) } }
      </Value>
            <Failures>
                <SYSTEM_ELECTRICAL_PANELS Action="0" />
                <GAUGE_FUEL_INDICATORS Action="Freeze" />
            </Failures>
            <Nonlinearity>
            <Item Value="0" X="77" Y="372"/>
            <Item Value="1000" X="61" Y="355"/>
            <Item Value="2000" X="54" Y="333"/>
            <Item Value="3000" X="60" Y="310"/>
            <Item Value="4000" X="78" Y="294"/>
            <Item Value="5000" X="100" Y="287"/>
            <Item Value="6000" X="123" Y="293"/>
            <Item Value="7000" X="140" Y="309"/>
            <Item Value="8000" X="146" Y="332"/>
            <Item Value="9000" X="141" Y="356"/>
            <Item Value="10000" X="125" Y="373"/>
            </Nonlinearity>
            <Delay DegreesPerSecond="20" />
        </Rotate>
    </Element>

Now that I've now added 2 other tanks, it needed to know which tank to subtract from after loading has occurred. I again done this based off the switch position:

XML:
<Element>
<Select>
<Value> (L:FLD_State,enum) 0 == (L:TankSub, number) 1 == &amp;&amp;
    if{ (A:FUEL TOTAL QUANTITY,gallon) (L:CurrentAmount,enum) - (>L:Loadsub, enum)
    (L:Fuel Gauge Switch, enum) 0 == if{ (L:EAFS, enum) (L:Loadsub, enum) - (>L:EAFS, enum) }
    (L:Fuel Gauge Switch, enum) 1 == if{ (L:LSGS, enum) (L:Loadsub, enum) - (>L:LSGS, enum) }
    (L:Fuel Gauge Switch, enum) 2 == if{ (L:UKBA, enum) (L:Loadsub, enum) - (>L:UKBA, enum) }
    0 (>L:TankSub, number) (L:EAFS, enum) 0 &lt; if{ 0 (>L:EAFS, enum) } </Value>
</Select>
</Element>

And of course when dumping, which tank to dump to:

XML:
(L:FLD_State,enum) -2 == (L:Fuel Gauge Switch, enum) 0 == &amp;&amp;
if{ (L:EAFS, enum) (A:FUEL TOTAL QUANTITY,gallon) + (>L:EAFS, enum) }
(L:Fuel Gauge Switch, enum) 1 == if{ (L:LSGS, enum) (A:FUEL TOTAL QUANTITY,gallon) + (>L:LSGS, enum) }
(L:Fuel Gauge Switch, enum) 2 == if{ (L:UKBA, enum) (A:FUEL TOTAL QUANTITY,gallon) + (>L:UKBA, enum) }

Some refinement required still with the dump. Need to recognize if the airport selected on the switch, is the airport i'm at, and if for example im at EAFS, but the switch is set LSGS, it will NOT dump.

Unsure on the approach to that problem, at the moment and unfortunately the weekend is over. Boo 😠
 
There is a way to find the closest airport to the user aircraft using GPS variables, but they are not simple to implement...
 
There is a way to find the closest airport to the user aircraft using GPS variables, but they are not simple to implement...
Thanks Tom
That was my fear, the gps looks very complicated and hard to understand. I’ll still take a look though.
I’ve seen some post that might help me gather the info I need, but it looks like another long road…

using coordinates would still be using some form of the gps I assume?

just a passing thought, maybe achievable by reading the airports ASL altitude, as each airport has is different on this case, if it matches allow dump/load.
Or
Need to be at a certain distance from a nav aid at the airport in question.
 
Last edited:
If you want to do the math, you can do it with simple FS variables. You can easily obtain the plane's latitude and longitude. Then compare them to the lat and long of the various airports you will be using and choose the closest. No GPS variables, needed, but some math will be.
 
I’m wondering if that would limit me to only 1 parking spot, and have to be exact every time?
also, is it possible to check the frequency Nav 1 is tuned to, and if so, is it the same way as checking for FLD_State as above?
(A:nav 1 frequency) 114.75 == ?

That would be a much simpler approach I think, but can’t get to the pc to try atm.
 
You do not check that they are equal, just that the plane is closer than a certain distance (i.e. airport center - aircraft location is less than a certain value).

I'm giving you a simple approach that should (?) work, although you should be able to find a formula online to calculate the distance between two lat long values if you wish.

1. Compare lat and long from the aircraft's location to the lat long for the center of EAFS (for example). Subtract lat from lat, long from long.
2. Add the two together.
3. Determine if this value is less than a certain value (determined by experiment). If so, you know what airport you are at and can check that the Fuel Gauge Switch is set appropriately.
3. If EAFS is not the correct airport, repeat this for each airport your code covers.
4. If none are less than the test distance, then you are not at one of the included airports.

Testing for the NAV frequency should work fine, I assume.
 
Back
Top