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 *is_valid_node; // is station data valid (may be way out
54 SGPropertyNode *power_btn_node;
55 SGPropertyNode *freq_node; // primary freq
56 SGPropertyNode *alt_freq_node; // standby freq
57 SGPropertyNode *sel_radial_node; // selected radial
58 SGPropertyNode *vol_btn_node;
59 SGPropertyNode *ident_btn_node;
60 SGPropertyNode *audio_btn_node;
61 SGPropertyNode *nav_serviceable_node;
62 SGPropertyNode *cdi_serviceable_node;
63 SGPropertyNode *gs_serviceable_node;
64 SGPropertyNode *tofrom_serviceable_node;
67 SGPropertyNode *fmt_freq_node; // formated frequency
68 SGPropertyNode *fmt_alt_freq_node; // formated alternate frequency
69 SGPropertyNode *heading_node; // true heading to nav station
70 SGPropertyNode *radial_node; // current radial we are on (taking
71 // into consideration the vor station
72 // alignment which likely doesn't
73 // match the magnetic alignment
75 SGPropertyNode *recip_radial_node; // radial_node(val) + 180 (for
77 SGPropertyNode *target_radial_true_node;
78 // true heading of selected radial
79 SGPropertyNode *target_auto_hdg_node;
80 // suggested autopilot heading
81 // to intercept selected radial
82 SGPropertyNode *time_to_intercept; // estimated time to intecept selected
83 // radial at current speed and heading
84 SGPropertyNode *to_flag_node;
85 SGPropertyNode *from_flag_node;
86 SGPropertyNode *inrange_node;
87 SGPropertyNode *cdi_deflection_node;
88 SGPropertyNode *cdi_xtrack_error_node;
89 SGPropertyNode *cdi_xtrack_hdg_err_node;
90 SGPropertyNode *has_gs_node;
91 SGPropertyNode *loc_node;
92 SGPropertyNode *loc_dist_node;
93 SGPropertyNode *gs_deflection_node;
94 SGPropertyNode *gs_rate_of_climb_node;
95 SGPropertyNode *gs_dist_node;
96 SGPropertyNode *nav_id_node;
97 SGPropertyNode *id_c1_node;
98 SGPropertyNode *id_c2_node;
99 SGPropertyNode *id_c3_node;
100 SGPropertyNode *id_c4_node;
102 // gps slaving support
103 SGPropertyNode *nav_slaved_to_gps_node;
104 SGPropertyNode *gps_cdi_deflection_node;
105 SGPropertyNode *gps_to_flag_node;
106 SGPropertyNode *gps_from_flag_node;
108 // internal (private) values
115 int index; // used for property binding
123 double target_radial;
131 double nav_elev; // use gs elev if available
136 double gs_dist_signed;
137 SGTimeStamp prev_time;
138 SGTimeStamp curr_time;
140 double effective_range;
145 double last_loc_dist;
146 double last_xtrack_error;
151 // internal periodic station search timer
152 double _time_before_search_sec;
154 // model standard VOR/DME/TACAN service volumes as per AIM 1-1-8
155 double adjustNavRange( double stationElev, double aircraftElev,
156 double nominalRange );
158 // model standard ILS service volumes as per AIM 1-1-9
159 double adjustILSRange( double stationElev, double aircraftElev,
160 double offsetDegrees, double distance );
164 FGNavRadio(SGPropertyNode *node);
170 void update (double dt);
172 // Update nav/adf radios based on current postition
177 #endif // _FG_NAVRADIO_HXX