1 // navcom.cxx -- class to manage a navcom instance
3 // Written by Curtis Olson, started April 2000.
5 // Copyright (C) 2000 - 2002 Curtis L. Olson - curt@flightgear.org
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #include <stdio.h> // snprintf
30 #include <simgear/compiler.h>
31 #include <simgear/math/sg_random.h>
32 #include <simgear/math/vector.hxx>
34 #include <Aircraft/aircraft.hxx>
35 #include <Navaids/ilslist.hxx>
36 #include <Navaids/navlist.hxx>
37 #include <Time/FGEventMgr.hxx>
46 FGNavCom::FGNavCom() :
47 lon_node(fgGetNode("/position/longitude-deg", true)),
48 lat_node(fgGetNode("/position/latitude-deg", true)),
49 alt_node(fgGetNode("/position/altitude-ft", true)),
66 SGPath path( globals->get_fg_root() );
68 term.append( "Navaids/range.term" );
70 low.append( "Navaids/range.low" );
72 high.append( "Navaids/range.high" );
74 term_tbl = new SGInterpTable( term.str() );
75 low_tbl = new SGInterpTable( low.str() );
76 high_tbl = new SGInterpTable( high.str() );
95 // We assume that index is valid now (it must be set before init()
98 // FIXME: Get rid of snprintf
100 snprintf(propname, 256, "/systems/electrical/outputs/navcom[%d]", index);
101 // default to true in case no electrical system defined.
102 fgSetDouble( propname, 60.0 );
103 bus_power = fgGetNode( propname, true );
105 snprintf(propname, 256, "/instrumentation/comm[%d]/servicable", index);
106 com_servicable = fgGetNode( propname, true );
107 com_servicable->setBoolValue( true );
109 snprintf(propname, 256, "/instrumentation/nav[%d]/servicable", index);
110 nav_servicable = fgGetNode( propname, true );
111 nav_servicable->setBoolValue( true );
113 snprintf(propname, 256, "/instrumentation/vor[%d]/cdi/servicable", index);
114 cdi_servicable = fgGetNode( propname, true );
115 cdi_servicable->setBoolValue( true );
117 snprintf(propname, 256, "/instrumentation/vor[%d]/gs/servicable", index);
118 gs_servicable = fgGetNode( propname, true );
119 gs_servicable->setBoolValue( true );
121 snprintf(propname, 256, "/instrumentation/vor[%d]/to-from/servicable", index);
122 tofrom_servicable = fgGetNode( propname, true );
123 tofrom_servicable->setBoolValue( true );
130 // FIXME: Get rid of snprintf
133 snprintf(propname, 256, "/radios/comm[%d]/inputs/power-btn", index);
134 fgTie( propname, this,
135 &FGNavCom::get_power_btn, &FGNavCom::set_power_btn );
136 fgSetArchivable( propname );
138 snprintf(propname, 256, "/radios/comm[%d]/frequencies/selected-mhz", index);
139 fgTie( propname, this, &FGNavCom::get_comm_freq, &FGNavCom::set_comm_freq );
140 fgSetArchivable( propname );
142 snprintf(propname, 256, "/radios/comm[%d]/frequencies/standby-mhz", index);
143 fgTie( propname, this,
144 &FGNavCom::get_comm_alt_freq, &FGNavCom::set_comm_alt_freq );
145 fgSetArchivable( propname );
147 snprintf(propname, 256, "/radios/comm[%d]/volume", index);
148 fgTie( propname, this,
149 &FGNavCom::get_comm_vol_btn, &FGNavCom::set_comm_vol_btn );
150 fgSetArchivable( propname );
152 snprintf(propname, 256, "/radios/nav[%d]/frequencies/selected-mhz", index);
153 fgTie( propname, this,
154 &FGNavCom::get_nav_freq, &FGNavCom::set_nav_freq );
155 fgSetArchivable( propname );
157 snprintf(propname, 256, "/radios/nav[%d]/frequencies/standby-mhz", index);
158 fgTie( propname , this,
159 &FGNavCom::get_nav_alt_freq, &FGNavCom::set_nav_alt_freq);
160 fgSetArchivable( propname );
162 snprintf(propname, 256, "/radios/nav[%d]/radials/selected-deg", index);
163 fgTie( propname, this,
164 &FGNavCom::get_nav_sel_radial, &FGNavCom::set_nav_sel_radial );
165 fgSetArchivable( propname );
167 snprintf(propname, 256, "/radios/nav[%d]/volume", index);
168 fgTie( propname, this,
169 &FGNavCom::get_nav_vol_btn, &FGNavCom::set_nav_vol_btn );
170 fgSetArchivable( propname );
172 snprintf(propname, 256, "/radios/nav[%d]/ident", index);
173 fgTie( propname, this,
174 &FGNavCom::get_nav_ident_btn, &FGNavCom::set_nav_ident_btn );
175 fgSetArchivable( propname );
178 snprintf(propname, 256, "/radios/nav[%d]/audio-btn", index);
179 fgTie( propname, this,
180 &FGNavCom::get_audio_btn, &FGNavCom::set_audio_btn );
181 fgSetArchivable( propname );
183 snprintf(propname, 256, "/radios/nav[%d]/radials/actual-deg", index);
184 fgTie( propname, this, &FGNavCom::get_nav_radial );
186 snprintf(propname, 256, "/radios/nav[%d]/to-flag", index);
187 fgTie( propname, this, &FGNavCom::get_nav_to_flag );
189 snprintf(propname, 256, "/radios/nav[%d]/from-flag", index);
190 fgTie( propname, this, &FGNavCom::get_nav_from_flag );
192 snprintf(propname, 256, "/radios/nav[%d]/in-range", index);
193 fgTie( propname, this, &FGNavCom::get_nav_inrange );
195 snprintf(propname, 256, "/radios/nav[%d]/heading-needle-deflection", index);
196 fgTie( propname, this, &FGNavCom::get_nav_heading_needle_deflection );
198 snprintf(propname, 256, "/radios/nav[%d]/has-gs", index);
199 fgTie( propname, this, &FGNavCom::get_nav_has_gs );
201 snprintf(propname, 256, "/radios/nav[%d]/gs-needle-deflection", index);
202 fgTie( propname, this, &FGNavCom::get_nav_gs_needle_deflection );
204 snprintf(propname, 256, "/radios/nav[%d]/nav-id", index);
205 fgTie( propname, this, &FGNavCom::get_nav_id );
207 // put nav_id characters into seperate properties for instrument displays
208 snprintf(propname, 256, "/radios/nav[%d]/nav-id_asc1", index);
209 fgTie( propname, this, &FGNavCom::get_nav_id_c1 );
211 snprintf(propname, 256, "/radios/nav[%d]/nav-id_asc2", index);
212 fgTie( propname, this, &FGNavCom::get_nav_id_c2 );
214 snprintf(propname, 256, "/radios/nav[%d]/nav-id_asc3", index);
215 fgTie( propname, this, &FGNavCom::get_nav_id_c3 );
217 snprintf(propname, 256, "/radios/nav[%d]/nav-id_asc4", index);
218 fgTie( propname, this, &FGNavCom::get_nav_id_c4 );
228 // FIXME: Get rid of snprintf
230 snprintf(propname, 256, "/radios/comm[%d]/inputs/power-btn", index);
232 snprintf(propname, 256, "/radios/comm[%d]/frequencies/selected-mhz", index);
234 snprintf(propname, 256, "/radios/comm[%d]/frequencies/standby-mhz", index);
237 snprintf(propname, 256, "/radios/nav[%d]/frequencies/selected-mhz", index);
239 snprintf(propname, 256, "/radios/nav[%d]/frequencies/standby-mhz", index);
241 snprintf(propname, 256, "/radios/nav[%d]/radials/actual-deg", index);
243 snprintf(propname, 256, "/radios/nav[%d]/radials/selected-deg", index);
245 snprintf(propname, 256, "/radios/nav[%d]/ident", index);
247 snprintf(propname, 256, "/radios/nav[%d]/to-flag", index);
249 snprintf(propname, 256, "/radios/nav[%d]/from-flag", index);
251 snprintf(propname, 256, "/radios/nav[%d]/in-range", index);
253 snprintf(propname, 256, "/radios/nav[%d]/heading-needle-deflection", index);
255 snprintf(propname, 256, "/radios/nav[%d]/gs-needle-deflection", index);
260 // model standard VOR/DME/TACAN service volumes as per AIM 1-1-8
261 double FGNavCom::adjustNavRange( double stationElev, double aircraftElev,
262 double nominalRange )
264 // extend out actual usable range to be 1.3x the published safe range
265 const double usability_factor = 1.3;
267 // assumptions we model the standard service volume, plus
268 // ... rather than specifying a cylinder, we model a cone that
269 // contains the cylinder. Then we put an upside down cone on top
270 // to model diminishing returns at too-high altitudes.
272 // altitude difference
273 double alt = ( aircraftElev * SG_METER_TO_FEET - stationElev );
274 // cout << "aircraft elev = " << aircraftElev * SG_METER_TO_FEET
275 // << " station elev = " << stationElev << endl;
277 if ( nominalRange < 25.0 + SG_EPSILON ) {
278 // Standard Terminal Service Volume
279 return term_tbl->interpolate( alt ) * usability_factor;
280 } else if ( nominalRange < 50.0 + SG_EPSILON ) {
281 // Standard Low Altitude Service Volume
282 // table is based on range of 40, scale to actual range
283 return low_tbl->interpolate( alt ) * nominalRange / 40.0
286 // Standard High Altitude Service Volume
287 // table is based on range of 130, scale to actual range
288 return high_tbl->interpolate( alt ) * nominalRange / 130.0
294 // model standard ILS service volumes as per AIM 1-1-9
295 double FGNavCom::adjustILSRange( double stationElev, double aircraftElev,
296 double offsetDegrees, double distance )
298 // assumptions we model the standard service volume, plus
300 // altitude difference
301 // double alt = ( aircraftElev * SG_METER_TO_FEET - stationElev );
302 // double offset = fabs( offsetDegrees );
304 // if ( offset < 10 ) {
305 // return FG_ILS_DEFAULT_RANGE;
306 // } else if ( offset < 35 ) {
307 // return 10 + (35 - offset) * (FG_ILS_DEFAULT_RANGE - 10) / 25;
308 // } else if ( offset < 45 ) {
309 // return (45 - offset);
310 // } else if ( offset > 170 ) {
311 // return FG_ILS_DEFAULT_RANGE;
312 // } else if ( offset > 145 ) {
313 // return 10 + (offset - 145) * (FG_ILS_DEFAULT_RANGE - 10) / 25;
314 // } else if ( offset > 135 ) {
315 // return (offset - 135);
319 return FG_ILS_DEFAULT_RANGE;
323 // Update the various nav values based on position and valid tuned in navs
325 FGNavCom::update(double dt)
327 double lon = lon_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
328 double lat = lat_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
329 double elev = alt_node->getDoubleValue() * SG_FEET_TO_METER;
333 Point3D aircraft = sgGeodToCart( Point3D( lon, lat, elev ) );
337 ////////////////////////////////////////////////////////////////////////
339 ////////////////////////////////////////////////////////////////////////
341 if ( nav_valid && power_btn && (bus_power->getDoubleValue() > 1.0)
342 && nav_servicable->getBoolValue() )
344 station = Point3D( nav_x, nav_y, nav_z );
345 nav_loc_dist = aircraft.distance3D( station );
348 // find closest distance to the gs base line
350 sgdSetVec3( p, aircraft.x(), aircraft.y(), aircraft.z() );
352 sgdSetVec3( p0, nav_gs_x, nav_gs_y, nav_gs_z );
353 double dist = sgdClosestPointToLineDistSquared( p, p0,
355 nav_gs_dist = sqrt( dist );
356 // cout << nav_gs_dist;
358 // Point3D tmp( nav_gs_x, nav_gs_y, nav_gs_z );
359 // cout << " (" << aircraft.distance3D( tmp ) << ")" << endl;
361 // wgs84 heading to glide slope (to determine sign of distance)
362 geo_inverse_wgs_84( elev,
363 lat * SGD_RADIANS_TO_DEGREES,
364 lon * SGD_RADIANS_TO_DEGREES,
365 nav_gslat, nav_gslon,
367 double r = az1 - nav_radial;
368 while ( r > 180.0 ) { r -= 360.0;}
369 while ( r < -180.0 ) { r += 360.0;}
370 if ( r >= -90.0 && r <= 90.0 ) {
371 nav_gs_dist_signed = nav_gs_dist;
373 nav_gs_dist_signed = -nav_gs_dist;
375 /* cout << "Target Radial = " << nav_radial
376 << " Bearing = " << az1
377 << " dist (signed) = " << nav_gs_dist_signed
384 // wgs84 heading to localizer
385 geo_inverse_wgs_84( elev,
386 lat * SGD_RADIANS_TO_DEGREES,
387 lon * SGD_RADIANS_TO_DEGREES,
388 nav_loclat, nav_loclon,
390 // cout << "az1 = " << az1 << " magvar = " << nav_magvar << endl;
391 nav_heading = az1 - nav_magvar;
392 // cout << " heading = " << nav_heading
393 // << " dist = " << nav_dist << endl;
396 double offset = nav_heading - nav_radial;
397 while ( offset < -180.0 ) { offset += 360.0; }
398 while ( offset > 180.0 ) { offset -= 360.0; }
399 // cout << "ils offset = " << offset << endl;
400 nav_effective_range = adjustILSRange(nav_elev, elev, offset,
401 nav_loc_dist * SG_METER_TO_NM );
403 nav_effective_range = adjustNavRange(nav_elev, elev, nav_range);
405 // cout << "nav range = " << nav_effective_range
406 // << " (" << nav_range << ")" << endl;
408 if ( nav_loc_dist < nav_effective_range * SG_NM_TO_METER ) {
410 } else if ( nav_loc_dist < 2 * nav_effective_range * SG_NM_TO_METER ) {
411 nav_inrange = sg_random() <
412 ( 2 * nav_effective_range * SG_NM_TO_METER - nav_loc_dist ) /
413 (nav_effective_range * SG_NM_TO_METER);
419 nav_radial = nav_sel_radial;
423 // cout << "not picking up vor. :-(" << endl;
426 if ( nav_valid && nav_inrange && nav_servicable->getBoolValue() ) {
427 // play station ident via audio system if on + ident,
428 // otherwise turn it off
429 if ( power_btn && (bus_power->getDoubleValue() > 1.0)
430 && nav_ident_btn && audio_btn )
432 SGSimpleSound *sound;
433 sound = globals->get_soundmgr()->find( nav_fx_name );
434 if ( sound != NULL ) {
435 sound->set_volume( nav_vol_btn );
437 SG_LOG( SG_COCKPIT, SG_ALERT,
438 "Can't find nav-vor-ident sound" );
440 sound = globals->get_soundmgr()->find( dme_fx_name );
441 if ( sound != NULL ) {
442 sound->set_volume( nav_vol_btn );
444 SG_LOG( SG_COCKPIT, SG_ALERT,
445 "Can't find nav-dme-ident sound" );
447 // cout << "nav_last_time = " << nav_last_time << " ";
448 // cout << "cur_time = "
449 // << globals->get_time_params()->get_cur_time();
451 globals->get_time_params()->get_cur_time() - 30 ) {
452 nav_last_time = globals->get_time_params()->get_cur_time();
455 // cout << " nav_play_count = " << nav_play_count << endl;
456 // cout << "playing = "
457 // << globals->get_soundmgr()->is_playing(nav_fx_name)
459 if ( nav_play_count < 4 ) {
461 if ( !globals->get_soundmgr()->is_playing(nav_fx_name) ) {
462 globals->get_soundmgr()->play_once( nav_fx_name );
465 } else if ( nav_play_count < 5 && nav_has_dme ) {
467 if ( !globals->get_soundmgr()->is_playing(nav_fx_name) &&
468 !globals->get_soundmgr()->is_playing(dme_fx_name) ) {
469 globals->get_soundmgr()->play_once( dme_fx_name );
474 globals->get_soundmgr()->stop( nav_fx_name );
475 globals->get_soundmgr()->stop( dme_fx_name );
481 // Update current nav/adf radio stations based on current postition
482 void FGNavCom::search()
484 double lon = lon_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
485 double lat = lat_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
486 double elev = alt_node->getDoubleValue() * SG_FEET_TO_METER;
491 ////////////////////////////////////////////////////////////////////////
493 ////////////////////////////////////////////////////////////////////////
495 if ( (ils = current_ilslist->findByFreq(nav_freq, lon, lat, elev)) != NULL ) {
496 nav_id = ils->get_locident();
498 if ( last_nav_id != nav_id || last_nav_vor ) {
499 nav_trans_ident = ils->get_trans_ident();
500 last_nav_id = nav_id;
501 last_nav_vor = false;
503 nav_has_dme = ils->get_has_dme();
504 nav_has_gs = ils->get_has_gs();
506 nav_loclon = ils->get_loclon();
507 nav_loclat = ils->get_loclat();
508 nav_gslon = ils->get_gslon();
509 nav_gslat = ils->get_gslat();
510 nav_elev = ils->get_gselev();
512 nav_range = FG_ILS_DEFAULT_RANGE;
513 nav_effective_range = nav_range;
514 nav_target_gs = ils->get_gsangle();
515 nav_radial = ils->get_locheading();
516 while ( nav_radial < 0.0 ) { nav_radial += 360.0; }
517 while ( nav_radial > 360.0 ) { nav_radial -= 360.0; }
518 nav_x = ils->get_x();
519 nav_y = ils->get_y();
520 nav_z = ils->get_z();
521 nav_gs_x = ils->get_gs_x();
522 nav_gs_y = ils->get_gs_y();
523 nav_gs_z = ils->get_gs_z();
525 // derive GS baseline
526 double tlon, tlat, taz;
527 geo_direct_wgs_84 ( 0.0, nav_gslat, nav_gslon, nav_radial + 90,
528 100.0, &tlat, &tlon, &taz );
529 // cout << nav_gslon << "," << nav_gslat << " "
530 // << tlon << "," << tlat << " (" << nav_elev << ")" << endl;
531 Point3D p1 = sgGeodToCart( Point3D(tlon*SGD_DEGREES_TO_RADIANS,
532 tlat*SGD_DEGREES_TO_RADIANS,
533 nav_elev*SG_FEET_TO_METER) );
534 // cout << nav_gs_x << "," << nav_gs_y << "," << nav_gs_z << endl;
535 // cout << p1 << endl;
536 sgdSetVec3( gs_base_vec,
537 p1.x()-nav_gs_x, p1.y()-nav_gs_y, p1.z()-nav_gs_z );
538 // cout << gs_base_vec[0] << "," << gs_base_vec[1] << ","
539 // << gs_base_vec[2] << endl;
541 if ( globals->get_soundmgr()->exists( nav_fx_name ) ) {
542 globals->get_soundmgr()->remove( nav_fx_name );
544 SGSimpleSound *sound;
545 sound = morse.make_ident( nav_trans_ident, LO_FREQUENCY );
546 sound->set_volume( 0.3 );
547 globals->get_soundmgr()->add( sound, nav_fx_name );
549 if ( globals->get_soundmgr()->exists( dme_fx_name ) ) {
550 globals->get_soundmgr()->remove( dme_fx_name );
552 sound = morse.make_ident( nav_trans_ident, HI_FREQUENCY );
553 sound->set_volume( 0.3 );
554 globals->get_soundmgr()->add( sound, dme_fx_name );
556 int offset = (int)(sg_random() * 30.0);
557 nav_play_count = offset / 4;
558 nav_last_time = globals->get_time_params()->get_cur_time() -
560 // cout << "offset = " << offset << " play_count = "
562 // << " nav_last_time = " << nav_last_time
563 // << " current time = "
564 // << globals->get_time_params()->get_cur_time() << endl;
566 // cout << "Found an ils station in range" << endl;
567 // cout << " id = " << ils->get_locident() << endl;
569 } else if ( (nav = current_navlist->findByFreq(nav_freq, lon, lat, elev)) != NULL ) {
570 nav_id = nav->get_ident();
571 nav_valid = (nav->get_type() == 'V');
572 if ( last_nav_id != nav_id || !last_nav_vor ) {
573 last_nav_id = nav_id;
575 nav_trans_ident = nav->get_trans_ident();
577 nav_has_dme = nav->get_has_dme();
579 nav_loclon = nav->get_lon();
580 nav_loclat = nav->get_lat();
581 nav_elev = nav->get_elev();
582 nav_magvar = nav->get_magvar();
583 nav_range = nav->get_range();
584 nav_effective_range = adjustNavRange(nav_elev, elev, nav_range);
586 nav_radial = nav_sel_radial;
587 nav_x = nav->get_x();
588 nav_y = nav->get_y();
589 nav_z = nav->get_z();
591 if ( globals->get_soundmgr()->exists( nav_fx_name ) ) {
592 globals->get_soundmgr()->remove( nav_fx_name );
594 SGSimpleSound *sound;
595 sound = morse.make_ident( nav_trans_ident, LO_FREQUENCY );
596 sound->set_volume( 0.3 );
597 if ( globals->get_soundmgr()->add( sound, nav_fx_name ) ) {
598 // cout << "Added nav-vor-ident sound" << endl;
600 SG_LOG(SG_COCKPIT, SG_WARN, "Failed to add v1-vor-ident sound");
603 if ( globals->get_soundmgr()->exists( dme_fx_name ) ) {
604 globals->get_soundmgr()->remove( dme_fx_name );
606 sound = morse.make_ident( nav_trans_ident, HI_FREQUENCY );
607 sound->set_volume( 0.3 );
608 globals->get_soundmgr()->add( sound, dme_fx_name );
610 int offset = (int)(sg_random() * 30.0);
611 nav_play_count = offset / 4;
612 nav_last_time = globals->get_time_params()->get_cur_time() -
614 // cout << "offset = " << offset << " play_count = "
615 // << nav_play_count << " nav_last_time = "
616 // << nav_last_time << " current time = "
617 // << globals->get_time_params()->get_cur_time() << endl;
619 // cout << "Found a vor station in range" << endl;
620 // cout << " id = " << nav->get_ident() << endl;
626 nav_trans_ident = "";
628 if ( ! globals->get_soundmgr()->remove( nav_fx_name ) ) {
629 SG_LOG(SG_COCKPIT, SG_WARN, "Failed to remove nav-vor-ident sound");
631 globals->get_soundmgr()->remove( dme_fx_name );
632 // cout << "not picking up vor1. :-(" << endl;
637 // return the amount of heading needle deflection, returns a value
638 // clamped to the range of ( -10 , 10 )
639 double FGNavCom::get_nav_heading_needle_deflection() const {
643 && nav_servicable->getBoolValue() && cdi_servicable->getBoolValue() )
645 r = nav_heading - nav_radial;
646 // cout << "Radial = " << nav_radial
647 // << " Bearing = " << nav_heading << endl;
649 while ( r > 180.0 ) { r -= 360.0;}
650 while ( r < -180.0 ) { r += 360.0;}
651 if ( fabs(r) > 90.0 )
652 r = ( r<0.0 ? -r-180.0 : -r+180.0 );
654 // According to Robin Peel, the ILS is 4x more sensitive than a vor
655 if ( nav_loc ) { r *= 4.0; }
656 if ( r < -10.0 ) { r = -10.0; }
657 if ( r > 10.0 ) { r = 10.0; }
666 // return the amount of glide slope needle deflection (.i.e. the
667 // number of degrees we are off the glide slope * 5.0
668 double FGNavCom::get_nav_gs_needle_deflection() const {
669 if ( nav_inrange && nav_has_gs
670 && nav_servicable->getBoolValue() && gs_servicable->getBoolValue() )
672 double x = nav_gs_dist;
673 double y = (fgGetDouble("/position/altitude-ft") - nav_elev)
675 // cout << "dist = " << x << " height = " << y << endl;
676 double angle = asin( y / x ) * SGD_RADIANS_TO_DEGREES;
677 return (nav_target_gs - angle) * 5.0;
685 * Return true if the NAV TO flag should be active.
688 FGNavCom::get_nav_to_flag () const
691 && nav_servicable->getBoolValue()
692 && tofrom_servicable->getBoolValue() )
694 double offset = fabs(nav_heading - nav_radial);
698 return (offset <= 90.0 || offset >= 270.0);
707 * Return true if the NAV FROM flag should be active.
710 FGNavCom::get_nav_from_flag () const
713 && nav_servicable->getBoolValue()
714 && tofrom_servicable->getBoolValue() ) {
715 double offset = fabs(nav_heading - nav_radial);
719 return (offset > 90.0 && offset < 270.0);
728 * Return the current radial.
730 * FIXME: the variable 'nav_radial' does not contain the current
731 * radial, while the variable 'nav_heading' contains the reciprocal of
732 * the current radial.
735 FGNavCom::get_nav_radial () const
737 if (nav_inrange && nav_servicable->getBoolValue()) {
738 double radial = nav_heading + 180;