]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/options.cxx
UIUC flight model contribution. This is based on LaRCsim, but can read
[flightgear.git] / src / Main / options.cxx
index 889d5d0dbd269cbf63094238739efefbcb8454c0..11951ed088f5ec29153ece6df74af1a90af15734 100644 (file)
@@ -29,7 +29,7 @@
 bool global_fullscreen = true;
 #endif
 
-#include <Include/compiler.h>
+#include <simgear/compiler.h>
 
 #include <math.h>            // rint()
 #include <stdio.h>
@@ -38,19 +38,21 @@ bool global_fullscreen = true;
 
 #include STL_STRING
 
-#include <Include/fg_constants.h>
+#include <simgear/constants.h>
+#include <simgear/debug/logstream.hxx>
+#include <simgear/misc/fgstream.hxx>
+
 #include <Include/general.hxx>
 #include <Cockpit/cockpit.hxx>
-#include <Debug/logstream.hxx>
 #include <FDM/flight.hxx>
-#include <Misc/fgstream.hxx>
+#include <FDM/UIUCModel/uiuc_aircraftdir.h>
 #ifdef FG_NETWORK_OLK
-#  include <Network/network.h>
+#  include <NetworkOLK/network.h>
 #endif
 #include <Time/fg_time.hxx>
 
+#include "views.hxx"
 #include "options.hxx"
-#include "fg_serial.hxx"
 
 FG_USING_STD(string);
 FG_USING_NAMESPACE(std);
@@ -81,6 +83,7 @@ atoi( const string& str )
 #endif
 }
 
+
 // Defined the shared options class here
 fgOPTIONS current_options;
 
@@ -153,6 +156,7 @@ fgOPTIONS::fgOPTIONS() :
     mouse_pointer(0),
     pause(0),
     control_mode(FG_JOYSTICK),
+    auto_coordination(FG_AUTO_COORD_NOT_SPECIFIED),
 
     // Features
     hud_status(1),
@@ -161,11 +165,14 @@ fgOPTIONS::fgOPTIONS() :
 
     // Flight Model options
     flight_model( FGInterface::FG_LARCSIM ),
+    aircraft( "c172" ),
     model_hz( NEW_DEFAULT_MODEL_HZ ),
     speed_up( 1 ),
 
     // Rendering options
     fog(FG_FOG_NICEST),  // nicest
+    clouds(true),
+    clouds_asl(5000*FEET_TO_METER),
     fov(55.0),
     fullscreen(0),
     shading(1),
@@ -174,7 +181,7 @@ fgOPTIONS::fgOPTIONS() :
     wireframe(0),
     xsize(640),
     ysize(480),
-    view_mode(FG_VIEW_FIRST_PERSON),
+    view_mode(FG_VIEW_PILOT),
 
     // Scenery options
     tile_diameter(5),
@@ -184,8 +191,12 @@ fgOPTIONS::fgOPTIONS() :
     tris_or_culled(0),
        
     // Time options
-    time_offset(0)
+    time_offset(0),
+
+    network_olk(false)
 {
+    aircraft_dir=""; // Initialize the Aircraft directory to "" (UIUC)
+
     // set initial values/defaults
     time_offset_type=FG_TIME_SYS_OFFSET;
     char* envp = ::getenv( "FG_ROOT" );
@@ -212,8 +223,7 @@ fgOPTIONS::fgOPTIONS() :
     net_id = "Johnney";                // default pilot's name
 
     // initialize port config string list
-    port_options_list.erase ( port_options_list.begin(), 
-                             port_options_list.end() );
+    channel_options_list.clear();
 }
 
 void 
@@ -494,16 +504,18 @@ fgOPTIONS::parse_tile_radius( const string& arg ) {
 // Parse --fdm=abcdefg type option 
 int
 fgOPTIONS::parse_fdm( const string& fm ) {
-    // printf("fdm = %s\n", fm);
+    // cout << "fdm = " << fm << endl;
 
-    if ( fm == "slew" ) {
-       return FGInterface::FG_SLEW;
+    if ( fm == "balloon" ) {
+       return FGInterface::FG_BALLOONSIM;
+    } else if ( fm == "external" ) {
+       return FGInterface::FG_EXTERNAL;
     } else if ( fm == "jsb" ) {
        return FGInterface::FG_JSBSIM;
     } else if ( (fm == "larcsim") || (fm == "LaRCsim") ) {
        return FGInterface::FG_LARCSIM;
-    } else if ( fm == "external" ) {
-       return FGInterface::FG_EXTERNAL;
+    } else if ( fm == "magic" ) {
+       return FGInterface::FG_MAGICCARPET;
     } else {
        FG_LOG( FG_GENERAL, FG_ALERT, "Unknown fdm = " << fm );
        exit(-1);
@@ -528,31 +540,35 @@ fgOPTIONS::parse_fov( const string& arg ) {
 }
 
 
-// Parse serial port option --serial=/dev/ttyS1,nmea,4800,out
+// Parse I/O channel option
+//
+// Format is "--protocol=medium,direction,hz,medium_options,..."
 //
-// Format is "--serial=device,format,baud,direction" where
+//   protocol = { native, nmea, garmin, fgfs, rul, pve, etc. }
+//   medium = { serial, socket, file, etc. }
+//   direction = { in, out, bi }
+//   hz = number of times to process channel per second (floating
+//        point values are ok.
+//
+// Serial example "--nmea=serial,dir,hz,device,baud" where
 // 
-//  device = OS device name to be open()'ed
-//  format = {nmea, garmin,fgfs,rul}
+//  device = OS device name of serial line to be open()'ed
 //  baud = {300, 1200, 2400, ..., 230400}
-//  direction = {in, out, bi}
+//
+// Socket exacmple "--native=socket,dir,hz,machine,port" where
+// 
+//  machine = machine name or ip address if client (leave empty if server)
+//  port = port, leave empty to let system choose
+//
+// File example "--garmin=file,dir,hz,filename" where
+// 
+//  filename = file system file name
 
 bool 
-fgOPTIONS::parse_serial( const string& serial_str ) {
-    string::size_type pos;
-
-    // cout << "Serial string = " << serial_str << endl;
-
-    // a flailing attempt to see if the port config string has a
-    // chance at being valid
-    pos = serial_str.find(",");
-    if ( pos == string::npos ) {
-       FG_LOG( FG_GENERAL, FG_ALERT, 
-               "Malformed serial port configure string" );
-       return false;
-    }
-    
-    port_options_list.push_back( serial_str );
+fgOPTIONS::parse_channel( const string& type, const string& channel_str ) {
+    // cout << "Channel string = " << channel_str << endl;
+
+    channel_options_list.push_back( type + "," + channel_str );
 
     return true;
 }
@@ -586,6 +602,10 @@ int fgOPTIONS::parse_option( const string& arg ) {
        pause = true;   
     } else if ( arg.find( "--control=") != string::npos ) {
        parse_control( arg.substr(10) );
+    } else if ( arg == "--disable-auto-coordination" ) {
+       auto_coordination = FG_AUTO_COORD_DISABLED;     
+    } else if ( arg == "--enable-auto-coordination" ) {
+       auto_coordination = FG_AUTO_COORD_ENABLED;      
     } else if ( arg == "--disable-hud" ) {
        hud_status = false;     
     } else if ( arg == "--enable-hud" ) {
@@ -613,21 +633,21 @@ int fgOPTIONS::parse_option( const string& arg ) {
        }
     } else if ( arg.find( "--uBody=" ) != string::npos ) {
        if ( units == FG_UNITS_FEET ) {
-           uBody = atof( arg.substr(8) ) * FEET_TO_METER;
-       } else {
            uBody = atof( arg.substr(8) );
+       } else {
+           uBody = atof( arg.substr(8) ) * FEET_TO_METER;
        }
     } else if ( arg.find( "--vBody=" ) != string::npos ) {
        if ( units == FG_UNITS_FEET ) {
-           vBody = atof( arg.substr(8) ) * FEET_TO_METER;
-       } else {
            vBody = atof( arg.substr(8) );
+       } else {
+           vBody = atof( arg.substr(8) ) * FEET_TO_METER;
        }
     } else if ( arg.find( "--wBody=" ) != string::npos ) {
        if ( units == FG_UNITS_FEET ) {
-           wBody = atof( arg.substr(8) ) * FEET_TO_METER;
-       } else {
            wBody = atof( arg.substr(8) );
+       } else {
+           wBody = atof( arg.substr(8) ) * FEET_TO_METER;
        }
     } else if ( arg.find( "--heading=" ) != string::npos ) {
        heading = atof( arg.substr(10) );
@@ -639,6 +659,10 @@ int fgOPTIONS::parse_option( const string& arg ) {
        fg_root = arg.substr( 10 );
     } else if ( arg.find( "--fdm=" ) != string::npos ) {
        flight_model = parse_fdm( arg.substr(6) );
+    } else if ( arg.find( "--aircraft=" ) != string::npos ) {
+       aircraft = arg.substr(11);
+    } else if ( arg.find( "--aircraft-dir=" ) != string::npos ) {
+       aircraft_dir =  arg.substr(15); //  (UIUC)
     } else if ( arg.find( "--model-hz=" ) != string::npos ) {
        model_hz = atoi( arg.substr(11) );
     } else if ( arg.find( "--speed=" ) != string::npos ) {
@@ -649,6 +673,16 @@ int fgOPTIONS::parse_option( const string& arg ) {
        fog = FG_FOG_FASTEST;   
     } else if ( arg == "--fog-nicest" ) {
        fog = FG_FOG_NICEST;    
+    } else if ( arg == "--disable-clouds" ) {
+       clouds = false; 
+    } else if ( arg == "--enable-clouds" ) {
+       clouds = true;  
+    } else if ( arg.find( "--clouds-asl=" ) != string::npos ) {
+       if ( units == FG_UNITS_FEET ) {
+           clouds_asl = atof( arg.substr(13) ) * FEET_TO_METER;
+       } else {
+           clouds_asl = atof( arg.substr(13) );
+       }
     } else if ( arg.find( "--fov=" ) != string::npos ) {
        fov = parse_fov( arg.substr(6) );
     } else if ( arg == "--disable-fullscreen" ) {
@@ -702,15 +736,15 @@ int fgOPTIONS::parse_option( const string& arg ) {
     } else if ( arg.find( "--tile-radius=" ) != string::npos ) {
        tile_radius = parse_tile_radius( arg.substr(14) );
        tile_diameter = tile_radius * 2 + 1;
-    } else if ( arg.find( "--time-offset-sys=" ) != string::npos ) {
-       time_offset = parse_time_offset( (arg.substr(18)) );
+    } else if ( arg.find( "--time-offset" ) != string::npos ) {
+       time_offset = parse_time_offset( (arg.substr(14)) );
+       //time_offset_type = FG_TIME_SYS_OFFSET;
+    } else if ( arg.find( "--time-match-real") != string::npos ) {
+      //time_offset = parse_time_offset(arg.substr(18));
        time_offset_type = FG_TIME_SYS_OFFSET;
-    } else if ( arg.find( "--time-offset-lat=") != string::npos ) {
-        time_offset = parse_time_offset(arg.substr(18));
+    } else if ( arg.find( "--time-match-local") != string::npos ) {
+      //time_offset = parse_time_offset(arg.substr(18));
        time_offset_type = FG_TIME_LAT_OFFSET;
-    } else if ( arg.find( "--time-offset-gmt=") != string::npos ) {
-        time_offset = parse_time_offset(arg.substr(18));
-       time_offset_type = FG_TIME_GMT_OFFSET;
     } else if ( arg.find( "--start-date-sys=") != string::npos ) {
         time_offset = parse_date( (arg.substr(17)) );
        time_offset_type = FG_TIME_SYS_ABSOLUTE;
@@ -725,9 +759,21 @@ int fgOPTIONS::parse_option( const string& arg ) {
        tris_or_culled = 0;     
     } else if ( arg == "--hud-culled" ) {
        tris_or_culled = 1;
-    } else if ( arg.find( "--serial=" ) != string::npos ) {
-       parse_serial( arg.substr(9) );
+    } else if ( arg.find( "--native=" ) != string::npos ) {
+       parse_channel( "native", arg.substr(9) );
+    } else if ( arg.find( "--garmin=" ) != string::npos ) {
+       parse_channel( "garmin", arg.substr(9) );
+    } else if ( arg.find( "--nmea=" ) != string::npos ) {
+       parse_channel( "nmea", arg.substr(7) );
+    } else if ( arg.find( "--pve=" ) != string::npos ) {
+       parse_channel( "pve", arg.substr(6) );
+    } else if ( arg.find( "--rul=" ) != string::npos ) {
+       parse_channel( "rul", arg.substr(6) );
 #ifdef FG_NETWORK_OLK
+    } else if ( arg == "--disable-network-olk" ) {
+       network_olk = false;    
+    } else if ( arg== "--enable-network-olk") {
+       network_olk = true;     
     } else if ( arg == "--net-hud" ) {
        net_hud_display = 1;    
     } else if ( arg.find( "--net-id=") != string::npos ) {
@@ -783,9 +829,11 @@ int fgOPTIONS::parse_config_file( const string& path ) {
        string line;
 
 #ifdef GETLINE_NEEDS_TERMINATOR
-       getline( in, line, '\n' );
+        getline( in, line, '\n' );
+#elif defined (MACOS)
+       getline( in, line, '\r' );
 #else
-       getline( in, line );
+        getline( in, line );
 #endif
 
        if ( parse_option( line ) == FG_OPTIONS_ERROR ) {
@@ -836,11 +884,17 @@ void fgOPTIONS::usage ( void ) {
     cout << endl;
  
     cout << "Flight Model:" << endl;
-    cout << "\t--fdm=abcd:  one of slew, jsb, larcsim, or external" << endl;
+    cout << "\t--fdm=abcd:  selects the core flight model code." << endl;
+    cout << "\t\tcan be one of jsb, larcsim, magic, or external" << endl;
+    cout << "\t--aircraft=abcd:  aircraft model to load" << endl;
     cout << "\t--model-hz=n:  run the FDM this rate (iterations per second)" 
         << endl;
     cout << "\t--speed=n:  run the FDM this much faster than real time" << endl;
     cout << endl;
+    //(UIUC)
+    cout <<"Aircraft model directory" << endl;
+    cout <<"\t--aircraft-dir=<path> path is relative to the path of the executable" << endl;
+    cout << endl;
 
     cout << "Initial Position and Orientation:" << endl;
     cout << "\t--airport-id=ABCD:  specify starting postion by airport id" 
@@ -868,6 +922,9 @@ void fgOPTIONS::usage ( void ) {
     cout << "\t--fog-disable:  disable fog/haze" << endl;
     cout << "\t--fog-fastest:  enable fastest fog/haze" << endl;
     cout << "\t--fog-nicest:  enable nicest fog/haze" << endl;
+    cout << "\t--enable-clouds:  enable demo cloud layer" << endl;
+    cout << "\t--disable-clouds:  disable demo cloud layer" << endl;
+    cout << "\t--clouds-asl=xxx:  specify altitude of cloud layer above sea level" << endl;
     cout << "\t--fov=xx.x:  specify initial field of view angle in degrees"
         << endl;
     cout << "\t--disable-fullscreen:  disable fullscreen mode" << endl;
@@ -897,12 +954,11 @@ void fgOPTIONS::usage ( void ) {
     cout << endl;
        
     cout << "Time Options:" << endl;
-    cout << "\t--time-offset-sys=[+-]hh:mm:ss: add this time offset to" << endl
-        << "\t\tyour system time" << endl;
-    cout << "\t--time-offset-gmt:[+-]hh:mm:ss: add this time offset to" << endl
-        << "\t\tGreenwich Mean Time (GMT)" << endl;
-    cout << "\t--time-offset-lat:[+-]hh:mm:ss: add this time offset to" << endl
-        << "\t\tLocal Aircraft Time (LAT)" << endl;   
+    cout << "\t--time-offset=[+-]hh:mm:ss: add this time offset" << endl;
+    cout << "\t--time-match-real: Synchronize real-world and FlightGear" << endl
+        << "\t\ttime. Can be used in combination with --time-offset." << endl;
+    cout << "\t--time-match-local:Synchronize local real-world and " << endl
+        << "\t\tFlightGear time" << endl;   
     cout << "\t--start-date-sys=yyyy:mm:dd:hh:mm:ss: specify a starting" << endl
         << "\t\tdate/time. Uses your system time " << endl;
     cout << "\t--start-date-gmt=yyyy:mm:dd:hh:mm:ss: specify a starting" << endl