From 6d6f0d3e71a9d774803e3a98d45f4c471b238587 Mon Sep 17 00:00:00 2001 From: curt Date: Mon, 12 Mar 2001 12:40:18 +0000 Subject: [PATCH] Cleaned up a few things relating to playing morse audio vor/ils idents. --- src/Cockpit/radiostack.cxx | 24 ++++++++++++++---------- src/Cockpit/radiostack.hxx | 2 ++ src/Navaids/ils.hxx | 15 +++++++++++++-- src/Navaids/nav.hxx | 9 +++++++++ src/Sound/soundmgr.cxx | 17 ----------------- 5 files changed, 38 insertions(+), 29 deletions(-) diff --git a/src/Cockpit/radiostack.cxx b/src/Cockpit/radiostack.cxx index 4c5bef248..e706317b7 100644 --- a/src/Cockpit/radiostack.cxx +++ b/src/Cockpit/radiostack.cxx @@ -259,7 +259,13 @@ FGRadioStack::update() } else { nav1_radial = nav1_sel_radial; } + } else { + nav1_inrange = false; + nav1_dme_dist = 0.0; + // cout << "not picking up vor. :-(" << endl; + } + if ( nav1_valid && nav1_inrange ) { // play station ident via audio system if on + ident, // otherwise turn it off if ( nav1_on_btn && nav1_ident_btn ) { @@ -286,12 +292,6 @@ FGRadioStack::update() globals->get_soundmgr()->stop( "nav1-vor-ident" ); globals->get_soundmgr()->stop( "nav1-dme-ident" ); } - } else { - nav1_inrange = false; - nav1_dme_dist = 0.0; - globals->get_soundmgr()->stop( "nav1-vor-ident" ); - globals->get_soundmgr()->stop( "nav1-dme-ident" ); - // cout << "not picking up vor. :-(" << endl; } if ( nav2_valid ) { @@ -380,6 +380,7 @@ void FGRadioStack::search() if ( current_ilslist->query( lon, lat, elev, nav1_freq, &ils ) ) { nav1_ident = ils.get_locident(); if ( last_nav1_ident != nav1_ident ) { + nav1_trans_ident = ils.get_trans_ident(); last_nav1_ident = nav1_ident; nav1_valid = true; nav1_loc = true; @@ -413,14 +414,14 @@ void FGRadioStack::search() globals->get_soundmgr()->remove( "nav1-vor-ident" ); } FGSimpleSound *sound; - sound = morse.make_ident( nav1_ident, LO_FREQUENCY ); + sound = morse.make_ident( nav1_trans_ident, LO_FREQUENCY ); sound->set_volume( 0.3 ); globals->get_soundmgr()->add( sound, "nav1-vor-ident" ); if ( globals->get_soundmgr()->exists( "nav1-dme-ident" ) ) { globals->get_soundmgr()->remove( "nav1-dme-ident" ); } - sound = morse.make_ident( nav1_ident, HI_FREQUENCY ); + sound = morse.make_ident( nav1_trans_ident, HI_FREQUENCY ); sound->set_volume( 0.3 ); globals->get_soundmgr()->add( sound, "nav1-dme-ident" ); @@ -439,6 +440,7 @@ void FGRadioStack::search() nav1_ident = nav.get_ident(); if ( last_nav1_ident != nav1_ident ) { last_nav1_ident = nav1_ident; + nav1_trans_ident = nav.get_trans_ident(); nav1_valid = true; nav1_loc = false; nav1_has_dme = nav.get_has_dme(); @@ -459,14 +461,14 @@ void FGRadioStack::search() globals->get_soundmgr()->remove( "nav1-vor-ident" ); } FGSimpleSound *sound; - sound = morse.make_ident( nav1_ident, LO_FREQUENCY ); + sound = morse.make_ident( nav1_trans_ident, LO_FREQUENCY ); sound->set_volume( 0.3 ); globals->get_soundmgr()->add( sound, "nav1-vor-ident" ); if ( globals->get_soundmgr()->exists( "nav1-dme-ident" ) ) { globals->get_soundmgr()->remove( "nav1-dme-ident" ); } - sound = morse.make_ident( nav1_ident, HI_FREQUENCY ); + sound = morse.make_ident( nav1_trans_ident, HI_FREQUENCY ); sound->set_volume( 0.3 ); globals->get_soundmgr()->add( sound, "nav1-dme-ident" ); @@ -495,6 +497,7 @@ void FGRadioStack::search() nav2_ident = ils.get_locident(); if ( last_nav2_ident != nav2_ident ) { last_nav2_ident = nav2_ident; + nav2_trans_ident = ils.get_trans_ident(); nav2_valid = true; nav2_loc = true; nav2_has_dme = ils.get_has_dme(); @@ -525,6 +528,7 @@ void FGRadioStack::search() nav2_ident = nav.get_ident(); if ( last_nav2_ident != nav2_ident ) { last_nav2_ident = nav2_ident; + nav2_trans_ident = nav.get_trans_ident(); nav2_valid = true; nav2_loc = false; nav2_has_dme = nav.get_has_dme(); diff --git a/src/Cockpit/radiostack.hxx b/src/Cockpit/radiostack.hxx index aa9f28d38..0cfafd968 100644 --- a/src/Cockpit/radiostack.hxx +++ b/src/Cockpit/radiostack.hxx @@ -46,6 +46,7 @@ class FGRadioStack : public FGSubsystem bool need_update; string nav1_ident; + string nav1_trans_ident; bool nav1_valid; bool nav1_inrange; bool nav1_has_dme; @@ -82,6 +83,7 @@ class FGRadioStack : public FGSubsystem bool nav1_ident_btn; string nav2_ident; + string nav2_trans_ident; bool nav2_valid; bool nav2_inrange; bool nav2_has_dme; diff --git a/src/Navaids/ils.hxx b/src/Navaids/ils.hxx index 6eedeb1c7..601ffb4cb 100644 --- a/src/Navaids/ils.hxx +++ b/src/Navaids/ils.hxx @@ -53,7 +53,7 @@ class FGILS { char aptcode[5]; char rwyno[4]; int locfreq; - char locident[5]; + char locident[5]; // official ident double locheading; double loclat; double loclon; @@ -75,6 +75,12 @@ class FGILS { double imlat; double imlon; + // for failure modeling + string trans_ident; // transmitted ident + bool loc_failed; // localizer failed? + bool gs_failed; // glide slope failed? + bool dme_failed; // dme failed? + public: inline FGILS(void) {} @@ -86,6 +92,7 @@ public: inline char *get_rwyno() { return rwyno; } inline int get_locfreq() const { return locfreq; } inline char *get_locident() { return locident; } + inline string get_trans_ident() { return trans_ident; } inline double get_locheading() const { return locheading; } inline double get_loclat() const { return loclat; } inline double get_loclon() const { return loclon; } @@ -167,7 +174,11 @@ operator >> ( istream& in, FGILS& i ) // cout << "dme = " << cart << endl; } - // return in >> skipeol; + i.trans_ident = "I"; + i.trans_ident += i.locident; + i.loc_failed = i.gs_failed = i.dme_failed = false; + + // return in >> skipeol; return in; } diff --git a/src/Navaids/nav.hxx b/src/Navaids/nav.hxx index 23e1fc015..97a7f2481 100644 --- a/src/Navaids/nav.hxx +++ b/src/Navaids/nav.hxx @@ -59,6 +59,11 @@ class FGNav { string ident; // to avoid a core dump with corrupt data double magvar; // magvar from true north (negative = W) + // for failure modeling + string trans_ident; // transmitted ident + bool nav_failed; // nav failed? + bool dme_failed; // dme failed? + public: inline FGNav(void) {} @@ -75,6 +80,7 @@ public: inline int get_range() const { return range; } inline bool get_has_dme() const { return has_dme; } inline const char *get_ident() { return ident.c_str(); } + inline string get_trans_ident() { return trans_ident; } inline double get_magvar () const { return magvar; } /* inline void set_type( char t ) { type = t; } @@ -156,6 +162,9 @@ operator >> ( istream& in, FGNav& n ) n.y = cart.y(); n.z = cart.z(); + n.trans_ident = n.ident; + n.nav_failed = n.dme_failed = false; + return in >> skipeol; } diff --git a/src/Sound/soundmgr.cxx b/src/Sound/soundmgr.cxx index a868dd13c..24d3154b6 100644 --- a/src/Sound/soundmgr.cxx +++ b/src/Sound/soundmgr.cxx @@ -129,23 +129,6 @@ bool FGSoundMgr::add( FGSimpleSound *sound, const string& refname ) { // remove a sound effect, return true if successful bool FGSoundMgr::remove( const string& refname ) { -#if defined ( PLIB_AUDIO_IS_BROKEN ) - // if PLIB_AUDIO_IS_BROKEN, we can't reliably remove sounds that - // are currently being played. :-( So, let's just not remove them - // and return false. The effects of this are that the sound - // sample will continue to finish playing (or continue to loop - // forever.) And the sound sample will remain registered in the - // plib audio system. This is a memory leak, and eventually this - // could cause us to max out the total number of allowed sound - // samples in plib, but what are you going to do? Hopefully the - // plib team will do a new stable relase with these problems - // fixed. - - cout << "plib broken audio, skipping remove" << endl; - - return false; -#endif - sound_map_iterator it = sounds.find( refname ); if ( it != sounds.end() ) { // first stop the sound from playing (so we don't bomb the