From: curt Date: Thu, 1 Mar 2001 16:32:29 +0000 (+0000) Subject: Contributed by Dave Luff: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5d423a94b0f6421af87817c006c515fec1953ca2;p=flightgear.git Contributed by Dave Luff: Added fuel-flow and total fuel to the LaRCSim model. Its still a bit rough for now but it works, except the engine dosn't stop when fuel runs out at the moment since there's no refuelling capability in the sim just now. It takes about 4 gallons use before you see the fuel guages begin to drop since there's 28 gal per tank but the guages go to 26. --- diff --git a/src/FDM/IO360.cxx b/src/FDM/IO360.cxx index 242836aa2..f4e1f29ee 100644 --- a/src/FDM/IO360.cxx +++ b/src/FDM/IO360.cxx @@ -73,7 +73,10 @@ // DCL 27/10/00 - Added first stab at cylinder head temperature model // See the comment block in the code for details // -// DCL 02/11/00 - Modified EGT code to reduce values to those more representative of a sensor downstream +// DCL 02/11/00 - Modified EGT code to reduce values to those more representative of a sensor downstream +// +// DCL 02/02/01 - Changed the prop model to one based on efficiency and co-efficient of power curves from McCormick instead of the +// blade element method we were using previously. This works much better, and is similar to how Jon is doing it in JSBSim. // ////////////////////////////////////////////////////////////////////// @@ -97,8 +100,7 @@ float FGNewEngine::Lookup_Combustion_Efficiency(float thi_actual) float factor; int i; - int j; - j = NUM_ELEMENTS; //This must be equal to the number of elements in the lookup table arrays + int j = NUM_ELEMENTS; //This must be equal to the number of elements in the lookup table arrays for(i=0;iset_Tank1Fuel(15.0); + //current_aircraft.fdm_state->set_Tank2Fuel(15.0); + //Tank1Fuel = 15.0; + //Tank2Fuel = 15.0; } FGLaRCsim::~FGLaRCsim(void) { @@ -74,7 +78,13 @@ void FGLaRCsim::init() { // update the engines interface FGEngInterface e; add_engine( e ); - + + // Fill the fuel tanks + // Hardwired to C172 full tanks for now - need to fix this sometime + // Also note that this is the max quantity - the usable quantity + // is slightly less + set_Tank1Fuel(28.0); + set_Tank2Fuel(28.0); // FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::init()" ); @@ -134,6 +144,13 @@ bool FGLaRCsim::update( int multiloop ) { e->set_EGT( eng.get_EGT() ); e->set_CHT( eng.get_CHT() ); e->set_prop_thrust( eng.get_prop_thrust_SI() ); + e->set_Fuel_Flow( eng.get_fuel_flow_gals_hr() ); + + //Assume we are using both tanks equally for now + reduce_Tank1Fuel( (eng.get_fuel_flow_gals_hr() / (2 * 3600)) + * get_delta_t() ); + reduce_Tank2Fuel( (eng.get_fuel_flow_gals_hr() / (2 * 3600)) + * get_delta_t() ); #if 0 FG_LOG( FG_FLIGHT, FG_INFO, "Throttle = " diff --git a/src/FDM/flight.hxx b/src/FDM/flight.hxx index cd8a2c705..47aa735c6 100644 --- a/src/FDM/flight.hxx +++ b/src/FDM/flight.hxx @@ -113,12 +113,13 @@ private: // outputs double RPM; - double Manifold_Pressure; + double Manifold_Pressure; //inches double MaxHP; - double Percentage_Power; - double EGT; - double CHT; - double prop_thrust; + double Percentage_Power; //HP + double EGT; //deg F + double CHT; //deg F + double prop_thrust; //lbs + double Fuel_Flow; //Gals/hr /* others... double PercentN1,N1; //GE,CFM @@ -145,6 +146,7 @@ public: inline double get_EGT() const { return EGT; } inline double get_CHT() const { return CHT; } inline double get_prop_thrust() const { return prop_thrust; } + inline double get_Fuel_Flow() const { return Fuel_Flow; } inline void set_Throttle( double t ) { Throttle = t; } inline void set_Mixture( double m ) { Mixture = m; } @@ -156,6 +158,7 @@ public: inline void set_EGT( double e ) { EGT = e; } inline void set_CHT( double c ) { CHT = c; } inline void set_prop_thrust( double t ) { prop_thrust = t; } + inline void set_Fuel_Flow( double f ) { Fuel_Flow = f; } }; @@ -269,6 +272,8 @@ private: double sin_longitude, cos_longitude; double sin_latitude, cos_latitude; double altitude_agl; + double Tank1Fuel; // Gals + double Tank2Fuel; // Gals // Engine list engine_list engines; @@ -541,7 +546,22 @@ public: virtual void set_Velocities_Local_Airmass (double wnorth, double weast, double wdown ); - + + // Consumables + inline void set_Tank1Fuel( double f ) { Tank1Fuel = f; } + inline void set_Tank2Fuel( double f ) { Tank2Fuel = f; } + + inline void reduce_Tank1Fuel( double f ) { + Tank1Fuel -= f; + if(Tank1Fuel < 0) + Tank1Fuel = 0; + } + inline void reduce_Tank2Fuel( double f ) { + Tank2Fuel -= f; + if(Tank2Fuel < 0) + Tank2Fuel = 0; + } + // ========== Mass properties and geometry values ========== @@ -1079,6 +1099,10 @@ public: return cos_latitude; } + // Consumables + inline double get_Tank1Fuel() const { return Tank1Fuel; } + inline double get_Tank2Fuel() const { return Tank2Fuel; } + // engines inline double get_num_engines() const { return engines.size(); diff --git a/src/Main/Makefile.am b/src/Main/Makefile.am index 7fb27f5e2..fd7d07797 100644 --- a/src/Main/Makefile.am +++ b/src/Main/Makefile.am @@ -69,8 +69,8 @@ fgfs_LDADD = \ $(top_builddir)/src/Time/libTime.a \ $(WEATHER_LIBS) \ $(top_builddir)/src/Joystick/libJoystick.a \ - -lsgroute -lsgsky -lsgephem -lsgtiming -lsgio -lsgscreen -lsgmath \ - -lsgbucket -lsgdebug -lsgmagvar -lsgmisc -lsgxml \ + -lsgroute -lsgsky -lsgephem -lsgmetar -lsgtiming -lsgio -lsgscreen \ + -lsgmath -lsgbucket -lsgdebug -lsgmagvar -lsgmisc -lsgxml \ $(SERIAL_LIBS) \ -lplibpu -lplibfnt -lplibssg -lplibsg \ -lmk4 -lz \ diff --git a/src/Main/bfi.cxx b/src/Main/bfi.cxx index 1d3fa5189..6083b288a 100644 --- a/src/Main/bfi.cxx +++ b/src/Main/bfi.cxx @@ -190,6 +190,11 @@ FGBFI::init () fgTie("/engines/engine0/egt", getEGT); fgTie("/engines/engine0/cht", getCHT); fgTie("/engines/engine0/mp", getMP); + fgTie("/engines/engine0/fuel-flow", getFuelFlow); + + //consumables + fgTie("/consumables/fuel/tank1/level", getTank1Fuel, setTank1Fuel, false); + fgTie("/consumables/fuel/tank2/level", getTank2Fuel, setTank2Fuel, false); // Autopilot fgTie("/autopilot/locks/altitude", getAPAltitudeLock, setAPAltitudeLock); @@ -322,7 +327,7 @@ FGBFI::setDateString (string date_string) mktime(&new_time) - mktime(current_time) + globals->get_warp(); double lon = current_aircraft.fdm_state->get_Longitude(); double lat = current_aircraft.fdm_state->get_Latitude(); - double alt = current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER; + // double alt = current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER; globals->set_warp(warp); st->update(lon, lat, warp); fgUpdateSkyAndLightingParams(); @@ -560,7 +565,7 @@ FGBFI::getCHT () /** - * Return the current engine0 CHT. + * Return the current engine0 Manifold Pressure. */ double FGBFI::getMP () @@ -572,6 +577,52 @@ FGBFI::getMP () } } +/** + * Return the current engine0 fuel flow + */ +double +FGBFI::getFuelFlow () +{ + if ( current_aircraft.fdm_state->get_engine(0) != NULL ) { + return current_aircraft.fdm_state->get_engine(0)->get_Fuel_Flow(); + } else { + return 0.0; + } +} + +//////////////////////////////////////////////////////////////////////// +// Consumables +//////////////////////////////////////////////////////////////////////// + +/** + * Return the fuel level in tank 1 + */ +double +FGBFI::getTank1Fuel () +{ + return current_aircraft.fdm_state->get_Tank1Fuel(); +} + +void +FGBFI::setTank1Fuel ( double gals ) +{ + current_aircraft.fdm_state->set_Tank1Fuel( gals ); +} + +/** + * Return the fuel level in tank 2 + */ +double +FGBFI::getTank2Fuel () +{ + return current_aircraft.fdm_state->get_Tank2Fuel(); +} + +void +FGBFI::setTank2Fuel ( double gals ) +{ + current_aircraft.fdm_state->set_Tank2Fuel( gals ); +} //////////////////////////////////////////////////////////////////////// @@ -1292,7 +1343,7 @@ FGBFI::setWindDown (double speed) double FGBFI::getFOV () { - globals->get_current_view()->get_fov(); + return globals->get_current_view()->get_fov(); } void diff --git a/src/Main/bfi.hxx b/src/Main/bfi.hxx index da6482549..bdff783cb 100644 --- a/src/Main/bfi.hxx +++ b/src/Main/bfi.hxx @@ -101,9 +101,16 @@ public: static double getRPM (); // revolutions/minute static void setRPM ( double rpm ); // revolutions/minute - static double getEGT (); // [unit??] - static double getCHT (); // [unit??] - static double getMP (); // [unit??] + static double getEGT (); // deg Fahrenheit + static double getCHT (); // deg Fahrenheit + static double getMP (); // inches mercury + static double getFuelFlow (); // gals/hr + + // Consumables + static double getTank1Fuel (); // gals + static void setTank1Fuel( double gals ); + static double getTank2Fuel (); // gals + static void setTank2Fuel( double gals ); // Velocities static double getAirspeed (); // knots