]> git.mxchange.org Git - flightgear.git/commitdiff
Properties:
authorcurt <curt>
Wed, 4 Oct 2000 22:52:34 +0000 (22:52 +0000)
committercurt <curt>
Wed, 4 Oct 2000 22:52:34 +0000 (22:52 +0000)
- /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)

src/FDM/LaRCsim.cxx
src/Main/fg_init.cxx
src/Main/fg_init.hxx
src/Main/main.cxx
src/Main/options.cxx
src/Main/options.hxx

index aebbdd38eb718993c6da6bf379cad2352f978c43..a22b1059fb2d6e0bad04104b9d77ea8e1eb7bee6 100644 (file)
@@ -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
index 42181b0a29994b0cce5b30738b420960ed523733..d6659673dca1b0e3f52d02eac9d883e5df817652 100644 (file)
@@ -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;
 }
 
 
index 1210e3daaff2ee92604137a8a6fdf7cdb3c1c0b4..75bdf100b931f93a04ddd0525674c88259991c94 100644 (file)
 #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 );
 
index c0d33fe4e32b68469f7b0448b9a4816cb99fbe44..0c15a3ffb27d449334b9fbf77522a97867d0772c 100644 (file)
@@ -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");
index 631dac8081c64e104b8baa9761e97c9eca6c429f..89cceff5dfdd6c17cae8e86d2421597359bb8627 100644 (file)
@@ -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;
 }
 
 
index 569a1f231245e77c01ffc5d0cf161a844194ef03..3bef864d9ae54a3f6d1097dfe970cffa6266f1a7 100644 (file)
@@ -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 );