2000-04-24 23:50:59 +00:00
|
|
|
// radiostack.cxx -- class to manage an instance of the radio stack
|
|
|
|
//
|
|
|
|
// Written by Curtis Olson, started April 2000.
|
|
|
|
//
|
|
|
|
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
|
|
|
|
|
|
|
|
#include <Navaids/ilslist.hxx>
|
|
|
|
#include <Navaids/navlist.hxx>
|
|
|
|
|
|
|
|
#include "radiostack.hxx"
|
|
|
|
|
|
|
|
|
2000-04-25 03:09:26 +00:00
|
|
|
FGRadioStack *current_radiostack;
|
|
|
|
|
|
|
|
|
2000-04-24 23:50:59 +00:00
|
|
|
// Constructor
|
|
|
|
FGRadioStack::FGRadioStack() {
|
|
|
|
need_update = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Destructor
|
|
|
|
FGRadioStack::~FGRadioStack() {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Update nav/adf radios based on current postition
|
|
|
|
void FGRadioStack::update( double lon, double lat, double elev ) {
|
|
|
|
need_update = false;
|
|
|
|
|
|
|
|
// nav1
|
2000-04-25 03:09:26 +00:00
|
|
|
FGILS ils;
|
|
|
|
if ( current_ilslist->query( lon, lat, elev, nav1_freq,
|
|
|
|
&ils, &nav1_heading, &nav1_dist) ) {
|
2000-04-24 23:50:59 +00:00
|
|
|
nav1_inrange = true;
|
2000-04-27 03:26:36 +00:00
|
|
|
nav1_loc = true;
|
2000-04-25 03:09:26 +00:00
|
|
|
nav1_lon = ils.get_loclon();
|
|
|
|
nav1_lat = ils.get_loclat();
|
|
|
|
nav1_elev = ils.get_gselev();
|
2000-04-25 04:58:25 +00:00
|
|
|
nav1_target_gs = ils.get_gsangle();
|
2000-04-30 22:21:47 +00:00
|
|
|
nav1_radial = ils.get_locheading() + 180.0;
|
|
|
|
while ( nav1_radial < 0.0 ) { nav1_radial += 360.0; }
|
|
|
|
while ( nav1_radial > 360.0 ) { nav1_radial -= 360.0; }
|
2000-04-25 04:58:25 +00:00
|
|
|
// cout << "Found a vor station in range" << endl;
|
|
|
|
// cout << " id = " << ils.get_locident() << endl;
|
|
|
|
// cout << " heading = " << nav1_heading
|
|
|
|
// << " dist = " << nav1_dist << endl;
|
2000-04-24 23:50:59 +00:00
|
|
|
} else {
|
|
|
|
nav1_inrange = false;
|
2000-04-27 03:26:36 +00:00
|
|
|
// cout << "not picking up vor. :-(" << endl;
|
2000-04-24 23:50:59 +00:00
|
|
|
}
|
|
|
|
|
2000-04-30 22:21:47 +00:00
|
|
|
// nav2
|
2000-04-25 03:09:26 +00:00
|
|
|
FGNav nav;
|
2000-04-24 23:50:59 +00:00
|
|
|
if ( current_navlist->query( lon, lat, elev, nav2_freq,
|
2000-04-25 03:09:26 +00:00
|
|
|
&nav, &nav2_heading, &nav2_dist) ) {
|
2000-04-24 23:50:59 +00:00
|
|
|
nav2_inrange = true;
|
2000-04-27 03:26:36 +00:00
|
|
|
nav2_loc = false;
|
2000-04-25 03:09:26 +00:00
|
|
|
nav2_lon = nav.get_lon();
|
|
|
|
nav2_lat = nav.get_lat();
|
|
|
|
nav2_elev = nav.get_elev();
|
2000-04-30 22:21:47 +00:00
|
|
|
nav2_radial = nav2_heading + 180.0;
|
|
|
|
while ( nav2_radial < 0.0 ) { nav2_radial += 360.0; }
|
|
|
|
while ( nav2_radial > 360.0 ) { nav2_radial -= 360.0; }
|
2000-04-25 04:58:25 +00:00
|
|
|
// cout << "Found a vor station in range" << endl;
|
|
|
|
// cout << " id = " << nav.get_ident() << endl;
|
|
|
|
// cout << " heading = " << nav2_heading
|
|
|
|
// << " dist = " << nav2_dist << endl;
|
2000-04-24 23:50:59 +00:00
|
|
|
} else {
|
|
|
|
nav2_inrange = false;
|
2000-04-27 03:26:36 +00:00
|
|
|
// cout << "not picking up vor. :-(" << endl;
|
2000-04-24 23:50:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// adf
|
|
|
|
double junk;
|
|
|
|
if ( current_navlist->query( lon, lat, elev, adf_freq,
|
2000-04-25 03:09:26 +00:00
|
|
|
&nav, &adf_heading, &junk) ) {
|
2000-04-24 23:50:59 +00:00
|
|
|
adf_inrange = true;
|
2000-04-25 03:09:26 +00:00
|
|
|
adf_lon = nav.get_lon();
|
|
|
|
adf_lat = nav.get_lat();
|
|
|
|
adf_elev = nav.get_elev();
|
2000-04-25 04:58:25 +00:00
|
|
|
// cout << "Found an adf station in range" << endl;
|
|
|
|
// cout << " id = " << nav.get_ident() << endl;
|
|
|
|
// cout << " heading = " << adf_heading
|
|
|
|
// << " dist = " << junk << endl;
|
2000-04-24 23:50:59 +00:00
|
|
|
} else {
|
|
|
|
adf_inrange = false;
|
2000-04-27 03:26:36 +00:00
|
|
|
// cout << "not picking up adf. :-(" << endl;
|
2000-04-24 23:50:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|