From db09e11ba0b70e3897b1db94d31b421e5dabc394 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Fri, 8 Jun 2012 13:28:08 +0200 Subject: [PATCH] Fix inconsistent NAV receiver gs-inrange behaviour. 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 | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/Instrumentation/navradio.cxx b/src/Instrumentation/navradio.cxx index fe0533d8c..576e074c3 100644 --- a/src/Instrumentation/navradio.cxx +++ b/src/Instrumentation/navradio.cxx @@ -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: