1 // navradio.hxx -- class to manage a nav radio instance
3 // Written by Curtis Olson, started April 2000.
5 // Copyright (C) 2000 - 2002 Curtis L. Olson - http://www.flightgear.org/~curt
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 #ifndef _FG_NAVRADIO_HXX
25 #define _FG_NAVRADIO_HXX
28 #include <Main/fg_props.hxx>
30 #include <simgear/compiler.h>
31 #include <simgear/structure/subsystem_mgr.hxx>
32 #include <simgear/math/interpolater.hxx>
33 #include <simgear/timing/timestamp.hxx>
35 #include <Navaids/navlist.hxx>
36 #include <Sound/morse.hxx>
38 class FGNavRadio : public SGSubsystem
42 SGInterpTable *term_tbl;
43 SGInterpTable *low_tbl;
44 SGInterpTable *high_tbl;
46 SGPropertyNode *lon_node;
47 SGPropertyNode *lat_node;
48 SGPropertyNode *alt_node;
49 SGPropertyNode *bus_power_node;
52 SGPropertyNode *power_btn_node;
53 SGPropertyNode *freq_node; // primary freq
54 SGPropertyNode *alt_freq_node; // standby freq
55 SGPropertyNode *sel_radial_node; // selected radial
56 SGPropertyNode *vol_btn_node;
57 SGPropertyNode *ident_btn_node;
58 SGPropertyNode *audio_btn_node;
59 SGPropertyNode *nav_serviceable_node;
60 SGPropertyNode *cdi_serviceable_node;
61 SGPropertyNode *gs_serviceable_node;
62 SGPropertyNode *tofrom_serviceable_node;
65 SGPropertyNode *fmt_freq_node; // formated frequency
66 SGPropertyNode *fmt_alt_freq_node; // formated alternate frequency
67 SGPropertyNode *heading_node; // true heading to nav station
68 SGPropertyNode *radial_node; // current radial we are on (taking
69 // into consideration the vor station
70 // alignment which likely doesn't
71 // match the magnetic alignment
73 SGPropertyNode *recip_radial_node; // radial_node(val) + 180 (for
75 SGPropertyNode *target_radial_true_node;
76 // true heading of selected radial
77 SGPropertyNode *target_auto_hdg_node;
78 // suggested autopilot heading
79 // to intercept selected radial
80 SGPropertyNode *time_to_intercept; // estimated time to intecept selected
81 // radial at current speed and heading
82 SGPropertyNode *to_flag_node;
83 SGPropertyNode *from_flag_node;
84 SGPropertyNode *inrange_node;
85 SGPropertyNode *cdi_deflection_node;
86 SGPropertyNode *cdi_xtrack_error_node;
87 SGPropertyNode *cdi_xtrack_hdg_err_node;
88 SGPropertyNode *has_gs_node;
89 SGPropertyNode *loc_node;
90 SGPropertyNode *loc_dist_node;
91 SGPropertyNode *gs_deflection_node;
92 SGPropertyNode *gs_rate_of_climb_node;
93 SGPropertyNode *gs_dist_node;
94 SGPropertyNode *nav_id_node;
95 SGPropertyNode *id_c1_node;
96 SGPropertyNode *id_c2_node;
97 SGPropertyNode *id_c3_node;
98 SGPropertyNode *id_c4_node;
100 // gps slaving support
101 SGPropertyNode *nav_slaved_to_gps_node;
102 SGPropertyNode *gps_cdi_deflection_node;
103 SGPropertyNode *gps_to_flag_node;
104 SGPropertyNode *gps_from_flag_node;
106 // internal (private) values
113 int index; // used for property binding
121 double target_radial;
129 double nav_elev; // use gs elev if available
134 double gs_dist_signed;
135 SGTimeStamp prev_time;
136 SGTimeStamp curr_time;
138 double effective_range;
143 double last_loc_dist;
144 double last_xtrack_error;
149 // internal periodic station search timer
150 double _time_before_search_sec;
152 // model standard VOR/DME/TACAN service volumes as per AIM 1-1-8
153 double adjustNavRange( double stationElev, double aircraftElev,
154 double nominalRange );
156 // model standard ILS service volumes as per AIM 1-1-9
157 double adjustILSRange( double stationElev, double aircraftElev,
158 double offsetDegrees, double distance );
162 FGNavRadio(SGPropertyNode *node);
168 void update (double dt);
170 // Update nav/adf radios based on current postition
175 #endif // _FG_NAVRADIO_HXX