]> git.mxchange.org Git - flightgear.git/blobdiff - src/Network/native_ctrls.cxx
YASim now supports the new fuel.nas fuel management system. It
[flightgear.git] / src / Network / native_ctrls.cxx
index e9267f984e7594f66c11eed47e89c17cf0f56e8a..5261d339acdf75a23fb71490279fd80788735b66 100644 (file)
@@ -113,10 +113,10 @@ void FGProps2NetCtrls( FGNetCtrls *net, bool honor_freezes,
     net->elevator_trim = node->getDoubleValue( "elevator-trim" );
     net->rudder = node->getDoubleValue( "rudder" );
     net->flaps = node->getDoubleValue( "flaps" );
-    node = fgGetNode("/controls", true); 
     net->flaps_power
-            = node->getDoubleValue( "/systems/electrical/outputs/flaps",
-                                    1.0 ) >= 1.0;
+        = fgGetDouble( "/systems/electrical/outputs/flaps", 1.0 ) >= 1.0;
+    net->flap_motor_ok = node->getBoolValue( "flaps-serviceable" );
+
     net->num_engines = FGNetCtrls::FG_MAX_ENGINES;
     for ( i = 0; i < FGNetCtrls::FG_MAX_ENGINES; ++i ) {
         // Controls
@@ -164,21 +164,10 @@ void FGProps2NetCtrls( FGNetCtrls *net, bool honor_freezes,
             net->fuel_selector[i] = false;
         }
     }
-    net->num_wheels = FGNetCtrls::FG_MAX_WHEELS;
-    tempnode = fgGetNode("/controls/gear", true);
-    for ( i = 0; i < FGNetCtrls::FG_MAX_WHEELS; ++i ) {
-        node = fgGetNode("/controls/gear/wheel", i);
-        if ( node->getChild("brake") != NULL ) {
-            if ( tempnode->getChild("parking-brake")->getDoubleValue() > 0.0 ) {
-                net->brake[i] = 1.0;
-           } else {
-                net->brake[i]
-                    = node->getChild("brake")->getDoubleValue();
-            }
-        } else {
-            net->brake[i] = 0.0;
-        }
-    }
+    node = fgGetNode("/controls/gear", true);
+    net->brake_left = node->getChild("brake-left")->getDoubleValue();
+    net->brake_right = node->getChild("brake-right")->getDoubleValue();
+    net->brake_parking = node->getChild("brake-parking")->getDoubleValue();
 
     node = fgGetNode("/controls/switches", true);
     tempnode = node->getChild("master-bat");
@@ -199,6 +188,9 @@ void FGProps2NetCtrls( FGNetCtrls *net, bool honor_freezes,
     net->turbulence_norm =
         fgGetDouble("/environment/turbulence/magnitude-norm");
 
+    net->temp_c = fgGetDouble("/environment/temperature-degc");
+    net->press_inhg = fgGetDouble("/environment/pressure-sea-level-inhg");
+
     // cur_fdm_state->get_ground_elev_ft() is what we want ... this
     // reports the altitude of the aircraft.
     // "/environment/ground-elevation-m" reports the ground elevation
@@ -229,6 +221,7 @@ void FGProps2NetCtrls( FGNetCtrls *net, bool honor_freezes,
         htond(net->rudder);
         htond(net->flaps);
         net->flaps_power = htonl(net->flaps_power);
+        net->flap_motor_ok = htonl(net->flap_motor_ok);
         for ( i = 0; i < FGNetCtrls::FG_MAX_ENGINES; ++i ) {
             net->magnetos[i] = htonl(net->magnetos[i]);
             net->starter_power[i] = htonl(net->starter_power[i]);
@@ -248,10 +241,9 @@ void FGProps2NetCtrls( FGNetCtrls *net, bool honor_freezes,
             net->fuel_selector[i] = htonl(net->fuel_selector[i]);
         }
         net->num_tanks = htonl(net->num_tanks);
-        for ( i = 0; i < FGNetCtrls::FG_MAX_WHEELS; ++i ) {
-            htond(net->brake[i]);
-        }
-        net->num_wheels = htonl(net->num_wheels);
+        htond(net->brake_left);
+        htond(net->brake_right);
+        htond(net->brake_parking);
         net->gear_handle = htonl(net->gear_handle);
         net->master_bat = htonl(net->master_bat);
         net->master_alt = htonl(net->master_alt);
@@ -259,7 +251,9 @@ void FGProps2NetCtrls( FGNetCtrls *net, bool honor_freezes,
         htond(net->wind_speed_kt);
         htond(net->wind_dir_deg);
         htond(net->turbulence_norm);
-        htond(net->hground);
+       htond(net->temp_c);
+        htond(net->press_inhg);
+       htond(net->hground);
         htond(net->magvar);
         net->speedup = htonl(net->speedup);
         net->freeze = htonl(net->freeze);
@@ -284,6 +278,7 @@ void FGNetCtrls2Props( FGNetCtrls *net, bool honor_freezes,
         htond(net->rudder);
         htond(net->flaps);
         net->flaps_power = htonl(net->flaps_power);
+        net->flap_motor_ok = htonl(net->flap_motor_ok);
         net->num_engines = htonl(net->num_engines);
         for ( i = 0; i < net->num_engines; ++i ) {
             net->magnetos[i] = htonl(net->magnetos[i]);
@@ -303,10 +298,9 @@ void FGNetCtrls2Props( FGNetCtrls *net, bool honor_freezes,
         for ( i = 0; i < net->num_tanks; ++i ) {
             net->fuel_selector[i] = htonl(net->fuel_selector[i]);
         }
-        net->num_wheels = htonl(net->num_wheels);
-        for ( i = 0; i < net->num_wheels; ++i ) {
-            htond(net->brake[i]);
-        }
+        htond(net->brake_left);
+        htond(net->brake_right);
+        htond(net->brake_parking);
         net->gear_handle = htonl(net->gear_handle);
         net->master_bat = htonl(net->master_bat);
         net->master_alt = htonl(net->master_alt);
@@ -314,6 +308,8 @@ void FGNetCtrls2Props( FGNetCtrls *net, bool honor_freezes,
         htond(net->wind_speed_kt);
         htond(net->wind_dir_deg);
         htond(net->turbulence_norm);
+       htond(net->temp_c);
+        htond(net->press_inhg);
         htond(net->hground);
         htond(net->magvar);
         net->speedup = htonl(net->speedup);
@@ -333,8 +329,8 @@ void FGNetCtrls2Props( FGNetCtrls *net, bool honor_freezes,
     node->setDoubleValue( "elevator-trim", net->elevator_trim );
     node->setDoubleValue( "rudder", net->rudder );
     node->setDoubleValue( "flaps", net->flaps );
-
     fgSetBool( "/systems/electrical/outputs/flaps", net->flaps_power );
+    node->setBoolValue( "flaps-serviceable", net->flap_motor_ok );
 
     for ( i = 0; i < FGNetCtrls::FG_MAX_ENGINES; ++i ) {
         // Controls
@@ -368,9 +364,11 @@ void FGNetCtrls2Props( FGNetCtrls *net, bool honor_freezes,
         node->getChild( "fuel_selector" )
             ->setBoolValue( net->fuel_selector[i] );
     }
-    for ( i = 0; i < FGNetCtrls::FG_MAX_WHEELS; ++i ) {
-        node = fgGetNode( "/controls/gear/wheel", i );
-        node->getChild( "brake" )->setDoubleValue( net->brake[i] );
+    node = fgGetNode( "/controls/gear" );
+    if ( node != NULL ) {
+        node->getChild( "brake-left" )->setDoubleValue( net->brake_left );
+        node->getChild( "brake-right" )->setDoubleValue( net->brake_right );
+        node->getChild( "brake-parking" )->setDoubleValue( net->brake_parking );
     }
 
     node = fgGetNode( "/controls/gear", true );
@@ -387,6 +385,11 @@ void FGNetCtrls2Props( FGNetCtrls *net, bool honor_freezes,
     node->setDoubleValue( "turbulence/magnitude-norm", net->turbulence_norm );
     node->setBoolValue( "magnetic-variation-deg", net->magvar );
 
+    node->setDoubleValue( "/environment/temperature-degc",
+                         net->temp_c );
+    node->setDoubleValue( "/environment/pressure-sea-level-inhg",
+                         net->press_inhg );
+
     // ground elevation ???
 
     fgSetInt( "/sim/speed-up", net->speedup );