]> git.mxchange.org Git - flightgear.git/commitdiff
A couple fixes to the network fdm interface.
authorcurt <curt>
Tue, 30 Jul 2002 04:37:16 +0000 (04:37 +0000)
committercurt <curt>
Tue, 30 Jul 2002 04:37:16 +0000 (04:37 +0000)
src/FDM/ExternalNet.cxx
src/Main/main.cxx
src/Network/raw_ctrls.hxx

index 47a1d2afdd7ffba3ce0f1735626132ab39bc3e43..97591c4d0a701de5c1f1cce51412ad00aae898ee 100644 (file)
@@ -73,6 +73,7 @@ static void global2raw( FGRawCtrls *raw ) {
     raw->elevator_trim = node->getDoubleValue( "elevator-trim" );
     raw->rudder = node->getDoubleValue( "rudder" );
     raw->flaps = node->getDoubleValue( "flaps" );
+    raw->num_engines = FGRawCtrls::FG_MAX_ENGINES;
     for ( i = 0; i < FGRawCtrls::FG_MAX_ENGINES; ++i ) {
        raw->throttle[i] = node->getDoubleValue( "throttle", 0.0 );
        raw->mixture[i] = node->getDoubleValue( "mixture", 0.0 );
@@ -87,11 +88,23 @@ static void global2raw( FGRawCtrls *raw ) {
          //      << endl;
        }
     }
+    raw->num_tanks = FGRawCtrls::FG_MAX_TANKS;
     for ( i = 0; i < FGRawCtrls::FG_MAX_TANKS; ++i ) {
-        raw->fuel_selector[i] = node->getDoubleValue( "fuel-selector", true );
+        if ( node->getChild("fuel-selector", i) != 0 ) {
+            raw->fuel_selector[i]
+                = node->getChild("fuel-selector", i)->getDoubleValue();
+        } else {
+            raw->fuel_selector[i] = false;
+        }
     }
+    raw->num_wheels = FGRawCtrls::FG_MAX_WHEELS;
     for ( i = 0; i < FGRawCtrls::FG_MAX_WHEELS; ++i ) {
-       raw->brake[i] = node->getDoubleValue( "brakes", 0.0 );
+        if ( node->getChild("brakes", i) != 0 ) {
+            raw->brake[i]
+                = node->getChild("brakes", i)->getDoubleValue();
+        } else {
+            raw->brake[i] = 0.0;
+        }
     }
     raw->hground = fgGetDouble( "/environment/ground-elevation-m" );
     raw->magvar = fgGetDouble("/environment/magnetic-variation-deg");
@@ -111,12 +124,15 @@ static void global2raw( FGRawCtrls *raw ) {
        raw->magnetos[i] = htonl(raw->magnetos[i]);
        raw->starter[i] = htonl(raw->starter[i]);
     }
+    raw->num_engines = htonl(raw->num_engines);
     for ( i = 0; i < FGRawCtrls::FG_MAX_TANKS; ++i ) {
         raw->fuel_selector[i] = htonl(raw->fuel_selector[i]);
     }
+    raw->num_tanks = htonl(raw->num_tanks);
     for ( i = 0; i < FGRawCtrls::FG_MAX_WHEELS; ++i ) {
        htond(raw->brake[i]);
     }
+    raw->num_wheels = htonl(raw->num_wheels);
     htond(raw->hground);
     htond(raw->magvar);
     raw->speedup = htonl(raw->speedup);
@@ -364,6 +380,8 @@ void FGExternalNet::update( double dt ) {
     global2raw( &ctrls );
     if ( data_client.send( (char *)(& ctrls), length, 0 ) != length ) {
        SG_LOG( SG_IO, SG_ALERT, "Error writing data." );
+    } else {
+       SG_LOG( SG_IO, SG_ALERT, "wrote control data." );
     }
 
     // Read next set of FDM data (blocking enabled to maintain 'sync')
index 67ec3f159721b6cd643984497f3bd4ffe57be7ce..765997437fb01626852b486c909992212b1c8720 100644 (file)
@@ -72,6 +72,7 @@ SG_USING_STD(endl);
 
 #include <plib/netChat.h>
 #include <plib/pu.h>
+#include <plib/sg.h>
 #include <plib/ssg.h>
 
 #include <simgear/constants.h>  // for VERSION
index 576197af899776a9c59472a32e51d3009bcda183..579c3a51b3ab2d7196685b334a33043e475a1f0f 100644 (file)
@@ -30,7 +30,7 @@
 # error This library requires C++
 #endif                                   
 
-const int FG_RAW_CTRLS_VERSION = 7;
+const int FG_RAW_CTRLS_VERSION = 8;
 
 
 // Define a structure containing the control parameters