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

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

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

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

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

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

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