diff --git a/src/Cockpit/radiostack.cxx b/src/Cockpit/radiostack.cxx index 94a68383a..3c0a91423 100644 --- a/src/Cockpit/radiostack.cxx +++ b/src/Cockpit/radiostack.cxx @@ -27,6 +27,9 @@ #include "radiostack.hxx" +FGRadioStack *current_radiostack; + + // Constructor FGRadioStack::FGRadioStack() { need_update = true; @@ -42,17 +45,16 @@ FGRadioStack::~FGRadioStack() { void FGRadioStack::update( double lon, double lat, double elev ) { need_update = false; - FGNav n; - // nav1 - if ( current_navlist->query( lon, lat, elev, nav1_freq, - &n, &nav1_heading, &nav1_dist) ) { + FGILS ils; + if ( current_ilslist->query( lon, lat, elev, nav1_freq, + &ils, &nav1_heading, &nav1_dist) ) { nav1_inrange = true; - nav1_lon = n.get_lon(); - nav1_lat = n.get_lat(); - nav1_elev = n.get_elev(); + nav1_lon = ils.get_loclon(); + nav1_lat = ils.get_loclat(); + nav1_elev = ils.get_gselev(); cout << "Found a vor station in range" << endl; - cout << " id = " << n.get_ident() << endl; + cout << " id = " << ils.get_locident() << endl; cout << " heading = " << nav1_heading << " dist = " << nav1_dist << endl; } else { @@ -61,14 +63,15 @@ void FGRadioStack::update( double lon, double lat, double elev ) { } // nav1 + FGNav nav; if ( current_navlist->query( lon, lat, elev, nav2_freq, - &n, &nav2_heading, &nav2_dist) ) { + &nav, &nav2_heading, &nav2_dist) ) { nav2_inrange = true; - nav2_lon = n.get_lon(); - nav2_lat = n.get_lat(); - nav2_elev = n.get_elev(); + nav2_lon = nav.get_lon(); + nav2_lat = nav.get_lat(); + nav2_elev = nav.get_elev(); cout << "Found a vor station in range" << endl; - cout << " id = " << n.get_ident() << endl; + cout << " id = " << nav.get_ident() << endl; cout << " heading = " << nav2_heading << " dist = " << nav2_dist << endl; } else { @@ -79,13 +82,13 @@ void FGRadioStack::update( double lon, double lat, double elev ) { // adf double junk; if ( current_navlist->query( lon, lat, elev, adf_freq, - &n, &adf_heading, &junk) ) { + &nav, &adf_heading, &junk) ) { adf_inrange = true; - adf_lon = n.get_lon(); - adf_lat = n.get_lat(); - adf_elev = n.get_elev(); + adf_lon = nav.get_lon(); + adf_lat = nav.get_lat(); + adf_elev = nav.get_elev(); cout << "Found an adf station in range" << endl; - cout << " id = " << n.get_ident() << endl; + cout << " id = " << nav.get_ident() << endl; cout << " heading = " << adf_heading << " dist = " << junk << endl; } else { diff --git a/src/Cockpit/radiostack.hxx b/src/Cockpit/radiostack.hxx index 0457da753..8cddfddf8 100644 --- a/src/Cockpit/radiostack.hxx +++ b/src/Cockpit/radiostack.hxx @@ -109,4 +109,7 @@ public: }; +extern FGRadioStack *current_radiostack; + + #endif // _FG_RADIOSTACK_HXX diff --git a/src/Cockpit/steam.cxx b/src/Cockpit/steam.cxx index 41b5e6b7c..8ec8f211e 100644 --- a/src/Cockpit/steam.cxx +++ b/src/Cockpit/steam.cxx @@ -36,6 +36,7 @@ FG_USING_NAMESPACE(std); +#include "radiostack.hxx" #include "steam.hxx" diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 3bf3ff11f..33f6fba7c 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -59,6 +59,7 @@ #include #include #include +#include #include #include #include @@ -469,6 +470,21 @@ bool fgInitSubsystems( void ) { p_fix.append( "Navaids/default.fix" ); current_fixlist->init( p_fix ); + // Initialize the underlying radio stack model + current_radiostack = new FGRadioStack; + + current_radiostack->set_nav1_freq( 111.70 ); + current_radiostack->set_nav1_radial( 280.0 ); + + current_radiostack->set_nav2_freq( 117.80 ); + current_radiostack->set_nav2_radial( 068.0 ); + + current_radiostack->set_adf_freq( 210.0 ); + + current_radiostack->update( cur_fdm_state->get_Longitude(), + cur_fdm_state->get_Latitude(), + cur_fdm_state->get_Altitude() * FEET_TO_METER ); + // Initialize the Cockpit subsystem if( fgCockpitInit( ¤t_aircraft )) { // Cockpit initialized ok. diff --git a/src/Main/main.cxx b/src/Main/main.cxx index f1d9ad8f6..61c104f2a 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -78,6 +78,7 @@ #include #include +#include #include #include #include @@ -742,6 +743,11 @@ void fgUpdateTimeDepCalcs(int multi_loop, int remainder) { // Update solar system ephem->update( t, cur_fdm_state->get_Latitude() ); + + // Update radio stack model + current_radiostack->update( cur_fdm_state->get_Longitude(), + cur_fdm_state->get_Latitude(), + cur_fdm_state->get_Altitude() * FEET_TO_METER ); } diff --git a/src/Navaids/ils.hxx b/src/Navaids/ils.hxx index c75ae6173..68bf72adc 100644 --- a/src/Navaids/ils.hxx +++ b/src/Navaids/ils.hxx @@ -83,6 +83,7 @@ public: inline double get_locheading() const { return locheading; } inline double get_loclat() const { return loclat; } inline double get_loclon() const { return loclon; } + inline double get_gselev() const { return gselev; } inline double get_gsangle() const { return gsangle; } inline double get_gslat() const { return gslat; } inline double get_gslon() const { return gslon; }