Sign in to follow this  

Recommended Posts

On some jet panels, the "FUEL USED" information is displayed, showing the fuel used by each engine. Do you know how to calculate this with the variables available in the FS2002 SDK?

Share this post


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

I'd try the following:When the panel is being loaded, set a variable to the actual value of the fuel tank content.Then you only have to calculate the difference between the actal fuel status and the variable. Display that difference on your gauge.Hope that makes some sense,Etienne :-wave

Share this post


Link to post
Share on other sites

I thought about this solution, but it is not perfect because you have the fuel quantity used, but not the fuel quantity used by each engine. This solution is OK if you suppose that all engines have exactly the same fuel consumption during the flight, but it is not always the case, especially if you have an engine failure.So I thought about another solution: each time the gauge is drawn (18 times per second), I read the fuel flow FOR EACH ENGINE, given in pounds per hour, and I translate it into the fuel flow in kg per 1/18th of second. This way, I get the fuel quantity by each engine every 1/18th of a second, and I sum them all...What do you think about this solution?I think it is OK, but kind of complex. That is why I was looking for something simpler...Your solution is not perfect, but much simpler.Thanks for your help !!

Share this post


Link to post
Share on other sites

I would maybe not refresh every 18th, but just every full second. The solution sounds good. I also don't have another idea at the moment...Regardshttp://members.lycos.co.uk/fs2k2/avsim/sig.jpgEdit:But maybe you can help you, because you made that neat radar. Can you help me getting the distance to AI aircraft, because I want to make a (currently invisible) gauge which calles 'traffic!' when you get too close to some traffic. This is not intended to be realistic, but just want to try it. Do I need to interact with FSUIPC for this? Thank you!

Share this post


Link to post
Share on other sites

You have no choice, FS refreshes the gauges every 1/18th of second, that's the way it works...About your traffic gauge, you need to interact with FSUIPC to get the position (lat/long) of all the AI aircrafts. You can easily retrieve the position of your aircraft, also in lat/long. Then you can easily calculate the distance with the following formula:distance = acos(sin(lat1)*sin(lat2) + cos(lat1)*cos(lat2) * cos(lon2 - lon1)) * ((60 * 180) / pi);lat1 and lon1 is the position of your aircraft (in radians)lat2 and lon1 is the position of AI aircraft (in radians)Hope this helps...

Share this post


Link to post
Share on other sites

Thanks for that formula. But since I never worked with FSUIPC, I'm just downloading the SDK and then I'll see what I can do.Stay tuned for more problems and questions... :-smoochEtienne

Share this post


Link to post
Share on other sites

Oh well, the problems are already there. ;-)The formula looks quite simple to do, just include math.h, then do some callbacks, but: I do not have any idea how to make up a connection to FSUIPC. No idea about all that offset stuff etc... Well I get the position of TCAS_DATA.lat/lon as far as I understood. And my position should be available thru the standard token variables. But please give me some advice, how to get connected to FSUIPC or if I don't have to connect, how to get the traffic's position... I'd really appreciate it, thanks.Etienne

Share this post


Link to post
Share on other sites

If you work with C gauges you can calculate used fuel with fuelflow*elapsed time for each engine seperately. For elapsed time use ELAPSED_SECONDS, calculate the time difference to the previous frames (not always 1/18 s e.g. at simrates different to 1), add the product of elapsed time and fuel flow to fuel used. It might be also possible in XML gauges this way, but I haven't tried.Arne Bartels

Share this post


Link to post
Share on other sites

Hi Arne,I have not tried to check yet for decimal / discreet values of the ELAPSED_SECOND. Isn't the ELAPSED_SECONDS in discreet increments(i.e. 1.0 then 2.0 then 3.0... seconds and not 1.23 then 1.24 then 1.25.... seconds)? if discreet values, the moment the FF is read and the ELAPSED_SECONDS is read might be in a lesser time than 1 second from the previous read, hence giving a NEWTIME - LASTTIME value of 0 and a fuel used for this time period to 0. If decimal values, then it is just fine. Could you confirm?

Share this post


Link to post
Share on other sites

Just a suggestion. Create a loop counter. On the X loop then do your calulation and reset the loop counter. That way your calulation will only be done every x.Bill

Share this post


Link to post
Share on other sites

I checked again: ELAPSED_SECONDS are the elapsed seconds of simulated flightsimulator time since startup of FS. It is always in decimal values showing also fractions of seconds. It is very handy for timer purposes, where you need not only the full seconds, but also the fractional part. It is even useful to detect pauses, if the simulation pauses ELAPSED_SECONDS also stops. It is not influenced by advancing time manually (e.g. increase hours on a clock).In difference to that CLOCK_TOTAL_SECOND shows the seconds from beginning of the present day with only full seconds. Nice for clocks: you need only one variable for hours/minutes/seconds and the hours/minutes needles can run smooth between the ticks.Arne Bartels

Share this post


Link to post
Share on other sites

Thanks for your help, Arne !!For your information, I code the gauges in C and not in XML.I hadn't thought about your solution. It is a good solution, but not perfect, because it calculates the average fuel consumption and not instantaneous consumption.The best solution can be to mix your solution with mine:At panel startup:- Initialize the Fuel Used variable to 0At each refresh cycle:- get the FUEL_FLOW and the ELAPSED_TIME- calculate the time difference between now and the last refresh (difference between the current ELAPSED_TIME value and the stored value)- multiply it by the current SIM_RATE- compute the instantaneous fuel flow for each engine- add it to the current value of Fuel Used, and display it- store the ELAPSED_TIME value for the next timeI think this works fine, except a problem:If you change your aircraft and come back to this one, the Fuel Used is re-initialized to 0, and then the displayed value is wrong.Or if during the flight, you save it, and reload it later, the fuel used value is also set to 0 and display is wrong.No solution is perfect, I'll have to choose the best one...Thanks for everybody's help !!

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