Archived

This topic is now archived and is closed to further replies.

n4gix

Just to make sure I'm not quite as thick as I think I am...

Recommended Posts

Still on fuel systems: I've read Bill's XML<=>C stuff and I think this is correct:execute_calculator_code("(>K:FUEL TANK LEFT TIP QUANTITY)", NULL, &fuel, NULL);where fuel is a SINT32 in gallons. I'd be grateful for a yea/nay from the front row....-Dai

Share this post


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

Dai, you got a nay...:-)Any of the three pointers are used to *retrieve* a value from the function. You pass the stringz argument, and the function fills the three pointers. Then you read the data that is pointed in your own function, using the one is most suitable for your purposes.Actually what execute_calculator_code does is to parse the stringz code (first parameter) using the XML parser and return the stack's resulting value, mostly like a or in an XML gauge.In your example, "(>K:FUEL TANK LEFT TIP QUANTITY)" returns an empty stack (0), then what you get in &fuel after calling the function is 0.So, you need to construct an assignment inside the stringz parameter, like thischar cChar[60];sprintf( cChar,"%d%s", fuel, " (>K:FUEL TANK LEFT TIP QUANTITY)");PCSTRINGZ szParam;szParam=cChar;execute_calculator_code(szParam, NULL, NULL, NULL);you don't need to read any of the three data pointers because you already know they would be 0.Tom

Share this post


Link to post
Share on other sites

>Still on fuel systems: I've read Bill's XML<=>C stuff and I>think this is correct:>>execute_calculator_code("(>K:FUEL TANK LEFT TIP QUANTITY)",>NULL, &fuel, NULL);>>where fuel is a SINT32 in gallons. I'd be grateful for a>yea/nay from the front row....>>-DaiOk, if you're wanting to read that value... it's not a "K" value.FLOAT64 fuel = 0;execute_calculator_code("(A:FUEL TANK LEFT TIP QUANTITY,gallons)",&fuel,NULL,NULL);

Share this post


Link to post
Share on other sites

>Hi Ed>>No: I want to write to it as part of the refueling procedure.>>-Dai(A:FUEL TANK LEFT TIP QUANTITY,gallons) is "settable" in FSX, but only via SimConnect!You cannot "set" A:vars by any XML method... ...A:vars are "read only" by any other method :(Only true Key_Events may be 'set' via the execute_calculator_code method. IOW, only those tags listed in the Event IDs.htm of the FSX SDK, or the similar document for FS9 SDK.The prototype for such a command is:execute_calculator_code("value (>K:event)", NULL, NULL, NULL);However, I can't honestly think of any good reason to resort to this method, unless it's for something that's not already got a C type key_event equivalent! ;)Where it DOES come in handy is if you have need to set a "custom L:var" via a C gauge!execute_calculator_code("value (>L:MyCustomVar,unit)", NULL, NULL, NULL);

Share this post


Link to post
Share on other sites

Like Bill said... you can't.I believe the only method of refueling is available via a SimConnect interface within FSX.

Share this post


Link to post
Share on other sites

. I'm not prepared to write a SimConnect interface just for that... I guess KEY_REQUEST_FUEL simply fills things to the brim? I really wanted to be able to control what goes into which tank. So I'm being really thick... which bit of this have I thoroughly misinterpreted and why? From the FSX CHM file:Simulation Variable Description Units SettableFUEL TANK CENTER LEVEL Percent of maximum Y capacity Percent Over 100 Does 'Settable' refer *only* to SimConnect?-Dai

Share this post


Link to post
Share on other sites

Yes, A: type variables are only settable via SimConnect. However, it's possible to assing values to events that perform actions which in term actualize the variables, meaning an indirect mode of obtaining the same result.My explanation was to show you the proper way to assign values to events using execute_calculator_code. Obviously I didn't pay attention to the actual name of the event you were using :-(But my code still remains as a clear example on how to concatenate values and strings to construct the strzero parameter.Tom

Share this post


Link to post
Share on other sites

Many thanks to all who replied. Now, please excuse me while I go and sulk in the 'You Can't Do That' corner... :( :)-Dai

Share this post


Link to post
Share on other sites

>. I'm not prepared to write a SimConnect interface just>for that... I guess KEY_REQUEST_FUEL simply fills things to>the brim? I really wanted to be able to control what goes into>which tank.You shouldn't need to. AFAIK, there's no real reason you shouldn't be able to invoke SimConnect stuff directly from your C gauge...However, from what I've read, even via SimConnect it is locked to 25% "fillrate" at each instance the function is invoked. At least, I seem to remember reading someone's comments about this about a year ago now... ;)

Share this post


Link to post
Share on other sites

Hi Bill>You shouldn't need to. AFAIK, there's no real reason you>shouldn't be able to invoke SimConnect stuff directly from>your C gauge...Now there's a thought... I am right; sometimes I am stupid :)>However, from what I've read, even via SimConnect it is>locked to 25% "fillrate" at each instance the>function is invoked.I confess I lost the thread of this one. Do you mean that KEY_REQUEST_FUEL only gives 25% of the total aircraft volume at each invocation?-Dai

Share this post


Link to post
Share on other sites

Dai, KEY_REQUEST_FUEL is used to require a fuel truck; to fill the tanks there is another event KEY_ADD_FUEL_QUANTITY (these names are the C version, to use them in execute_calculator code you must write their XML version)This event supports a passed value of 0 (no fuel) to 65535 (max fuel); if invoked with no passing value adds a 25% of fuel by default. The major drawback is you can't control which tanks are going to be filled, as the event applies to all of them in once. And like Bill's stated, you can use SimConnect from within your own dll; though it's a bit of tricky to handle the asyncronious flow of data.Tom

Share this post


Link to post
Share on other sites

> KEY_REQUEST_FUEL is used to require a fuel truckAh! That useful piece of information is not in the help files anywhere, hence my confusion.> KEY_ADD_FUEL_QUANTITY Oh-oh, how did I miss that? :-eek-Dai

Share this post


Link to post
Share on other sites

>> KEY_ADD_FUEL_QUANTITY >>Oh-oh, how did I miss that? :-eekMaybe because the $&*(!@'s at ACES put that new key_event under the "Aircraft Miscellaneous Systems" section instead of the "Aircraft Fuel System" heading? ;)Also, since you're coding in C anyway, and there is a C KEY_ event, it would be rather silly to bother with the execute_calculator_code method in this instance...To be perfectly honest, I had completely forgotten about that new KEY_ event myself... It's hard getting old... :~P

Share this post


Link to post
Share on other sites