More tweaks to radios so we can listen to Nav2 and ADF as well.
Fixed a bug which could make a station appear to be out of range when it isn't. Expanded usable range to 1.3x times the FAA guaranteed service volume.
This commit is contained in:
parent
bdde4e0581
commit
07c23f5866
2 changed files with 201 additions and 35 deletions
|
@ -32,7 +32,11 @@
|
||||||
#include "radiostack.hxx"
|
#include "radiostack.hxx"
|
||||||
|
|
||||||
static int nav1_play_count = 0;
|
static int nav1_play_count = 0;
|
||||||
|
static int nav2_play_count = 0;
|
||||||
|
static int adf_play_count = 0;
|
||||||
static time_t nav1_last_time = 0;
|
static time_t nav1_last_time = 0;
|
||||||
|
static time_t nav2_last_time = 0;
|
||||||
|
static time_t adf_last_time = 0;
|
||||||
|
|
||||||
|
|
||||||
FGRadioStack *current_radiostack;
|
FGRadioStack *current_radiostack;
|
||||||
|
@ -179,6 +183,12 @@ FGRadioStack::bind ()
|
||||||
&FGRadioStack::get_adf_alt_freq, &FGRadioStack::set_adf_alt_freq);
|
&FGRadioStack::get_adf_alt_freq, &FGRadioStack::set_adf_alt_freq);
|
||||||
fgTie("/radios/adf/rotation", this,
|
fgTie("/radios/adf/rotation", this,
|
||||||
&FGRadioStack::get_adf_rotation, &FGRadioStack::set_adf_rotation);
|
&FGRadioStack::get_adf_rotation, &FGRadioStack::set_adf_rotation);
|
||||||
|
fgTie("/radios/adf/on", this,
|
||||||
|
&FGRadioStack::get_adf_on_btn,
|
||||||
|
&FGRadioStack::set_adf_on_btn);
|
||||||
|
fgTie("/radios/adf/ident", this,
|
||||||
|
&FGRadioStack::get_adf_ident_btn,
|
||||||
|
&FGRadioStack::set_adf_ident_btn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -215,6 +225,8 @@ FGRadioStack::unbind ()
|
||||||
fgUntie("/radios/adf/frequencies/selected");
|
fgUntie("/radios/adf/frequencies/selected");
|
||||||
fgUntie("/radios/adf/frequencies/standby");
|
fgUntie("/radios/adf/frequencies/standby");
|
||||||
fgUntie("/radios/adf/rotation");
|
fgUntie("/radios/adf/rotation");
|
||||||
|
fgUntie("/radios/adf/on");
|
||||||
|
fgUntie("/radios/adf/ident");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -222,6 +234,9 @@ FGRadioStack::unbind ()
|
||||||
double FGRadioStack::adjustNavRange( double stationElev, double aircraftElev,
|
double FGRadioStack::adjustNavRange( double stationElev, double aircraftElev,
|
||||||
double nominalRange )
|
double nominalRange )
|
||||||
{
|
{
|
||||||
|
// extend out actual usable range to be 1.3x the published safe range
|
||||||
|
const double usability_factor = 1.3;
|
||||||
|
|
||||||
// assumptions we model the standard service volume, plus
|
// assumptions we model the standard service volume, plus
|
||||||
// ... rather than specifying a cylinder, we model a cone that
|
// ... rather than specifying a cylinder, we model a cone that
|
||||||
// contains the cylinder. Then we put an upside down cone on top
|
// contains the cylinder. Then we put an upside down cone on top
|
||||||
|
@ -234,15 +249,17 @@ double FGRadioStack::adjustNavRange( double stationElev, double aircraftElev,
|
||||||
|
|
||||||
if ( nominalRange < 25.0 + FG_EPSILON ) {
|
if ( nominalRange < 25.0 + FG_EPSILON ) {
|
||||||
// Standard Terminal Service Volume
|
// Standard Terminal Service Volume
|
||||||
return term_tbl->interpolate( alt );
|
return term_tbl->interpolate( alt ) * usability_factor;
|
||||||
} else if ( nominalRange < 50.0 + FG_EPSILON ) {
|
} else if ( nominalRange < 50.0 + FG_EPSILON ) {
|
||||||
// Standard Low Altitude Service Volume
|
// Standard Low Altitude Service Volume
|
||||||
// table is based on range of 40, scale to actual range
|
// table is based on range of 40, scale to actual range
|
||||||
return low_tbl->interpolate( alt ) * nominalRange / 40.0;
|
return low_tbl->interpolate( alt ) * nominalRange / 40.0
|
||||||
|
* usability_factor;
|
||||||
} else {
|
} else {
|
||||||
// Standard High Altitude Service Volume
|
// Standard High Altitude Service Volume
|
||||||
// table is based on range of 130, scale to actual range
|
// table is based on range of 130, scale to actual range
|
||||||
return high_tbl->interpolate( alt ) * nominalRange / 130.0;
|
return high_tbl->interpolate( alt ) * nominalRange / 130.0
|
||||||
|
* usability_factor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,14 +332,14 @@ FGRadioStack::update()
|
||||||
double offset = nav1_heading - nav1_radial;
|
double offset = nav1_heading - nav1_radial;
|
||||||
while ( offset < -180.0 ) { offset += 360.0; }
|
while ( offset < -180.0 ) { offset += 360.0; }
|
||||||
while ( offset > 180.0 ) { offset -= 360.0; }
|
while ( offset > 180.0 ) { offset -= 360.0; }
|
||||||
cout << "ils offset = " << offset << endl;
|
// cout << "ils offset = " << offset << endl;
|
||||||
nav1_effective_range = adjustILSRange(nav1_elev, elev, offset,
|
nav1_effective_range = adjustILSRange(nav1_elev, elev, offset,
|
||||||
nav1_loc_dist * METER_TO_NM );
|
nav1_loc_dist * METER_TO_NM );
|
||||||
} else {
|
} else {
|
||||||
nav1_effective_range = adjustNavRange(nav1_elev, elev, nav1_range);
|
nav1_effective_range = adjustNavRange(nav1_elev, elev, nav1_range);
|
||||||
}
|
}
|
||||||
cout << "nav1 range = " << nav1_effective_range
|
// cout << "nav1 range = " << nav1_effective_range
|
||||||
<< " (" << nav1_range << ")" << endl;
|
// << " (" << nav1_range << ")" << endl;
|
||||||
|
|
||||||
if ( nav1_loc_dist < nav1_effective_range * NM_TO_METER ) {
|
if ( nav1_loc_dist < nav1_effective_range * NM_TO_METER ) {
|
||||||
nav1_inrange = true;
|
nav1_inrange = true;
|
||||||
|
@ -403,14 +420,14 @@ FGRadioStack::update()
|
||||||
double offset = nav2_heading - nav2_radial;
|
double offset = nav2_heading - nav2_radial;
|
||||||
while ( offset < -180.0 ) { offset += 360.0; }
|
while ( offset < -180.0 ) { offset += 360.0; }
|
||||||
while ( offset > 180.0 ) { offset -= 360.0; }
|
while ( offset > 180.0 ) { offset -= 360.0; }
|
||||||
cout << "ils offset = " << offset << endl;
|
// cout << "ils offset = " << offset << endl;
|
||||||
nav2_effective_range = adjustILSRange(nav2_elev, elev, offset,
|
nav2_effective_range = adjustILSRange(nav2_elev, elev, offset,
|
||||||
nav2_loc_dist * METER_TO_NM );
|
nav2_loc_dist * METER_TO_NM );
|
||||||
} else {
|
} else {
|
||||||
nav2_effective_range = adjustNavRange(nav2_elev, elev, nav2_range);
|
nav2_effective_range = adjustNavRange(nav2_elev, elev, nav2_range);
|
||||||
}
|
}
|
||||||
cout << "nav2 range = " << nav2_effective_range
|
// cout << "nav2 range = " << nav2_effective_range
|
||||||
<< " (" << nav2_range << ")" << endl;
|
// << " (" << nav2_range << ")" << endl;
|
||||||
|
|
||||||
if ( nav2_loc_dist < nav2_effective_range * NM_TO_METER ) {
|
if ( nav2_loc_dist < nav2_effective_range * NM_TO_METER ) {
|
||||||
nav2_inrange = true;
|
nav2_inrange = true;
|
||||||
|
@ -431,6 +448,35 @@ FGRadioStack::update()
|
||||||
// cout << "not picking up vor. :-(" << endl;
|
// cout << "not picking up vor. :-(" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( nav2_valid && nav2_inrange ) {
|
||||||
|
// play station ident via audio system if on + ident,
|
||||||
|
// otherwise turn it off
|
||||||
|
if ( nav2_on_btn && nav2_ident_btn ) {
|
||||||
|
if ( nav2_last_time <
|
||||||
|
globals->get_time_params()->get_cur_time() - 30 ) {
|
||||||
|
nav2_last_time = globals->get_time_params()->get_cur_time();
|
||||||
|
nav2_play_count = 0;
|
||||||
|
}
|
||||||
|
if ( nav2_play_count < 4 ) {
|
||||||
|
// play VOR ident
|
||||||
|
if ( !globals->get_soundmgr()->is_playing("nav2-vor-ident") ) {
|
||||||
|
globals->get_soundmgr()->play_once( "nav2-vor-ident" );
|
||||||
|
++nav2_play_count;
|
||||||
|
}
|
||||||
|
} else if ( nav2_play_count < 5 && nav2_has_dme ) {
|
||||||
|
// play DME ident
|
||||||
|
if ( !globals->get_soundmgr()->is_playing("nav2-vor-ident") &&
|
||||||
|
!globals->get_soundmgr()->is_playing("nav2-dme-ident") ) {
|
||||||
|
globals->get_soundmgr()->play_once( "nav2-dme-ident" );
|
||||||
|
++nav2_play_count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
globals->get_soundmgr()->stop( "nav2-vor-ident" );
|
||||||
|
globals->get_soundmgr()->stop( "nav2-dme-ident" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// adf
|
// adf
|
||||||
if ( adf_valid ) {
|
if ( adf_valid ) {
|
||||||
// staightline distance
|
// staightline distance
|
||||||
|
@ -458,6 +504,27 @@ FGRadioStack::update()
|
||||||
} else {
|
} else {
|
||||||
adf_inrange = false;
|
adf_inrange = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( adf_valid && adf_inrange ) {
|
||||||
|
// play station ident via audio system if on + ident,
|
||||||
|
// otherwise turn it off
|
||||||
|
if ( adf_on_btn && adf_ident_btn ) {
|
||||||
|
if ( adf_last_time <
|
||||||
|
globals->get_time_params()->get_cur_time() - 30 ) {
|
||||||
|
adf_last_time = globals->get_time_params()->get_cur_time();
|
||||||
|
adf_play_count = 0;
|
||||||
|
}
|
||||||
|
if ( adf_play_count < 4 ) {
|
||||||
|
// play ADF ident
|
||||||
|
if ( !globals->get_soundmgr()->is_playing("adf-ident") ) {
|
||||||
|
globals->get_soundmgr()->play_once( "adf-ident" );
|
||||||
|
++adf_play_count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
globals->get_soundmgr()->stop( "adf-ident" );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -474,15 +541,16 @@ void FGRadioStack::search()
|
||||||
|
|
||||||
static string last_nav1_ident = "";
|
static string last_nav1_ident = "";
|
||||||
static string last_nav2_ident = "";
|
static string last_nav2_ident = "";
|
||||||
|
static string last_adf_ident = "";
|
||||||
static bool last_nav1_vor = false;
|
static bool last_nav1_vor = false;
|
||||||
static bool last_nav2_vor = false;
|
static bool last_nav2_vor = false;
|
||||||
if ( current_ilslist->query( lon, lat, elev, nav1_freq, &ils ) ) {
|
if ( current_ilslist->query( lon, lat, elev, nav1_freq, &ils ) ) {
|
||||||
nav1_ident = ils.get_locident();
|
nav1_ident = ils.get_locident();
|
||||||
|
nav1_valid = true;
|
||||||
if ( last_nav1_ident != nav1_ident || last_nav1_vor ) {
|
if ( last_nav1_ident != nav1_ident || last_nav1_vor ) {
|
||||||
nav1_trans_ident = ils.get_trans_ident();
|
nav1_trans_ident = ils.get_trans_ident();
|
||||||
last_nav1_ident = nav1_ident;
|
last_nav1_ident = nav1_ident;
|
||||||
last_nav1_vor = false;
|
last_nav1_vor = false;
|
||||||
nav1_valid = true;
|
|
||||||
nav1_loc = true;
|
nav1_loc = true;
|
||||||
nav1_has_dme = ils.get_has_dme();
|
nav1_has_dme = ils.get_has_dme();
|
||||||
nav1_has_gs = ils.get_has_gs();
|
nav1_has_gs = ils.get_has_gs();
|
||||||
|
@ -530,20 +598,22 @@ void FGRadioStack::search()
|
||||||
nav1_play_count = offset / 4;
|
nav1_play_count = offset / 4;
|
||||||
nav1_last_time = globals->get_time_params()->get_cur_time() -
|
nav1_last_time = globals->get_time_params()->get_cur_time() -
|
||||||
offset;
|
offset;
|
||||||
cout << "offset = " << offset << " play_count = " << nav1_play_count
|
// cout << "offset = " << offset << " play_count = "
|
||||||
<< " nav1_last_time = " << nav1_last_time << " current time = "
|
// << nav1_play_count
|
||||||
<< globals->get_time_params()->get_cur_time() << endl;
|
// << " nav1_last_time = " << nav1_last_time
|
||||||
|
// << " current time = "
|
||||||
|
// << globals->get_time_params()->get_cur_time() << endl;
|
||||||
|
|
||||||
cout << "Found an ils station in range" << endl;
|
// cout << "Found an ils station in range" << endl;
|
||||||
cout << " id = " << ils.get_locident() << endl;
|
// cout << " id = " << ils.get_locident() << endl;
|
||||||
}
|
}
|
||||||
} else if ( current_navlist->query( lon, lat, elev, nav1_freq, &nav ) ) {
|
} else if ( current_navlist->query( lon, lat, elev, nav1_freq, &nav ) ) {
|
||||||
nav1_ident = nav.get_ident();
|
nav1_ident = nav.get_ident();
|
||||||
|
nav1_valid = true;
|
||||||
if ( last_nav1_ident != nav1_ident || !last_nav1_vor ) {
|
if ( last_nav1_ident != nav1_ident || !last_nav1_vor ) {
|
||||||
last_nav1_ident = nav1_ident;
|
last_nav1_ident = nav1_ident;
|
||||||
last_nav1_vor = true;
|
last_nav1_vor = true;
|
||||||
nav1_trans_ident = nav.get_trans_ident();
|
nav1_trans_ident = nav.get_trans_ident();
|
||||||
nav1_valid = true;
|
|
||||||
nav1_loc = false;
|
nav1_loc = false;
|
||||||
nav1_has_dme = nav.get_has_dme();
|
nav1_has_dme = nav.get_has_dme();
|
||||||
nav1_has_gs = false;
|
nav1_has_gs = false;
|
||||||
|
@ -578,30 +648,33 @@ void FGRadioStack::search()
|
||||||
nav1_play_count = offset / 4;
|
nav1_play_count = offset / 4;
|
||||||
nav1_last_time = globals->get_time_params()->get_cur_time() -
|
nav1_last_time = globals->get_time_params()->get_cur_time() -
|
||||||
offset;
|
offset;
|
||||||
cout << "offset = " << offset << " play_count = " << nav1_play_count
|
// cout << "offset = " << offset << " play_count = "
|
||||||
<< " nav1_last_time = " << nav1_last_time << " current time = "
|
// << nav1_play_count << " nav1_last_time = "
|
||||||
<< globals->get_time_params()->get_cur_time() << endl;
|
// << nav1_last_time << " current time = "
|
||||||
|
// << globals->get_time_params()->get_cur_time() << endl;
|
||||||
|
|
||||||
cout << "Found a vor station in range" << endl;
|
// cout << "Found a vor station in range" << endl;
|
||||||
cout << " id = " << nav.get_ident() << endl;
|
// cout << " id = " << nav.get_ident() << endl;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nav1_valid = false;
|
nav1_valid = false;
|
||||||
nav1_ident = "";
|
nav1_ident = "";
|
||||||
nav1_radial = 0;
|
nav1_radial = 0;
|
||||||
nav1_dme_dist = 0;
|
nav1_dme_dist = 0;
|
||||||
|
nav1_trans_ident = "";
|
||||||
|
last_nav1_ident = "";
|
||||||
globals->get_soundmgr()->remove( "nav1-vor-ident" );
|
globals->get_soundmgr()->remove( "nav1-vor-ident" );
|
||||||
globals->get_soundmgr()->remove( "nav1-dme-ident" );
|
globals->get_soundmgr()->remove( "nav1-dme-ident" );
|
||||||
cout << "not picking up vor1. :-(" << endl;
|
// cout << "not picking up vor1. :-(" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( current_ilslist->query( lon, lat, elev, nav2_freq, &ils ) ) {
|
if ( current_ilslist->query( lon, lat, elev, nav2_freq, &ils ) ) {
|
||||||
nav2_ident = ils.get_locident();
|
nav2_ident = ils.get_locident();
|
||||||
|
nav2_valid = true;
|
||||||
if ( last_nav2_ident != nav2_ident || last_nav2_vor ) {
|
if ( last_nav2_ident != nav2_ident || last_nav2_vor ) {
|
||||||
last_nav2_ident = nav2_ident;
|
last_nav2_ident = nav2_ident;
|
||||||
last_nav2_vor = false;
|
last_nav2_vor = false;
|
||||||
nav2_trans_ident = ils.get_trans_ident();
|
nav2_trans_ident = ils.get_trans_ident();
|
||||||
nav2_valid = true;
|
|
||||||
nav2_loc = true;
|
nav2_loc = true;
|
||||||
nav2_has_dme = ils.get_has_dme();
|
nav2_has_dme = ils.get_has_dme();
|
||||||
nav2_has_gs = ils.get_has_gs();
|
nav2_has_gs = ils.get_has_gs();
|
||||||
|
@ -625,16 +698,41 @@ void FGRadioStack::search()
|
||||||
nav2_dme_x = ils.get_dme_x();
|
nav2_dme_x = ils.get_dme_x();
|
||||||
nav2_dme_y = ils.get_dme_y();
|
nav2_dme_y = ils.get_dme_y();
|
||||||
nav2_dme_z = ils.get_dme_z();
|
nav2_dme_z = ils.get_dme_z();
|
||||||
|
|
||||||
|
if ( globals->get_soundmgr()->exists( "nav2-vor-ident" ) ) {
|
||||||
|
globals->get_soundmgr()->remove( "nav2-vor-ident" );
|
||||||
|
}
|
||||||
|
FGSimpleSound *sound;
|
||||||
|
sound = morse.make_ident( nav2_trans_ident, LO_FREQUENCY );
|
||||||
|
sound->set_volume( 0.3 );
|
||||||
|
globals->get_soundmgr()->add( sound, "nav2-vor-ident" );
|
||||||
|
|
||||||
|
if ( globals->get_soundmgr()->exists( "nav2-dme-ident" ) ) {
|
||||||
|
globals->get_soundmgr()->remove( "nav2-dme-ident" );
|
||||||
|
}
|
||||||
|
sound = morse.make_ident( nav2_trans_ident, HI_FREQUENCY );
|
||||||
|
sound->set_volume( 0.3 );
|
||||||
|
globals->get_soundmgr()->add( sound, "nav2-dme-ident" );
|
||||||
|
|
||||||
|
int offset = (int)(sg_random() * 30.0);
|
||||||
|
nav2_play_count = offset / 4;
|
||||||
|
nav2_last_time = globals->get_time_params()->get_cur_time() -
|
||||||
|
offset;
|
||||||
|
// cout << "offset = " << offset << " play_count = "
|
||||||
|
// << nav2_play_count << " nav2_last_time = "
|
||||||
|
// << nav2_last_time << " current time = "
|
||||||
|
// << globals->get_time_params()->get_cur_time() << endl;
|
||||||
|
|
||||||
// cout << "Found an ils station in range" << endl;
|
// cout << "Found an ils station in range" << endl;
|
||||||
// cout << " id = " << ils.get_locident() << endl;
|
// cout << " id = " << ils.get_locident() << endl;
|
||||||
}
|
}
|
||||||
} else if ( current_navlist->query( lon, lat, elev, nav2_freq, &nav ) ) {
|
} else if ( current_navlist->query( lon, lat, elev, nav2_freq, &nav ) ) {
|
||||||
nav2_ident = nav.get_ident();
|
nav2_ident = nav.get_ident();
|
||||||
|
nav2_valid = true;
|
||||||
if ( last_nav2_ident != nav2_ident || !last_nav2_vor ) {
|
if ( last_nav2_ident != nav2_ident || !last_nav2_vor ) {
|
||||||
last_nav2_ident = nav2_ident;
|
last_nav2_ident = nav2_ident;
|
||||||
last_nav2_vor = true;
|
last_nav2_vor = true;
|
||||||
nav2_trans_ident = nav.get_trans_ident();
|
nav2_trans_ident = nav.get_trans_ident();
|
||||||
nav2_valid = true;
|
|
||||||
nav2_loc = false;
|
nav2_loc = false;
|
||||||
nav2_has_dme = nav.get_has_dme();
|
nav2_has_dme = nav.get_has_dme();
|
||||||
nav2_has_dme = false;
|
nav2_has_dme = false;
|
||||||
|
@ -649,6 +747,31 @@ void FGRadioStack::search()
|
||||||
nav2_x = nav2_dme_x = nav.get_x();
|
nav2_x = nav2_dme_x = nav.get_x();
|
||||||
nav2_y = nav2_dme_y = nav.get_y();
|
nav2_y = nav2_dme_y = nav.get_y();
|
||||||
nav2_z = nav2_dme_z = nav.get_z();
|
nav2_z = nav2_dme_z = nav.get_z();
|
||||||
|
|
||||||
|
if ( globals->get_soundmgr()->exists( "nav2-vor-ident" ) ) {
|
||||||
|
globals->get_soundmgr()->remove( "nav2-vor-ident" );
|
||||||
|
}
|
||||||
|
FGSimpleSound *sound;
|
||||||
|
sound = morse.make_ident( nav2_trans_ident, LO_FREQUENCY );
|
||||||
|
sound->set_volume( 0.3 );
|
||||||
|
globals->get_soundmgr()->add( sound, "nav2-vor-ident" );
|
||||||
|
|
||||||
|
if ( globals->get_soundmgr()->exists( "nav2-dme-ident" ) ) {
|
||||||
|
globals->get_soundmgr()->remove( "nav2-dme-ident" );
|
||||||
|
}
|
||||||
|
sound = morse.make_ident( nav2_trans_ident, HI_FREQUENCY );
|
||||||
|
sound->set_volume( 0.3 );
|
||||||
|
globals->get_soundmgr()->add( sound, "nav2-dme-ident" );
|
||||||
|
|
||||||
|
int offset = (int)(sg_random() * 30.0);
|
||||||
|
nav2_play_count = offset / 4;
|
||||||
|
nav2_last_time = globals->get_time_params()->get_cur_time() -
|
||||||
|
offset;
|
||||||
|
// cout << "offset = " << offset << " play_count = "
|
||||||
|
// << nav2_play_count << " nav2_last_time = "
|
||||||
|
// << nav2_last_time << " current time = "
|
||||||
|
// << globals->get_time_params()->get_cur_time() << endl;
|
||||||
|
|
||||||
// cout << "Found a vor station in range" << endl;
|
// cout << "Found a vor station in range" << endl;
|
||||||
// cout << " id = " << nav.get_ident() << endl;
|
// cout << " id = " << nav.get_ident() << endl;
|
||||||
}
|
}
|
||||||
|
@ -657,25 +780,60 @@ void FGRadioStack::search()
|
||||||
nav2_ident = "";
|
nav2_ident = "";
|
||||||
nav2_radial = 0;
|
nav2_radial = 0;
|
||||||
nav2_dme_dist = 0;
|
nav2_dme_dist = 0;
|
||||||
// cout << "not picking up vor2. :-(" << endl;
|
nav2_trans_ident = "";
|
||||||
|
last_nav2_ident = "";
|
||||||
|
globals->get_soundmgr()->remove( "nav2-vor-ident" );
|
||||||
|
globals->get_soundmgr()->remove( "nav2-dme-ident" );
|
||||||
|
// cout << "not picking up vor1. :-(" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// adf
|
// adf
|
||||||
if ( current_navlist->query( lon, lat, elev, adf_freq, &nav ) ) {
|
if ( current_navlist->query( lon, lat, elev, adf_freq, &nav ) ) {
|
||||||
|
char freq[128];
|
||||||
|
snprintf( freq, 10, "%.0f", adf_freq );
|
||||||
|
adf_ident = freq;
|
||||||
|
adf_ident += nav.get_ident();
|
||||||
|
// cout << "adf ident = " << adf_ident << endl;
|
||||||
adf_valid = true;
|
adf_valid = true;
|
||||||
|
if ( last_adf_ident != adf_ident ) {
|
||||||
|
last_adf_ident = adf_ident;
|
||||||
|
|
||||||
adf_lon = nav.get_lon();
|
adf_trans_ident = nav.get_trans_ident();
|
||||||
adf_lat = nav.get_lat();
|
adf_lon = nav.get_lon();
|
||||||
adf_elev = nav.get_elev();
|
adf_lat = nav.get_lat();
|
||||||
adf_range = nav.get_range();
|
adf_elev = nav.get_elev();
|
||||||
adf_effective_range = kludgeRange(adf_elev, elev, adf_range);
|
adf_range = nav.get_range();
|
||||||
adf_x = nav.get_x();
|
adf_effective_range = kludgeRange(adf_elev, elev, adf_range);
|
||||||
adf_y = nav.get_y();
|
adf_x = nav.get_x();
|
||||||
adf_z = nav.get_z();
|
adf_y = nav.get_y();
|
||||||
// cout << "Found an adf station in range" << endl;
|
adf_z = nav.get_z();
|
||||||
// cout << " id = " << nav.get_ident() << endl;
|
|
||||||
|
if ( globals->get_soundmgr()->exists( "adf-ident" ) ) {
|
||||||
|
globals->get_soundmgr()->remove( "adf-ident" );
|
||||||
|
}
|
||||||
|
FGSimpleSound *sound;
|
||||||
|
sound = morse.make_ident( adf_trans_ident, LO_FREQUENCY );
|
||||||
|
sound->set_volume( 0.3 );
|
||||||
|
globals->get_soundmgr()->add( sound, "adf-ident" );
|
||||||
|
|
||||||
|
int offset = (int)(sg_random() * 30.0);
|
||||||
|
adf_play_count = offset / 4;
|
||||||
|
adf_last_time = globals->get_time_params()->get_cur_time() -
|
||||||
|
offset;
|
||||||
|
// cout << "offset = " << offset << " play_count = "
|
||||||
|
// << adf_play_count << " adf_last_time = "
|
||||||
|
// << adf_last_time << " current time = "
|
||||||
|
// << globals->get_time_params()->get_cur_time() << endl;
|
||||||
|
|
||||||
|
// cout << "Found an adf station in range" << endl;
|
||||||
|
// cout << " id = " << nav.get_ident() << endl;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
adf_valid = false;
|
adf_valid = false;
|
||||||
|
adf_ident = "";
|
||||||
|
adf_trans_ident = "";
|
||||||
|
globals->get_soundmgr()->remove( "adf-ident" );
|
||||||
|
last_adf_ident = "";
|
||||||
// cout << "not picking up adf. :-(" << endl;
|
// cout << "not picking up adf. :-(" << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,6 +127,8 @@ class FGRadioStack : public FGSubsystem
|
||||||
bool nav2_on_btn;
|
bool nav2_on_btn;
|
||||||
bool nav2_ident_btn;
|
bool nav2_ident_btn;
|
||||||
|
|
||||||
|
string adf_ident;
|
||||||
|
string adf_trans_ident;
|
||||||
bool adf_valid;
|
bool adf_valid;
|
||||||
bool adf_inrange;
|
bool adf_inrange;
|
||||||
double adf_freq;
|
double adf_freq;
|
||||||
|
@ -142,6 +144,8 @@ class FGRadioStack : public FGSubsystem
|
||||||
double adf_x;
|
double adf_x;
|
||||||
double adf_y;
|
double adf_y;
|
||||||
double adf_z;
|
double adf_z;
|
||||||
|
bool adf_on_btn;
|
||||||
|
bool adf_ident_btn;
|
||||||
|
|
||||||
// model standard VOR/DME/TACAN service volumes as per AIM 1-1-8
|
// model standard VOR/DME/TACAN service volumes as per AIM 1-1-8
|
||||||
double adjustNavRange( double stationElev, double aircraftElev,
|
double adjustNavRange( double stationElev, double aircraftElev,
|
||||||
|
@ -192,6 +196,8 @@ public:
|
||||||
}
|
}
|
||||||
inline void set_adf_alt_freq( double freq ) { adf_alt_freq = freq; }
|
inline void set_adf_alt_freq( double freq ) { adf_alt_freq = freq; }
|
||||||
inline void set_adf_rotation( double rot ) { adf_rotation = rot; }
|
inline void set_adf_rotation( double rot ) { adf_rotation = rot; }
|
||||||
|
inline void set_adf_on_btn( bool val ) { adf_on_btn = val; }
|
||||||
|
inline void set_adf_ident_btn( bool val ) { adf_ident_btn = val; }
|
||||||
|
|
||||||
|
|
||||||
// NAV1 Accessors
|
// NAV1 Accessors
|
||||||
|
@ -270,6 +276,8 @@ public:
|
||||||
inline double get_adf_lon() const { return adf_lon; }
|
inline double get_adf_lon() const { return adf_lon; }
|
||||||
inline double get_adf_lat() const { return adf_lat; }
|
inline double get_adf_lat() const { return adf_lat; }
|
||||||
inline double get_adf_heading() const { return adf_heading; }
|
inline double get_adf_heading() const { return adf_heading; }
|
||||||
|
inline bool get_adf_on_btn() const { return adf_on_btn; }
|
||||||
|
inline bool get_adf_ident_btn() const { return adf_ident_btn; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue