X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FInstrumentation%2Fnewnavradio.cxx;h=41b606c152bbe3b49702815e98d9bb4693bc5456;hb=9d995907db00728da7eac9297ecbab93ed8a7400;hp=202fd24724fe431973a03012266e054c707a5edf;hpb=c6062ad93cf3bfbffb6dec63cd6844167bb56980;p=flightgear.git diff --git a/src/Instrumentation/newnavradio.cxx b/src/Instrumentation/newnavradio.cxx old mode 100755 new mode 100644 index 202fd2472..41b606c15 --- a/src/Instrumentation/newnavradio.cxx +++ b/src/Instrumentation/newnavradio.cxx @@ -29,11 +29,11 @@ #include #include -#include #include #include #include #include +#include #include
#include @@ -149,7 +149,7 @@ public: protected: virtual double computeSignalQuality_norm( const SGGeod & aircraftPosition ); - virtual FGNavList * getNavaidList() = 0; + virtual FGNavList::TypeFilter* getNavaidFilter() = 0; // General-purpose sawtooth function. Graph looks like this: // /\ . @@ -174,7 +174,7 @@ protected: PropertyObject _trackDistance_m; PropertyObject _slantDistance_m; PropertyObject _heightAboveStation_ft; - PropertyObject _ident; + PropertyObject _ident; PropertyObject _inRange; PropertyObject _range_nm; }; @@ -259,7 +259,8 @@ double NavRadioComponent::getRange_nm( const SGGeod & aircraftPosition ) void NavRadioComponent::search( double frequency, const SGGeod & aircraftPosition ) { - if( NULL == (_navRecord = getNavaidList()->findByFreq(frequency, aircraftPosition )) ) { + _navRecord = FGNavList::findByFreq(frequency, aircraftPosition, getNavaidFilter() ); + if( NULL == _navRecord ) { SG_LOG(SG_INSTR,SG_ALERT, "No " << _name << " available at " << frequency ); _ident = ""; return; @@ -323,7 +324,7 @@ public: virtual double getRange_nm(const SGGeod & aircraftPosition); protected: virtual double computeSignalQuality_norm( const SGGeod & aircraftPosition ); - virtual FGNavList * getNavaidList(); + virtual FGNavList::TypeFilter* getNavaidFilter(); private: double _totalTime; @@ -377,7 +378,9 @@ double VOR::ServiceVolume::adjustRange( double height_ft, double nominalRange_nm } VOR::VOR( SGPropertyNode_ptr rootNode) : - NavRadioComponentWithIdent("vor", rootNode, new VORAudioIdent(getIdentString(string("vor"), rootNode->getIndex()))), + NavRadioComponentWithIdent("vor", rootNode, + new VORAudioIdent(getIdentString(std::string("vor"), + rootNode->getIndex()))), _totalTime(0.0), _radial( rootNode->getNode(_name,true)->getNode("radial",true) ), _radialInbound( rootNode->getNode(_name,true)->getNode("radial-inbound",true) ) @@ -393,9 +396,10 @@ double VOR::getRange_nm( const SGGeod & aircraftPosition ) return _serviceVolume.adjustRange( _heightAboveStation_ft, _navRecord->get_range() ); } -FGNavList * VOR::getNavaidList() +FGNavList::TypeFilter* VOR::getNavaidFilter() { - return globals->get_navlist(); + static FGNavList::TypeFilter filter(FGPositioned::VOR); + return &filter; } double VOR::computeSignalQuality_norm( const SGGeod & aircraftPosition ) @@ -468,7 +472,7 @@ public: protected: virtual double computeSignalQuality_norm( const SGGeod & aircraftPosition ); - virtual FGNavList * getNavaidList(); + virtual FGNavList::TypeFilter* getNavaidFilter(); private: class ServiceVolume { @@ -521,7 +525,8 @@ double LOC::ServiceVolume::adjustRange( double azimuthAngle_deg, double elevatio } LOC::LOC( SGPropertyNode_ptr rootNode) : - NavRadioComponentWithIdent("loc", rootNode, new LOCAudioIdent(getIdentString(string("loc"), rootNode->getIndex()))), + NavRadioComponentWithIdent("loc", rootNode, new LOCAudioIdent(getIdentString(std::string("loc"), + rootNode->getIndex()))), _serviceVolume(), _localizerOffset_norm( rootNode->getNode(_name,true)->getNode("offset-norm",true) ), _localizerWidth_deg( rootNode->getNode(_name,true)->getNode("width-deg",true) ) @@ -532,9 +537,9 @@ LOC::~LOC() { } -FGNavList * LOC::getNavaidList() +FGNavList::TypeFilter* LOC::getNavaidFilter() { - return globals->get_loclist(); + return FGNavList::locFilter(); } void LOC::search( double frequency, const SGGeod & aircraftPosition ) @@ -618,8 +623,7 @@ public: virtual double getRange_nm(const SGGeod & aircraftPosition); protected: - virtual FGNavList * getNavaidList(); - + virtual FGNavList::TypeFilter* getNavaidFilter(); private: class ServiceVolume { public: @@ -687,9 +691,10 @@ GS::~GS() { } -FGNavList * GS::getNavaidList() +FGNavList::TypeFilter* GS::getNavaidFilter() { - return globals->get_gslist(); + static FGNavList::TypeFilter filter(FGPositioned::GS); + return &filter; } double GS::getRange_nm(const SGGeod & aircraftPosition) @@ -880,7 +885,7 @@ NavRadioImpl::NavRadioImpl( SGPropertyNode_ptr node ) : _legacy( this ), _name(node->getStringValue("name", "nav")), _num(node->getIntValue("number", 0)), - _rootNode(fgGetNode( string("/instrumentation/") + _name, _num, true)), + _rootNode(fgGetNode( std::string("/instrumentation/") + _name, _num, true)), _useFrequencyFormatter( _rootNode->getNode("frequencies/selected-mhz",true), _rootNode->getNode("frequencies/selected-mhz-fmt",true), 0.05 ), _stbyFrequencyFormatter( _rootNode->getNode("frequencies/standby-mhz",true), _rootNode->getNode("frequencies/standby-mhz-fmt",true), 0.05 ), _navIndicator(_rootNode), @@ -899,7 +904,7 @@ NavRadioImpl::~NavRadioImpl() void NavRadioImpl::init() { - if( 0 < _components.size() ) + if( ! _components.empty() ) return; _components.push_back( new VOR(_rootNode) ); @@ -966,7 +971,7 @@ void NavRadioImpl::Legacy::update( double dt ) _navRadioImpl->_components[VOR_COMPONENT]->valid() || _navRadioImpl->_components[LOC_COMPONENT]->valid() ); - string ident = _navRadioImpl->_components[VOR_COMPONENT]->getIdent(); + std::string ident = _navRadioImpl->_components[VOR_COMPONENT]->getIdent(); if( ident.empty() ) ident = _navRadioImpl->_components[LOC_COMPONENT]->getIdent();