1
0
Fork 0

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.
This commit is contained in:
curt 2003-01-12 23:39:18 +00:00
parent e4b3eebdbb
commit f3d4f741f0
6 changed files with 33 additions and 27 deletions

View file

@ -46,6 +46,7 @@
# include <Network/jpg-httpd.hxx>
#endif
#include <Network/joyclient.hxx>
#include <Network/mini_fdm.hxx>
#include <Network/native.hxx>
#include <Network/native_ctrls.hxx>
#include <Network/native_fdm.hxx>
@ -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;

View file

@ -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;

View file

@ -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 \

View file

@ -35,7 +35,7 @@
#include <Main/fg_props.hxx>
#include <Main/globals.hxx>
#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 );

View file

@ -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 <simgear/compiler.h>
@ -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

View file

@ -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: