Jump to content
Sign in to follow this  
Guest Patrick_Waugh

FSX: C-gauge correct events order

Recommended Posts

Hi all,When I started testing my gauges in FSX a few weeks ago, I quickly ran into all kinds of strange problems after resizing the FSX window, or hiding and resizing panels. The most troubeling problem I ran into was that my exported variables where destroyed when I resized the window! It became apparent quite quickly that the sequence of events that take place whilst running FSX is different from the sequence in FS2004. This lead to my gauges destroying variables at resize in stead of while unloading the gauges. I decided to map all the FSX events as they occur in sequence, and this are the results of this mapping exercise. I hope this will help other panel developers.This is the correct event sequence (without the opening screen so direct to 2D panel in a saved flight):1. Start-up FSX: PANEL_SERVICE_CONNECT_TO_WINDOW PANEL_SERVICE_PRE_QUERY PANEL_SERVICE_POST_QUERY2. FSX continues to load other gauges3. After msadp32.acm has been loaded PANEL_SERVICE_PRE_INSTALL PANEL_SERVICE_POST_INSTALL PANEL_SERVICE_PRE_INITIALIZE PANEL_SERVICE_POST_INITIALIZE PANEL_SERVICE_PANEL_OPEN4. FS starts loading scenery stuff PANEL_SERVICE_PRE_INITIALIZE PANEL_SERVICE_POST_INITIALIZE PANEL_SERVICE_PRE_UPDATE PANEL_SERVICE_POST_UPDATE PANEL_SERVICE_PRE_GENERATE PANEL_SERVICE_POST_GENERATE PANEL_SERVICE_PRE_DRAW PANEL_SERVICE_POST_DRAW PANEL_SERVICE_PRE_UPDATE ==> sound starts to work PANEL_SERVICE_POST_UPDATE5. then PRE and POST_UPDATE continu to be called with each tick so I removed those breakpoints6. next call while FS loading bar is slowly increasing: PANEL_SERVICE_PRE_DRAW PANEL_SERVICE_POST_DRAW (etc...)7. when "loading terrain data" is displayed all events stop in the gauges8. loading terrain data is finished ==> back to after is finished PRE/POST DRAW switching9. while wx/traffic, etc is loading etc gauge updating stops again10. End of loading PRE/POST DRAW on each tick11. Change FS window size, only has an effect when the mouse button is released PANEL_SERVICE_PRE_KILL PANEL_SERVICE_POST_KILL PANEL_SERVICE_CONNECT_TO_WINDOW PANEL_SERVICE_PRE_INSTALL PANEL_SERVICE_POST_INSTALL PANEL_SERVICE_DISCONNECT PANEL_SERVICE_PRE_INITIALIZE PANEL_SERVICE_POST_INITIALIZE PANEL_SERVICE_PRE_UPDATE PANEL_SERVICE_POST_UPDATE PANEL_SERVICE_PRE_GENERATE PANEL_SERVICE_POST_GENERATE PANEL_SERVICE_PRE_UPDATE PANEL_SERVICE_POST_UPDATE PANEL_SERVICE_PRE_UPDATE PANEL_SERVICE_POST_UPDATE etc...12. Hide window (Shift-1 for instance) PANEL_SERVICE_PANEL_CLOSE ==> panel disappears and PRE/POST UPDATE starts again13. re-open panel PANEL_SERVICE_PANEL_OPEN PANEL_SERVICE_PRE_INITIALIZE PANEL_SERVICE_POST_INITIALIZE14. This is what happens when FS is closed PANEL_SERVICE_PANEL_CLOSE PANEL_SERVICE_PRE_KILL PANEL_SERVICE_POST_KILL PANEL_SERVICE_DISCONNECT15. Here is what happens when you have loaded your aircraft and then open the FSX aircraft dialog:- when the aircraft dialog is opened and as long as it is open no events are triggered- CANCEL aircraft dialog: update and draw event continu as before- Select the current active aircraft and select OK: PANEL_SERVICE_PANEL_CLOSE PANEL_SERVICE_PRE_KILL PANEL_SERVICE_POST_KILL PANEL_SERVICE_DISCONNECT PANEL_SERVICE_CONNECT_TO_WINDOW PANEL_SERVICE_PRE_QUERY PANEL_SERVICE_POST_QUERYThen all the gauges are loaded ... PANEL_SERVICE_PRE_INSTALL PANEL_SERVICE_POST_INSTALL PANEL_SERVICE_PRE_INITIALIZE PANEL_SERVICE_POST_INITIALIZE PANEL_SERVICE_PANEL_OPEN PANEL_SERVICE_PRE_INITIALIZE PANEL_SERVICE_POST_INITIALIZE PANEL_SERVICE_PRE_UPDATE PANEL_SERVICE_POST_UPDATE PANEL_SERVICE_PRE_UPDATE PANEL_SERVICE_POST_UPDATE PANEL_SERVICE_PRE_GENERATE PANEL_SERVICE_POST_GENERATE PANEL_SERVICE_PRE_DRAW PANEL_SERVICE_POST_DRAWThen UPDATE and DRAW events start again...And finally open the aircraft dialog, select a different aircraft and click OK: PANEL_SERVICE_PANEL_CLOSE PANEL_SERVICE_PRE_KILL PANEL_SERVICE_POST_KILL PANEL_SERVICE_DISCONNECTThe new panel is loaded.I now initialize my exported variables during the PRE_INITIALIZE event and I destroy them during the SERVICE_DISCONNECT event. I had to move all the exported variables to 1 server gauge because placing them in different gauges again crashed FSX.Bj


simcheck_sig_banner_devteam.jpg

 

Bj

Share this post


Link to post
Share on other sites

Thanks Bjorn.One thing that has me puzzled, though, is why you destroy the variables on a PANEL_SERVICE_DISCONNECT...from what I see in your post, the PANEL_SERVICE_DISCONNECT state is also set during a panel resize.How does one now determine that the gauges are being unloaded?CheersBob ScottATP IMEL Gulfstream II-III-IV-V L-300Santiago de Chile


Bob Scott | President and CEO, AVSIM Inc
ATP Gulfstream II-III-IV-V

System1 (P3Dv5/v4): i9-13900KS @ 6.0GHz, water 2x360mm, ASUS Z790 Hero, 32GB GSkill 7800MHz CAS36, ASUS RTX4090
Samsung 55" JS8500 4K TV@30Hz,
3x 2TB WD SN850X 1x 4TB Crucial P3 M.2 NVME SSD, EVGA 1600T2 PSU, 1.2Gbps internet
Fiber link to Yamaha RX-V467 Home Theater Receiver, Polk/Klipsch 6" bookshelf speakers, Polk 12" subwoofer, 12.9" iPad Pro
PFC yoke/throttle quad/pedals with custom Hall sensor retrofit, Thermaltake View 71 case, Stream Deck XL button box

Sys2 (MSFS/XPlane): i9-10900K @ 5.1GHz, 32GB 3600/15, nVidia RTX4090FE, Alienware AW3821DW 38" 21:9 GSync, EVGA 1000P2
Thrustmaster TCA Boeing Yoke, TCA Airbus Sidestick, 2x TCA Airbus Throttle quads, PFC Cirrus Pedals, Coolermaster HAF932 case

Portable Sys3 (P3Dv4/FSX/DCS): i9-9900K @ 5.0 Ghz, Noctua NH-D15, 32GB 3200/16, EVGA RTX3090, Dell S2417DG 24" GSync
Corsair RM850x PSU, TM TCA Officer Pack, Saitek combat pedals, TM Warthog HOTAS, Coolermaster HAF XB case

Share this post


Link to post
Share on other sites

Keep in mind, you can, if you wish, replace this:GAUGE_TABLE_BEGIN() GAUGE_TABLE_ENTRY(&gaugehdr_dsd_xml_sound3)GAUGE_TABLE_END()with this:void FSAPI module_init(void) { } void FSAPI module_deinit(void) { }BOOL WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved) { return TRUE;}GAUGESIMPORT ImportTable = { { 0x0000000F, (PPANELS)NULL }, { 0x00000000, NULL } };GAUGESLINKAGE Linkage = { 0x00000013, module_init, module_deinit, 0, 0, FS9LINK_VERSION, { (&gaugehdr_dsd_xml_sound3), 0 }};Certainly a lot more verbose, but the module_init and module_deinit functions will only ever be called once each, so you don't have to worry about the callback messing up your shared variables.Doug

Share this post


Link to post
Share on other sites

Hi Bob,Well that is exactly the problem with FSX !I haven't tried the code Doug provided in his reply and from what I understand of it it does exactly that what you want. But in my case using the DISCONNECT and the PRE_INITIALIZE events works just fine.Kind regards,Bj


simcheck_sig_banner_devteam.jpg

 

Bj

Share this post


Link to post
Share on other sites

Hi Guys,Reading all of this: PLEASE, let nobody complain anymore that XML gauges are difficult to make ....LOL :-)Cheers, Rob

Share this post


Link to post
Share on other sites

Thanks Doug...a faint glimmer of a clue light is barely perceptible through the fog now.CheersBob ScottATP IMEL Gulfstream II-III-IV-V L-300Santiago de Chile


Bob Scott | President and CEO, AVSIM Inc
ATP Gulfstream II-III-IV-V

System1 (P3Dv5/v4): i9-13900KS @ 6.0GHz, water 2x360mm, ASUS Z790 Hero, 32GB GSkill 7800MHz CAS36, ASUS RTX4090
Samsung 55" JS8500 4K TV@30Hz,
3x 2TB WD SN850X 1x 4TB Crucial P3 M.2 NVME SSD, EVGA 1600T2 PSU, 1.2Gbps internet
Fiber link to Yamaha RX-V467 Home Theater Receiver, Polk/Klipsch 6" bookshelf speakers, Polk 12" subwoofer, 12.9" iPad Pro
PFC yoke/throttle quad/pedals with custom Hall sensor retrofit, Thermaltake View 71 case, Stream Deck XL button box

Sys2 (MSFS/XPlane): i9-10900K @ 5.1GHz, 32GB 3600/15, nVidia RTX4090FE, Alienware AW3821DW 38" 21:9 GSync, EVGA 1000P2
Thrustmaster TCA Boeing Yoke, TCA Airbus Sidestick, 2x TCA Airbus Throttle quads, PFC Cirrus Pedals, Coolermaster HAF932 case

Portable Sys3 (P3Dv4/FSX/DCS): i9-9900K @ 5.0 Ghz, Noctua NH-D15, 32GB 3200/16, EVGA RTX3090, Dell S2417DG 24" GSync
Corsair RM850x PSU, TM TCA Officer Pack, Saitek combat pedals, TM Warthog HOTAS, Coolermaster HAF XB case

Share this post


Link to post
Share on other sites

>Reading all of this: PLEASE, let nobody complain anymore that>XML gauges are difficult to make ....LOL :-)XML gauges are difficult to make. :((yes I am a C++ dude) :-hahHappy coding! :-beerchugEtienne :-wave

Share this post


Link to post
Share on other sites

Have to agree with Badderjet, C++ gauges are really not that difficult once you know how they work. I always set up the basic gauge design in EasyGauge (which is by now completely out of date though) and then clean up the code by hand, and add functionality. To me XML is much less transparent, so it really depends on what you are used to use... Bj


simcheck_sig_banner_devteam.jpg

 

Bj

Share this post


Link to post
Share on other sites

>C++ gauges are really not that difficult once you know how they work.XML guys might say the same about XML *:-*, but I do agree with you :-lol and I...>so it really depends on what you are used to use... ... second that for sure. :) Depends on your prior knowledge, the use of the gauge etc well we've already had the discussion I believe... ;)Cheers,Etienne

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...