FSDeveloper Community

Go Back   FSDeveloper Community > Microsoft Flight Simulator development > Aircraft Design > Gauges

Gauges Use this forum for all your gauges related discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 26 Sep 2006, 13:02
Hans Hartmann's Avatar
Hans Hartmann Hans Hartmann is offline
  germany
Location: Bad Iburg, Germany
Join Date: Sep 2006
Posts: 21
C/C++ Gauges: Accessing FS variables

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
Reply With Quote
  #2  
Old 26 Sep 2006, 13:17
n4gix n4gix is offline
  unitedstates
Location: Hammond, Indiana
Join Date: Sep 2006
Posts: 8,522
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...

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.
Reply With Quote
  #3  
Old 30 Sep 2006, 11:12
ddawson's Avatar
ddawson ddawson is offline
  canada
Location: Ottawa, Canada
Join Date: Sep 2006
Posts: 273
Quote:
Originally Posted by n4gix View Post
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
Reply With Quote
  #4  
Old 30 Sep 2006, 11:22
n4gix n4gix is offline
  unitedstates
Location: Hammond, Indiana
Join Date: Sep 2006
Posts: 8,522
Quote:
Originally Posted by ddawson View Post
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 by n4gix; 30 Sep 2006 at 11:28.
Reply With Quote
  #5  
Old 30 Sep 2006, 11:42
ddawson's Avatar
ddawson ddawson is offline
  canada
Location: Ottawa, Canada
Join Date: Sep 2006
Posts: 273
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
Reply With Quote
  #6  
Old 01 Oct 2006, 12:31
n4gix n4gix is offline
  unitedstates
Location: Hammond, Indiana
Join Date: Sep 2006
Posts: 8,522
Quote:
Originally Posted by ddawson View Post
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...

Last edited by n4gix; 01 Oct 2006 at 12:33.
Reply With Quote
  #7  
Old 01 Oct 2006, 15:15
ddawson's Avatar
ddawson ddawson is offline
  canada
Location: Ottawa, Canada
Join Date: Sep 2006
Posts: 273
Quote:
Originally Posted by n4gix View Post
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...
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
Reply With Quote
  #8  
Old 02 Oct 2006, 12:11
n4gix n4gix is offline
  unitedstates
Location: Hammond, Indiana
Join Date: Sep 2006
Posts: 8,522
Quote:
Originally Posted by ddawson View Post
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...

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 by n4gix; 02 Oct 2006 at 12:26.
Reply With Quote
  #9  
Old 02 Oct 2006, 15:13
Mick's Avatar
Mick Mick is offline
 
Join Date: Apr 2005
Posts: 116
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 by Mick; 19 Sep 2011 at 05:07.
Reply With Quote
  #10  
Old 03 Oct 2006, 12:54
n4gix n4gix is offline
  unitedstates
Location: Hammond, Indiana
Join Date: Sep 2006
Posts: 8,522
Quote:
Originally Posted by Mick View Post
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...

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...
Reply With Quote
  #11  
Old 05 Oct 2006, 10:33
Mick's Avatar
Mick Mick is offline
 
Join Date: Apr 2005
Posts: 116
Thanks for the clarification, N4GIX.
________
LIVE SEX

Last edited by Mick; 19 Sep 2011 at 05:07.
Reply With Quote
  #12  
Old 06 Dec 2006, 13:45
pepe3w pepe3w is offline
  spain
Location: Madrid
Join Date: Dec 2006
Posts: 1
Quote:
Originally Posted by n4gix View Post
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...
Hi,

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

Thanks
Jose
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Variables available in FS arno General 25 09 Aug 2012 15:00
variables buffer overflow AlanMzk SCASM & ASM tweaking 6 20 Jun 2005 14:40
About FS variables Ranger SCASM & ASM tweaking 8 14 May 2005 03:27
lighted gauges in VC mcq General 4 08 Apr 2005 08:31
Using variables in dynamic scenery Gorchi General 16 27 Sep 2004 18:12


All times are GMT -4. The time now is 15:35.

Kirsch designed by Andrew & Austin


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.