lon_node(fgGetNode("/position/longitude-deg", true)),
lat_node(fgGetNode("/position/latitude-deg", true)),
alt_node(fgGetNode("/position/altitude-ft", true)),
+ is_valid_node(NULL),
power_btn_node(NULL),
freq_node(NULL),
alt_freq_node(NULL),
fgGetNode(("/systems/electrical/outputs/" + name).c_str(), true);
// inputs
+ is_valid_node = node->getChild("data-is-valid", 0, true);
power_btn_node = node->getChild("power-btn", 0, true);
power_btn_node->setBoolValue( true );
vol_btn_node = node->getChild("volume", 0, true);
void
FGNavRadio::update(double dt)
{
+ // Do a nav station search only once a second to reduce
+ // unnecessary work. (Also, make sure to do this before caching
+ // any values!)
+ _time_before_search_sec -= dt;
+ if ( _time_before_search_sec < 0 ) {
+ search();
+ }
+
// cache a few strategic values locally for speed
double lon = lon_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
double lat = lat_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
sprintf( tmp, "%.2f", alt_freq_node->getDoubleValue() );
fmt_alt_freq_node->setStringValue(tmp);
- // Do a nav station search only once a second to reduce
- // unnecessary work.
- _time_before_search_sec -= dt;
- if ( _time_before_search_sec < 0 ) {
- search();
- }
-
// cout << "is_valid = " << is_valid
// << " power_btn = " << power_btn
// << " bus_power = " << bus_power_node->getDoubleValue()
if ( globals->get_soundmgr()->exists( nav_fx_name ) ) {
globals->get_soundmgr()->remove( nav_fx_name );
}
- SGSoundSample *sound;
- sound = morse.make_ident( trans_ident, LO_FREQUENCY );
- sound->set_volume( 0.3 );
- if ( globals->get_soundmgr()->add( sound, nav_fx_name ) ) {
- // cout << "Added nav-vor-ident sound" << endl;
- } else {
- SG_LOG(SG_COCKPIT, SG_WARN, "Failed to add v1-vor-ident sound");
- }
-
- if ( globals->get_soundmgr()->exists( dme_fx_name ) ) {
- globals->get_soundmgr()->remove( dme_fx_name );
- }
- sound = morse.make_ident( trans_ident, HI_FREQUENCY );
- sound->set_volume( 0.3 );
- globals->get_soundmgr()->add( sound, dme_fx_name );
-
- int offset = (int)(sg_random() * 30.0);
- play_count = offset / 4;
- last_time = globals->get_time_params()->get_cur_time() - offset;
- // cout << "offset = " << offset << " play_count = "
- // << play_count << " last_time = "
- // << last_time << " current time = "
- // << globals->get_time_params()->get_cur_time() << endl;
+ try {
+ SGSoundSample *sound;
+ sound = morse.make_ident( trans_ident, LO_FREQUENCY );
+ sound->set_volume( 0.3 );
+ if ( globals->get_soundmgr()->add( sound, nav_fx_name ) ) {
+ // cout << "Added nav-vor-ident sound" << endl;
+ } else {
+ SG_LOG(SG_COCKPIT, SG_WARN, "Failed to add v1-vor-ident sound");
+ }
- // cout << "Found a vor station in range" << endl;
- // cout << " id = " << nav->get_ident() << endl;
+ if ( globals->get_soundmgr()->exists( dme_fx_name ) ) {
+ globals->get_soundmgr()->remove( dme_fx_name );
+ }
+ sound = morse.make_ident( trans_ident, HI_FREQUENCY );
+ sound->set_volume( 0.3 );
+ globals->get_soundmgr()->add( sound, dme_fx_name );
+
+ int offset = (int)(sg_random() * 30.0);
+ play_count = offset / 4;
+ last_time = globals->get_time_params()->get_cur_time() - offset;
+ // cout << "offset = " << offset << " play_count = "
+ // << play_count << " last_time = "
+ // << last_time << " current time = "
+ // << globals->get_time_params()->get_cur_time() << endl;
+
+ // cout << "Found a vor station in range" << endl;
+ // cout << " id = " << nav->get_ident() << endl;
+ } catch ( sg_io_exception &e ) {
+ SG_LOG(SG_GENERAL, SG_ALERT, e.getFormattedMessage());
+ }
}
} else {
is_valid = false;
// cout << "not picking up vor1. :-(" << endl;
}
+ is_valid_node->setBoolValue( is_valid );
+
char tmpid[5];
strncpy( tmpid, nav_id.c_str(), 5 );
id_c1_node->setIntValue( (int)tmpid[0] );