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

Glad you have it working. And yes, number will give you more accuracy. Enum is typically used for variables used in case expressions, etc. which need to be discreet integer values.
 
So, the working week is over and the fun begins again 😁 (well after a visit to grandmother 👵, bless her xx)
some brain storming

next I want to
have some code that recognises / detects when a switch, with 3 positions, (1 down, 0 middle, 2 up) has gone from 2 to 0 and when it does, it puts (A:TOTAL FUEL QUANTITY) into (>L:EAFS)

bearing / distance of airport from current position. Maybe a compass face with a needle pointing to bearing. Old type drum DME readout maybe

I wouldn’t know where to start with this one but maybe have to dial a frequency in order for the quantity to show on the gauge? is that even possible?

That should be enough to keep me busy today ( or even the next 3 weekends 😄)
 
I'm currently trying to accomplish the first task of having the switch position recognized and then something done, which isn't going to well. Everything i try just increases the Lvar's value instead of decreasing it

Here are some of many failed attempts :

XML:
<Element>
<Select>
<Value>(L:FLD_State,enum) 2 (L:FLD_State,enum) 0 if{ (L:EAFS, enum) (A:FUEL TOTAL QUANTITY,gallons) - (>L:EAFS,enum) }</Value>
.................

<Value>(L:FLD_State,enum) 2 (L:FLD_State,enum) 0 if{ (L:EAFS,enum) (A:FUEL TOTAL QUANTITY,gallons) - (>L:EAFS, enum) } </Value> increases value

<Value>(L:FLD_State,enum) 2 (L:FLD_State,enum) 0 if{ (>L:EAFS,enum) -- (A:FUEL TOTAL QUANTITY,gallons) (L:EAFS, enum) /-/ } </Value> increases value

<Value>(L:FLD_State,enum) 2 (L:FLD_State,enum) 0 if{ (L:EAFS,enum) -- (A:FUEL TOTAL QUANTITY,gallons) (>L:EAFS, enum) /-/ } </Value>

<Value>(L:FLD_State,enum) 2 (L:FLD_State,enum) 0 if{ (L:EAFS,enum) (A:FUEL TOTAL QUANTITY,gallons) (>L:EAFS, enum) -} </Value>

<Value>(L:FLD_State,enum) 2 (L:FLD_State,enum) 0 if{ (L:EAFS,enum) (A:FUEL TOTAL QUANTITY,gallons) (&gt;L:EAFS, enum) -} </Value>

<Value>(L:FLD_State,enum) 2 (L:FLD_State,enum) 0 if{0} (L:EAFS,enum) (A:FUEL TOTAL QUANTITY,gallons) (&gt;L:EAFS, enum) -} </Value>

<Value>(L:FLD_State,enum) 2 (L:FLD_State,enum) 0 if{ (A:FUEL TOTAL QUANTITY,gallons) (L:EAFS, enum) (>L:EAFS,enum) -}</Value> all increases value

putting this in an <Element> would be the correct approach?

Clearly i'm biting of more than i can chew...never attempted 'IF's' or else's, and if i look at other gauges with them, i can see my attempts are wrong, but cant see 'what'

So it's working, but in reverse and replacing the '-' with '+' makes no difference so i think something is being ignored..?

any tips on this gents?
 
If you want to check for a value the usual way is to use == after the test variable. Example:

<Value>(L:FLD_State,enum) 2 == (L:FLD_State,enum) 0 == if{ (L:EAFS,enum) (A:FUEL TOTAL QUANTITY,gallons) - (>L:EAFS, enum) } </Value> increases value

Then you need to decide if this is AND or OR for the two test variables. If AND, then at the end there should be &&, if OR there should be ||. The AND example:

<Value>(L:FLD_State,enum) 2 == (L:FLD_State,enum) 0 == && if{ (L:EAFS,enum) (A:FUEL TOTAL QUANTITY,gallons) - (>L:EAFS, enum) } </Value> increases value

You generally need to write && as
Code:
&amp;&amp;
to avoid possible issues.

XML:
<Value>(L:FLD_State,enum) 2 == (L:FLD_State,enum) 0 ==  &amp;&amp; if{ (L:EAFS,enum) (A:FUEL TOTAL QUANTITY,gallons) - (>L:EAFS, enum) } </Value> increases value

Also, the way you have the above line written you are subtracting the FUEL TOTAL QUANTITY from L:EAFS. Is this what you want? If not, reverse them.

Once all that is fixed we can talk further if needed, but it might fix your problem.
 
Hi Tom,
I gave it a go with this :

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

But i get nothing from it.
I'm monitoring (L:FLD_State,enum) from the dump gauge from within my gauge in that ^ Element...or thats my understanding of how it should work

But when i move the switch, it doesn't change the value of L:EAFS
Also, the way you have the above line written you are subtracting the FUEL TOTAL QUANTITY from L:EAFS. Is this what you want?
Yes that's correct.
So when i move the switch to the fill position the tanks are filled, when the switch is moved back to central off position, that is when i want it to read the total fuel, then subtract from L:EAFS.
I dont think i can ask it to do that in just the off position, as it initializes there. so it would put the value of ''total fuel'' in L:EAFS on launching the session. But is the above method the correct way? is that code asking for both 2 and 0 to be true at the same time?, because that is never the case. Or, is that code looking for 2, then 0 and THEN executing?
 
Full code :

XML:
<Gauge Name="EAFS_fuel_Level" Version="1.0">
<Image Name="EAFS_solid1.bmp"/>

<Element>
<Position X="151" Y="151"/>
<Image Name="needleVolts.bmp" PointsTo="North">
<Axis X="2" Y="55"/>
</Image>
<Rotate>
<Value Maximum="10000" Minimum="0"> (L:EAFS, number)</Value>
<Nonlinearity>
            <Item Value="0" X="95" Y="247"/>
            <Item Value="1000" X="53" Y="208"/>
            <Item Value="2000" X="36" Y="152"/>
            <Item Value="3000" X="53" Y="95"/>
            <Item Value="4000" X="94" Y="53"/>
            <Item Value="5000" X="150" Y="41"/>
        <Item Value="6000" X="206" Y="55"/>
            <Item Value="7000" X="247" Y="95"/>
            <Item Value="8000" X="264" Y="150"/>
            <Item Value="9000" X="248" Y="208"/>
            <Item Value="10000" X="210" Y="245"/>
         </Nonlinearity>
         <Delay DegreesPerSecond="2"/>
      </Rotate>
   </Element>

<Element>
<Select>
<Value>(L:FLD_State,enum) 2 == (L:FLD_State,enum) 0 ==  &amp;&amp; if{ (L:EAFS, enum) (A:FUEL TOTAL QUANTITY,gallons) - (>L:EAFS, enum) } </Value>
</Select>
</Element>
</Gauge>
 
I've now tried so many different ways i'm now confused ...it just wont work ?

I've move the Lvars about, reversed them, ect ect.

1 thing i haven't tried is move the FLD_State '0' and '2' around.

...nope didnt work either
 
another none working example

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



I think the problem may be this part:
XML:
(L:FLD_State,enum) 2 == (L:FLD_State,enum) 0 ==

the switch is is never in position 2 and 0 at the same time, it's either/or

:confused:
 
Last edited:
XML:
<Value>(L:FLD_State,enum) 2 == (L:FLD_State,enum) 0 ==  &amp;&amp; if{ 0 } (L:EAFS, enum) 10000 &lt; if{ (L:EAFS, enum) (A:FUEL TOTAL QUANTITY,gallons) - (>L:EAFS, enum) } els{ 2 } } </Value>

Went bonkers :

] LVar: EAFS = -3301084.08
[L] LVar: EAFS = -3314992.98
[L] LVar: EAFS = -3324265.58
[L] LVar: EAFS = -3338174.48
[L] LVar: EAFS = -3352083.37
[L] LVar: EAFS = -3365992.27
[L] LVar: EAFS = -3375264.87
[L] LVar: EAFS = -3389173.77
[L] LVar: EAFS = -3403082.66
[L] LVar: EAFS = -3416991.56
[L] LVar: EAFS = -3430900.46
[L] LVar: EAFS = -3444809.36
[L] LVar: EAFS = -3458718.25
[L] LVar: EAFS = -3467990.85
[L] LVar: EAFS = -3481899.75
[L] LVar: EAFS = -3495808.65
[L] LVar: EAFS = -3509717.54
[L] LVar: EAFS = -3523626.44
[L] LVar: EAFS = -3537535.34
[L] LVar: EAFS = -3546807.94
[L] LVar: EAFS = -3560716.84
[L] LVar: EAFS = -3574625.73
[L] LVar: EAFS = -3588534.63
[L] LVar: EAFS = -3602443.53
[L] LVar: EAFS = -3616352.43
[L] LVar: EAFS = -3625625.02
[L] LVar: EAFS = -3639533.92
[L] LVar: EAFS = -3653442.82
[L] LVar: EAFS = -3667351.72
[L] LVar: EAFS = -3681260.61
[L] LVar: EAFS = -3695169.51
[L] LVar: EAFS = -3709078.41
[L] LVar: EAFS = -3722987.31
[L] LVar: EAFS = -3736896.2
[L] LVar: EAFS = -3750805.1
[L] LVar: EAFS = -3760077.7
[L] LVar: EAFS = -3773986.6
[L] LVar: EAFS = -3787895.49
[L] LVar: EAFS = -3801804.39
[L] LVar: EAFS = -3815713.29
[L] LVar: EAFS = -3829622.19
[L] LVar: EAFS = -3838894.78
[L] LVar: EAFS = -3852803.68
[L] LVar: EAFS = -3866712.58
[L] LVar: EAFS = -3880621.48
[L] LVar: EAFS = -3894530.37
[L] LVar: EAFS = -3908439.27
[L] LVar: EAFS = -3917711.87
[L] LVar: EAFS = -3931620.77
[L] LVar: EAFS = -3945529.67
[L] LVar: EAFS = -3959438.56
[L] LVar: EAFS = -3973347.46
[L] LVar: EAFS = -3987256.36
 
Sorry, I didn't notice you were testing the same variable twice. Certainly a variable cannot be equal to 0 and 2 at the same time, so nothing will happen. If you want the code to be true if the variable is 0 OR 2, then you need to use || in place of the && - OR instead of AND.
 
Hi Tom Thanks for the reply.

Thats almost what i want, but it to be true after being zero. As the gauge loads in zero state, so it would load the fuel on session load. i want it to load the fuel after moving from 2 - 0.
 
So you can add another variable to check for the 2 to 0 movement. It is often called a "flag", because it turns on when the desired situation occurs, and once you respond to it you turn it off again.

1. Set up an L: variable that (obviously) will be 0 on aircraft load. When your gauge sets the original variable to 2, also set this variable to 1.
2. Now check for the original variable = 0 AND the new variable = 1. This means that the original variable used to = 2 (and thus the new variable was set at 1), and then the original variable was set to 0. If true, load the fuel.
3. After the fuel load, set the new variable back to 0, so the fuel load will not happen again until the code sets the original variable to 2 again.

Hope this helps,
 
Many thanks Tom, appreciate the insight. Been a little stumped 🤔 with this one but you’ve given me the idea. Certainly has helped.
Hopefully before, but I’ll be on it again the weekend.
 
Filling tanks :


<Element>
<Select>
<Value> (L:FLD_State,enum) 2 == (>L:TankSub, number) 1 </Value>
</Select>
</Element>

Load on:
[L] LVar: FLD_State = 2
[L] LVar: TankSub = 1

Load off:
[L] LVar: FLD_State = 0
[L] LVar: TankSub = 0

Above code is setting TankSub to 1 when the dump switch is moved from 0 > 2
And when dump switch is moved back to 0, TankSub is 0.
So:

If{
(L:FLD_State, enum) 0 == (L:TankSub, number) 1 ==

Then
Minus the total fuel from EAFS:

(L:EAFS, enum) (A:FUEL TOTAL QUANTITY,gallon) - (>L:EAFS, enum) << this code works when tested in a <click> zone. It takes the fuel amount in the aircraft tanks and subtracts from EAFS, as desired.

But when i string it all together like this :

<Value> (L:FLD_State,enum) 2 == (>L:TankSub, number) 1 if{ (L:FLD_State,enum) 0 == (L:TankSub, number) 1 == (L:EAFS, enum) (A:FUEL TOTAL QUANTITY,gallon) - (>L:EAFS, enum) }</Value>

the quantity in L:EAFS does not change - - - ive just realised that when the switch is moved back from 2-0, (L:TankSub) returns to 0 aswell.

Hence:
if{ (L:FLD_State,enum) 0 == (L:TankSub, number) 1
will never happen

ughhh....


have a massive head cold too which is blurring things |>_<|

How can i set L:TankSub to 1 and not have it change back to 0, until i want it too?
 
Last edited:
You cannot tie them all together that way. They need to be two separate statements as I wrote above. Four steps:

1. Set the State to 2, and set the tanksub to 1 at the same time.
2. In a separate statement, check for state = 0 and tanksub = 1. If true, go to step 3.
3. If true, do your unloading.
4. Then at the end of the unloading code, set the tanksub to 0.
 
You cannot tie them all together that way. They need to be two separate statements as I wrote above. Four steps:

1. Set the State to 2, and set the tanksub to 1 at the same time.
2. In a separate statement, check for state = 0 and tanksub = 1. If true, go to step 3.
3. If true, do your unloading.
4. Then at the end of the unloading code, set the tanksub to 0.
Hi Tom

Its no.2 that i have problem with. When state goes back to zero, so also does tanksub. It does not hold the 1 value, but returns to 0.
So i tried other ways and as you say, in another statment also.

Here's a none working attempt, (sets tanksub to higher numbers)


XML:
<Element>
<Select>
<Value> (L:FLD_State,enum) 2 d / max ++ (>L:TankSub, number) </Value>
</Select>
</Element>

<Element>
<Select>
<Value> (L:FLD_State,enum) 0 == (L:TankSub, number) 2 == if{ (L:EAFS, enum) (A:FUEL TOTAL QUANTITY,gallon) - } els{ (L:FUEL TOTAL LEVEL,percent) 99 &gt; 0 (>L:TankSub, number) } </Value>
</Select>
</Element>

but that causes a race condition when the switch state is 2
 
Sorry, I don't understand what this code is supposed to do. And you have the tanksub going to 0 in the ELSE part of the statement, which means it happens when the conditions are NOT true. It should happen when they ARE TRUE - i.e. in the IF part of the statement. And why is there an ELSE section at all? And what is the test for 99 percent fuel for? And in the IF section you are not saving the results of the L:EAFS minus Total Fuel to anything. And you are missing the AND function.

Perhaps something like:

XML:
<Element>
<Select>
<Value> (L:FLD_State,enum) 2  == if{ 1 (>L:TankSub, number) } </Value>
</Select>
</Element>

<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) } </Value>
</Select>
</Element>

I would normally have the first Element's 1 saved into TankSub instead in a click statement that actually changes the L:FLD_state variable to 2. That way it's only run once. Better coding, but not critical.
 
Sorry, I don't understand what this code is supposed to do. And you have the tanksub going to 0 in the ELSE part of the statement, which means it happens when the conditions are NOT true. It should happen when they ARE TRUE - i.e. in the IF part of the statement. And why is there an ELSE section at all? And what is the test for 99 percent fuel for? And in the IF section you are not saving the results of the L:EAFS minus Total Fuel to anything. And you are missing the AND function.

Perhaps something like:

XML:
<Element>
<Select>
<Value> (L:FLD_State,enum) 2  == if{ 1 (>L:TankSub, number) } </Value>
</Select>
</Element>

<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) } </Value>
</Select>
</Element>

I would normally have the first Element's 1 saved into TankSub instead in a click statement that actually changes the L:FLD_state variable to 2. That way it's only run once. Better coding, but not critical.
Sorry, I don't understand what this code is supposed to do.
OK, so now that I’m not so delirious with a bad cold, I also don’t know, 😳. I think I was trying to get it to do it’s thing when the fuel was above 99%…
I was trying all sorts to try and get some kind of result. But as you pointed out, I got nowhere.

All those mistakes was just not seen that day. Now you’ve pointed them out, wow, what was I doing. 🤦‍♂️
Apologies Tom for not taking into account the knowledge you have shared with me. A lesson or two learnt here.

I have tested your code, and of course, works perfect 1st time, and also by reading it, makes something I wasn’t sure about very clear. Thank you.

I would normally have the first Element's 1 saved into TankSub instead in a click statement that actually changes the L:FLD_state variable to 2. That way it's only run once. Better coding, but not critical.

could you elaborate on this please Tom.
The way it works at the moment, is using Rob‘s dump guageV3, and reading it’s switch position (L:FLD_State), and when the switch is in the off position, it reads and writes the fuel values.
You are right that it will keep subtracting for example 2000 gals ( whatever amount is in the aircraft tanks at the time) every time the switch is off , ‘0’ state.

would that not happen if it was in a click statement and clicked more than once??

or could another variable be used to compare the amount loaded or unloaded, ….maybe when sim on ground, actually when engines are off …read the tank levels , pass that value in another Lvar to compare in some way and if the values equal, (as in, if +2000, -2000) it no longer allows unloading or loading? (As right now it will subtract into negative values)
Would that be a rather long loop?

Again Tom, thanks for the reply
it is very much appreciated
 
Back
Top