From f3d4f741f097e1a9e1545389b95413d8b78f3b0f Mon Sep 17 00:00:00 2001 From: curt Date: Sun, 12 Jan 2003 23:39:18 +0000 Subject: [PATCH] Update to the Mini FDM network protocal (mostly renaming class and file names) Wired this in to options.cxx and fg_io.cxx so it can be activated. --- src/Main/fg_io.cxx | 4 +++ src/Main/options.cxx | 2 ++ src/Network/Makefile.am | 2 +- .../{native_fdm_mini.cxx => mini_fdm.cxx} | 26 +++++++++---------- .../{native_fdm_mini.hxx => mini_fdm.hxx} | 24 ++++++++--------- src/Network/net_fdm_mini.hxx | 2 +- 6 files changed, 33 insertions(+), 27 deletions(-) rename src/Network/{native_fdm_mini.cxx => mini_fdm.cxx} (92%) rename src/Network/{native_fdm_mini.hxx => mini_fdm.hxx} (69%) diff --git a/src/Main/fg_io.cxx b/src/Main/fg_io.cxx index b623d2a5e..b987fe6a7 100644 --- a/src/Main/fg_io.cxx +++ b/src/Main/fg_io.cxx @@ -46,6 +46,7 @@ # include #endif #include +#include #include #include #include @@ -136,6 +137,9 @@ FGIO::parse_port_config( const string& config ) } else if ( protocol == "native_fdm" ) { FGNativeFDM *native_fdm = new FGNativeFDM; io = native_fdm; + } else if ( protocol == "mini_fdm" ) { + FGMiniFDM *mini_fdm = new FGMiniFDM; + io = mini_fdm; } else if ( protocol == "nmea" ) { FGNMEA *nmea = new FGNMEA; io = nmea; diff --git a/src/Main/options.cxx b/src/Main/options.cxx index ce2c40f2f..abe3acb61 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -915,6 +915,8 @@ parse_option (const string& arg) add_channel( "native_ctrls", arg.substr(15) ); } else if ( arg.find( "--native-fdm=" ) == 0 ) { add_channel( "native_fdm", arg.substr(13) ); + } else if ( arg.find( "--mini-fdm=" ) == 0 ) { + add_channel( "mini_fdm", arg.substr(13) ); } else if ( arg.find( "--opengc=" ) == 0 ) { // char stop; // cout << "Adding channel for OpenGC Display" << endl; cin >> stop; diff --git a/src/Network/Makefile.am b/src/Network/Makefile.am index d9a2eed61..5d307cd55 100644 --- a/src/Network/Makefile.am +++ b/src/Network/Makefile.am @@ -14,10 +14,10 @@ libNetwork_a_SOURCES = \ httpd.cxx httpd.hxx \ $(JPEG_SERVER) \ joyclient.cxx joyclient.hxx \ + mini_fdm.cxx mini_fdm.hxx \ native.cxx native.hxx \ native_ctrls.cxx native_ctrls.hxx \ native_fdm.cxx native_fdm.hxx \ - native_fdm_mini.cxx native_fdm_mini.hxx \ net_ctrls.hxx net_fdm.hxx net_fdm_mini.hxx \ nmea.cxx nmea.hxx \ opengc.cxx opengc.hxx opengc_data.hxx \ diff --git a/src/Network/native_fdm_mini.cxx b/src/Network/mini_fdm.cxx similarity index 92% rename from src/Network/native_fdm_mini.cxx rename to src/Network/mini_fdm.cxx index 3375df8be..f5b7ef229 100644 --- a/src/Network/native_fdm_mini.cxx +++ b/src/Network/mini_fdm.cxx @@ -35,7 +35,7 @@ #include
#include
-#include "native_fdm_mini.hxx" +#include "mini_fdm.hxx" // FreeBSD works better with this included last ... (?) #if defined(WIN32) && !defined(__CYGWIN__) @@ -71,15 +71,15 @@ static void htond (double &x) } -FGNativeFDMmini::FGNativeFDMmini() { +FGMiniFDM::FGMiniFDM() { } -FGNativeFDMmini::~FGNativeFDMmini() { +FGMiniFDM::~FGMiniFDM() { } // open hailing frequencies -bool FGNativeFDMmini::open() { +bool FGMiniFDM::open() { if ( is_enabled() ) { SG_LOG( SG_IO, SG_ALERT, "This shouldn't happen, but the channel " << "is already in use, ignoring" ); @@ -100,7 +100,7 @@ bool FGNativeFDMmini::open() { } -void FGProps2NetFDMmini( FGNetFDMmini *net ) { +void FGProps2NetMiniFDM( FGNetMiniFDM *net ) { int i; // Version sanity checking @@ -115,7 +115,7 @@ void FGProps2NetFDMmini( FGNetFDMmini *net ) { net->psi = cur_fdm_state->get_Psi(); // Consumables - net->num_tanks = FGNetFDMmini::FG_MAX_TANKS; + net->num_tanks = FGNetMiniFDM::FG_MAX_TANKS; for ( i = 0; i < net->num_tanks; ++i ) { SGPropertyNode *node = fgGetNode("/consumables/fuel/tank", i, true); net->fuel_quantity[i] = node->getDoubleValue("level-gal_us"); @@ -145,7 +145,7 @@ void FGProps2NetFDMmini( FGNetFDMmini *net ) { } -void FGNetFDMmini2Props( FGNetFDMmini *net ) { +void FGNetMiniFDM2Props( FGNetMiniFDM *net ) { int i; // Convert to the net buffer from network format @@ -191,7 +191,7 @@ void FGNetFDMmini2Props( FGNetFDMmini *net ) { globals->set_warp( net->warp ); } else { SG_LOG( SG_IO, SG_ALERT, - "Error: version mismatch in FGNetFDMmini2Props()" ); + "Error: version mismatch in FGNetMiniFDM2Props()" ); SG_LOG( SG_IO, SG_ALERT, "\tread " << net->version << " need " << FG_NET_FDM_MINI_VERSION ); SG_LOG( SG_IO, SG_ALERT, @@ -201,13 +201,13 @@ void FGNetFDMmini2Props( FGNetFDMmini *net ) { // process work for this port -bool FGNativeFDMmini::process() { +bool FGMiniFDM::process() { SGIOChannel *io = get_io_channel(); int length = sizeof(buf); if ( get_direction() == SG_IO_OUT ) { // cout << "size of cur_fdm_state = " << length << endl; - FGProps2NetFDMmini( &buf ); + FGProps2NetMiniFDM( &buf ); if ( ! io->write( (char *)(& buf), length ) ) { SG_LOG( SG_IO, SG_ALERT, "Error writing data." ); return false; @@ -216,12 +216,12 @@ bool FGNativeFDMmini::process() { if ( io->get_type() == sgFileType ) { if ( io->read( (char *)(& buf), length ) == length ) { SG_LOG( SG_IO, SG_DEBUG, "Success reading data." ); - FGNetFDMmini2Props( &buf ); + FGNetMiniFDM2Props( &buf ); } } else { while ( io->read( (char *)(& buf), length ) == length ) { SG_LOG( SG_IO, SG_DEBUG, "Success reading data." ); - FGNetFDMmini2Props( &buf ); + FGNetMiniFDM2Props( &buf ); } } } @@ -231,7 +231,7 @@ bool FGNativeFDMmini::process() { // close the channel -bool FGNativeFDMmini::close() { +bool FGMiniFDM::close() { SGIOChannel *io = get_io_channel(); set_enabled( false ); diff --git a/src/Network/native_fdm_mini.hxx b/src/Network/mini_fdm.hxx similarity index 69% rename from src/Network/native_fdm_mini.hxx rename to src/Network/mini_fdm.hxx index a95c1725c..aa110c529 100644 --- a/src/Network/native_fdm_mini.hxx +++ b/src/Network/mini_fdm.hxx @@ -1,4 +1,4 @@ -// native_fdm_mini.hxx -- FGFS "Mini-Native" flight dynamics protocal class +// mini_fdm.hxx -- FGFS "mini" flight dynamics protocal class // // Written by Curtis Olson, started January 2002. // @@ -21,8 +21,8 @@ // $Id$ -#ifndef _FG_NATIVE_FDM_MINI_HXX -#define _FG_NATIVE_FDM_MINI_HXX +#ifndef _FG_MINI_FDM_HXX +#define _FG_MINI_FDM_HXX #include @@ -33,15 +33,15 @@ #include "net_fdm_mini.hxx" -class FGNativeFDMmini : public FGProtocol, public FGInterface { +class FGMiniFDM : public FGProtocol, public FGInterface { - FGNetFDMmini buf; + FGNetMiniFDM buf; int length; public: - FGNativeFDMmini(); - ~FGNativeFDMmini(); + FGMiniFDM(); + ~FGMiniFDM(); // open hailing frequencies bool open(); @@ -56,13 +56,13 @@ public: // Helper functions which may be useful outside this class -// Populate the FGNetFDMmini structure from the property tree. -void FGProps2NetFDMmini( FGNetFDMmini *net ); +// Populate the FGNetMiniFDM structure from the property tree. +void FGProps2NetMiniFDM( FGNetMiniFDM *net ); -// Update the property tree from the FGNetFDMmini structure. -void FGNetFDMmini2Props( FGNetFDMmini *net ); +// Update the property tree from the FGNetMiniFDM structure. +void FGNetMiniFDM2Props( FGNetMiniFDM *net ); -#endif // _FG_NATIVE_FDM_MINI_HXX +#endif // _FG_MINI_FDM_HXX diff --git a/src/Network/net_fdm_mini.hxx b/src/Network/net_fdm_mini.hxx index 1f3e1fb78..71c922a7f 100644 --- a/src/Network/net_fdm_mini.hxx +++ b/src/Network/net_fdm_mini.hxx @@ -37,7 +37,7 @@ const int FG_NET_FDM_MINI_VERSION = 1; // Define a structure containing the top level flight dynamics model // parameters -class FGNetFDMmini { +class FGNetMiniFDM { public: -- 2.39.5