]> 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 eb10053b86fdc189767b1e7f54dd3765c1208091..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 <Debug/logstream.hxx>
-#include <Misc/fgstream.hxx>
-#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 <FDM/flight.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;
 
@@ -162,6 +165,7 @@ fgOPTIONS::fgOPTIONS() :
 
     // Flight Model options
     flight_model( FGInterface::FG_LARCSIM ),
+    aircraft( "c172" ),
     model_hz( NEW_DEFAULT_MODEL_HZ ),
     speed_up( 1 ),
 
@@ -187,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" );
@@ -215,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 
@@ -497,7 +504,7 @@ 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 == "balloon" ) {
        return FGInterface::FG_BALLOONSIM;
@@ -533,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 "--serial=device,format,baud,direction" where
+// Format is "--protocol=medium,direction,hz,medium_options,..."
+//
+//   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,pve}
+//  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;
 }
@@ -622,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) );
@@ -648,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 ) {
@@ -744,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 ) {
@@ -802,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 ) {
@@ -855,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"