1 // radiostack.cxx -- class to manage an instance of the radio stack
3 // Written by Curtis Olson, started April 2000.
5 // Copyright (C) 2000 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.
24 #include <Navaids/ilslist.hxx>
25 #include <Navaids/navlist.hxx>
27 #include "radiostack.hxx"
30 FGRadioStack *current_radiostack;
34 FGRadioStack::FGRadioStack() {
40 FGRadioStack::~FGRadioStack() {
44 // Update nav/adf radios based on current postition
45 void FGRadioStack::update( double lon, double lat, double elev ) {
50 if ( current_ilslist->query( lon, lat, elev, nav1_freq,
51 &ils, &nav1_heading, &nav1_dist) ) {
54 nav1_lon = ils.get_loclon();
55 nav1_lat = ils.get_loclat();
56 nav1_elev = ils.get_gselev();
57 nav1_target_gs = ils.get_gsangle();
58 nav1_radial = ils.get_locheading() + 180.0;
59 while ( nav1_radial < 0.0 ) { nav1_radial += 360.0; }
60 while ( nav1_radial > 360.0 ) { nav1_radial -= 360.0; }
61 // cout << "Found a vor station in range" << endl;
62 // cout << " id = " << ils.get_locident() << endl;
63 // cout << " heading = " << nav1_heading
64 // << " dist = " << nav1_dist << endl;
67 // cout << "not picking up vor. :-(" << endl;
72 if ( current_navlist->query( lon, lat, elev, nav2_freq,
73 &nav, &nav2_heading, &nav2_dist) ) {
76 nav2_lon = nav.get_lon();
77 nav2_lat = nav.get_lat();
78 nav2_elev = nav.get_elev();
79 nav2_radial = nav2_heading + 180.0;
80 while ( nav2_radial < 0.0 ) { nav2_radial += 360.0; }
81 while ( nav2_radial > 360.0 ) { nav2_radial -= 360.0; }
82 // cout << "Found a vor station in range" << endl;
83 // cout << " id = " << nav.get_ident() << endl;
84 // cout << " heading = " << nav2_heading
85 // << " dist = " << nav2_dist << endl;
88 // cout << "not picking up vor. :-(" << endl;
93 if ( current_navlist->query( lon, lat, elev, adf_freq,
94 &nav, &adf_heading, &junk) ) {
96 adf_lon = nav.get_lon();
97 adf_lat = nav.get_lat();
98 adf_elev = nav.get_elev();
99 // cout << "Found an adf station in range" << endl;
100 // cout << " id = " << nav.get_ident() << endl;
101 // cout << " heading = " << adf_heading
102 // << " dist = " << junk << endl;
105 // cout << "not picking up adf. :-(" << endl;