Jump to content
Sign in to follow this  
Guest schwudde

FUEL_TANK_LEFT_MAIN_LEVEL

Recommended Posts

Guest VAPilot

I must say that I am ashamed to be posting this,(could not find an ashamed smile to put here) but how do you get FUEL_TANK_LEFT_MAIN_LEVEL to show gallons in C++ :-hmmmIn xml is was simple, but every way I try in C++ I either get compiler errors or it complies but does not work.:-zhelp

Share this post


Link to post
Share on other sites

You didn't show exactly what you're doing... but, in C++ the normal variable for the left tank is FUEL_QUANTITY_LEFT. It returns the amount of fuel in gallons by default.The variable you're using is a bit "odd". It returns a value of 8388608.0 to represent 100%. To translate that into gallons or pounds of fuel you'd have to also reference the FUEL_TANK_LEFT_MAIN_CAPACITY variable which returns the total tank capacity in gallons.To convert from gallons to pounds you need to use the FUEL_WEGHT_PER_GALLON variable.


Ed Wilson

Mindstar Aviation
My Playland - I69

Share this post


Link to post
Share on other sites
Guest VAPilot

Hi EdI was going to use FUEL_QUANTITY_LEFT, but if I remember correctly that gives the combined total for Left Main as well as Left Aux, and I need seperate gauges for each tank.The code I am trying to get to work is using the variables FUEL_TANK_LEFT_MAIN_LEVEL and FUEL_TANK_LEFT_MAIN_CAPACITY, As you pointed out the first variable does give out a odd number, which is where I am getting confused. Some how I have got to use FUEL_TANK_LEFT_MAIN_CAPACITY to alter 8388608.0 to 62 gallons :-roll. Time to give it a rest tonight, my brain is just not working, will start again tomorrow, thanks for the help so far Ed, at least I now know I am using the right variables :-)

Share this post


Link to post
Share on other sites

Russell,Declare a float variable:FLOAT64 LeftFuelQty;Then use:execute_calculator_code("(A:FUEL TANK LEFT MAIN QUANTITY, gallons)", &LeftFuelQty, NULL, NULL);Much easier than messing around with the native C variables.Doug

Share this post


Link to post
Share on other sites

Ok... here's what you need to do:FLOAT64 fuel_pct = FUEL_TANK_LEFT_MAIN_LEVELvar.var_value.n/8388608.0;FLOAT64 fuel_amt_gal = FUEL_TANK_LEFT_MAIN_CAPACITYvar.var_value.n * fuel_pct;


Ed Wilson

Mindstar Aviation
My Playland - I69

Share this post


Link to post
Share on other sites
Guest JeanLuc_

Hi Russel,here is what I use for the rxpGNS WAAS (and for previous GNS as well):double rxpGNS::AcftFuelCapacity(){ module_var mvar; double value = 0.0; mvar.Init(FUEL_TANK_LEFT_MAIN_CAPACITY); value += mvar.Lookup(); mvar.Init(FUEL_TANK_LEFT_AUX_CAPACITY); value += mvar.Lookup(); mvar.Init(FUEL_TANK_LEFT_TIP_CAPACITY); value += mvar.Lookup(); mvar.Init(FUEL_TANK_CENTER_CAPACITY); value += mvar.Lookup(); mvar.Init(FUEL_TANK_CENTER2_CAPACITY); value += mvar.Lookup(); mvar.Init(FUEL_TANK_RIGHT_MAIN_CAPACITY); value += mvar.Lookup(); mvar.Init(FUEL_TANK_RIGHT_AUX_CAPACITY); value += mvar.Lookup(); mvar.Init(FUEL_TANK_RIGHT_TIP_CAPACITY); value += mvar.Lookup(); return (value * 3.7853); // convert gallons to liters}double rxpGNS::AcftFuelLevel(){ module_var mvar; double value = 0.0; mvar.Init(FUEL_QUANTITY_RIGHT); value += mvar.Lookup(); mvar.Init(FUEL_QUANTITY_LEFT); value += mvar.Lookup(); mvar.Init(FUEL_QUANTITY_CENTER); value += mvar.Lookup(); return (value * 3.7853); // convert gallons to liters}double rxpGNS::AcftFuelFlow(){ module_var mvar; double value = 0.0; mvar.Init(ENGINE1_FF_GPH); value += mvar.Lookup(); mvar.Init(ENGINE2_FF_GPH); value += mvar.Lookup(); mvar.Init(ENGINE3_FF_GPH); value += mvar.Lookup(); mvar.Init(ENGINE4_FF_GPH); value += mvar.Lookup(); return (value * 3.7853); // convert gallons to liters}class module_var : public MODULE_VAR{public: module_var() {id = MODULE_VAR_NONE; var_ptr = 0; var_type = VAR_TYPE_NONE; var_value.n = 0.0; var_old.n = 0.0;}; void Init(GAUGE_TOKEN tok){id = tok; initialize_var((PMODULE_VAR) this);}; void Update() {lookup_var((PMODULE_VAR) this);}; FLOAT64 Lookup() {lookup_var((PMODULE_VAR) this); return var_value.n;}; FLOAT64 Val() {return var_value.n;}; int ValInt() {return var_value.e; }; int ValFlag() {return var_value.f; }; bool ValBool() {return (var_value.:( ? true : false; }; void* ValPtr() {return var_value.p; }; long ValOctal() {return var_value.o; };};Hope this helps!

Share this post


Link to post
Share on other sites
Guest VAPilot

I should have checked this thread before I started. Brain is working today, came up with this:FLOAT64 FSAPI left_main_fuel_quantity_cb(PELEMENT_NEEDLE pelement){ lookup_var(&left_main_fuel); current_fuel_left_main = left_main_fuel.var_value.n; lookup_var(&left_main); left_main_capacity = left_main.var_value.n; current_fuel_left_main = current_fuel_left_main /8388608.0; current_fuel_left_main = left_main_capacity * current_fuel_left_main; return current_fuel_left_main;}Ed looks like your code is the same but with a lot less typing. Doug I have not tried using the execute_calculator_code before, so will give that a try. JeanLuc will add your code to the long list of bits of code I have for future reference.Thanks

Share this post


Link to post
Share on other sites
Guest schwudde

As Doug said, "execute_calculator_code" is easy to use, especially if you need the Fuel-Quantity in lbs or kg:FLOAT64 FuelSys::GetCenterTankQuantityLbs() const{ FLOAT64 val; execute_calculator_code("(A:FUEL TANK CENTER QUANTITY, gallons)",&val,NULL,NULL); return val * FuelSys::GetFuelWeightPerGallonLbs();}FLOAT64 FuelSys::GetCenterTankQuantityKilograms() const{ FLOAT64 val; execute_calculator_code("(A:FUEL TANK CENTER QUANTITY, gallons)",&val,NULL,NULL); return val * FuelSys::GetFuelWeightPerGallonKilograms();}

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  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...