Sign in to follow this  
Guest HartmannH

Gauge Communication

Recommended Posts

Ok.Thought this was going to be no big deal, but something's missing from my understanding of this which is not surprising.I want to communicate within a mult-gauge. While I would like to just declare a variable like this:UINT32 some_var = 0; // Global variable.and then in another sub-gauge:extern UINT32 some_var; // Define elsewhere.as we do in C, this approach was clearly not the Way.After reading up on the server/client gauges in both the SDK, and in sd2gau17.zip, and reviewing SDK.FlightMap.c, I'm still confused as to why my attempts have been unsuccessful.What I'm attempting to do is have one switch sub-gauge toggle a variable which is used in another gauge in a decision.In my "server" gauge (which just means to me the gauge where the variable is declared and defined, thus originating the variable), I have:UINT32 lrrpm_mute = 0; // Reset mute(off) when RRPM > 90%.UINT32 low_rrpm = 0; // Warn when RRPM falls below 90%.in a call back function I have:

FLOAT64 FSAPI	lrrpm_cb( PELEMENT_ICON pelement ){	// Determine RRPM, set flag, & reset mute.	double	rrpm = pelement->source_var.var_value.n;	MODULE_VAR r_rpm = {TURB_ENGINE_1_N2};	lookup_var(&r_rpm);	rrpm = r_rpm.var_value.n;	if (rrpm > 90)		// Reset mute		lrrpm_mute = 0;	if (rrpm < 90) {		low_rrpm = 1;	}else{		low_rrpm = 0;	}}

and in the gauge call back:

		case	PANEL_SERVICE_PRE_INSTALL:			// Register server values.			register_var_by_name (&lrrpm_mute, TYPE_UINT32, "Warning Mute");		case	PANEL_SERVICE_PRE_KILL:			unregister_var_by_name("lrrpm_mute");

Now, in the "client" gauge, I want to be able to set lrrpm_mute to 0 or 1, and have this:// Client vars.MODULE_VAR var;static UINT32 *Mute_On;near the top, and:

		case	PANEL_SERVICE_PRE_INSTALL:			// Initialize client vars.			if (var.var_ptr == NULL)			{				initialize_var_by_name (&var, "Warning Mute");				Mute_On = var.var_ptr;			}

in the gauge call back.Now, I then tried this:Mute_On = 1;which didn't work, and appeared to need to be dereferenced, so I tried:*Mute_On = 1;But, as you likely aready know, I'm doing something wrong.Any thoughts on what I'm doing wrong?Thanks.

Share this post


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

Since a multi-gauge is technically only one big C file (due to the #includes) you can declare all global variables and structures in the main gauge file and directly access them from any of the "sub"-gauges. That *_var_by_name stuff is only necessary when you need to share variables between different gauge files (like a.gau and b.gau).

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