From: jmt Date: Fri, 9 Oct 2009 20:16:31 +0000 (+0000) Subject: Make GPS slaved mode on the navradio slightly more robust. Not done yet. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=bde366e0e3cf41e112752f926de12ff6bc66968b;p=flightgear.git Make GPS slaved mode on the navradio slightly more robust. Not done yet. --- diff --git a/src/Instrumentation/navradio.cxx b/src/Instrumentation/navradio.cxx index eacb7a6d6..aa238d3a9 100644 --- a/src/Instrumentation/navradio.cxx +++ b/src/Instrumentation/navradio.cxx @@ -130,6 +130,7 @@ FGNavRadio::FGNavRadio(SGPropertyNode *node) : gps_to_flag_node(NULL), gps_from_flag_node(NULL), gps_has_gs_node(NULL), + gps_xtrack_error_nm_node(NULL), play_count(0), last_time(0), target_radial(0.0), @@ -245,7 +246,8 @@ FGNavRadio::init () gps_from_flag_node = fgGetNode("/instrumentation/gps/from-flag", true); gps_has_gs_node = fgGetNode("/instrumentation/gps/has-gs", true); gps_course_node = fgGetNode("/instrumentation/gps/selected-course-deg", true); - + gps_xtrack_error_nm_node = fgGetNode("/instrumentation/gps/wp/wp[1]/course-error-nm", true); + std::ostringstream temp; temp << _name << "nav-ident" << _num; nav_fx_name = temp.str(); @@ -598,13 +600,25 @@ void FGNavRadio::updateGPSSlaved() _toFlag = gps_to_flag_node->getBoolValue(); _fromFlag = gps_from_flag_node->getBoolValue(); - inrange_node->setBoolValue(_toFlag | _fromFlag); + bool gpsValid = (_toFlag | _fromFlag); + inrange_node->setBoolValue(gpsValid); + if (!gpsValid) { + signal_quality_norm_node->setDoubleValue(0.0); + _cdiDeflection = 0.0; + _cdiCrossTrackErrorM = 0.0; + _gsNeedleDeflection = 0.0; + return; + } + + // this is unfortunate, but panel instruments use this value to decide + // if the navradio output is valid. + signal_quality_norm_node->setDoubleValue(1.0); _cdiDeflection = gps_cdi_deflection_node->getDoubleValue(); // clmap to some range (+/- 10 degrees) as the regular deflection SG_CLAMP_RANGE(_cdiDeflection, -10.0, 10.0 ); - _cdiCrossTrackErrorM = 0.0; // FIXME, supply this + _cdiCrossTrackErrorM = gps_xtrack_error_nm_node->getDoubleValue() * SG_NM_TO_METER; _gsNeedleDeflection = 0.0; // FIXME, supply this //sel_radial_node->setDoubleValue(gps_course_node->getDoubleValue()); diff --git a/src/Instrumentation/navradio.hxx b/src/Instrumentation/navradio.hxx index 760c67f20..79a2d87a8 100644 --- a/src/Instrumentation/navradio.hxx +++ b/src/Instrumentation/navradio.hxx @@ -114,7 +114,8 @@ class FGNavRadio : public SGSubsystem SGPropertyNode_ptr gps_from_flag_node; SGPropertyNode_ptr gps_has_gs_node; SGPropertyNode_ptr gps_course_node; - + SGPropertyNode_ptr gps_xtrack_error_nm_node; + // internal (private) values int play_count;