更新 'src/Network/fgcom.cxx'

This commit is contained in:
zhongjin 2022-11-30 22:26:25 +08:00
parent 4ddf59ebe4
commit 342230a7de

View File

@ -79,7 +79,7 @@ static int iaxc_callback( iaxc_event e )
}
//zhongjin
SG_LOG(SG_SOUND, SG_INFO, "FCCom iaxc_callback:" << e.type);
SG_LOG(SG_SOUND, SG_ALERT, "FCCom iaxc_callback:" << e.type);
return 1;
}
@ -226,7 +226,7 @@ void FGCom::init()
_maxRange = MAX_RANGE;
_minRange = MIN_RANGE;
SG_LOG(SG_SOUND, SG_DEBUG, "FGCom: init");
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: init");
}
@ -235,7 +235,7 @@ void FGCom::init()
void FGCom::postinit()
{
SG_LOG(SG_SOUND, SG_DEBUG, "FGCom: postinit() 11111111111111111111111111");
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: postinit() 11111111111111111111111111");
if( !_enabled ) {
return;
@ -243,7 +243,7 @@ void FGCom::postinit()
//WARNING: this _must_ be executed after sound system is totally initialized !
if( iaxc_initialize(4) ) {
SG_LOG(SG_SOUND, SG_DEBUG, "FGCom: cannot initialize iaxclient");
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: cannot initialize iaxclient");
_enabled = false;
return;
}
@ -289,7 +289,7 @@ void FGCom::postinit()
const_cast<char*>(_password.c_str()),
const_cast<char*>(_server.c_str()) );
if( _regId == -1 ) {
SG_LOG(SG_SOUND, SG_DEBUG, "FGCom: cannot register iaxclient");
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: cannot register iaxclient");
return;
}
}
@ -372,7 +372,7 @@ void FGCom::postinit()
connectToCommFrequency();
SG_LOG(SG_SOUND, SG_INFO, "FGCom: postinit 初始化完成");
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: postinit 初始化完成");
@ -383,13 +383,13 @@ double FGCom::getCurrentCommVolume() const {
if (_speakerLevel_node)
rv = _speakerLevel_node->getFloatValue();
SG_LOG(SG_SOUND, SG_DEBUG, "FGCom: _speakerLevel_node " << _speakerLevel_node->getFloatValue());
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: _speakerLevel_node " << _speakerLevel_node->getFloatValue());
if (_commVolumeNode)
//暂时关闭 _commVolumeNode
//rv = rv * _commVolumeNode->getFloatValue();
SG_LOG(SG_SOUND, SG_DEBUG, "FGCom: _commVolumeNode " << _commVolumeNode->getFloatValue());
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: _commVolumeNode " << _commVolumeNode->getFloatValue());
return rv;
}
@ -399,7 +399,7 @@ double FGCom::getCurrentFrequencyKhz() const {
void FGCom::setupCommFrequency(int channel) {
SG_LOG(SG_SOUND, SG_DEBUG, "setupCommFrequency1 channel=" << channel);
SG_LOG(SG_SOUND, SG_ALERT, "setupCommFrequency1 channel=" << channel);
if (channel < 1) {
if (_selected_comm_node != nullptr) {
@ -407,13 +407,13 @@ void FGCom::setupCommFrequency(int channel) {
}
}
SG_LOG(SG_SOUND, SG_DEBUG, "setupCommFrequency2 channel=" << channel);
SG_LOG(SG_SOUND, SG_ALERT, "setupCommFrequency2 channel=" << channel);
// disconnect if channel set to 0
if (channel < 1) {
if (_currentCallIdent != -1) {
iaxc_dump_call_number(_currentCallIdent);
SG_LOG(SG_SOUND, SG_DEBUG, "FGCom: disconnect as channel 0 " << _currentCallIdent);
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: disconnect as channel 0 " << _currentCallIdent);
_currentCallIdent = -1;
}
_currentCommFrequency = 0.0;
@ -445,15 +445,15 @@ void FGCom::setupCommFrequency(int channel) {
}
}
}
SG_LOG(SG_SOUND, SG_DEBUG, "FGCom: setupCommFrequency node listener failed: channel " << channel);
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: setupCommFrequency node listener failed: channel " << channel);
}
SG_LOG(SG_SOUND, SG_DEBUG, "setupCommFrequency3 _commFrequencyNode=" << _commFrequencyNode);
SG_LOG(SG_SOUND, SG_ALERT, "setupCommFrequency3 _commFrequencyNode=" << _commFrequencyNode);
if (_commFrequencyNode)
_commFrequencyNode->removeChangeListener(this);
SG_LOG(SG_SOUND, SG_DEBUG, "FGCom: setupCommFrequency invalid channel " << channel);
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: setupCommFrequency invalid channel " << channel);
_currentCommFrequency = 0.0;
}
@ -467,7 +467,7 @@ void FGCom::connectToCommFrequency() {
if ((_currentCallFrequency > 0.0) && !isInRange(_currentCallFrequency)) {
SG_LOG(SG_SOUND, SG_WARN, "FGCom: call out of range of: " << _currentCallFrequency);
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: call out of range of: " << _currentCallFrequency);
_currentCallFrequency = 0.0;
}
@ -477,7 +477,7 @@ void FGCom::connectToCommFrequency() {
if (_currentCallIdent != -1) {
iaxc_dump_call_number(_currentCallIdent);
SG_LOG(SG_SOUND, SG_DEBUG, "FGCom: disconnect as freq 0: current call " << _currentCallIdent);
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: disconnect as freq 0: current call " << _currentCallIdent);
_currentCallIdent = -1;
}
return;
@ -487,7 +487,7 @@ void FGCom::connectToCommFrequency() {
if (_currentCallIdent != -1) {
iaxc_dump_call_number(_currentCallIdent);
SG_LOG(SG_SOUND, SG_DEBUG, "FGCom: dump_call_number " << _currentCallIdent);
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: dump_call_number " << _currentCallIdent);
_currentCallIdent = -1;
}
@ -499,7 +499,7 @@ void FGCom::connectToCommFrequency() {
if (!isInRange(_currentCommFrequency)) {
if (_currentCallIdent != -1) {
SG_LOG(SG_SOUND, SG_INFO, "FGCom: disconnect call as not in range " << _currentCallIdent);
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: disconnect call as not in range " << _currentCallIdent);
if (_currentCallIdent != -1) {
iaxc_dump_call_number(_currentCallIdent);
_currentCallIdent = -1;
@ -508,22 +508,22 @@ void FGCom::connectToCommFrequency() {
return;
}
SG_LOG(SG_SOUND, SG_DEBUG, "FGCom: connectToCommFrequency num=" << num);
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: connectToCommFrequency num=" << num);
if (!num.empty()) {
_currentCallIdent = iaxc_call(num.c_str());
SG_LOG(SG_SOUND, SG_DEBUG, "FGCom: iaxc_call(" << num << ") _currentCallIdent=" << _currentCallIdent);
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: iaxc_call(" << num << ") _currentCallIdent=" << _currentCallIdent);
if (_currentCallIdent == -1)
SG_LOG(SG_SOUND, SG_DEBUG, "FGCom: cannot call " << num.c_str());
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: cannot call " << num.c_str());
else {
SG_LOG(SG_SOUND, SG_DEBUG, "FGCom: call established " << num.c_str() << " Freq: " << _currentCommFrequency);
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: call established " << num.c_str() << " Freq: " << _currentCommFrequency);
_currentCallFrequency = _currentCommFrequency;
}
}
else
SG_LOG(SG_SOUND, SG_WARN, "FGCom: frequency " << _currentCommFrequency << " does not map to valid IAX address");
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: frequency " << _currentCommFrequency << " does not map to valid IAX address");
}
}
}
@ -531,7 +531,7 @@ void FGCom::connectToCommFrequency() {
void FGCom::updateCall()
{
SG_LOG(SG_SOUND,SG_DEBUG,"updateCall()");
SG_LOG(SG_SOUND,SG_ALERT,"updateCall()");
if (_processingTimer.elapsedMSec() > IAX_DELAY) {
@ -600,25 +600,25 @@ void FGCom::valueChanged(SGPropertyNode *prop)
if (prop == _commVolumeNode && _enabled) {
if (_ptt_node->getIntValue()) {
SG_LOG(SG_SOUND, SG_INFO, "FGCom: ignoring change comm volume as PTT pressed");
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: ignoring change comm volume as PTT pressed");
}
else
{
iaxc_input_level_set(0.0);
// iaxc_output_level_set(getCurrentCommVolume());
iaxc_output_level_set(1.0);
SG_LOG(SG_SOUND, SG_INFO, "FGCom: change comm volume=" << _commVolumeNode->getFloatValue());
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: change comm volume=" << _commVolumeNode->getFloatValue());
}
}
if (prop == _selected_comm_node && _enabled) {
setupCommFrequency();
SG_LOG(SG_SOUND, SG_INFO, "FGCom: change comm frequency (selected node): set to " << _currentCommFrequency);
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: change comm frequency (selected node): set to " << _currentCommFrequency);
}
if (prop == _commFrequencyNode && _enabled) {
setupCommFrequency();
SG_LOG(SG_SOUND, SG_INFO, "FGCom: change comm frequency (property updated): set to " << _currentCommFrequency);
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: change comm frequency (property updated): set to " << _currentCommFrequency);
}
if (prop == _ptt_node && _enabled) {
@ -629,13 +629,13 @@ void FGCom::valueChanged(SGPropertyNode *prop)
iaxc_input_level_set(_micLevel_node->getFloatValue()); //0.0 = min , 1.0 = max
_mpTransmitFrequencyNode->setValue(_currentCallFrequency * 1000000);
_mpTransmitPowerNode->setValue(1.0);
SG_LOG(SG_SOUND, SG_INFO, "FGCom: PTT active: " << _currentCallFrequency);
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: PTT active: " << _currentCallFrequency);
}
else {
// iaxc_output_level_set(getCurrentCommVolume());
iaxc_output_level_set(1.0);
iaxc_input_level_set(0.0);
SG_LOG(SG_SOUND, SG_INFO, "FGCom: PTT release: " << _currentCallFrequency << " vol=" << getCurrentCommVolume());
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: PTT release: " << _currentCallFrequency << " vol=" << getCurrentCommVolume());
_mpTransmitFrequencyNode->setValue(0);
_mpTransmitPowerNode->setValue(0);
}
@ -709,7 +709,7 @@ void FGCom::testMode(bool testMode)
_currentCallIdent = iaxc_call(num.c_str());
}
if( _currentCallIdent == -1 )
SG_LOG( SG_SOUND, SG_DEBUG, "FGCom: cannot call " << num.c_str() );
SG_LOG( SG_SOUND, SG_ALERT, "FGCom: cannot call " << num.c_str() );
} else {
if( _initialized ) {
iaxc_dump_all_calls();
@ -815,7 +815,7 @@ std::string FGCom::computePhoneNumber(const double& freq, const std::string& ica
exten);
SG_LOG(SG_SOUND, SG_INFO, "FGCom: computePhoneNumber:" << phoneNumber << "icao:" << icao);
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: computePhoneNumber:" << phoneNumber << "icao:" << icao);
return phoneNumber;
}