From ea543c121028ac261278b66d91f7bdb0ed1c5e9a Mon Sep 17 00:00:00 2001 From: curt Date: Wed, 15 Jan 2003 02:09:10 +0000 Subject: [PATCH] Renamed mini_fdm to native_gui which makes a lot more sense to me. --- src/Main/fg_io.cxx | 8 +- src/Main/options.cxx | 4 +- src/Network/Makefile.am | 2 +- src/Network/{mini_fdm.cxx => native_gui.cxx} | 38 +++++----- src/Network/{mini_fdm.hxx => native_gui.hxx} | 26 +++---- src/Network/net_gui.hxx | 79 ++++++++++++++++++++ 6 files changed, 118 insertions(+), 39 deletions(-) rename src/Network/{mini_fdm.cxx => native_gui.cxx} (89%) rename src/Network/{mini_fdm.hxx => native_gui.hxx} (70%) create mode 100644 src/Network/net_gui.hxx diff --git a/src/Main/fg_io.cxx b/src/Main/fg_io.cxx index b987fe6a7..397ec166d 100644 --- a/src/Main/fg_io.cxx +++ b/src/Main/fg_io.cxx @@ -46,10 +46,10 @@ # include #endif #include -#include #include #include #include +#include #include #include #include @@ -137,9 +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 == "native_gui" ) { + FGNativeGUI *net_gui = new FGNativeGUI; + io = net_gui; } else if ( protocol == "nmea" ) { FGNMEA *nmea = new FGNMEA; io = nmea; diff --git a/src/Main/options.cxx b/src/Main/options.cxx index dc55328d3..93e1a068e 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -915,8 +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(11) ); + } else if ( arg.find( "--native-gui=" ) == 0 ) { + add_channel( "native_gui", 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 5d307cd55..ffe499c79 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_gui.cxx native_gui.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/mini_fdm.cxx b/src/Network/native_gui.cxx similarity index 89% rename from src/Network/mini_fdm.cxx rename to src/Network/native_gui.cxx index 80bb4c4b8..5dbcf9520 100644 --- a/src/Network/mini_fdm.cxx +++ b/src/Network/native_gui.cxx @@ -1,8 +1,8 @@ -// native_fdm.cxx -- FGFS "Native" flight dynamics protocal class +// native_gui.cxx -- FGFS external gui data export class // -// Written by Curtis Olson, started September 2001. +// Written by Curtis Olson, started January 2002. // -// Copyright (C) 2001 Curtis L. Olson - curt@flightgear.org +// Copyright (C) 2002 Curtis L. Olson - curt@flightgear.org // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as @@ -35,7 +35,7 @@ #include
#include
-#include "mini_fdm.hxx" +#include "native_gui.hxx" // FreeBSD works better with this included last ... (?) #if defined(WIN32) && !defined(__CYGWIN__) @@ -71,15 +71,15 @@ static void htond (double &x) } -FGMiniFDM::FGMiniFDM() { +FGNativeGUI::FGNativeGUI() { } -FGMiniFDM::~FGMiniFDM() { +FGNativeGUI::~FGNativeGUI() { } // open hailing frequencies -bool FGMiniFDM::open() { +bool FGNativeGUI::open() { if ( is_enabled() ) { SG_LOG( SG_IO, SG_ALERT, "This shouldn't happen, but the channel " << "is already in use, ignoring" ); @@ -100,11 +100,11 @@ bool FGMiniFDM::open() { } -void FGProps2NetMiniFDM( FGNetMiniFDM *net ) { +void FGProps2NetGUI( FGNetGUI *net ) { int i; // Version sanity checking - net->version = FG_NET_FDM_MINI_VERSION; + net->version = FG_NET_GUI_VERSION; // Aero parameters net->longitude = cur_fdm_state->get_Longitude(); @@ -119,7 +119,7 @@ void FGProps2NetMiniFDM( FGNetMiniFDM *net ) { net->climb_rate = cur_fdm_state->get_Climb_Rate(); // Consumables - net->num_tanks = FGNetMiniFDM::FG_MAX_TANKS; + net->num_tanks = FGNetGUI::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"); @@ -151,7 +151,7 @@ void FGProps2NetMiniFDM( FGNetMiniFDM *net ) { } -void FGNetMiniFDM2Props( FGNetMiniFDM *net ) { +void FGNetGUI2Props( FGNetGUI *net ) { int i; // Convert to the net buffer from network format @@ -174,7 +174,7 @@ void FGNetMiniFDM2Props( FGNetMiniFDM *net ) { net->cur_time = ntohl(net->cur_time); net->warp = ntohl(net->warp); - if ( net->version == FG_NET_FDM_MINI_VERSION ) { + if ( net->version == FG_NET_GUI_VERSION ) { // cout << "pos = " << net->longitude << " " << net->latitude << endl; // cout << "sea level rad = " << cur_fdm_state->get_Sea_level_radius() // << endl; @@ -202,9 +202,9 @@ void FGNetMiniFDM2Props( FGNetMiniFDM *net ) { globals->set_warp( net->warp ); } else { SG_LOG( SG_IO, SG_ALERT, - "Error: version mismatch in FGNetMiniFDM2Props()" ); + "Error: version mismatch in FGNetNativeGUI2Props()" ); SG_LOG( SG_IO, SG_ALERT, - "\tread " << net->version << " need " << FG_NET_FDM_MINI_VERSION ); + "\tread " << net->version << " need " << FG_NET_GUI_VERSION ); SG_LOG( SG_IO, SG_ALERT, "\tNeed to upgrade net_fdm.hxx and recompile." ); } @@ -212,13 +212,13 @@ void FGNetMiniFDM2Props( FGNetMiniFDM *net ) { // process work for this port -bool FGMiniFDM::process() { +bool FGNativeGUI::process() { SGIOChannel *io = get_io_channel(); int length = sizeof(buf); if ( get_direction() == SG_IO_OUT ) { // cout << "size of cur_fdm_state = " << length << endl; - FGProps2NetMiniFDM( &buf ); + FGProps2NetGUI( &buf ); if ( ! io->write( (char *)(& buf), length ) ) { SG_LOG( SG_IO, SG_ALERT, "Error writing data." ); return false; @@ -227,12 +227,12 @@ bool FGMiniFDM::process() { if ( io->get_type() == sgFileType ) { if ( io->read( (char *)(& buf), length ) == length ) { SG_LOG( SG_IO, SG_DEBUG, "Success reading data." ); - FGNetMiniFDM2Props( &buf ); + FGNetGUI2Props( &buf ); } } else { while ( io->read( (char *)(& buf), length ) == length ) { SG_LOG( SG_IO, SG_DEBUG, "Success reading data." ); - FGNetMiniFDM2Props( &buf ); + FGNetGUI2Props( &buf ); } } } @@ -242,7 +242,7 @@ bool FGMiniFDM::process() { // close the channel -bool FGMiniFDM::close() { +bool FGNativeGUI::close() { SGIOChannel *io = get_io_channel(); set_enabled( false ); diff --git a/src/Network/mini_fdm.hxx b/src/Network/native_gui.hxx similarity index 70% rename from src/Network/mini_fdm.hxx rename to src/Network/native_gui.hxx index aa110c529..c92d9e6a7 100644 --- a/src/Network/mini_fdm.hxx +++ b/src/Network/native_gui.hxx @@ -1,4 +1,4 @@ -// mini_fdm.hxx -- FGFS "mini" flight dynamics protocal class +// native_gui.hxx -- FGFS external gui data export class // // Written by Curtis Olson, started January 2002. // @@ -21,8 +21,8 @@ // $Id$ -#ifndef _FG_MINI_FDM_HXX -#define _FG_MINI_FDM_HXX +#ifndef _FG_NATIVE_GUI_HXX +#define _FG_NATIVE_GUI_HXX #include @@ -30,18 +30,18 @@ #include #include "protocol.hxx" -#include "net_fdm_mini.hxx" +#include "net_gui.hxx" -class FGMiniFDM : public FGProtocol, public FGInterface { +class FGNativeGUI : public FGProtocol, public FGInterface { - FGNetMiniFDM buf; + FGNetGUI buf; int length; public: - FGMiniFDM(); - ~FGMiniFDM(); + FGNativeGUI(); + ~FGNativeGUI(); // open hailing frequencies bool open(); @@ -56,13 +56,13 @@ public: // Helper functions which may be useful outside this class -// Populate the FGNetMiniFDM structure from the property tree. -void FGProps2NetMiniFDM( FGNetMiniFDM *net ); +// Populate the FGNetGUI structure from the property tree. +void FGProps2NetGUI( FGNetGUI *net ); -// Update the property tree from the FGNetMiniFDM structure. -void FGNetMiniFDM2Props( FGNetMiniFDM *net ); +// Update the property tree from the FGNetGUI structure. +void FGNetGUI2Props( FGNetGUI *net ); -#endif // _FG_MINI_FDM_HXX +#endif // _FG_NATIVE_GUI_HXX diff --git a/src/Network/net_gui.hxx b/src/Network/net_gui.hxx new file mode 100644 index 000000000..7fb16fd98 --- /dev/null +++ b/src/Network/net_gui.hxx @@ -0,0 +1,79 @@ +// net_gui.hxx -- defines a simple subset I/O interface to the flight +// dynamics model variables +// +// Written by Curtis Olson, started January 2002. +// +// Copyright (C) 2002 Curtis L. Olson - curt@flightgear.com +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License as +// published by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// +// $Id$ + + +#ifndef _NET_GUI_HXX +#define _NET_GUI_HXX + + +#ifndef __cplusplus +# error This library requires C++ +#endif + + +const int FG_NET_GUI_VERSION = 1; + + +// Define a structure containing the top level flight dynamics model +// parameters + +class FGNetGUI { + +public: + + enum { + FG_MAX_ENGINES = 4, + FG_MAX_WHEELS = 3, + FG_MAX_TANKS = 4 + }; + + int version; // increment when data values change + int pad; // keep doubles 64-bit aligned for some + // hardware platforms, such as the Sun + // SPARC, which don't like misaligned + // data + + // Positions + double longitude; // geodetic (radians) + double latitude; // geodetic (radians) + double altitude; // above sea level (meters) + double agl; // above ground level (meters) + double phi; // roll (radians) + double theta; // pitch (radians) + double psi; // yaw or true heading (radians) + + // Velocities + double vcas; + double climb_rate; // feet per second + + // Consumables + int num_tanks; // Max number of fuel tanks + double fuel_quantity[FG_MAX_TANKS]; + + // Environment + time_t cur_time; // current unix time + long int warp; // offset in seconds to unix time +}; + + +#endif // _NET_GUI_HXX -- 2.39.5