1
0
Fork 0

CommRadio: fix power and noise/squelch

- when add-noise is false, mute noise completely
- if the CommRadio is not powered by the generic electrical system,
  work by default (as was previously the case)
This commit is contained in:
James Turner 2019-06-11 23:26:44 +01:00
parent 6ebc91d3f7
commit cfae6d2c9f
2 changed files with 11 additions and 5 deletions

View file

@ -57,9 +57,11 @@ void AbstractInstrument::initServicePowerProperties(SGPropertyNode* node)
if (_powerButtonNode->getType() == simgear::props::NONE)
_powerButtonNode->setBoolValue(true);
_powerSupplyNode = fgGetNode(_powerSupplyPath, true);
if (_powerSupplyPath != "NO_DEFAULT") {
_powerSupplyNode = fgGetNode(_powerSupplyPath, true);
}
node->tie( "operable", SGRawValueMethods<AbstractInstrument,bool>
node->tie( "operable", SGRawValueMethods<AbstractInstrument,bool>
( *this, &AbstractInstrument::isServiceableAndPowered ) );
}
@ -76,7 +78,7 @@ bool AbstractInstrument::isServiceableAndPowered() const
if (!_serviceableNode->getBoolValue() || !isPowerSwitchOn())
return false;
if (_powerSupplyNode->getDoubleValue() < _minimumSupplyVolts)
if (_powerSupplyNode && (_powerSupplyNode->getDoubleValue() < _minimumSupplyVolts))
return false;
return true;

View file

@ -494,6 +494,9 @@ CommRadioImpl::CommRadioImpl(SGPropertyNode_ptr node) :
_metarBridge(new MetarBridge),
_signalQualityComputer(new SimpleDistanceSquareSignalQualityComputer)
{
// set a special value to indicate we don't require a power supply node
// by default
setDefaultPowerSupplyPath("NO_DEFAULT");
readConfig(node, "comm");
_soundPrefix = name() + "_" + std::to_string(number()) + "_";
_useEightPointThree = node->getBoolValue("eight-point-three", false );
@ -689,11 +692,12 @@ void CommRadioImpl::updateAudio()
}
// adjust volumes
double atisVolume = (_signalQuality_norm >= _cutoffSignalQuality) ? _volume_norm : 0.0;
const bool doSquelch = (_signalQuality_norm < _cutoffSignalQuality);
double atisVolume = doSquelch ? 0.0 : _volume_norm;
if (_addNoise) {
const double noiseVol = (1.0 - _signalQuality_norm) * _volume_norm;
atisVolume = _signalQuality_norm * _volume_norm;
noiseSample->set_volume(noiseVol);
noiseSample->set_volume(doSquelch ? 0.0: noiseVol);
}
SGSoundSample* s = _sampleGroup->find(atisRef);