]> git.mxchange.org Git - flightgear.git/commitdiff
Fix inconsistent NAV receiver gs-inrange behaviour.
authorThorstenB <brehmt@gmail.com>
Fri, 8 Jun 2012 11:28:08 +0000 (13:28 +0200)
committerThorstenB <brehmt@gmail.com>
Fri, 8 Jun 2012 11:28:08 +0000 (13:28 +0200)
Make sure gs-inrange and deflection outputs have same behaviour, no matter
which out-of-range condition applies (i.e. aircraft moved out of range,
frequency changed, ...).

src/Instrumentation/navradio.cxx

index fe0533d8cad3f379574e032ec1541b8735eed8d5..576e074c3c156f59a4cfb2fe343fb86cee63018a 100644 (file)
@@ -453,6 +453,8 @@ void FGNavRadio::updateReceiver(double dt)
     heading_node->setDoubleValue(0.0);
     inrange_node->setBoolValue(false);
     signal_quality_norm_node->setDoubleValue(0.0);
+    gs_dist_node->setDoubleValue( 0.0 );
+    gs_inrange_node->setBoolValue(false);
     return;
   }
 
@@ -578,7 +580,7 @@ void FGNavRadio::updateReceiver(double dt)
   SG_CLAMP_RANGE(_cdiDeflection, -10.0, 10.0 );
   _cdiDeflection *= signal_quality_norm;
   
-  // cross-track error (in metres)
+  // cross-track error (in meters)
   _cdiCrossTrackErrorM = loc_dist * sin(r * SGD_DEGREES_TO_RADIANS);
   
   updateGlideSlope(dt, aircraft, signal_quality_norm);
@@ -586,22 +588,25 @@ void FGNavRadio::updateReceiver(double dt)
 
 void FGNavRadio::updateGlideSlope(double dt, const SGVec3d& aircraft, double signal_quality_norm)
 {
-  _gsNeedleDeflection = 0.0;
-  if (!_gs || !inrange_node->getBoolValue()) {
-    gs_dist_node->setDoubleValue( 0.0 );
-    gs_inrange_node->setBoolValue(false);
+  bool gsInRange = (_gs && inrange_node->getBoolValue());
+  double gsDist = 0;
+
+  if (gsInRange)
+  {
+    gsDist = dist(aircraft, _gsCart);
+    gsInRange = (gsDist < (_gs->get_range() * SG_NM_TO_METER));
+  }
+
+  gs_inrange_node->setBoolValue(gsInRange);
+  gs_dist_node->setDoubleValue( gsDist );
+
+  if (!gsInRange)
+  {
     _gsNeedleDeflection = 0.0;
     _gsNeedleDeflectionNorm = 0.0;
     return;
   }
   
-  double gsDist = dist(aircraft, _gsCart);
-  gs_dist_node->setDoubleValue(gsDist);
-  bool gsInRange = (gsDist < (_gs->get_range() * SG_NM_TO_METER));
-  gs_inrange_node->setBoolValue(gsInRange);
-        
-  if (!gsInRange) return;
-  
   SGVec3d pos = aircraft - _gsCart; // relative vector from gs antenna to aircraft
   // The positive GS axis points along the runway in the landing direction,
   // toward the far end, not toward the approach area, so we need a - sign here: