]> git.mxchange.org Git - flightgear.git/commitdiff
Make GPS slaved mode on the navradio slightly more robust. Not done yet.
authorjmt <jmt>
Fri, 9 Oct 2009 20:16:31 +0000 (20:16 +0000)
committerTim Moore <timoore@redhat.com>
Mon, 12 Oct 2009 05:55:51 +0000 (07:55 +0200)
src/Instrumentation/navradio.cxx
src/Instrumentation/navradio.hxx

index eacb7a6d67fe27d2d6fb3bc55c9fb32659f47766..aa238d3a9c0ba77775911a4b97795f7d8be65883 100644 (file)
@@ -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());
index 760c67f20e330ad46d84f8e2abf15d257c796a05..79a2d87a89d11a1c702b720480ae008dad49f65d 100644 (file)
@@ -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;