]> git.mxchange.org Git - flightgear.git/blob - src/Instrumentation/navradio.hxx
More naming cleanups.
[flightgear.git] / src / Instrumentation / navradio.hxx
1 // navradio.hxx -- class to manage a nav radio instance
2 //
3 // Written by Curtis Olson, started April 2000.
4 //
5 // Copyright (C) 2000 - 2002  Curtis L. Olson - http://www.flightgear.org/~curt
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 #ifndef _FG_NAVRADIO_HXX
25 #define _FG_NAVRADIO_HXX
26
27
28 #include <Main/fg_props.hxx>
29
30 #include <simgear/compiler.h>
31 #include <simgear/structure/subsystem_mgr.hxx>
32 #include <simgear/math/interpolater.hxx>
33 #include <simgear/timing/timestamp.hxx>
34
35 #include <Navaids/navlist.hxx>
36 #include <Sound/morse.hxx>
37
38 class FGNavRadio : public SGSubsystem
39 {
40     FGMorse morse;
41
42     SGInterpTable *term_tbl;
43     SGInterpTable *low_tbl;
44     SGInterpTable *high_tbl;
45
46     SGPropertyNode *lon_node;
47     SGPropertyNode *lat_node;
48     SGPropertyNode *alt_node;
49     SGPropertyNode *bus_power_node;
50
51     // property inputs
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;
63
64     // property outputs
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
72                                        // exactly.)
73     SGPropertyNode *recip_radial_node; // radial_node(val) + 180 (for
74                                        // convenience)
75     SGPropertyNode *target_radial_true_node;
76                                        // true heading of selected radial
77     SGPropertyNode *target_auto_hdg_node;
78     SGPropertyNode *to_flag_node;
79     SGPropertyNode *from_flag_node;
80     SGPropertyNode *inrange_node;
81     SGPropertyNode *cdi_deflection_node;
82     SGPropertyNode *cdi_xtrack_error_node;
83     SGPropertyNode *has_gs_node;
84     SGPropertyNode *loc_node;
85     SGPropertyNode *loc_dist_node;
86     SGPropertyNode *gs_deflection_node;
87     SGPropertyNode *gs_rate_of_climb_node;
88     SGPropertyNode *gs_dist_node;
89     SGPropertyNode *id_node;
90     SGPropertyNode *id_c1_node;
91     SGPropertyNode *id_c2_node;
92     SGPropertyNode *id_c3_node;
93     SGPropertyNode *id_c4_node;
94
95     // gps slaving support
96     SGPropertyNode *nav_slaved_to_gps_node;
97     SGPropertyNode *gps_cdi_deflection_node;
98     SGPropertyNode *gps_to_flag_node;
99     SGPropertyNode *gps_from_flag_node;
100
101     // internal (private) values
102
103     string last_id;
104     bool last_nav_vor;
105     int play_count;
106     time_t last_time;
107
108     int index;                  // used for property binding
109     string nav_fx_name;
110     string dme_fx_name;
111
112     string trans_ident;
113     bool is_valid;
114     bool has_dme;
115     double target_radial;
116     double loc_lon;
117     double loc_lat;
118     double nav_x;
119     double nav_y;
120     double nav_z;
121     double gs_lon;
122     double gs_lat;
123     double nav_elev;            // use gs elev if available
124     double gs_x;
125     double gs_y;
126     double gs_z;
127     sgdVec3 gs_base_vec;
128     double gs_dist_signed;
129     SGTimeStamp prev_time;
130     SGTimeStamp curr_time;
131     double range;
132     double effective_range;
133     double target_gs;
134     double twist;
135     double horiz_vel;
136     double last_x;
137
138     string name;
139     int num;
140
141     // internal periodic station search timer
142     double _time_before_search_sec;
143
144     // model standard VOR/DME/TACAN service volumes as per AIM 1-1-8
145     double adjustNavRange( double stationElev, double aircraftElev,
146                            double nominalRange );
147
148     // model standard ILS service volumes as per AIM 1-1-9
149     double adjustILSRange( double stationElev, double aircraftElev,
150                            double offsetDegrees, double distance );
151
152 public:
153
154     FGNavRadio(SGPropertyNode *node);
155     ~FGNavRadio();
156
157     void init ();
158     void bind ();
159     void unbind ();
160     void update (double dt);
161
162     // Update nav/adf radios based on current postition
163     void search ();
164
165     // NavCom Accessors
166     inline bool has_power() const {
167         return power_btn_node->getBoolValue()
168             && (bus_power_node->getDoubleValue() > 1.0);
169     }
170 };
171
172
173 #endif // _FG_NAVRADIO_HXX