X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FInstrumentation%2Fnavradio.cxx;h=dc9c094b9871af5e0a2a2b1b622804710b65ca4f;hb=61812ef4b88f5aa74e9cc0630c84d6fc6b4a51cd;hp=e8732a063320f3689fb50ef096c547730b9131e6;hpb=aad3c711a1bb98a50a414b7004d5ff2c8c7b60dc;p=flightgear.git diff --git a/src/Instrumentation/navradio.cxx b/src/Instrumentation/navradio.cxx index e8732a063..dc9c094b9 100644 --- a/src/Instrumentation/navradio.cxx +++ b/src/Instrumentation/navradio.cxx @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -40,7 +41,7 @@ #include "navradio.hxx" #include -SG_USING_STD(string); +using std::string; // Constructor @@ -100,8 +101,8 @@ FGNavRadio::FGNavRadio(SGPropertyNode *node) : last_x(0.0), last_loc_dist(0.0), last_xtrack_error(0.0), - name("nav"), - num(0), + _name(node->getStringValue("name", "nav")), + _num(node->getIntValue("number", 0)), _time_before_search_sec(-1.0) { SGPath path( globals->get_fg_root() ); @@ -115,25 +116,6 @@ FGNavRadio::FGNavRadio(SGPropertyNode *node) : term_tbl = new SGInterpTable( term.str() ); low_tbl = new SGInterpTable( low.str() ); high_tbl = new SGInterpTable( high.str() ); - - int i; - for ( i = 0; i < node->nChildren(); ++i ) { - SGPropertyNode *child = node->getChild(i); - string cname = child->getName(); - string cval = child->getStringValue(); - if ( cname == "name" ) { - name = cval; - } else if ( cname == "number" ) { - num = child->getIntValue(); - } else { - SG_LOG( SG_INSTR, SG_WARN, - "Error in nav radio config logic" ); - if ( name.length() ) { - SG_LOG( SG_INSTR, SG_WARN, "Section = " << name ); - } - } - } - } @@ -152,12 +134,12 @@ FGNavRadio::init () morse.init(); string branch; - branch = "/instrumentation/" + name; + branch = "/instrumentation/" + _name; - SGPropertyNode *node = fgGetNode(branch.c_str(), num, true ); + SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true ); bus_power_node = - fgGetNode(("/systems/electrical/outputs/" + name).c_str(), true); + fgGetNode(("/systems/electrical/outputs/" + _name).c_str(), true); // inputs is_valid_node = node->getChild("data-is-valid", 0, true); @@ -222,9 +204,9 @@ FGNavRadio::init () gps_from_flag_node = fgGetNode("/instrumentation/gps/from-flag", true); std::ostringstream temp; - temp << name << "nav-ident" << num; + temp << _name << "nav-ident" << _num; nav_fx_name = temp.str(); - temp << name << "dme-ident" << num; + temp << _name << "dme-ident" << _num; dme_fx_name = temp.str(); } @@ -233,8 +215,8 @@ FGNavRadio::bind () { std::ostringstream temp; string branch; - temp << num; - branch = "/instrumentation/" + name + "[" + temp.str() + "]"; + temp << _num; + branch = "/instrumentation/" + _name + "[" + temp.str() + "]"; } @@ -243,8 +225,8 @@ FGNavRadio::unbind () { std::ostringstream temp; string branch; - temp << num; - branch = "/instrumentation/" + name + "[" + temp.str() + "]"; + temp << _num; + branch = "/instrumentation/" + _name + "[" + temp.str() + "]"; } @@ -462,7 +444,7 @@ FGNavRadio::update(double dt) ////////////////////////////////////////////////////////// // compute to/from flag status ////////////////////////////////////////////////////////// - double value = false; + bool value = false; double offset = fabs(radial - target_radial); if ( tofrom_serviceable ) { if ( nav_slaved_to_gps_node->getBoolValue() ) { @@ -931,11 +913,8 @@ void FGNavRadio::search() target_radial = 0; trans_ident = ""; last_nav_id = ""; - if ( ! globals->get_soundmgr()->remove( nav_fx_name ) ) { - SG_LOG(SG_COCKPIT, SG_WARN, "Failed to remove nav-vor-ident sound"); - } + globals->get_soundmgr()->remove( nav_fx_name ); globals->get_soundmgr()->remove( dme_fx_name ); - // cout << "not picking up vor1. :-(" << endl; } is_valid_node->setBoolValue( is_valid );