]> git.mxchange.org Git - flightgear.git/commitdiff
Changes to better support arbitrary external flight models.
authorcurt <curt>
Tue, 4 Sep 2001 14:38:15 +0000 (14:38 +0000)
committercurt <curt>
Tue, 4 Sep 2001 14:38:15 +0000 (14:38 +0000)
src/FDM/flight.cxx
src/FDM/flight.hxx
src/Main/fg_io.cxx
src/Main/options.cxx
src/Network/Makefile.am
src/Network/native_ctrls.cxx
src/Network/raw_ctrls.hxx

index 1caf20c99885648d04d7eb726ada81a615a22a41..1c16f7c4f3b56132d2c7e9adf1ce7ddcd26412ad 100644 (file)
@@ -405,6 +405,8 @@ bool FGInterface::update( int multi_loop ) {
 void FGInterface::_updatePosition( double lat_geoc, double lon, double alt ) {
     double lat_geod, tmp_alt, sl_radius1, sl_radius2, tmp_lat_geoc;
        
+    // cout << "starting sea level rad = " << get_Sea_level_radius() << endl;
+
     sgGeocToGeod( lat_geoc, ( get_Sea_level_radius() + alt ) * SG_FEET_TO_METER,
                  &lat_geod, &tmp_alt, &sl_radius1 );
     sgGeodToGeoc( lat_geod, alt * SG_FEET_TO_METER, &sl_radius2, &tmp_lat_geoc );
index a09520f2d44148b147b76bd20a317f4b4e471d90..d8ad9624f9f8f6761c33daa07ebe15a2aec388cf 100644 (file)
@@ -285,7 +285,8 @@ private:
     // SGTimeStamp valid_stamp;          // time this record is valid
     // SGTimeStamp next_stamp;           // time this record is valid
 
-protected:
+// protected:
+public:
 
                                // deliberately not virtual so that
                                // FGInterface constructor will call
index 9760f83e6ae925ef2fa1ac9bb00fa4915ca71728..498bdf3f0068e3191879b390ea1b43accdcc967f 100644 (file)
@@ -42,6 +42,7 @@
 #include <Network/joyclient.hxx>
 #include <Network/native.hxx>
 #include <Network/native_ctrls.hxx>
+#include <Network/native_fdm.hxx>
 #include <Network/nmea.hxx>
 #include <Network/props.hxx>
 #include <Network/pve.hxx>
@@ -100,6 +101,9 @@ static FGProtocol *parse_port_config( const string& config )
     } else if ( protocol == "native_ctrls" ) {
        FGNativeCtrls *native_ctrls = new FGNativeCtrls;
        io = native_ctrls;
+    } else if ( protocol == "native_fdm" ) {
+       FGNativeFDM *native_fdm = new FGNativeFDM;
+       io = native_fdm;
     } else if ( protocol == "nmea" ) {
        FGNMEA *nmea = new FGNMEA;
        io = nmea;
index 770fce0a16180d3066d18efb8699185e09c11661..4acf21ed1b3af4186b057e303160515ae8677260 100644 (file)
@@ -796,6 +796,8 @@ parse_option (const string& arg)
        add_channel( "native", arg.substr(9) );
     } else if ( arg.find( "--native-ctrls=" ) == 0 ) {
        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( "--garmin=" ) == 0 ) {
        add_channel( "garmin", arg.substr(9) );
     } else if ( arg.find( "--nmea=" ) == 0 ) {
index c0f6ce2c100aa46d0e90a6d28846d66b7d82520a..361da9c30c93b96b033050b47afdfb7ba4cd14e1 100644 (file)
@@ -8,10 +8,11 @@ libNetwork_a_SOURCES = \
        joyclient.cxx joyclient.hxx \
        native.cxx native.hxx \
        native_ctrls.cxx native_ctrls.hxx \
+       native_fdm.cxx native_fdm.hxx \
        nmea.cxx nmea.hxx \
        props.cxx props.hxx \
        pve.cxx pve.hxx \
-       raw_ctrls.hxx \
+       raw_ctrls.hxx raw_fdm.hxx \
        ray.cxx ray.hxx \
        rul.cxx rul.hxx
 
index 27f7b3694e9081bfa0f7d3eb0714fd2b70c65346..2cc20ff5f56c50e3755f69ccc2556cd5eb8c0b9c 100644 (file)
@@ -55,9 +55,10 @@ bool FGNativeCtrls::open() {
 }
 
 
-static void global2raw( FGControls *global, FGRawCtrls *raw ) {
+static void global2raw( const FGControls *global, FGRawCtrls *raw ) {
     int i;
 
+    raw->version = FG_RAW_CTRLS_VERSION;
     raw->aileron = globals->get_controls()->get_aileron();
     raw->elevator = globals->get_controls()->get_elevator();
     raw->elevator_trim = globals->get_controls()->get_elevator_trim();
@@ -74,21 +75,27 @@ static void global2raw( FGControls *global, FGRawCtrls *raw ) {
 }
 
 
-static void raw2global( FGRawCtrls *raw, FGControls *global ) {
+static void raw2global( const FGRawCtrls *raw, FGControls *global ) {
     int i;
 
-    globals->get_controls()->set_aileron( raw->aileron );
-    globals->get_controls()->set_elevator( raw->elevator );
-    globals->get_controls()->set_elevator_trim( raw->elevator_trim );
-    globals->get_controls()->set_rudder( raw->rudder );
-    globals->get_controls()->set_flaps( raw->flaps );
-    for ( i = 0; i < FG_MAX_ENGINES; ++i ) {    
-       globals->get_controls()->set_throttle( i, raw->throttle[i] );
-       globals->get_controls()->set_mixture( i, raw->mixture[i] );
-       globals->get_controls()->set_prop_advance( i, raw->prop_advance[i] );
-    }
-    for ( i = 0; i < FG_MAX_WHEELS; ++i ) {
-       globals->get_controls()->set_brake( i, raw->brake[i] );
+    if ( raw->version == FG_RAW_CTRLS_VERSION ) {
+       globals->get_controls()->set_aileron( raw->aileron );
+       globals->get_controls()->set_elevator( raw->elevator );
+       globals->get_controls()->set_elevator_trim( raw->elevator_trim );
+       globals->get_controls()->set_rudder( raw->rudder );
+       globals->get_controls()->set_flaps( raw->flaps );
+       for ( i = 0; i < FG_MAX_ENGINES; ++i ) {    
+           globals->get_controls()->set_throttle( i, raw->throttle[i] );
+           globals->get_controls()->set_mixture( i, raw->mixture[i] );
+           globals->get_controls()->set_prop_advance( i, raw->prop_advance[i]);
+       }
+       for ( i = 0; i < FG_MAX_WHEELS; ++i ) {
+           globals->get_controls()->set_brake( i, raw->brake[i] );
+       }
+    } else {
+       SG_LOG( SG_IO, SG_ALERT, "Error: version mismatch in raw2global()" );
+       SG_LOG( SG_IO, SG_ALERT,
+               "\tsomeone needs to upgrade raw_ctrls.hxx and recompile." );
     }
 }
 
index fd0b1452979809a97df3da5ceea451c39cbaf67c..dafedece8875eb2f3d9d9419f6f64b78d252ec53 100644 (file)
@@ -30,6 +30,7 @@
 # error This library requires C++
 #endif                                   
 
+const int FG_RAW_CTRLS_VERSION = 1;
 
 const int FG_MAX_ENGINES = 10;
 const int FG_MAX_WHEELS = 3;
@@ -40,6 +41,7 @@ class FGRawCtrls {
 
 public:
 
+    int version;                        // increment when data values change
     double aileron;                     // -1 ... 1
     double elevator;                    // -1 ... 1
     double elevator_trim;               // -1 ... 1