// $Id$
-#include <Include/compiler.h>
+#include <simgear/compiler.h>
#include STL_STRING
-#include <Debug/logstream.hxx>
-#include <Include/fg_types.hxx>
-#include <Main/options.hxx>
+#include <simgear/debug/logstream.hxx>
+#include <simgear/io/iochannel.hxx>
+#include <simgear/io/sg_file.hxx>
+#include <simgear/io/sg_serial.hxx>
+#include <simgear/io/sg_socket.hxx>
+
+#include <simgear/math/fg_types.hxx>
-#include <Network/iochannel.hxx>
-#include <Network/fg_file.hxx>
-#include <Network/fg_serial.hxx>
+#include <Main/options.hxx>
#include <Network/protocol.hxx>
+#include <Network/native.hxx>
#include <Network/garmin.hxx>
#include <Network/nmea.hxx>
#include <Network/pve.hxx>
+#include <Network/ray.hxx>
#include <Network/rul.hxx>
+#include <Network/joyclient.hxx>
#include <Time/timestamp.hxx>
FG_LOG( FG_IO, FG_INFO, " protocol = " << protocol );
FGProtocol *io;
- if ( protocol == "garmin" ) {
+ if ( protocol == "native" ) {
+ FGNative *native = new FGNative;
+ io = native;
+ } else if ( protocol == "garmin" ) {
FGGarmin *garmin = new FGGarmin;
io = garmin;
} else if ( protocol == "nmea" ) {
} else if ( protocol == "pve" ) {
FGPVE *pve = new FGPVE;
io = pve;
+ } else if ( protocol == "ray" ) {
+ FGRAY *ray = new FGRAY;
+ io = ray;
} else if ( protocol == "rul" ) {
FGRUL *rul = new FGRUL;
io = rul;
+ } else if ( protocol == "joyclient" ) {
+ FGJoyClient *joyclient = new FGJoyClient;
+ io = joyclient;
} else {
return NULL;
}
FG_LOG( FG_IO, FG_INFO, " hertz = " << hertz );
if ( medium == "serial" ) {
- FGSerial *ch = new FGSerial;
- io->set_io_channel( ch );
-
// device name
end = config.find(",", begin);
if ( end == string::npos ) {
return NULL;
}
- ch->set_device( config.substr(begin, end - begin) );
+ string device = config.substr(begin, end - begin);
begin = end + 1;
- FG_LOG( FG_IO, FG_INFO, " device = " << ch->get_device() );
+ FG_LOG( FG_IO, FG_INFO, " device = " << device );
// baud
- ch->set_baud( config.substr(begin) );
- FG_LOG( FG_IO, FG_INFO, " baud = " << ch->get_baud() );
+ string baud = config.substr(begin);
+ FG_LOG( FG_IO, FG_INFO, " baud = " << baud );
+ SGSerial *ch = new SGSerial( device, baud );
io->set_io_channel( ch );
} else if ( medium == "file" ) {
- FGFile *ch = new FGFile;
-
// file name
- ch->set_file_name( config.substr(begin) );
- FG_LOG( FG_IO, FG_INFO, " file name = " << ch->get_file_name() );
+ string file = config.substr(begin);
+ FG_LOG( FG_IO, FG_INFO, " file name = " << file );
+ SGFile *ch = new SGFile( file );
io->set_io_channel( ch );
} else if ( medium == "socket" ) {
- // ch = new FGSocket;
+ // hostname
+ end = config.find(",", begin);
+ if ( end == string::npos ) {
+ return NULL;
+ }
+
+ string hostname = config.substr(begin, end - begin);
+ begin = end + 1;
+ FG_LOG( FG_IO, FG_INFO, " hostname = " << hostname );
+
+ // port string
+ end = config.find(",", begin);
+ if ( end == string::npos ) {
+ return NULL;
+ }
+
+ string port = config.substr(begin, end - begin);
+ begin = end + 1;
+ FG_LOG( FG_IO, FG_INFO, " port string = " << port );
+
+ // socket style
+ string style_str = config.substr(begin);
+ FG_LOG( FG_IO, FG_INFO, " style string = " << style_str );
+
+ SGSocket *ch = new SGSocket( hostname, port, style_str );
+ io->set_io_channel( ch );
}
return io;
if ( p->is_enabled() ) {
p->dec_count_down( interval );
- if ( p->get_count_down() < 0 ) {
+ while ( p->get_count_down() < 0 ) {
p->process();
- p->set_count_down( 1000000.0 / p->get_hz() );
+ p->dec_count_down( -1000000.0 / p->get_hz() );
}
}
}