]> git.mxchange.org Git - flightgear.git/blob - src/Cockpit/radiostack.cxx
94a68383a8b57c563dbdf05c06efd71e90f41aaf
[flightgear.git] / src / Cockpit / radiostack.cxx
1 // radiostack.cxx -- class to manage an instance of the radio stack
2 //
3 // Written by Curtis Olson, started April 2000.
4 //
5 // Copyright (C) 2000  Curtis L. Olson - curt@flightgear.org
6 //
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.
11 //
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.
16 //
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.
20 //
21 // $Id$
22
23
24 #include <Navaids/ilslist.hxx>
25 #include <Navaids/navlist.hxx>
26
27 #include "radiostack.hxx"
28
29
30 // Constructor
31 FGRadioStack::FGRadioStack() {
32     need_update = true;
33 }
34
35
36 // Destructor
37 FGRadioStack::~FGRadioStack() {
38 }
39
40
41 // Update nav/adf radios based on current postition
42 void FGRadioStack::update( double lon, double lat, double elev ) {
43     need_update = false;
44
45     FGNav n;
46
47     // nav1
48     if ( current_navlist->query( lon, lat, elev, nav1_freq,
49                                  &n, &nav1_heading, &nav1_dist) ) {
50         nav1_inrange = true;
51         nav1_lon = n.get_lon();
52         nav1_lat = n.get_lat();
53         nav1_elev = n.get_elev();
54         cout << "Found a vor station in range" << endl;
55         cout << " id = " << n.get_ident() << endl;
56         cout << " heading = " << nav1_heading
57              << " dist = " << nav1_dist << endl;
58     } else {
59         nav1_inrange = false;
60         cout << "not picking up vor. :-(" << endl;
61     }
62
63     // nav1
64     if ( current_navlist->query( lon, lat, elev, nav2_freq,
65                                  &n, &nav2_heading, &nav2_dist) ) {
66         nav2_inrange = true;
67         nav2_lon = n.get_lon();
68         nav2_lat = n.get_lat();
69         nav2_elev = n.get_elev();
70         cout << "Found a vor station in range" << endl;
71         cout << " id = " << n.get_ident() << endl;
72         cout << " heading = " << nav2_heading
73              << " dist = " << nav2_dist << endl;
74     } else {
75         nav2_inrange = false;
76         cout << "not picking up vor. :-(" << endl;
77     }
78
79     // adf
80     double junk;
81     if ( current_navlist->query( lon, lat, elev, adf_freq,
82                                  &n, &adf_heading, &junk) ) {
83         adf_inrange = true;
84         adf_lon = n.get_lon();
85         adf_lat = n.get_lat();
86         adf_elev = n.get_elev();
87         cout << "Found an adf station in range" << endl;
88         cout << " id = " << n.get_ident() << endl;
89         cout << " heading = " << adf_heading
90              << " dist = " << junk << endl;
91     } else {
92         adf_inrange = false;
93         cout << "not picking up adf. :-(" << endl;
94     }
95 }
96