2004-11-19 23:10:44 +00:00
|
|
|
// navradio.hxx -- class to manage a nav radio instance
|
|
|
|
//
|
|
|
|
// Written by Curtis Olson, started April 2000.
|
|
|
|
//
|
|
|
|
// Copyright (C) 2000 - 2002 Curtis L. Olson - http://www.flightgear.org/~curt
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
2006-02-21 01:16:04 +00:00
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2004-11-19 23:10:44 +00:00
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _FG_NAVRADIO_HXX
|
|
|
|
#define _FG_NAVRADIO_HXX
|
|
|
|
|
|
|
|
|
|
|
|
#include <Main/fg_props.hxx>
|
2009-09-02 17:01:30 +00:00
|
|
|
#include "Sound/morse.hxx"
|
2004-11-19 23:10:44 +00:00
|
|
|
|
|
|
|
#include <simgear/compiler.h>
|
|
|
|
#include <simgear/structure/subsystem_mgr.hxx>
|
|
|
|
#include <simgear/timing/timestamp.hxx>
|
|
|
|
|
2009-09-02 17:01:30 +00:00
|
|
|
// forward decls
|
|
|
|
class SGInterpTable;
|
|
|
|
|
|
|
|
class FGNavRecord;
|
|
|
|
typedef SGSharedPtr<FGNavRecord> FGNavRecordPtr;
|
2004-11-19 23:10:44 +00:00
|
|
|
|
|
|
|
class FGNavRadio : public SGSubsystem
|
|
|
|
{
|
|
|
|
FGMorse morse;
|
|
|
|
|
|
|
|
SGInterpTable *term_tbl;
|
|
|
|
SGInterpTable *low_tbl;
|
|
|
|
SGInterpTable *high_tbl;
|
|
|
|
|
2006-06-11 10:21:10 +00:00
|
|
|
SGPropertyNode_ptr lon_node;
|
|
|
|
SGPropertyNode_ptr lat_node;
|
|
|
|
SGPropertyNode_ptr alt_node;
|
|
|
|
SGPropertyNode_ptr bus_power_node;
|
2005-12-28 16:53:19 +00:00
|
|
|
|
2005-12-28 18:05:03 +00:00
|
|
|
// property inputs
|
2006-06-11 10:21:10 +00:00
|
|
|
SGPropertyNode_ptr is_valid_node; // is station data valid (may be way out
|
2006-07-21 19:37:04 +00:00
|
|
|
// of range.)
|
2006-06-11 10:21:10 +00:00
|
|
|
SGPropertyNode_ptr power_btn_node;
|
|
|
|
SGPropertyNode_ptr freq_node; // primary freq
|
|
|
|
SGPropertyNode_ptr alt_freq_node; // standby freq
|
|
|
|
SGPropertyNode_ptr sel_radial_node; // selected radial
|
|
|
|
SGPropertyNode_ptr vol_btn_node;
|
|
|
|
SGPropertyNode_ptr ident_btn_node;
|
|
|
|
SGPropertyNode_ptr audio_btn_node;
|
2006-07-21 19:37:04 +00:00
|
|
|
SGPropertyNode_ptr backcourse_node;
|
2006-06-11 10:21:10 +00:00
|
|
|
SGPropertyNode_ptr nav_serviceable_node;
|
|
|
|
SGPropertyNode_ptr cdi_serviceable_node;
|
|
|
|
SGPropertyNode_ptr gs_serviceable_node;
|
|
|
|
SGPropertyNode_ptr tofrom_serviceable_node;
|
2005-12-28 16:53:19 +00:00
|
|
|
|
2005-12-28 18:05:03 +00:00
|
|
|
// property outputs
|
2006-06-11 10:21:10 +00:00
|
|
|
SGPropertyNode_ptr fmt_freq_node; // formated frequency
|
|
|
|
SGPropertyNode_ptr fmt_alt_freq_node; // formated alternate frequency
|
|
|
|
SGPropertyNode_ptr heading_node; // true heading to nav station
|
|
|
|
SGPropertyNode_ptr radial_node; // current radial we are on (taking
|
2005-12-28 17:26:57 +00:00
|
|
|
// into consideration the vor station
|
|
|
|
// alignment which likely doesn't
|
|
|
|
// match the magnetic alignment
|
|
|
|
// exactly.)
|
2006-06-11 10:21:10 +00:00
|
|
|
SGPropertyNode_ptr recip_radial_node; // radial_node(val) + 180 (for
|
2005-12-28 17:26:57 +00:00
|
|
|
// convenience)
|
2006-06-11 10:21:10 +00:00
|
|
|
SGPropertyNode_ptr target_radial_true_node;
|
2005-12-28 17:26:57 +00:00
|
|
|
// true heading of selected radial
|
2006-06-11 10:21:10 +00:00
|
|
|
SGPropertyNode_ptr target_auto_hdg_node;
|
2005-12-28 21:45:43 +00:00
|
|
|
// suggested autopilot heading
|
|
|
|
// to intercept selected radial
|
2006-06-11 10:21:10 +00:00
|
|
|
SGPropertyNode_ptr time_to_intercept; // estimated time to intecept selected
|
2005-12-28 21:45:43 +00:00
|
|
|
// radial at current speed and heading
|
2006-06-11 10:21:10 +00:00
|
|
|
SGPropertyNode_ptr to_flag_node;
|
|
|
|
SGPropertyNode_ptr from_flag_node;
|
|
|
|
SGPropertyNode_ptr inrange_node;
|
2008-08-28 21:24:02 +00:00
|
|
|
SGPropertyNode_ptr signal_quality_norm_node;
|
2006-06-11 10:21:10 +00:00
|
|
|
SGPropertyNode_ptr cdi_deflection_node;
|
2009-09-09 09:44:52 +00:00
|
|
|
SGPropertyNode_ptr cdi_deflection_norm_node;
|
2006-06-11 10:21:10 +00:00
|
|
|
SGPropertyNode_ptr cdi_xtrack_error_node;
|
|
|
|
SGPropertyNode_ptr cdi_xtrack_hdg_err_node;
|
|
|
|
SGPropertyNode_ptr has_gs_node;
|
|
|
|
SGPropertyNode_ptr loc_node;
|
|
|
|
SGPropertyNode_ptr loc_dist_node;
|
|
|
|
SGPropertyNode_ptr gs_deflection_node;
|
2009-09-10 08:15:46 +00:00
|
|
|
SGPropertyNode_ptr gs_deflection_deg_node;
|
2009-09-08 16:02:59 +00:00
|
|
|
SGPropertyNode_ptr gs_deflection_norm_node;
|
2006-06-11 10:21:10 +00:00
|
|
|
SGPropertyNode_ptr gs_rate_of_climb_node;
|
|
|
|
SGPropertyNode_ptr gs_dist_node;
|
|
|
|
SGPropertyNode_ptr nav_id_node;
|
|
|
|
SGPropertyNode_ptr id_c1_node;
|
|
|
|
SGPropertyNode_ptr id_c2_node;
|
|
|
|
SGPropertyNode_ptr id_c3_node;
|
|
|
|
SGPropertyNode_ptr id_c4_node;
|
2005-12-28 16:53:19 +00:00
|
|
|
|
2005-12-28 18:05:03 +00:00
|
|
|
// gps slaving support
|
2006-06-11 10:21:10 +00:00
|
|
|
SGPropertyNode_ptr nav_slaved_to_gps_node;
|
|
|
|
SGPropertyNode_ptr gps_cdi_deflection_node;
|
|
|
|
SGPropertyNode_ptr gps_to_flag_node;
|
|
|
|
SGPropertyNode_ptr gps_from_flag_node;
|
2009-04-09 15:36:42 +00:00
|
|
|
SGPropertyNode_ptr gps_has_gs_node;
|
2009-10-05 21:09:20 +00:00
|
|
|
SGPropertyNode_ptr gps_course_node;
|
|
|
|
|
2005-12-28 18:05:03 +00:00
|
|
|
// internal (private) values
|
|
|
|
|
|
|
|
int play_count;
|
|
|
|
time_t last_time;
|
2009-09-02 17:01:30 +00:00
|
|
|
FGNavRecordPtr _navaid;
|
|
|
|
FGNavRecordPtr _gs;
|
|
|
|
|
2004-12-03 21:21:16 +00:00
|
|
|
string nav_fx_name;
|
|
|
|
string dme_fx_name;
|
2004-11-19 23:10:44 +00:00
|
|
|
|
2005-12-28 18:05:03 +00:00
|
|
|
bool has_dme;
|
|
|
|
double target_radial;
|
2004-11-19 23:10:44 +00:00
|
|
|
SGTimeStamp prev_time;
|
|
|
|
SGTimeStamp curr_time;
|
2005-12-28 18:05:03 +00:00
|
|
|
double effective_range;
|
|
|
|
double target_gs;
|
|
|
|
double twist;
|
2004-11-19 23:10:44 +00:00
|
|
|
double horiz_vel;
|
|
|
|
double last_x;
|
2005-12-28 21:45:43 +00:00
|
|
|
double last_loc_dist;
|
|
|
|
double last_xtrack_error;
|
2009-09-11 23:05:23 +00:00
|
|
|
double _localizerWidth; // cached localizer width in degrees
|
|
|
|
|
2006-12-06 22:11:43 +00:00
|
|
|
string _name;
|
|
|
|
int _num;
|
2004-11-19 23:10:44 +00:00
|
|
|
|
|
|
|
// internal periodic station search timer
|
|
|
|
double _time_before_search_sec;
|
|
|
|
|
2009-09-11 23:05:23 +00:00
|
|
|
SGVec3d _gsCart, _gsAxis, _gsVertical;
|
|
|
|
|
2009-09-08 14:23:44 +00:00
|
|
|
// CDI properties
|
|
|
|
bool _toFlag, _fromFlag;
|
|
|
|
double _cdiDeflection;
|
|
|
|
double _cdiCrossTrackErrorM;
|
|
|
|
double _gsNeedleDeflection;
|
2009-09-08 16:02:59 +00:00
|
|
|
double _gsNeedleDeflectionNorm;
|
2009-09-08 14:23:44 +00:00
|
|
|
|
2009-09-02 17:01:30 +00:00
|
|
|
bool updateWithPower(double aDt);
|
|
|
|
|
2004-11-19 23:10:44 +00:00
|
|
|
// model standard VOR/DME/TACAN service volumes as per AIM 1-1-8
|
|
|
|
double adjustNavRange( double stationElev, double aircraftElev,
|
|
|
|
double nominalRange );
|
|
|
|
|
|
|
|
// model standard ILS service volumes as per AIM 1-1-9
|
|
|
|
double adjustILSRange( double stationElev, double aircraftElev,
|
|
|
|
double offsetDegrees, double distance );
|
|
|
|
|
2009-09-08 14:23:44 +00:00
|
|
|
void updateAudio();
|
2009-09-02 17:01:30 +00:00
|
|
|
void audioNavidChanged();
|
|
|
|
|
2009-09-08 14:23:44 +00:00
|
|
|
void updateReceiver(double dt);
|
|
|
|
void updateGlideSlope(double dt, const SGVec3d& aircraft, double signal_quality_norm);
|
|
|
|
void updateGPSSlaved();
|
|
|
|
void updateCDI(double dt);
|
|
|
|
|
|
|
|
void clearOutputs();
|
|
|
|
|
2009-09-11 23:05:23 +00:00
|
|
|
/**
|
|
|
|
* Compute the localizer width in degrees - see implementation for
|
|
|
|
* more information on the relevant standards and formulae.
|
|
|
|
*/
|
|
|
|
double localizerWidth(FGNavRecord* aLOC);
|
2009-09-02 17:01:30 +00:00
|
|
|
FGNavRecord* findPrimaryNavaid(const SGGeod& aPos, double aFreqMHz);
|
2004-11-19 23:10:44 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
FGNavRadio(SGPropertyNode *node);
|
|
|
|
~FGNavRadio();
|
|
|
|
|
|
|
|
void init ();
|
|
|
|
void bind ();
|
|
|
|
void unbind ();
|
|
|
|
void update (double dt);
|
|
|
|
|
|
|
|
// Update nav/adf radios based on current postition
|
|
|
|
void search ();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _FG_NAVRADIO_HXX
|