]> git.mxchange.org Git - flightgear.git/commitdiff
Navradio: provide property is-localizer-frequency
authorTorsten Dreyer <Torsten@t3r.de>
Wed, 15 Feb 2012 21:43:15 +0000 (22:43 +0100)
committerTorsten Dreyer <Torsten@t3r.de>
Wed, 15 Feb 2012 21:43:15 +0000 (22:43 +0100)
This property is true if the active frequency is tuned to a
paired LOC/GS frequency in the range 108.00 - 111.95 with a
odd 100kHz digit (108.10, 108.15, 108.30, 108.35 ...)
It only indicates, that this _is_ a LOC/GS frequency,
it does _not_ provide any indication if a LOC/GS station is
actually being received.

src/Instrumentation/navradio.cxx
src/Instrumentation/navradio.hxx

index 076839c36362ab147b1df84202c9f3a2e8e6b735..bc45c6944d99d85d01c4e5dc318114e68123a457 100644 (file)
@@ -201,6 +201,7 @@ FGNavRadio::init ()
     alt_freq_node = subnode->getChild("standby-mhz", 0, true);
     fmt_freq_node = subnode->getChild("selected-mhz-fmt", 0, true);
     fmt_alt_freq_node = subnode->getChild("standby-mhz-fmt", 0, true);
+    is_loc_freq_node = subnode->getChild("is-localizer-frequency", 0, true );
 
     // radials
     subnode = node->getChild("radials", 0, true);
@@ -346,6 +347,16 @@ double FGNavRadio::adjustILSRange( double stationElev, double aircraftElev,
     return FG_LOC_DEFAULT_RANGE;
 }
 
+// Frequencies with odd 100kHz numbers in the range from 108.00 - 111.95
+// are LOC/GS (ILS) frequency pairs
+// (108.00, 108.05, 108.20, 108.25.. =VOR)
+// (108.10, 108.15, 108.30, 108.35.. =ILS)
+static inline bool IsLocalizerFrequency( double f )
+{
+  if( f < 108.0 || f >= 112.00 ) return false;
+  return (((SGMiscd::roundToInt(f * 100.0) % 100)/10) % 2) != 0;
+}
+
 
 //////////////////////////////////////////////////////////////////////////
 // Update the various nav values based on position and valid tuned in navs
@@ -364,6 +375,7 @@ FGNavRadio::update(double dt)
   fmt_freq_node->setStringValue(tmp);
   sprintf( tmp, "%.2f", alt_freq_node->getDoubleValue() );
   fmt_alt_freq_node->setStringValue(tmp);
+  is_loc_freq_node->setBoolValue( IsLocalizerFrequency( freq_node->getDoubleValue() ));
 
   if (power_btn_node->getBoolValue() 
       && (bus_power_node->getDoubleValue() > 1.0)
index 54c2e531edd175f222a6325e4e65f3fd657a9dda..17ac3b092b4c56f685f68525c7b1fe53efd68849 100644 (file)
@@ -53,6 +53,7 @@ class FGNavRadio : public SGSubsystem, public SGPropertyChangeListener
     SGPropertyNode_ptr power_btn_node;
     SGPropertyNode_ptr freq_node;       // primary freq
     SGPropertyNode_ptr alt_freq_node;   // standby freq
+    SGPropertyNode_ptr is_loc_freq_node;// is the primary freq a loc/gs (paired) freq?
     SGPropertyNode_ptr sel_radial_node; // selected radial
     SGPropertyNode_ptr vol_btn_node;
     SGPropertyNode_ptr ident_btn_node;