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

Elementary XML L:Vars question

Dave_W

Resource contributor
Messages
185
I have very little experience with XML and gauge programming.

If it matters, this relates to gauges in a VC in FSX. The gauges use FS9 syntax.

A [Windowxx] is opened by clicking an icon.

Two L:Vars are set by clicking on gauges in that window.

In [Vcockpitxx], I would like to increment a gauge that also uses L:Vars, based on the L:Vars set from that window.

I can't make that work. It appears to me that the L:Vars from the window aren't being read. Maybe it's just my lack of programming knowledge.

The SDK says that L:Parameters are available to all other gauges in an aircraft panel.

Is that window considered a separate panel?

TIA
 
Gauges in panel windows are only updated when said panel window is open.
 
If you have any gauges that need to "work in the background", add them to the VCockpit sections. They will update all the time. I often just make a "logic gauge" for the VCockpit section and leave the rest of the gauge code in the subpanel's gauges.
 
If you have any gauges that need to "work in the background", add them to the VCockpit sections. They will update all the time. I often just make a "logic gauge" for the VCockpit section and leave the rest of the gauge code in the subpanel's gauges.
That also works in [Window00] I have a "background" gauge that does various calculations consisting of 1,500 lines. In effect it is the avionics bay!!
 
That doesn't work for me in FS9 if I load only the VC and the main 2D panel is never displayed.
 
In FS9 the main 2D panel is always loaded. In FSX the VC is always loaded. When I say always loaded, I mean that when you first load the aircraft... that is the initial panel load.
 
Not in my FS9. You can load from the VC simply by making that view your default flight. But if you don't do that, you can still load from the VC by going to that view and then reloading the plane from the Select Aircraft menu.

And second, it does matter where you put the gauges you want to load from any and all starting views.

I ran this test. First I created two gauges, a test gauge that sets an L: variable to 1 if it is loaded, and a display gauge to check if the test gauge is loaded into the sim.

Test gauge:

Code:
<Gauge Name="TEST_GAUGE" Version="1.0">

   <Element>
      <Position X="20" Y="78"/>
      <Select>
         <Value> 1 (>L:Panel_Load_Test, bool) </Value>
      </Select>
   </Element>

</Gauge>

Display gauge:

Code:
<Gauge Name="TEST_READOUT" Version="1.0">
   <Image Name="FUEL_POUNDS_BACK.bmp" ImageSizes="256,256"/>

   <Element>
      <Position X="45" Y="80"/>
      <Text X="230" Y="30" Length="350" Font="Arial" Color="#FFFFF0" Adjust="Left" VerticalAdjust="Center" Multiline="No" Fixed="No">
         <String>Gauge Loaded?</String>
      </Text>
   </Element>

   <Element>
    <Visible> (L:Panel_Load_Test, bool) </Visible>
      <Position X="40" Y="140"/>
      <Text X="330" Y="30" Length="350" Font="Arial" Color="#FFFFF0" Adjust="Left" VerticalAdjust="Center" Multiline="No" Fixed="No">
         <String>Gauge is Loaded</String>
      </Text>
   </Element>

   <Element>
    <Visible> (L:Panel_Load_Test, bool) ! </Visible>
      <Position X="40" Y="140"/>
      <Text X="330" Y="30" Length="350" Font="Arial" Color="#FFFFF0" Adjust="Left" VerticalAdjust="Center" Multiline="No" Fixed="No">
         <String>Gauge is NOT Loaded</String>
      </Text>
   </Element>

   <Mouse>
         <Tooltip>Gauge Test</Tooltip>
   </Mouse>
</Gauge>

I placed the display gauge in both the 2D and VC panels. Then I placed the test gauge only in the in the main 2D panel (Window00) listing.

When I reload the plane with the 2D panel visible, I get the "Gauge is Loaded" message, as expected. When I check the VC that message is there too, showing that the L: variable is accessible to all gauges, as expected.

But if I go to VC view mode and then reload the plane, I get the "Gauge is NOT Loaded" message, showing that the test gauge was NOT loaded from the Window00 gauge listing. If I then go to the 2D panel, I see the "Gauge is NOT Loaded" message for a brief moment, which then changes to the "Gauge is Loaded" message after the test gauge code is loaded after the 2D panel (and thus the Window00 gauge listing) loads.

Now if I place the test gauge into the VC panel listing instead (I put it in the VCockpit01 section, but it doesn't matter) and load with the VC visible, I get the "Gauge is Loaded" message as expected. When I then go to the 2D panel, the "Gauge is Loaded" message is present there too (as expected). And then when I load the plane with the 2D panel visible, the Gauge is NOT Loaded" message is visible for a brief moment, but quickly changes to the "Gauge is Loaded" message as the VC gauges are loaded (even though the VC is not visible).

These results demonstrate that in FS9, the gauges listed in the VCockpit sections of a panel.cfg file are loaded no matter the view, while the gauges in the Window00 section are only loaded when the main panel is visible at aircraft load.

Hope this helps,
 
Well, then the sim is treating XML gauges completely differently than C gauges... my info is based on C gauge callbacks. The fact that XML is completely inconsistent is not surprising...
 
Well, don't you (un)learn something new every day! :-)

When I started writing XML for my own FS9 gauges some five or six years ago, the one or two gauges I downloaded to use as a learning guide gave me the (false-ish) impression that there was one sort of gauge for displaying a gauge in a panel ( displaying needles and numbers, accepting mouse commands ) and another sort for doing the logic bits (updating L:Vars etc.).

All of my logic bits were placed in a gauge known as AfterTakeOff (due to the fact that the logic I wanted to cater for at the time was to do with take-off and landing call-outs. This gauge was (randomly but luckily, by the sound of things!!) placed in the Window00 panel.

As time went on everything other than display and mouse commands was placed in the AfterTakeOff gauge. It got so big that I even created a gauge called AfterTakeOff1 and shared the code out to make it easier to read and debug.

Then, from this forum and others, I copped on that you could have logic in any gauge. So my gauges began to look like 'Display - Mouse - relevant Logic'. Out came some of the logic code from AfterTakeOff and it was placed in the gauges where it was deemed relevant.

Now comes the revelation that, if these gauges happen to be in a panel which is not being displayed, then the code is not being executed behind the scenes. Wow!

My pedestal gauge and overhead gauge in my B737 are in panels that spend most of their time closed. My radios gauge in my C172 is in a panel which is only open to make radio calls and change navigational stuff.

I have had a rather urgent look now at the code that executed logic at the back end of these gauges and luckily none of the code was critical and was only relevant when the panel was actually open - validation of inputs, correct position of switches, and the like.

To think I might have been relying on a call-out or warning from a sleeping gauge in a panel which was not open!

Happily, my passengers just didn't realise the level of incompetence in the programming that was supposed to be ensuring their safety!

Six years on I still have the AfterTakeOff gauge - perhaps I will be putting more code in there in the future. (Maybe I should get around to renaming it too.)

Thanks for the heads-up.

Walter
 
Now comes the revelation that, if these gauges happen to be in a panel which is not being displayed, then the code is not being executed behind the scenes. Wow!
Walter
Not sure if you have something to worry about ...:)

As best as that I know (that is in all my own XML gauges and the C-coded gauges I use):
It's not relevant for code execution in a gauge whether a 2D-panel window is visible or not.
What IS relevant, is if the 2D-panel window has been made visible at least once after loading the aircraft. Because a gauge in a 2D-panel window isn't loaded until you make the window in which it is defined, is made visible.
After that, the gauge code remains executing, and at the update freq. you have defined.
And this applies to any 2D-panel window, including the main panel window (usually Window00).

As a gauge defined in a VC section of the panel, is ALWAYS loaded and executing at aircraft load; no matter in what view mode you load the aircraft.

This works exactly the same in FS9 and FSX.

So Yes: if you have control logic (e.g. code that should always be executing) as part of a gauge that is defined in a 2D-panel window (because it has a visible pilot-interface), you better split of that code and place it in a no-bitmap gauge in a VC section. Because you cannot predict how the user (in what view mode, and with which 2D-windows opened initially) loads the aircraft.

Part of the confusion probably comes from what one calls "initial"aircraft-load.
If you load an aircraft from the FS menu, by composing a new flight (select an aircraft, select a scenery, etc etc):
Yes, in FS9 the default view is 2D (so the main window00 is loaded; therewith all gauges defined in window00)
In FSX, the default view (2D or VC) depends on the FSX preference setting.

However, if you load an existing flight (or load another aircraft from within an existing flight) it comes up in the current view.
So if this is eg. Spotplane view, the 2D main panel window (and gauges defined in it) are NOT loaded yet.
Unlike gauges defined in the a VC section (Always loaded).
Again, works the same in FS9 and FSX ....

In short, what Tom wrote is correct.

HOWEVER, this is valid for my own XML gauges, and the C-coded gauges I use.
And I'm pretty sure that, as to loading a gauge, the above is true. For whatever type of gauge.
BUT: as to a gauge scheduling/updating it might be different.

That is: may be there is a way that the gauge coder can prevent gauge coded being updated (executing) when the window it's defined in is not visible.
Maybe this is what the <Update> section in an XML does ????
(I never quite understood the meaning/advantage of it).
And maybe, the same is possible in a C-coded gauge (I can't code in C/C++, so I don't know).
IF this would be possible, I can think of a purpose why a designer would want to use that: to prevent framerate-eating by complex gauges when they are not visible.
Can somebody comment on this ??

For reference, I tried all of my loading/executing experiments with Doug Dawson's gauges (like XMLsounds, etc ...).
And those behave exactly the same as my XML gauges (loading/executing/updating wise).

To the OP:
So what you want (setting Lvars by clicking a gauge defined in a 2Dwindow, and read these updates Lvars in another gauge defined in a VC section) is perfectly possible.
If it doesn't work, you're doing something wrong. Copy/paste the code here, and no doubt someone will help ...

Rob
 
Rob, once upon a very long time ago I actually forced all popup panels to open briefly then close each time the aircraft was loaded simply because I didn't know any better... Well, it worked! :rotfl:
 
Rob, once upon a very long time ago I actually forced all popup panels to open briefly then close each time the aircraft was loaded simply because I didn't know any better... Well, it worked! :rotfl:
Hi Bill,
Yes, I did apply the same trick ...LoL ...
But since most of my gauges are "control logic", I discovered that defining them in a VC section was much easier ....; even if I had to define a "dummy" VC for that purpose ..

By the way, I just posted a new thread on the "Update section" in XML.
I'm sure you can enlighten me ...LoL

Cheers, Rob
 
Rob,

Your description on post #10 is essentially correct.

Just to add that the complete gaugeset of a selected aircraft is loaded at startup, only that 2D hidden panels do not process code (and execute scripts) until those panels are made visible at least once.

All of the LVars defined in the gaugeset (excluding those "visibles" at runtime) are initialized when panel loads, being the order 2Dpanel-VC-Modeldef so far I've tested (but it may be different in some cases).

Tom
 
Thanks for all the information so far.

I would have been back sooner with more questions, my code, etc., but I really wanted to try and figure this out myself, just for the learning experience. That isn't looking very likely yet.

In keeping with trying to get this to work myself, I will ask about something that happens with the test code that Tom Gibson posted. I've been using it to try and understand what works where.

I'm not using his "TEST_GAUGE". I'm only using part of the "TEST_READOUT" gauge code with my L:Var from the switch that is in the 2D window:

Code:
<Gauge Name="TEST_READOUT" Version="1.0">
  <Image Name="test_background.bmp" ImageSizes="256,256"/>
 
  <Element>
  <Visible> (L:Switch, bool) </Visible>
  <Position X="40" Y="140"/>
  <Text X="330" Y="30" Length="350" Font="Arial" Color="#FFFFF0" Adjust="Left" VerticalAdjust="Center" Multiline="No" Fixed="No">
  <String>Gauge is Loaded</String>
  </Text>
  </Element>

  <Element>
  <Visible>(L:Switch, bool) !</Visible>
  <Position X="40" Y="140"/>
  <Text X="330" Y="30" Length="350" Font="Arial" Color="#FFFFF0" Adjust="Left" VerticalAdjust="Center" Multiline="No" Fixed="No">
  <String>Gauge is NOT Loaded</String>
  </Text>
  </Element> 

  <Mouse>
  <Tooltip>Gauge Test</Tooltip>
  </Mouse>
</Gauge>

I have a TEST_READOUT gauge in the 2D window and another one in the VC. The plane loads in the VC and "Gauge is NOT Loaded" is displayed, because the switch in the 2D window is off.

I open the 2D window and the same "Gauge is NOT Loaded" message is displayed. When I turn on the switch, the NOT Loaded message disappears in both panels and that is all that happens.

I thought that the panels should then display "Gauge is Loaded". If not, can someone explain why?

If I turn the switch off, the not loaded message appears again.

It seems to me that this is some similar issue to why my code doesn't work with my gauges in the VC.

I hope that I have provided enough details to be useful.
 
That should be working, but so the problem may be in the clickcode of the switch that toggles Lvar Switch,bool ...
What is that Xml code ?

Rob
 
Rob, once upon a very long time ago I actually forced all popup panels to open briefly then close each time the aircraft was loaded simply because I didn't know any better... Well, it worked! :rotfl:

A certain 737 panel set does this and it's quite annoying if you have to reload the aircraft every couple of minutes.
 
Thanks for all the information so far.

I would have been back sooner with more questions, my code, etc., but I really wanted to try and figure this out myself, just for the learning experience. That isn't looking very likely yet.

In keeping with trying to get this to work myself, I will ask about something that happens with the test code that Tom Gibson posted. I've been using it to try and understand what works where.

I'm not using his "TEST_GAUGE". I'm only using part of the "TEST_READOUT" gauge code with my L:Var from the switch that is in the 2D window:

Code:
<Gauge Name="TEST_READOUT" Version="1.0">
  <Image Name="test_background.bmp" ImageSizes="256,256"/>

  <Element>
  <Visible> (L:Switch, bool) </Visible>
  <Position X="40" Y="140"/>
  <Text X="330" Y="30" Length="350" Font="Arial" Color="#FFFFF0" Adjust="Left" VerticalAdjust="Center" Multiline="No" Fixed="No">
  <String>Gauge is Loaded</String>
  </Text>
  </Element>

  <Element>
  <Visible>(L:Switch, bool) !</Visible>
  <Position X="40" Y="140"/>
  <Text X="330" Y="30" Length="350" Font="Arial" Color="#FFFFF0" Adjust="Left" VerticalAdjust="Center" Multiline="No" Fixed="No">
  <String>Gauge is NOT Loaded</String>
  </Text>
  </Element>

  <Mouse>
  <Tooltip>Gauge Test</Tooltip>
  </Mouse>
</Gauge>

I have a TEST_READOUT gauge in the 2D window and another one in the VC. The plane loads in the VC and "Gauge is NOT Loaded" is displayed, because the switch in the 2D window is off.

I open the 2D window and the same "Gauge is NOT Loaded" message is displayed. When I turn on the switch, the NOT Loaded message disappears in both panels and that is all that happens.

I thought that the panels should then display "Gauge is Loaded". If not, can someone explain why?

If I turn the switch off, the not loaded message appears again.

It seems to me that this is some similar issue to why my code doesn't work with my gauges in the VC.

I hope that I have provided enough details to be useful.

Yes, you did ...
I used exactly your gauge code above, and have the same problem ("Gauge is Loaded" is never displayed).

The problem is in your print code.
Use this will display what you expect:

Code:
<Gauge Name="TEST_READOUT" Version="1.0">
  <Image Name="test_background.bmp" ImageSizes="256,256"/>

  <Element>
  <Visible> (L:Switch, bool) </Visible>
  <Position X="40" Y="140"/>
  <Element>
  <Text X="330" Y="30" Length="350" Font="Arial" Color="#FFFFF0" Adjust="Left" VerticalAdjust="Center" Multiline="No" Fixed="No">
  <String>Gauge is Loaded</String>
  </Text>
  </Element>
  </Element>

  <Element>
  <Visible>(L:Switch, bool) !</Visible>
  <Position X="40" Y="140"/>
  <Element>
  <Text X="330" Y="30" Length="350" Font="Arial" Color="#FFFFF0" Adjust="Left" VerticalAdjust="Center" Multiline="No" Fixed="No">
  <String>Gauge is NOT Loaded</String>
  </Text>
  </Element>
  </Element>

  <Mouse>
  <Tooltip>Gauge Test</Tooltip>
  </Mouse>
</Gauge>

So: put the <Tekst> section in another, nested <Element> section.

Now it WILL work ....

I had this very problem when I started to use my FS9 XML gauges in FSX: sometimes it worked, sometimes not (the string wouldn't display).
I've never been able to figure out when .....

But adding the extra, nested Element did the trick and never fails.
Don't ask me why, since I can't find it documented; probably a change in the FSX XML parser (compared to FS9) ??

Cheers, Rob
 
Hi,

Yes, I should have mentioned that my gauges were tested in FS2004 which does not require such things.
 
Thanks a lot Rob. I have almost everything working like I expect it to.

Tom Gibson, it was pretty clear to me that you did your tests in FS9. Thanks for demonstrating that test. I don't know enough about the differences between the code for the two sims to have a clue what works or not.

It looks like I have a gauge conflict problem now. I'll start another thread for it.
 
Glad it works now ...
Allthough I still don't understand why an additional, nested Element for the Tekst section, would help; but it does.
Maybe somebody can comment ...

Rob
 
Back
Top