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

Gauges on 2D and 3D panels - interaction?

  • Thread starter Thread starter B21
  • Start date Start date

B21

Messages
149
Country
unitedkingdom
Can anyone remind me how planes with both 2D and 3D panels control the execution of the gauges? I can't work out if the 2D gauges *always* get loaded and the virtual cockpit gauges only get loaded when that view is chosen, or what.

My issue is important because I want to make the same complex XML gauge available on both the 2D and 3D panels and if they both run simulataneously then they'll be fighting over the same variables....

thanks
B21
 
Hey B21!,

Well you could just rename the XML file's with 2D and the other file copy with 3D at the file's name end so it should only see each variables...however talking in C++ gauges level there is a way to determine when 2D window is ON/OFF...for example in C++ gauge there are functions like "is_panel_window_visible_ident" which refers to the PANEL window to see if 2D window is visible or not...also if you decide to combine XML and C++, there is a class named "GetScreenRectangle" (look at the "gauges.h" file):

"virtual const PIXRECT* GetScreenRectangle () const = 0; // return pointer to a rect relative to the flight sim window left top corner or NULL if undocked or virtual cockpit"

..which returns a pointer only when its 2D view not virtual cockpit or undocked.....

I'm not an expert in Gauges, but i had read some of the SDK for a while...

http://msdn.microsoft.com/en-us/library/cc526958.aspx#is_panel_window_visible_ident
http://msdn.microsoft.com/en-us/library/cc526958.aspx#CreatingaGaugeusingXMLandC

ALSO!, you could just "L:" local variables which are available across gauges, in C++ can be accessed thru "named variables"...they are like "global" between gauges, and since they are not "pointers", and doesnt dynamicly change in size in memory you can write/read from gauges without the worry of crashing other gauge because the memory doesnt exists (as usually happens with dynamic pointers that changes in size ...)

I know that you mentioned XML gauge so im not sure if you will only do XML or could consider mixing with C++, because with C++ there are possible "ways" to determine when you are under 2D cockpit or 3D virtual cockpit...

Hope it helps...

Manuel
 
Last edited:
Thanks Manuel - good to see you still plugging away with FSX development - I found the solution to my problem.

One thing I did discover is that although XML gauges are loaded in the order they appear in the panel.cfg, they then execute in parallel, i.e. you can't assume the init sequence of one gauge has completed before another gauge is loaded. It was a race-condition between the init sections that caused me a problem - I actually have gauges that communicate via shared variables.

All my gauges are XML, and some are >1000 lines. The gauges on the 2D panel and 3D panel could be made effectively different gauges by renaming all my L:variables, but that would mean maintaining two sets of gauges. My first choice would be dump the 2D panel but in the case of a particular project the agreement is to include a 2D panel (flight sim is awash with pilots wanting to keep FS2004 or keep the 2D panel - I can understand why MSoft wanted to start again...).

My gauges typically have an 'init' section:

Code:
(L:B21_variometer_init, bool) ! if{
  ... initialise some vars
  1 (>L:B21_variometer_init, bool)
}

i.e. this section of code only runs once when the gauge is loaded because the update to the init bool causes the code to be skipped after the first iteration.

I actually have another gauge hidden on the panel that contains a variety of config variables (like sink rate at certain speeds to calibrate a variometer), so that when the gauges are ported to another aircraft I edit the config gauge, not all the gauges that depend on those values.

So I had to make sure the config had completed *before* running the init of the dependent gauge, so the correct values were included. The fix was to modify the dependent gauge init section:

Code:
(L:B21_variometer_init, bool) ! if{
   (L:B21_config_init, bool) ! if{ quit } // i.e. check init has completed of other gauge
   ... now initialise vars in this gauge knowing config code has completed
   1 (>L:B21_variometer_init, bool)
}
thanks... B21
 
Back
Top