Sign in to follow this  
Guest AndrewW

Help setting up client gauge in C

Recommended Posts

I have a gauge I would like to receive a var sent out from a server gauge. I have read the SDK, which illustrates three syntax codes: void register_var_by_name(PVOID var, VAR_TYPE var_type, PSTRINGZ name)void unregister_var_by_name(PSTRINGZ name)void initialize_var_by_name(PMODULE_VAR module_var, PSTRINGZ name)However, I'm a little unsure how to use them, as I cannot find any examples in the SDK or elsewhere. If anyone has any experience setting up a client gauge to receive a custom var from a server gauge I would really appreciate a little help getting started! Many thanks. Andrew

Share this post


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

Server Gauge:BOOL fcc_pos;In PANEL_SERVICE_PRE_INSTALL: register_var_by_name (&fcc_pos, TYPE_BOOL, "FCC Power On");In PANEL_SERVICE_PRE_KILL: unregister_var_by_name ("FCC Power On");Make sure the server gauge is on the main panel.Client Gauge:MODULE_VAR fcc_pos;BOOL* FCC_On;In PANEL_SERVICE_PRE_UPDATE:if (fcc_pos.var_ptr == NULL){ initialize_var_by_name (&fcc_pos, "FCC Power On"); FCC_On = fcc_pos.var_ptr;}Use FCC_On as normal. ;)Matt

Share this post


Link to post
Share on other sites

Check the SDK.Flightmap.c sample from the SDK, it shows the use of a clint gauge (not the server).Arne Bartels

Share this post


Link to post
Share on other sites

Thanks for your help. I have looked at the Flightmap.SDK and the above example - though I'm still missing something - and I can't find out what. I don't understand why what I have below does not work? If anyone can see anything I have missed out, or something that may be in the wrong place I would be very grateful if you could let me know. The gauge compiles and works in FS with token vars - though I would like it to use my own. /////////////////////////////////////////MODULE_VAR afttrim;initialize_var_by_name (&afttrim, "Afttrim System");aft = (afttrim*)afttrim.var_ptr;void FSAPI atatankCallback ( PGAUGEHDR pgauge, SINT32 service_id, UINT32 extra_data ){switch(service_id){case PANEL_SERVICE_CONNECT_TO_WINDOW:FSUIPC_Open(SIM_FS2K2 , &dwResult);break;case PANEL_SERVICE_PRE_UPDATE://if condition to top up tanks set the level to 100%=66536*128if (aft == 0){ fuellevel=66536*128;FSUIPC_Write(LEFT_AUX_LEVEL, 4, &fuellevel, &dwResult);FSUIPC_Write(RIGHT_AUX_LEVEL, 4, &fuellevel, &dwResult);FSUIPC_Process(&dwResult);}//if condition to empty tanks set the level to 0%=0if (aft == 1){ fuellevel=0;FSUIPC_Write(LEFT_AUX_LEVEL, 4, &fuellevel, &dwResult);FSUIPC_Write(RIGHT_AUX_LEVEL, 4, &fuellevel, &dwResult);FSUIPC_Process(&dwResult);}break;////////////////////////////////////////Thanks again, Andrew

Share this post


Link to post
Share on other sites

Got it to work. :-) I found some good examples in the sd2gau14 documentation that showed the layout of the client gauge. Thanks Matt for the post, and also a big thank you to Arne, for all your help this week. Regards,Andrew

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