C/C++ Gauges: Accessing FS variables

#1
Hi everybody,

first post for me here. Thanks to Nick and Arno for setting this up. I hope it's going to be successful :)

So here's my question. Not really a question. More a request for opinions.
With FSX, we have three different ways to access FS variables:
- MODULE_VAR / lookup_var()
- XML / execute_calculator_code()
- SimConnect

Which one of those do you actually prefer (for gauge use!) and why?
I used the old module_var/lookup_var stuff in FS2004 but I thought it's time to consider the other ways too. Does anyone have any profiling information for the different methods?

Thanks a lot.

Best regards,
Hans Hartmann
Digital Aviation / Flight1
 

n4gix

Resource contributor
#2
Hans, with each new gauge I have found myself using the execute_calculator_code(); method more and more often, particularly for those variables which are returned in truly horrible pseudo-variables, which then require a large hunk of conversion code... :rolleyes:

When you can ask for a return in MHz directly, it just makes no sense to perform the typical bcd-to-decimal conversion kung-fu. Asking for a return in percent is easier and faster than having to rescale a return from 0 to 16384, etc. ;)

Perhaps it's just me, but personally ACES should have named the command something more descriptive, such as get_xml_var (which I actually have implemented by modifying my local fs9gauges.h file... :)

As for the use of SimConnect within a gauge, that simply doesn't make any sense at all to me, since it would be unnecessarily complex and quite possibly suffer from latency issues. :eek:
 

ddawson

Resource contributor
#3
Perhaps it's just me, but personally ACES should have named the command something more descriptive, such as get_xml_var (which I actually have implemented by modifying my local fs9gauges.h file... :)
Bill,

The default name is appropriate - you are not limited to just A:Vars. You can use any valid xml expression that returns a number (or string, I suppose...)

Doug
 

n4gix

Resource contributor
#4
Bill,

The default name is appropriate - you are not limited to just A:Vars. You can use any valid xml expression that returns a number (or string, I suppose...)

Doug
execute_calculator_code() is more descriptive than get_xml_variable()???

The prototype allows one to fetch float, integer or string variables, but they are all A:vars AFAIK...

Aside from a handful of E:var types and P:var types, all of 'em are A:var types. Regardless though, they are all XML variables... ;)

Unless execute_calculator_code() would allow one to send an XML event to the sim, get_xml_variable() seems more intuitive...
 
Last edited:

ddawson

Resource contributor
#5
execute_calculator_code( "(A:SIM ON GROUND, bool) if{(L:Some LVAR, number)} els{(L:Some Other LVAR, number)}", &answer, NULL, NULL);

A trivial example perhaps, but, assuming my syntax is correct, this will work.

Doug
 

n4gix

Resource contributor
#6
execute_calculator_code( "(A:SIM ON GROUND, bool) if{(L:Some LVAR, number)} els{(L:Some Other LVAR, number)}", &answer, NULL, NULL);

A trivial example perhaps, but, assuming my syntax is correct, this will work.

Doug

OK, Doug. Point taken. I do in fact "fetch" custom XML L:vars using the same technique...

I know I'm being pedantic, but L:vars are still simply "XML variables" albeit custom created...

As I recall though from my conversation with Susan (and others) while in Redmond last year is that this part of the gauges.h was created for their benefit in programming the gps.dll and a few other fiddly-bits, and they never actually foresaw anyone else using 'em themselves in their C gauges... :)

In any event, what is needed is a send_calculator_code (or send_xml_event) to really make it 'complete.' It would be extremely handy to be able to control some events that've been left out of gauges.h file... :eek:
 
Last edited:

ddawson

Resource contributor
#7
In any event, what is needed is a send_calculator_code (or send_xml_event) to really make it 'complete.' It would be extremely handy to be able to control some events that've been left out of gauges.h file... :eek:
Something like this? Tested, and working...
execute_calculator_code("(>K:SOUND_TOGGLE)", NULL, &return_value, NULL);

The return value is zero. It would presumably be non-zero if the event somehow failed when called.

Doug
 

n4gix

Resource contributor
#8
Something like this? Tested, and working...
execute_calculator_code("(>K:SOUND_TOGGLE)", NULL, &return_value, NULL);

The return value is zero. It would presumably be non-zero if the event somehow failed when called.

Doug
Thanks. I posed the same question on the official Beta Testers "Gauges" newsgroup several months ago and had no response whatever... :confused:

I simply haven't had the time to test this at all myself, being overly busy upgrading models and gauges of all Eaglesoft products I have had a hand in for FSX release.

The only remaining question is how one would pass a value for a _SET event...
 
Last edited:
#9
You've been upgrading gauges, N4GIX? Here's a question:

How easy (or difficult) is it to upgrade FS98-style gauges to XML? I made a bunch of custom gauges for a chopper I made by replacing the graphics in the FS9 default Bell 206B. I was originally going to release the project as an FS9 addon, but at this point it seems like a better idea to upgrade the gauges to XML and continue developing in FSX when it's available. So I'm hoping that upgrading the gauges won't be a nightmare.
________
Buy new condo in Pattaya
 
Last edited:

n4gix

Resource contributor
#10
You've been upgrading gauges, N4GIX? Here's a question:

How easy (or difficult) is it to upgrade FS98-style gauges to XML?
That's a good question. I don't "do" XML much anymore, so am not the best person to ask. I program in C, C++ & GDI+ for 98% of my work, reserving XML code for embedded code in models... :cool:

OTOH, if you can legally strip the bitmaps out of an FS98 style gauge, recreating it in XML shouldn't be that difficult. Nearly every gauge you would "convert" already has a working XML prototype in FSX, so copying the code and replacing the bitmaps with your own would only leave making the necessary edits to sizes, centers of rotation, and non-linearity tables.

Frankly though, the new "XML Gauge Program" that will come with the Deluxe version should make creating XML gauges from your own bitmaps a much faster process... :D
 
#12
Hans, with each new gauge I have found myself using the execute_calculator_code(); method more and more often, particularly for those variables which are returned in truly horrible pseudo-variables, which then require a large hunk of conversion code... :rolleyes:
Hi,

Can you retrieve a value from an XML variable from inside a C++ gauge?
How can I do that?

Thanks
Jose
 
Top