]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/ExternalNet.cxx
Added flap_deflection so that remote fdm can pass back actual flap deflection
[flightgear.git] / src / FDM / ExternalNet.cxx
index 01d565e79abfbdc5fd893f26e8020d0bc72708d4..160dc2f8370802d71b88aa2ec9b7085275b481f5 100644 (file)
@@ -74,14 +74,14 @@ static void global2raw( FGRawCtrls *raw ) {
     raw->rudder = node->getDoubleValue( "rudder" );
     raw->flaps = node->getDoubleValue( "flaps" );
     for ( i = 0; i < FGRawCtrls::FG_MAX_ENGINES; ++i ) {
-       raw->throttle[i] = node->getDoubleValue( "throttle", i );
-       raw->mixture[i] = node->getDoubleValue( "mixture", i );
-       raw->prop_advance[i] = node->getDoubleValue( "propeller-pitch", i );
-       raw->magnetos[i] = node->getIntValue( "magnetos", i );
-       raw->starter[i] = node->getBoolValue( "starter", i );
+       raw->throttle[i] = node->getDoubleValue( "throttle", 0.0 );
+       raw->mixture[i] = node->getDoubleValue( "mixture", 0.0 );
+       raw->prop_advance[i] = node->getDoubleValue( "propeller-pitch", 0.0 );
+       raw->magnetos[i] = node->getIntValue( "magnetos", 0 );
+       raw->starter[i] = node->getBoolValue( "starter", false );
     }
     for ( i = 0; i < FGRawCtrls::FG_MAX_WHEELS; ++i ) {
-       raw->brake[i] = node->getDoubleValue( "brakes", i );
+       raw->brake[i] = node->getDoubleValue( "brakes", 0.0 );
     }
     raw->hground = fgGetDouble( "/environment/ground-elevation-m" );
     raw->magvar = fgGetDouble("/environment/magnetic-variation-deg");
@@ -149,9 +149,8 @@ static void net2global( FGNetFDM *net ) {
     }
 
     net->num_wheels = htonl(net->num_wheels);
-    for ( i = 0; i < net->num_wheels; ++i ) {
-       net->wow[i] = htonl(net->wow[i]);
-    }
+    // I don't need to convert the Wow flags, since they are one byte in size
+    htond(net->flap_deflection);
 
     net->cur_time = ntohl(net->cur_time);
     net->warp = ntohl(net->warp);
@@ -214,6 +213,8 @@ static void net2global( FGNetFDM *net ) {
            node->setDoubleValue("wow", net->wow[i] );
        }
 
+        fgSetDouble("/surface-positions/flap-pos-norm", net->flap_deflection);
+
        /* these are ignored for now  ... */
        /*
        if ( net->cur_time ) {
@@ -235,7 +236,7 @@ static void net2global( FGNetFDM *net ) {
 
 FGExternalNet::FGExternalNet( double dt, string host, int dop, int dip, int cp )
 {
-    set_delta_t( dt );
+//     set_delta_t( dt );
 
     valid = true;
 
@@ -331,10 +332,13 @@ void FGExternalNet::init() {
 // Run an iteration of the EOM.  This is a NOP here because the flight
 // model values are getting filled in elsewhere (most likely from some
 // external source.)
-void FGExternalNet::update( int multiloop ) {
+void FGExternalNet::update( double dt ) {
     int length;
     int result;
 
+    if (is_suspended())
+      return;
+
     // Send control positions to remote fdm
     length = sizeof(ctrls);
     global2raw( &ctrls );