add min/max freq to the frequencyformatter
This commit is contained in:
parent
5465895278
commit
75933d3e1e
3 changed files with 16 additions and 7 deletions
|
@ -81,6 +81,7 @@ double SimpleDistanceSquareSignalQualityComputer::computeSignalQuality( double d
|
|||
class OnExitHandler {
|
||||
public:
|
||||
virtual void onExit() = 0;
|
||||
virtual ~OnExitHandler() {}
|
||||
};
|
||||
|
||||
class OnExit {
|
||||
|
@ -113,6 +114,7 @@ class OutputProperties : public OnExitHandler {
|
|||
_PO_trackDistance_m( rootNode->getNode("track-distance-m",true) ),
|
||||
_PO_heightAboveStation_ft( rootNode->getNode("height-above-station-ft",true) )
|
||||
{}
|
||||
virtual ~OutputProperties() {}
|
||||
|
||||
protected:
|
||||
SGPropertyNode_ptr _rootNode;
|
||||
|
@ -282,9 +284,9 @@ CommRadioImpl::CommRadioImpl( SGPropertyNode_ptr node ) :
|
|||
_num( node->getIntValue("number",0)),
|
||||
_metarBridge( new MetarBridge() ),
|
||||
_useFrequencyFormatter( _rootNode->getNode("frequencies/selected-mhz",true),
|
||||
_rootNode->getNode("frequencies/selected-mhz-fmt",true), 0.025 ),
|
||||
_rootNode->getNode("frequencies/selected-mhz-fmt",true), 0.025, 118.0, 136.0 ),
|
||||
_stbyFrequencyFormatter( _rootNode->getNode("frequencies/standby-mhz",true),
|
||||
_rootNode->getNode("frequencies/standby-mhz-fmt",true), 0.025 ),
|
||||
_rootNode->getNode("frequencies/standby-mhz-fmt",true), 0.025, 118.0, 136.0 ),
|
||||
_signalQualityComputer( new SimpleDistanceSquareSignalQualityComputer(10*SG_NM_TO_METER) ),
|
||||
|
||||
_stationTTL(0.0),
|
||||
|
|
|
@ -5,10 +5,12 @@
|
|||
|
||||
class FrequencyFormatter : public SGPropertyChangeListener {
|
||||
public:
|
||||
FrequencyFormatter( SGPropertyNode_ptr freqNode, SGPropertyNode_ptr fmtFreqNode, double channelSpacing ) :
|
||||
FrequencyFormatter( SGPropertyNode_ptr freqNode, SGPropertyNode_ptr fmtFreqNode, double channelSpacing, double min, double max ) :
|
||||
_freqNode( freqNode ),
|
||||
_fmtFreqNode( fmtFreqNode ),
|
||||
_channelSpacing(channelSpacing)
|
||||
_channelSpacing(channelSpacing),
|
||||
_min(min),
|
||||
_max(max)
|
||||
{
|
||||
_freqNode->addChangeListener( this );
|
||||
valueChanged(_freqNode);
|
||||
|
@ -34,13 +36,18 @@ public:
|
|||
{
|
||||
double d = SGMiscd::roundToInt(_freqNode->getDoubleValue() / _channelSpacing) * _channelSpacing;
|
||||
// strip last digit, do not round
|
||||
return ((int)(d*100))/100.0;
|
||||
double f = ((int)(d*100))/100.0;
|
||||
if( f < _min ) return _min;
|
||||
if( f >= _max ) return _max;
|
||||
return f;
|
||||
}
|
||||
|
||||
private:
|
||||
SGPropertyNode_ptr _freqNode;
|
||||
SGPropertyNode_ptr _fmtFreqNode;
|
||||
double _channelSpacing;
|
||||
double _min;
|
||||
double _max;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -843,8 +843,8 @@ NavRadioImpl::NavRadioImpl( SGPropertyNode_ptr node ) :
|
|||
_name(node->getStringValue("name", "nav")),
|
||||
_num(node->getIntValue("number", 0)),
|
||||
_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 ),
|
||||
_useFrequencyFormatter( _rootNode->getNode("frequencies/selected-mhz",true), _rootNode->getNode("frequencies/selected-mhz-fmt",true), 0.05, 108.0, 118.0 ),
|
||||
_stbyFrequencyFormatter( _rootNode->getNode("frequencies/standby-mhz",true), _rootNode->getNode("frequencies/standby-mhz-fmt",true), 0.05, 108.0, 118.0 ),
|
||||
_navIndicator(_rootNode),
|
||||
_stationTTL(0.0),
|
||||
_frequency(-1.0),
|
||||
|
|
Loading…
Add table
Reference in a new issue