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

Questions about C++ Gauges

Messages
132
Country
france
Hello,

Sorry for the newbie questions, but is for me a little complex to create C++ gauges.

In first, I would be sure that all "service_id" have a 18Hz cycle (PANEL_SERVICE_xxx).

And second, is the better way to use execute_calculator_code() to share C++ / XML variable.
The method works fine, but I would be sure is good.

It is possible to confirm that point, because I haven't found any information in the SDK documentation !

Thank you ;)
 
David,

PANEL_SERVICE_PRE_UPDATE and PANEL_SERVICE_POST_UPDATE are executed at 18hz.
Others are used for different purposes and so are executed at different times.
PANEL_SERVICE_CONNECT_TO_WINDOW is executed once, when the gauge is loaded.
PANEL_SERVICE_DISCONNECT is executed once, when the gauge is unloaded.
PANEL_SERVICE_PRE_INSTALL is executed when the gauge's window is moved or resized (and when the gauge is loaded.)
PANEL_SERVICE_PRE_DRAW is executed once on each visual frame, and only when the gauge is visible.

execute_calculator_code works well.
I prefer
register_named_variable
check_named_variable
get_named_variable_value
set_named_variable_value
It really is a matter of personal preference.

Doug
 
What Doug said...

If I only have a few* L:vars to send, I tend to use execute_calculator_code.

If I have a lot of L:vars, I use the method Doug cites.

* "few" in this case meaning ten or less
 
Thank you Doug and N4gix, you are my guide !!

It is possible to bypass the 18hz ? See below

I use a sinus to create vibration (C++ code), and to share the value on modeldef.xml (3D needle) but I can have a smooth animation with all "service_id". Look the YouTube video link.

http://www.youtube.com/watch?v=bGecIkSnMPc
 
Inside your gauge callback function, you should have a switch statement like this:
Code:
switch(service_id)
{
case PANEL_SERVICE_CONNECT_TO_WINDOW:
  // code here executes once only
break;
case PANEL_SERVICE_PRE_UPDATE:
  // code here executes at 18hz.
break:
case PANEL_SERVICE_PRE_DRAW:
  // code here executes once on each visual frame.
break:
}

I'm guessing you want to put your code in the PANEL_SERVICE_PRE_DRAW case.
Peut-etre vous pouvez placer votre code en "PANEL_SERVICE_PRE_DRAW"

Doug
 
I have found animations to be quite smooth in the VC at 18Hz. but yes you can set the L vars every frame from the PANEL_SERVICE_PRE_DRAW case.

Another alternative is creating windows tick timers at any frequency you want up to 1Khz.
 
Thank you for your answers!

I'll let you know this weekend, I have a little time to look at the code.
 
Thank you Doug and N4gix, you are my guide !!

It is possible to bypass the 18hz ? See below

I use a sinus to create vibration (C++ code), and to share the value on modeldef.xml (3D needle) but I can have a smooth animation with all "service_id". Look the YouTube video link.

http://www.youtube.com/watch?v=bGecIkSnMPc

Hi David,
Why don't you use directly (P:local time, seconds) variable into your animation code? Modeldef.xml code is called by every drawing frame, isn't it? I guess it is useless to be faster...
So I'm not sure there's any benefit in using a panel service statement to create such animation.
I guess you can use C++ code to manage amplitude or frequency of the vibration using L: variable (but it doesn't need to be refreshed at higher freq than 18hz).

regards,
Sylvain
 
Back
Top