Jump to content
Sign in to follow this  
Guest Patrick_Waugh

MAIN_EXIT_OPEN - Using this and detecting secondary exit

Recommended Posts

Guest Patrick_Waugh

Hey all,Things are coming along well with my project. I have converted all the code to C++, and got that all working, making it much easier to encapsulate stuff. Soon, I'll see if I can eliminate the need for global variables altogether by creating class wrappers for gauges.Anyway, I have a question. I noticed that the gauge token, MAIN_EXIT_OPEN, transitions to true when the user opens the main exit, but then it transitions back to false once the exit is open. Have you guys noticed this as well, or is it my imagination?While I can easily solve the problem this creates, what I'd like to do is detect exit 2 openning/closing. However, it appears there is no corresponding token. I suspect all this is because the exits work like the engines in that you first have to select the engine, then do something to it.Still, I cannot locate the correct token(s) after reviewing the fs9gauge.h several times.Anyone know how to do this?PatrickFYI: I want you guys to know that if you are not yet using VS 2005, you are missing a treat. I highly recommend it.

Share this post


Link to post
Share on other sites
Guest bartels

There is no token for exit 2, but you can use the detour via the XML access functions aicraft_varget(get_aircraft_var_enum doesn't work, use XML_TOKENS instead) or execute_calculator_code.

Share this post


Link to post
Share on other sites

I would also point out that there is some inconsistency between the index 'systems' used by the SDK...The "token's" index begins at zero, but the key_event index begins at one... execute_calculator_code("(A:Exit:0, bool)",&exit1,NULL,NULL);execute_calculator_code("(A:Exit:1, bool)",&exit2,NULL,NULL);execute_calculator_code("(A:Exit:2, bool)",&exit3,NULL,NULL);execute_calculator_code("(A:Exit:3, bool)",&exit4,NULL,NULL);The key_events (both C and XML) would use Select 1 for Exit:0, Select 2 for Exit:1, etc. *:-*


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites
Guest Patrick_Waugh

Wow... did you hear that sound?That was the sound of both of your responses going right over my head! Hahahaha :-zhelpJust when I thought I had this stuff down to a science. :-lolPatrick

Share this post


Link to post
Share on other sites
Guest bartels

OK step by step.There are some tokens available in XML that aren't in the GAUGE_TOKEN list.Therefore you can't use them as a SOURCE_VAR in any MAKE_... macro, but you can use MODULE_VAR_NONE instead and introduce a matching callback function, where you call one of the both mentioned methods to get the tokens from the XML engine instead. E.g. a MAKE_ICON like this:FLOAT64 FSAPI exit2_cb(PELEMENT_ICON pelement){ FLOAT64 exit2 = 0; execute_calculator_code("(A:Exit:1, bool)",&exit2,NULL,NULL); return exit2;}MAKE_ICON( exit_2_icon, ..., ..., ..., ..., ..., ..., ..., MODULE_VAR_NONE, exit_2_cb, ..., ..., ..., ...)More clear?

Share this post


Link to post
Share on other sites
Guest Patrick_Waugh

Yes, I understand now. Now I understand why you added all the XML vars to the gauge.h too. :-beerchugNever noticed those functions before, so I'll have a look at them as well.Thanks for the help guys.Patrick

Share this post


Link to post
Share on other sites
Guest Patrick_Waugh

Ok, I tried this code, setting it to the main exit so that I could easily test it, and no joy.ICON_UPDATE_CALLBACK baggageDoor_cb;MAKE_ICON( baggageDoor_icon, BMP_ANNUNCIATOR_BAGGAGEDOOR_OFF, NULL, annunciator_fail, IMAGE_USE_TRANSPARENCY | IMAGE_USE_ERASE, 0, X_C7, Y_BTM, MODULE_VAR_NONE, baggageDoor_cb, ICON_SWITCH_TYPE_SET_CUR_ICON, 2, 0, 0)FLOAT64 FSAPI baggageDoor_cb(PELEMENT_ICON pelement_icon){ FLOAT64 isBaggageDoorOpen; execute_calculator_code("(A:Exit:0, bool)", &isBaggageDoorOpen, NULL, NULL); return isBaggageDoorOpen;}By the way, any idea what the other two parameters are for?Patrick

Share this post


Link to post
Share on other sites
Guest bartels

Sorry wrong XML-Syntax. Try execute_calculator_code("(A:EXIT OPEN:0,bool)", &isBaggageDoorOpen, NULL, NULL);The other parameters are for the cases where integer or string results are returned.

Share this post


Link to post
Share on other sites
Guest Patrick_Waugh

Thanks Arne, works perfectly. It's been so long since I've looked at XML tokens I didn't notice either.Patrick

Share this post


Link to post
Share on other sites

>Thanks Arne, works perfectly. It's been so long since I've>looked at XML tokens I didn't notice either.Sorry! I was more concerned with the different indexes used and spaced out on the precise XML variable name... :-spacecraft


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites
Guest Patrick_Waugh

Bill,No worries, if I wasn't such a noob, I'd have caught it.Patrick

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