]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/fg_io.cxx
- adjusted for no-value constructor for FGPanel
[flightgear.git] / src / Main / fg_io.cxx
index f57dac4868c9c7a62027e2717c3dff3b31ee8d77..4a75a78fb0ba65413981c8a4d0d08cad734f2fcc 100644 (file)
 #include <simgear/io/sg_serial.hxx>
 #include <simgear/io/sg_socket.hxx>
 #include <simgear/math/sg_types.hxx>
-
-#include <Main/options.hxx>
+#include <simgear/timing/timestamp.hxx>
 
 #include <Network/protocol.hxx>
-#include <Network/native.hxx>
+#include <Network/atlas.hxx>
 #include <Network/garmin.hxx>
+#include <Network/joyclient.hxx>
+#include <Network/native.hxx>
 #include <Network/nmea.hxx>
 #include <Network/props.hxx>
 #include <Network/pve.hxx>
 #include <Network/ray.hxx>
 #include <Network/rul.hxx>
-#include <Network/joyclient.hxx>
 
-#include <Time/timestamp.hxx>
+#include "globals.hxx"
 
-FG_USING_STD(string);
+SG_USING_STD(string);
 
 
 // define the global I/O channel list
@@ -60,7 +60,7 @@ static FGProtocol *parse_port_config( const string& config )
 
     begin = 0;
 
-    FG_LOG( FG_IO, FG_INFO, "Parse I/O channel request: " << config );
+    SG_LOG( SG_IO, SG_INFO, "Parse I/O channel request: " << config );
 
     // determine protocol
     end = config.find(",", begin);
@@ -70,15 +70,21 @@ static FGProtocol *parse_port_config( const string& config )
     
     string protocol = config.substr(begin, end - begin);
     begin = end + 1;
-    FG_LOG( FG_IO, FG_INFO, "  protocol = " << protocol );
+    SG_LOG( SG_IO, SG_INFO, "  protocol = " << protocol );
 
     FGProtocol *io;
-    if ( protocol == "native" ) {
-       FGNative *native = new FGNative;
-       io = native;
+    if ( protocol == "atlas" ) {
+       FGAtlas *atlas = new FGAtlas;
+       io = atlas;
     } else if ( protocol == "garmin" ) {
        FGGarmin *garmin = new FGGarmin;
        io = garmin;
+    } else if ( protocol == "joyclient" ) {
+       FGJoyClient *joyclient = new FGJoyClient;
+       io = joyclient;
+    } else if ( protocol == "native" ) {
+       FGNative *native = new FGNative;
+       io = native;
     } else if ( protocol == "nmea" ) {
        FGNMEA *nmea = new FGNMEA;
        io = nmea;
@@ -94,9 +100,6 @@ static FGProtocol *parse_port_config( const string& config )
     } else if ( protocol == "rul" ) {
        FGRUL *rul = new FGRUL;
        io = rul;
-    } else if ( protocol == "joyclient" ) {
-       FGJoyClient *joyclient = new FGJoyClient;
-       io = joyclient;
     } else {
        return NULL;
     }
@@ -109,7 +112,7 @@ static FGProtocol *parse_port_config( const string& config )
     
     string medium = config.substr(begin, end - begin);
     begin = end + 1;
-    FG_LOG( FG_IO, FG_INFO, "  medium = " << medium );
+    SG_LOG( SG_IO, SG_INFO, "  medium = " << medium );
 
     // determine direction
     end = config.find(",", begin);
@@ -120,7 +123,7 @@ static FGProtocol *parse_port_config( const string& config )
     string direction = config.substr(begin, end - begin);
     begin = end + 1;
     io->set_direction( direction );
-    FG_LOG( FG_IO, FG_INFO, "  direction = " << direction );
+    SG_LOG( SG_IO, SG_INFO, "  direction = " << direction );
 
     // determine hertz
     end = config.find(",", begin);
@@ -132,7 +135,7 @@ static FGProtocol *parse_port_config( const string& config )
     begin = end + 1;
     double hertz = atof( hertz_str.c_str() );
     io->set_hz( hertz );
-    FG_LOG( FG_IO, FG_INFO, "  hertz = " << hertz );
+    SG_LOG( SG_IO, SG_INFO, "  hertz = " << hertz );
 
     if ( medium == "serial" ) {
        // device name
@@ -143,18 +146,18 @@ static FGProtocol *parse_port_config( const string& config )
     
        string device = config.substr(begin, end - begin);
        begin = end + 1;
-       FG_LOG( FG_IO, FG_INFO, "  device = " << device );
+       SG_LOG( SG_IO, SG_INFO, "  device = " << device );
 
        // baud
        string baud = config.substr(begin);
-       FG_LOG( FG_IO, FG_INFO, "  baud = " << baud );
+       SG_LOG( SG_IO, SG_INFO, "  baud = " << baud );
 
        SGSerial *ch = new SGSerial( device, baud );
        io->set_io_channel( ch );
     } else if ( medium == "file" ) {
        // file name
        string file = config.substr(begin);
-       FG_LOG( FG_IO, FG_INFO, "  file name = " << file );
+       SG_LOG( SG_IO, SG_INFO, "  file name = " << file );
 
        SGFile *ch = new SGFile( file );
        io->set_io_channel( ch );
@@ -167,7 +170,7 @@ static FGProtocol *parse_port_config( const string& config )
     
        string hostname = config.substr(begin, end - begin);
        begin = end + 1;
-       FG_LOG( FG_IO, FG_INFO, "  hostname = " << hostname );
+       SG_LOG( SG_IO, SG_INFO, "  hostname = " << hostname );
 
        // port string
        end = config.find(",", begin);
@@ -177,11 +180,11 @@ static FGProtocol *parse_port_config( const string& config )
     
        string port = config.substr(begin, end - begin);
        begin = end + 1;
-       FG_LOG( FG_IO, FG_INFO, "  port string = " << port );
+       SG_LOG( SG_IO, SG_INFO, "  port string = " << port );
 
        // socket style
        string style_str = config.substr(begin);
-       FG_LOG( FG_IO, FG_INFO, "  style string = " << style_str );
+       SG_LOG( SG_IO, SG_INFO, "  style string = " << style_str );
        
        SGSocket *ch = new SGSocket( hostname, port, style_str );
        io->set_io_channel( ch );
@@ -194,9 +197,11 @@ static FGProtocol *parse_port_config( const string& config )
 // step through the port config streams (from fgOPTIONS) and setup
 // serial port channels for each
 void fgIOInit() {
+    // SG_LOG( SG_IO, SG_INFO, "I/O Channel initialization, " << 
+    //         globals->get_channel_options_list()->size() << " requests." );
+
     FGProtocol *p;
-    string_list channel_options_list = 
-       current_options.get_channel_options_list();
+    string_list *channel_options_list = globals->get_channel_options_list();
 
     // we could almost do this in a single step except pushing a valid
     // port onto the port list copies the structure and destroys the
@@ -204,17 +209,17 @@ void fgIOInit() {
 
     // parse the configuration strings and store the results in the
     // appropriate FGIOChannel structures
-    for ( int i = 0; i < (int)channel_options_list.size(); ++i ) {
-       p = parse_port_config( channel_options_list[i] );
+    for ( int i = 0; i < (int)channel_options_list->size(); ++i ) {
+       p = parse_port_config( (*channel_options_list)[i] );
        if ( p != NULL ) {
            p->open();
            global_io_list.push_back( p );
            if ( !p->is_enabled() ) {
-               FG_LOG( FG_IO, FG_ALERT, "I/O Channel config failed." );
+               SG_LOG( SG_IO, SG_ALERT, "I/O Channel config failed." );
                exit(-1);
            }
        } else {
-           FG_LOG( FG_IO, FG_INFO, "I/O Channel parse failed." );
+           SG_LOG( SG_IO, SG_INFO, "I/O Channel parse failed." );
        }
     }
 }
@@ -228,8 +233,8 @@ void fgIOProcess() {
 
     static int inited = 0;
     int interval;
-    static FGTimeStamp last;
-    FGTimeStamp current;
+    static SGTimeStamp last;
+    SGTimeStamp current;
 
     if ( ! inited ) {
        inited = 1;