]> git.mxchange.org Git - flightgear.git/blob - src/Instrumentation/navradio.hxx
- Add an "is-valid" property node so other modules can do a quick check if
[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 *is_valid_node;   // is station data valid (may be way out
53                                      // of range.)
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;
65
66     // property outputs
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
74                                        // exactly.)
75     SGPropertyNode *recip_radial_node; // radial_node(val) + 180 (for
76                                        // convenience)
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;
101
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;
107
108     // internal (private) values
109
110     string nav_id;
111     string last_nav_id;
112     bool last_nav_vor;
113     int play_count;
114     time_t last_time;
115
116     int index;                  // used for property binding
117     string nav_fx_name;
118     string dme_fx_name;
119
120     string trans_ident;
121     bool is_valid;
122     bool has_dme;
123     double radial;
124     double target_radial;
125     double loc_lon;
126     double loc_lat;
127     double nav_x;
128     double nav_y;
129     double nav_z;
130     double gs_lon;
131     double gs_lat;
132     double nav_elev;            // use gs elev if available
133     double gs_x;
134     double gs_y;
135     double gs_z;
136     sgdVec3 gs_base_vec;
137     double gs_dist_signed;
138     SGTimeStamp prev_time;
139     SGTimeStamp curr_time;
140     double range;
141     double effective_range;
142     double target_gs;
143     double twist;
144     double horiz_vel;
145     double last_x;
146     double last_loc_dist;
147     double last_xtrack_error;
148
149     string name;
150     int num;
151
152     // internal periodic station search timer
153     double _time_before_search_sec;
154
155     // model standard VOR/DME/TACAN service volumes as per AIM 1-1-8
156     double adjustNavRange( double stationElev, double aircraftElev,
157                            double nominalRange );
158
159     // model standard ILS service volumes as per AIM 1-1-9
160     double adjustILSRange( double stationElev, double aircraftElev,
161                            double offsetDegrees, double distance );
162
163 public:
164
165     FGNavRadio(SGPropertyNode *node);
166     ~FGNavRadio();
167
168     void init ();
169     void bind ();
170     void unbind ();
171     void update (double dt);
172
173     // Update nav/adf radios based on current postition
174     void search ();
175 };
176
177
178 #endif // _FG_NAVRADIO_HXX