FlightGear next
navradio.hxx
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: GPL-2.0+
3 * SPDX-FileCopyrightText: 2000 - 2002 (C) Curtis L. Olson - http://www.flightgear.org/~curt
4 *
5 * navradio.hxx -- class to manage a nav radio instance
6 * Written by Curtis Olson, started April 2000.
7 *
8 * Copyright (C) 2000 - 2002 Curtis L. Olson - http://www.flightgear.org/~curt
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of the
13 * License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 *
24 * $Id$
25*/
26
27#pragma once
28
30#include <Main/fg_props.hxx>
31
32#include <simgear/compiler.h>
33#include <simgear/timing/timestamp.hxx>
34
36
37class SGSampleGroup;
38
40 public SGPropertyChangeListener
41{
42 SGPropertyNode_ptr _radio_node;
43
44 // property inputs
45 SGPropertyNode_ptr is_valid_node; // is station data valid (may be way out
46 // of range.)
47 SGPropertyNode_ptr freq_node; // primary freq
48 SGPropertyNode_ptr alt_freq_node; // standby freq
49 SGPropertyNode_ptr is_loc_freq_node;// is the primary freq a loc/gs (paired) freq?
50 SGPropertyNode_ptr sel_radial_node; // selected radial
51 SGPropertyNode_ptr vol_btn_node;
52 SGPropertyNode_ptr ident_btn_node;
53 SGPropertyNode_ptr audio_btn_node;
54 SGPropertyNode_ptr backcourse_node;
55 SGPropertyNode_ptr nav_serviceable_node;
56 SGPropertyNode_ptr cdi_serviceable_node;
57 SGPropertyNode_ptr gs_serviceable_node;
58 SGPropertyNode_ptr tofrom_serviceable_node;
59
60 // property outputs
61 SGPropertyNode_ptr fmt_freq_node; // formated frequency
62 SGPropertyNode_ptr fmt_alt_freq_node; // formated alternate frequency
63 SGPropertyNode_ptr heading_node; // true heading to nav station
64 SGPropertyNode_ptr radial_node; // current radial we are on (taking
65 // into consideration the vor station
66 // alignment which likely doesn't
67 // match the magnetic alignment
68 // exactly.)
69 SGPropertyNode_ptr recip_radial_node; // radial_node(val) + 180 (for
70 // convenience)
71 SGPropertyNode_ptr target_radial_true_node;
72 // true heading of selected radial
73 SGPropertyNode_ptr target_auto_hdg_node;
74 // suggested autopilot heading
75 // to intercept selected radial
76 SGPropertyNode_ptr time_to_intercept; // estimated time to intecept selected
77 // radial at current speed and heading
78 SGPropertyNode_ptr to_flag_node;
79 SGPropertyNode_ptr from_flag_node;
80 SGPropertyNode_ptr inrange_node;
81 SGPropertyNode_ptr signal_quality_norm_node;
82 SGPropertyNode_ptr cdi_deflection_node;
83 SGPropertyNode_ptr cdi_deflection_norm_node;
84 SGPropertyNode_ptr cdi_xtrack_error_node;
85 SGPropertyNode_ptr cdi_xtrack_hdg_err_node;
86 SGPropertyNode_ptr has_gs_node;
87 SGPropertyNode_ptr loc_node;
88 SGPropertyNode_ptr loc_dist_node;
89 SGPropertyNode_ptr gs_deflection_node;
90 SGPropertyNode_ptr gs_deflection_deg_node;
91 SGPropertyNode_ptr gs_deflection_norm_node;
92 SGPropertyNode_ptr gs_direct_node;
93 SGPropertyNode_ptr gs_rate_of_climb_node;
94 SGPropertyNode_ptr gs_rate_of_climb_fpm_node;
95 SGPropertyNode_ptr gs_dist_node;
96 SGPropertyNode_ptr gs_inrange_node;
97 SGPropertyNode_ptr nav_id_node;
98 SGPropertyNode_ptr id_c1_node;
99 SGPropertyNode_ptr id_c2_node;
100 SGPropertyNode_ptr id_c3_node;
101 SGPropertyNode_ptr id_c4_node;
102
103 // gps slaving support
104 SGPropertyNode_ptr nav_slaved_to_gps_node;
105 SGPropertyNode_ptr gps_cdi_deflection_node;
106 SGPropertyNode_ptr gps_to_flag_node;
107 SGPropertyNode_ptr gps_from_flag_node;
108 SGPropertyNode_ptr gps_has_gs_node;
109 SGPropertyNode_ptr gps_course_node;
110 SGPropertyNode_ptr gps_xtrack_error_nm_node;
111 SGPropertyNode_ptr _magvarNode;
112
113 // realism setting, are false courses and GS lobes enabled?
114 SGPropertyNode_ptr falseCoursesEnabledNode;
115
116 // internal (private) values
117
118 // When the selected frequency is changed or when leaving GPS slave mode,
119 // the low-pass filter applied to signal quality must be disabled. Setting
120 // this member to 'false' has one-shot behavior.
121 bool _apply_lowpass_filter = false;
122 int play_count;
123 bool _nav_search;
124 double _last_freq;
125 FGNavRecordRef _navaid;
126 FGNavRecordRef _gs;
127
128 double target_radial;
129 double effective_range;
130 double target_gs;
131 double twist;
132 double horiz_vel;
133 double last_x;
134 double last_xtrack_error;
135 double xrate_ms;
136 double _localizerWidth; // cached localizer width in degrees
137
138 // internal periodic station search timer
139 double _time_before_search_sec;
140
141 SGVec3d _gsCart, _gsAxis, _gsVertical, _gsBaseline;
142
143 // CDI properties
144 bool _toFlag, _fromFlag;
145 double _cdiDeflection;
146 double _cdiCrossTrackErrorM;
147 double _gsNeedleDeflection;
148 double _gsNeedleDeflectionNorm;
149 double _gsDirect;
150
151 class AudioIdent * _audioIdent;
152
153 bool updateWithPower(double aDt);
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 void updateAudio( double dt );
164
165 void updateReceiver(double dt);
166 void updateGlideSlope(double dt, const SGVec3d& aircraft, double signal_quality_norm);
167 void updateGPSSlaved();
168 void updateCDI(double dt);
169 void updateFormattedFrequencies();
170
171 void clearOutputs();
172
173 FGNavRecord* findPrimaryNavaid(const SGGeod& aPos, double aFreqMHz);
174
175 // implement SGPropertyChangeListener
176 virtual void valueChanged (SGPropertyNode * prop);
177
178public:
179 FGNavRadio(SGPropertyNode *node);
180 ~FGNavRadio();
181
182 // Subsystem API.
183 void init() override;
184 void reinit() override;
185 void update(double dt) override;
186
187 // Subsystem identification.
188 static const char* staticSubsystemClassId() { return "old-navradio"; }
189
190 // Update nav/adf radios based on current postition
191 void search ();
192 void updateNav();
193};
void updateNav()
Definition navradio.cxx:921
void reinit() override
Definition navradio.cxx:276
void init() override
Definition navradio.cxx:171
FGNavRadio(SGPropertyNode *node)
Definition navradio.cxx:105
void update(double dt) override
Definition navradio.cxx:362
static const char * staticSubsystemClassId()
Definition navradio.hxx:188
void search()
Definition navradio.cxx:875
SGSharedPtr< FGNavRecord > FGNavRecordRef