• 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 Very Basic Question

TurboCompound

Resource contributor
Messages
190
I have decided to take a crack at XML Gauge making, using the tutorials at FS2X.

I made a basic Korry Switch that will light up when clicked, but I want to take it to the next level.
Code:
<Gauge Name="CL6_APU_Fuel" Version="0.1">
    <Image Name="APU_Panel.bmp"/>
    <Element>
    <Position X="221" Y="52"/>
        <Select>
            <Value>(L:APU_FuelSOV)</Value>
            <Case Value="0">
                <Image Name="FuelValveClosed.bmp"/>
            </Case>
            <Case Value="1">
                <Image Name="FuelValveOpen.bmp"/>
            </Case>
        </Select>
    </Element>
    <Mouse>
        <Area Left="220" Right="284" Top="52" Bottom="116">
            <Tooltip>APU Fuel Valve</Tooltip>
            <Cursor Type="Hand"/>
            <Click>(L:APU_FuelSOV,Bool) ! (&gt;L:APU_FuelSOV,Bool)</Click>
        </Area>
    </Mouse>
</Gauge>

How can I add a condition so that the switch will not light up if the Aircraft Battery is not on?

Thanks
 
There are a few ways to do this. I've always preferred to build the "OFF" lamp image into my gauge background itself, then display the "ON" image when certain conditions are met, like Switch On + Battery. Or, add the "OFF" as a separate Element, followed by the "ON" Element.

<Visible> is a common way to introduce a condition:

Code:
<Gauge Name="CL6_APU_Fuel" Version="0.1">
    <Image Name="APU_Panel.bmp"/>
      
        <Element>
            <Position X="221" Y="52"/>
                <Image Name="FuelValveClosed.bmp"/>
        </Element>

        <Element>
            <Position X="221" Y="52"/>
            <Visible>(L:APU_FuelSOV,Bool) (A:ELECTRICAL MASTER BATTERY, bool) and</Visible>
                <Image Name="FuelValveOpen.bmp"/>
        </Element>
      
    <Mouse>
        <Area Left="220" Right="284" Top="52" Bottom="116">
            <Tooltip>APU Fuel Valve</Tooltip>
            <Cursor Type="Hand"/>
            <Click>(L:APU_FuelSOV,Bool) ! (&gt;L:APU_FuelSOV,Bool)</Click>
        </Area>
    </Mouse>
</Gauge>

There are other ways to approach this, but becoming familiar with <Visible> is important. It can do more than manage images ... can also enable/disable mouse click areas, etc. Very handy.

Hope this helps,

Bob
 
You can even refine this.

Code:
<Gauge Name="CL6_APU_Fuel" Version="0.1">
<Image Name="APU_Panel.bmp"/>
<Element>
<Position X="221" Y="52"/>
<Select>
<Value>(L:APU_FuelSOV) (A:ELECTRICAL MAIN BUS VOLTAGE, volts) 10 &gt; and</Value>
<Case Value="0">
<Image Name="FuelValveClosed.bmp"/>
</Case>
<Case Value="1">
<Image Name="FuelValveOpen.bmp"/>
</Case>
</Select>
</Element>
<Mouse>
<Area Left="220" Right="284" Top="52" Bottom="116">
<Tooltip>APU Fuel Valve</Tooltip>
<Cursor Type="Hand"/>
<Click>(L:APU_FuelSOV,Bool) ! (&gt;L:APU_FuelSOV,Bool)</Click>
</Area>
</Mouse>
</Gauge>

This will take the current on the main bus into account. If the battery is off, it's zero and if the battery is on, the light will illuminate until the current falls below 10 volts (or any other limit that you want to set).
 
Thanks for the help guys, I'll try my new script when I get a chance. This might even grow to a full panel.
 
I'll be able to test this tomorrow. Any glaring mistakes? I've also added a second button.
Code:
<Gauge Name="CL6_APU_Panel" Version="0.2">
    <Image Name="APU_Panel.bmp"/>
    <Element>
    <Position X="221" Y="52"/>
        <Select>
            <Value>(L:APU_FuelSOV,Bool) (A:ELECTRICAL MASTER BATTERY, bool) and</Value>
            <Case Value="0">
                <Image Name="FuelValveClosed.bmp"/>
            </Case>
            <Case Value="1">
                <Image Name="FuelValveOpen.bmp"/>
            </Case>
        </Select>
    </Element>
    <Mouse>
        <Area Left="221" Right="285" Top="52" Bottom="116">
            <Tooltip>APU Fuel Valve</Tooltip>
            <Cursor Type="Hand"/>
            <Click>(L:APU_FuelSOV,Bool) ! (&gt;L:APU_FuelSOV,Bool)</Click>
        </Area>
    </Mouse>
    <Element>
    <Position X="289" Y="52"/>
        <Select>
            <Value>(L:APU_Starter,Bool) (A:FUEL TANK LEFT MAIN LEVEL, pounds) 15 &gt (A:ELECTRICAL MASTER BATTERY, bool) (L:APU_FuelSOV,Bool) and</Value>
            <Case Value="0">
                <Image Name="APU_Start.bmp"/>
            </Case>
            <Case Value="1">
                <Image Name="APU_Start_Ign.bmp"/>
            </Case>
        </Select>
    </Element>
    <Mouse>
        <Area Left="289" Right="353" Top="52" Bottom="116">
            <Tooltip>APU Start/Stop</Tooltip>
            <Cursor Type="Hand"/>
            <Click>(L:APU_Starter,Bool) ! (&gt;L:APU_Starter,Bool)</Click>
        </Area>
    </Mouse>
</Gauge>

The idea should be that the first button requires the battery to work, and the second button requires the first button, the battery, and a certain amount of fuel to work.
 
This is ok:

<Value>(L:APU_FuelSOV,Bool) (A:ELECTRICAL MASTER BATTERY, bool) and</Value>


Alternatively, it could be written

<Value>(L:APU_FuelSOV,Bool) (A:ELECTRICAL MASTER BATTERY, bool) *</Value>


But this has some errors:

<Value>(L:APU_Starter,Bool) (A:FUEL TANK LEFT MAIN LEVEL, pounds) 15 &gt (A:ELECTRICAL MASTER BATTERY, bool) (L:APU_FuelSOV,Bool) and</Value>

Instead, you want this:

<Value>(L:APU_Starter,Bool) (A:FUEL TANK LEFT MAIN LEVEL, pounds) 15 &gt; and (A:ELECTRICAL MASTER BATTERY, bool) and (L:APU_FuelSOV,Bool) and</Value>


or

<Value>(L:APU_Starter,Bool) (A:FUEL TANK LEFT MAIN LEVEL, pounds) 15 &gt; (A:ELECTRICAL MASTER BATTERY, bool) (L:APU_FuelSOV,Bool) and and and</Value>

One other note... it doesn't apply to (A:ELECTRICAL MASTER BATTERY, bool), but not all A:Var bools return either 1 or 0. A few return -1 and 0, for example.

And, take care that the L:Var bools you create are truly 1 or 0, not something like a computed 1.000012. Just because you give your L:Var a "bool" unit does not force it to be either an integer or only 1 or 0.

Bob
 
Last edited:
Alternatively, it could be written

<Value>(L:APU_FuelSOV,Bool) (A:ELECTRICAL MASTER BATTERY, bool) *</Value>

Thanks. Just to clarify, * can also mean "and?"

Instead, you want this:

<Value>(L:APU_Starter,Bool) (A:FUEL TANK LEFT MAIN LEVEL, pounds) 15 &gt; and (A:ELECTRICAL MASTER BATTERY, bool) and (L:APU_FuelSOV,Bool) and</Value>

Ahh, okay.

This language is very different than what I'm used to. But it sure is fun.
 
* is multiplication. So, no, it is not like "and".. This is yields an equivalent result only because you are dealing with 1 or 0.

And yeah, you need to compare each pair of values. With 4 variables, you need 3 "and".

Bob
 
Ahh, yes. Makes sense. Can't wait to try this thing out!

By the way, do you know where I can find more tutorials for XML? I've been reading the ones on FS2X and they're very useful, but they don't go into quite as much detail on L:Var use as I would like.
 
Nick Pike's documents are still the best Flight Sim XML tuts I believe. After that, the way everyone else in here learns is by studying working XML gauge examples found in Flight Sim itself and discussion in FSDeveloper and other forums such as AVSIM.

There are two "types" of XML format... FS9 and FSX schemas and mostly, you will see people use FS9, as you are using in your example above. I suggest you learn using FS9. You will recognize the difference when you look at some of the XML gauges included in FSX.

As you get further into it, I highly suggest you get a logic debug tool such as BlackBox3 that will show you a real time readout of all of your L:Vars of A:Vars. It's very helpful.

BB3 isn't the only tool out there. Take a look also at XMLTools (from Tom Aguilo) and one from Doug Dawson. All can be freely downloaded.

If you venture into the 3D cockpit and animation world, then that is a separate topic. Though largely XML based, virtual cockpit design might not be the easiest place to cut your XML teeth, in my opinion.

To learn XML, or any gauge design language ... test, test, and re-test.

Bob
 
I have been told to avoid the FSX schema, as it is supposedly more complicated and far less intuitive.
I already use Doug's XML debugger, as I am also a cockpit builder and have to find LVars to write to offsets for SIOC use.

Speaking of Doug's Gauges, I plan to use his fuel tank management gauge to allow the APU to actually "use" fuel. I hope it'll work.
 
To expand a little further, XML uses a Stack to temporarily store data while performing calcs. Here is what your script looks like as viewed from the Stack perspective:

upload_2015-5-9_22-47-54.jpeg



Note that I highly abbreviated your variable names to make it fit more easily into the diagram.

If you look at it this way, you can see why you needed the two extra "and" operators.

The maximum allowed depth of the Flight Simulator XML Stack ... to be safe ... is 27. Reference this old blog discussion.

Hope this helps,

Bob
 
Last edited:
That is a very helpful visual, thanks. I'll test my Gauge today, then report back.

By the way, is there a command I can use to not just change the bitmap for the APU Starter, but also change another variable to 1?
 
By the way, is there a command I can use to not just change the bitmap for the APU Starter, but also change another variable to 1?
What variable specifically? An A:Var?

Its hard to know what it is you want to do, so could you explain a bit more?
 
What I'm looking to do is have something like:
Code:
<Case Value="1">
     <Set L:APU_Ign to 1>
However, I'm not sure exactly the syntax for accomplishing this.
 
One great way to learn XML is study existing applications and a great example of this is the fs9gps.cab in your FSX/Gauges folder. Use a program such as 7z to extract(unzip) the cab file and gps_295.xml and gps_500.xml are a wealth of information.

One good reason not to use the FSX schema for XML is that 99% of people who write XML don't use it. So if you have a question it is much easier for them to answer using the old XML style.

And if you haven't done it already get something like notepad++ to write your XML. It's free and it's a hundred times better than using the default MS text editor.
 
Back
Top