From: curt Date: Wed, 4 Oct 2000 22:52:34 +0000 (+0000) Subject: Properties: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=981d4dbd7d83db80b446b33c4f2d86a5514c3b72;p=flightgear.git Properties: - /engines/engine0/rpm changed to read-only - /engines/engine0/egt added (read-only) - /controls/mixture added - /controls/propellor-pitch added (not used for C172) BFI: - getEGT() added - getMixture() and setMixture() added - getPropAdvance() and setPropAdvance() added (= pitch) - cleaned up reinit function a bit - force reinit only when values are actually changed; for example, setting the flight model to the current flight model will not cause a reinit LaRCSim: - hook up mixture and pitch to FGControls (they were hard-coded before) --- diff --git a/src/FDM/LaRCsim.cxx b/src/FDM/LaRCsim.cxx index aebbdd38e..a22b1059f 100644 --- a/src/FDM/LaRCsim.cxx +++ b/src/FDM/LaRCsim.cxx @@ -92,10 +92,10 @@ int FGLaRCsim::update( int multiloop ) { eng.set_IAS( V_calibrated_kts ); eng.set_Throttle_Lever_Pos( controls.get_throttle( 0 ) * 100.0 ); eng.set_Propeller_Lever_Pos( 100 ); - if ( controls.get_mixture( 0 ) > 0.51 ) { + if ( controls.get_mixture( 0 ) > 0.60 ) { eng.set_Mixture_Lever_Pos( controls.get_mixture( 0 ) * 100.0 ); } else { - eng.set_Mixture_Lever_Pos( 51.0 ); + eng.set_Mixture_Lever_Pos( 60.0 ); } // update engine model @@ -113,9 +113,8 @@ int FGLaRCsim::update( int multiloop ) { e->set_EGT( eng.get_EGT() ); e->set_prop_thrust( eng.get_prop_thrust_SI() ); -#if 0 cout << "Throttle = " << controls.get_throttle( 0 ) * 100.0; - cout << " Mixture = " << 80; + cout << " Mixture = " << controls.get_mixture( 0 ) * 100.0; cout << " RPM = " << eng.get_RPM(); cout << " MP = " << eng.get_Manifold_Pressure(); cout << " HP = " << ( eng.get_MaxHP() * eng.get_Percentage_Power() @@ -123,7 +122,6 @@ int FGLaRCsim::update( int multiloop ) { cout << " EGT = " << eng.get_EGT(); cout << " Thrust (N) " << eng.get_prop_thrust_SI(); // Thrust in Newtons cout << '\n'; -#endif // 0 F_X_engine = eng.get_prop_thrust_SI() * 0.07; #endif // USE_NEW_ENGINE_CODE diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 42181b0a2..d6659673d 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -105,6 +105,30 @@ FG_USING_STD(string); extern const char *default_root; +// Read in configuration (file and command line) and just set fg_root +bool fgInitFGRoot ( int argc, char **argv ) { + // Attempt to locate and parse a config file + // First check fg_root + FGPath config( current_options.get_fg_root() ); + config.append( "system.fgfsrc" ); + current_options.scan_config_file_for_root( config.str() ); + + // Next check home directory + char* envp = ::getenv( "HOME" ); + if ( envp != NULL ) { + config.set( envp ); + config.append( ".fgfsrc" ); + current_options.scan_config_file_for_root( config.str() ); + } + + // Parse remaining command line options + // These will override anything specified in a config file + current_options.scan_command_line_for_root(argc, argv); + + return true; +} + + // Read in configuration (file and command line) bool fgInitConfig ( int argc, char **argv ) { // Attempt to locate and parse a config file @@ -133,7 +157,7 @@ bool fgInitConfig ( int argc, char **argv ) { return false; } - return true; + return true; } diff --git a/src/Main/fg_init.hxx b/src/Main/fg_init.hxx index 1210e3daa..75bdf100b 100644 --- a/src/Main/fg_init.hxx +++ b/src/Main/fg_init.hxx @@ -31,6 +31,10 @@ #endif +// Read in configuration (file and command line) and just set fg_root +bool fgInitFGRoot ( int argc, char **argv ); + + // Read in configuration (file and command line) bool fgInitConfig ( int argc, char **argv ); diff --git a/src/Main/main.cxx b/src/Main/main.cxx index c0d33fe4e..0c15a3ffb 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -1326,10 +1326,11 @@ int main( int argc, char **argv ) { // seed the random number generater fg_srandom(); - // Read global preferences from $FG_ROOT/preferences.xml - // FIXME: this will *not* work with an --fg_root option because - // we have not read the command-line yet. Suggestions? + // Scan the config file(s) and command line options to see if + // fg_root was specified (ignore all other options for now) + fgInitFGRoot(argc, argv); + // Read global preferences from $FG_ROOT/preferences.xml FGPath props_path(current_options.get_fg_root()); props_path.append("preferences.xml"); FG_LOG(FG_INPUT, FG_INFO, "Reading global preferences"); diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 631dac808..89cceff5d 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -870,6 +870,66 @@ int fgOPTIONS::parse_option( const string& arg ) { } +// Scan the command line options for an fg_root definition and set +// just that. +int fgOPTIONS::scan_command_line_for_root( int argc, char **argv ) { + int i = 1; + int result; + + FG_LOG(FG_GENERAL, FG_INFO, "Processing command line arguments"); + + while ( i < argc ) { + FG_LOG( FG_GENERAL, FG_DEBUG, "argv[" << i << "] = " << argv[i] ); + + string arg = argv[i]; + if ( arg.find( "--fg-root=" ) != string::npos ) { + fg_root = arg.substr( 10 ); + } + + i++; + } + + return FG_OPTIONS_OK; +} + + +// Scan the config file for an fg_root definition and set just that. +int fgOPTIONS::scan_config_file_for_root( const string& path ) { + fg_gzifstream in( path ); + if ( !in.is_open() ) + return(FG_OPTIONS_ERROR); + + FG_LOG( FG_GENERAL, FG_INFO, "Processing config file: " << path ); + + in >> skipcomment; +#ifndef __MWERKS__ + while ( ! in.eof() ) { +#else + char c = '\0'; + while ( in.get(c) && c != '\0' ) { + in.putback(c); +#endif + string line; + +#ifdef GETLINE_NEEDS_TERMINATOR + getline( in, line, '\n' ); +#elif defined( macintosh ) + getline( in, line, '\r' ); +#else + getline( in, line ); +#endif + + if ( line.find( "--fg-root=" ) != string::npos ) { + fg_root = line.substr( 10 ); + } + + in >> skipcomment; + } + + return FG_OPTIONS_OK; +} + + // Parse the command line options int fgOPTIONS::parse_command_line( int argc, char **argv ) { int i = 1; @@ -888,7 +948,7 @@ int fgOPTIONS::parse_command_line( int argc, char **argv ) { i++; } - return(FG_OPTIONS_OK); + return FG_OPTIONS_OK; } diff --git a/src/Main/options.hxx b/src/Main/options.hxx index 569a1f231..3bef864d9 100644 --- a/src/Main/options.hxx +++ b/src/Main/options.hxx @@ -216,6 +216,14 @@ public: // Parse a single option int parse_option( const string& arg ); + // Scan the command line options for an fg_root definition and set + // just that. + int scan_command_line_for_root( int argc, char **argv ); + + // Scan the config file for an fg_root definition and set just + // that. + int scan_config_file_for_root( const string& path ); + // Parse the command line options int parse_command_line( int argc, char **argv );