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

IF Statements

Messages
259
Country
ca-ontario
Hi Guys,

I've never tried an IF statement before in a gauge. Am I anywhere even close with this one?

<Click>(A:FUEL CROSS FEED, Enum) 0 == if{CROSS_FEED_OPEN}) else (A:FUEL CROSS FEED, Enum) 1 == if{CROSS_FEED_OFF}</Click>
 
Your close, a bit of formatting error. I always nest my condition to make the easier to read.

Code:
<Click>(A:FUEL CROSS FEED, Enum) 0 == 
    if{(>K:CROSS_FEED_OPEN)}
    els{ (A:FUEL CROSS FEED, Enum) 1 == 
        if{(>K:CROSS_FEED_OFF)}
    }
</Click>

I am not sure of the Key command are correct, and I am unable to look them up ATM.
 
Note also that the else command becomes 'els'. A common mistake is to put spaces between the 'if' and the '{}': it should just be if{ }, as DNLK has demonstrated.
 
...also, don't forget to leave a space between the bracket and the following command!

Code:
if{ 1 (&gt;L:DO SOMETING,bool) }

NOT:
Code:
if{1 (&gt;L:DO NOTHING,bool)}
 
Here is my complete gauge code

<Gauge Name="Crossfeed" Version="1.0">

<Image Name="crossfeed.bmp"/>

<Element>
<Visible>(A:FUEL CROSS FEED, Enum) 1 ==</Visible>
<Image Name="crossfeed_on.bmp" Bright="Yes"/>
</Element>

<Mouse>
<Cursor Type="Hand"/>
<Click>(A:FUEL CROSS FEED, Enum) 0 ==
if{ (>K:CROSS_FEED_OPEN) }
els{ (A:FUEL CROSS FEED, Enum) 1 ==
if{ (>K:CROSS_FEED_OFF) }
}
</Click>
</Mouse>

</Gauge>

The images work, but the crossfeed never opens. The lines are correct as far as I can see from the SDK.

Can you see what the issue might be?
 
Here is my complete gauge code
The images work, but the crossfeed never opens. The lines are correct as far as I can see from the SDK.
Can you see what the issue might be?

This from the SimConnect SDK:
CROSS_FEED_OPEN Opens cross feed valve (when used in conjunction with “isolate” tank)
CROSS_FEED_TOGGLE Toggles crossfeed valve (when used in conjunction with “isolate” tank)
CROSS_FEED_OFF Closes crossfeed valve (when used in conjunction with “isolate” tank)

Have you done anything to "isolate" the tank?

Doug
 
From the FSX SDK:

FUEL_TANK_SELECTOR_ISOLATE = 18

To "isolate" a tank you need to issue a key event prior to using the Crossfeed function.

For example:

Code:
18 (>K:FUEL_SELECTOR_SET)
18 (>K:FUEL_SELECTOR_SET_2)
etc.

I'm afraid that the SDK isn't really very clear on how to use this "feature."

For my own use, I simply roll my own control scripts...

For example, the T-38A Talon has fuselage fuel bladders; one set for the left system and another set for the right system. There are two fuel pump switches and a crossfeed switch.

Code:
    <!-- FUEL SYSTEM -->
    (L:CrossFeedUpdate,bool) 1 ==
    if{
      (L:T38_Left_Fuel,enum) 2 &gt; (A:GENERAL ENG FUEL PUMP SWITCH:1,bool) and (>L:Press1,bool)
      (L:T38_Right_Fuel,enum) 2 &gt; (A:GENERAL ENG FUEL PUMP SWITCH:2,bool) and (>L:Press2,bool)
      
      (L:T38_FuelCrossFeed,bool) !
      if{
        4 (>K:FUEL_SELECTOR_SET)
        5 (>K:FUEL_SELECTOR_2_SET)
      }
      (L:T38_FuelCrossFeed,bool) (L:Press1,bool) (L:Press2,bool) and and
      if{
        1 (>K:FUEL_SELECTOR_SET)
        1 (>K:FUEL_SELECTOR_2_SET)
      }
      (L:T38_FuelCrossFeed,bool) (L:Press1,bool) and (L:Press2,bool) ! and
      if{
        14 (>K:FUEL_SELECTOR_SET)
        14 (>K:FUEL_SELECTOR_2_SET)
      }
      (L:T38_FuelCrossFeed,bool) (L:Press1,bool) ! and (L:Press2,bool) and
      if{
        15 (>K:FUEL_SELECTOR_SET)
        15 (>K:FUEL_SELECTOR_2_SET)
      }
      0 (>L:CrossFeedUpdate,bool)
    }
    <!-- If either tank goes to 0 with its BP on and xfeed open, air ingestion will flame out both engines -->
    (L:T38_FuelCrossFeed,bool)
    if{
      (L:T38_Left_Fuel,enum) 2 &lt; (A:GENERAL ENG FUEL PUMP SWITCH:1,bool) and
      if{
        4 (>K:FUEL_SELECTOR_SET)
        4 (>K:FUEL_SELECTOR_2_SET)
      }
      (L:T38_Right_Fuel,enum) 2 &lt; (A:GENERAL ENG FUEL PUMP SWITCH:2,bool) and
      if{
        5 (>K:FUEL_SELECTOR_SET)
        5 (>K:FUEL_SELECTOR_2_SET)
        }
      }

    <!-- END FUEL SYSTEM -->
 
Last edited:
Andy, don't get discouraged!

What the "isolate" command does is -well- isolate the tank from its engine.

You do know that each tank is linked with only one engine, right?

So, let's assume that you have two engines and two tanks.

Left engine uses Left Main
Right engine uses Right Main

To get Crossfeed working from Right Main to Left engine, you need to first disconnect ("isolate") the fuel selector from the Left Main to the Left engine, then issue the Crossfeed command:

Code:
<Click>
   18 (>K:FUEL_SELECTOR_SET)
   (>K:CROSS_FEED_OPEN)
</Click>

This should disconnect the Left engine from the Left Main tank, then crossfeed fuel from the Right Main tank to both Left and Right engines...
 
Man, I was so hoping to learn from this, and the isolation part totally went over my head as well. arrghhh...


For those that can think in code, you dont realise how blessed you are. This is some sophisticated work here. I love graphics and mesh work. But thinking in code.... That is an art unto itself...
 
Good timing. I was wondering how to do this. modeldef seems to just toggle crossfeed,bool to get the switch to move.

Roy
 
Good timing. I was wondering how to do this. modeldef seems to just toggle crossfeed,bool to get the switch to move.

Roy

Roy, the main reason why I "roll my own" is that this "isolate tank" per selector only works with tanks that're linked to a specific engine.

What if your real world a/c has a common feed to a center (holding) tank from which both engines draw?

The default "system" has far too many limitations, which is precisely why I use the enumerated list of tank/selector values to program my own system... :D
 
Bill,

What if your real world a/c has a common feed to a center (holding) tank from which both engines draw?

That is why I have the flight manuals for all the planes I build, so I understand their systems. Most twin engine fighters have a common feed from a collection tank, with no crossfeed. The ancient Gloster Meteor had a main tank separated into two compartments with the front part feeding the left engine and the back part feeding the right engine. If you lost an engine you could open a balance cock and draw fuel from both compartments.

The SeaKing I'm working on has a crossfeed. It has three tanks.
With Crossfeed closed the Forward tank feeds #1, Aft tank feeds #2, Center feeds Forward and Aft. So the two engines have separate fuel supplies. With Crossfeed open the separation is removed and fuel can flow to any one or two engines. Crossfeed does not transfer fuel between tanks. So it basically is the same as the Meteor balance cock. I think I just need to set the two fuel selectors to 1 to model that.

Roy
 
Last edited:
Does the "ALL" setting for a fuel selector indeed mean drawing fuel from all tanks or will it respect the "left engine, left tank; right engine,right tank" constraint?

If not, it would practically mean that one would have to declare two fuel selectors in the aircraft.cfg, right?
 
Each engine should have its own fuel selector so yes to 2 in the config file. If they both have ALL selected then I think that is what it means, a common pool for remaining fuel, which should feed evenly until both engines flame out when zero "ALL" fuel remains.
Roy
 
Up until FS9, it was known as BOTH. Since FS9 and FSX support more tank types, I guess MS/ACES figured it'd make more sense to change the name to ALL... ;)
 
I have a if/els question. (EDIT: Questions)

I see that these have a 'condition' that must be a first string on these, yes? Can they be anything else then a 'condition'?

Can the condition be roughly stated, such as;
<Value>EXIT OPEN
.....if/else bits.....
</Value>

(sort of like <Value>EXIT OPEN</Value>

Or does it need to be something like
<Value>
(A:EXIT OPEN,percent) 100
....if/els bits.....
</Value>


Next question..

Can you have the same condition in the front, as you have in the if/else sections, or will that cut the system out, cause it to not function?

For instance,

<Value>
(A:EXIT OPEN,percent) 100
if{ (EXIT OPEN,percent) 100
2 (&gt;L:XMLSND64,enum) }
els{ (EXIT OPEN,percent) 0
3 (&gt;L:XMLSND64,enum) }

Above, note that EXIT OPEN is depicted 3X, top, if, and els sections. Is that 'ok' or does that kill a if/els?


Third, (sorry, so many questions)

Is there a rule on if/els amounts? Can I have 1 if and 3 els'?


Fourth, (yep)

Do you have to have a first condition? or can I go straight to if/els scenarios? It makes sense to me, not knowing how a basic if/els works, that I should just right a if, then els, instead of the opening condition. That makes no sense to me whatsoever, except to have another condition. If I have one condition, then it should just be if/els instead. But I do not fully fathom this equasion or logic.


Man, I will love writing some nice logic.. But just getting through this first hurtle is a struggle to comprehend. What am I missing?
 
I can see this is a scary subject now, lol....


A bit of realization fell upon me today, that perhaps if/els is sort of like <Element> 's are in a 2D code. I note this as some people will place If's inside of If's and the { and } are acting like < and >.

So.... Perhaps this helps me to 'see' a bit as to how these if/els things work.


Example;

<Value>
(A:ELECTRICAL MASTER BATTERY,bool)
if{ (A:EXIT OPEN:1,percent) 1 &gt;
if{ 1 (&gt;L:XMLSND64,enum) }
els{ 3 (&gt;L:XMLSND64,enum) }
}
els{ 3 (&gt;L:XMLSND64,enum) }
</Value>

First 'if' has 1 if and one els in it. The second 'if' is an 'els' and is in its own 'curly bracket' section or string.

So, one can say that 2 or more things can occur in a first 'if' section.

Note, this code above does not work, but its an interesting study.


Bill
 
Back
Top