mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-04 08:55:43 +08:00
[AFV] Allow to set the tx/rx values for the AFV client
Simplified function
This commit is contained in:
committed by
Mat Sutcliffe
parent
63cc2a7e3e
commit
ea8198d26e
@@ -581,6 +581,60 @@ namespace BlackCore
|
|||||||
return this->isTransmittingTransceiver(comUnitToTransceiverId(comUnit));
|
return this->isTransmittingTransceiver(comUnitToTransceiverId(comUnit));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CAfvClient::setRxTx(bool rx1, bool tx1, bool rx2, bool tx2)
|
||||||
|
{
|
||||||
|
QVector<TxTransceiverDto> txs;
|
||||||
|
if (tx1)
|
||||||
|
{
|
||||||
|
const TxTransceiverDto tx = { comUnitToTransceiverId(CComSystem::Com1) };
|
||||||
|
txs.push_back(tx);
|
||||||
|
}
|
||||||
|
if (tx2)
|
||||||
|
{
|
||||||
|
const TxTransceiverDto tx = { comUnitToTransceiverId(CComSystem::Com2) };
|
||||||
|
txs.push_back(tx);
|
||||||
|
}
|
||||||
|
this->setTransmittingTransceivers(txs);
|
||||||
|
|
||||||
|
QSet<quint16> enabledTransceivers;
|
||||||
|
if (rx1 || tx1)
|
||||||
|
{
|
||||||
|
enabledTransceivers.insert(comUnitToTransceiverId(CComSystem::Com1));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rx2 || tx2)
|
||||||
|
{
|
||||||
|
enabledTransceivers.insert(comUnitToTransceiverId(CComSystem::Com2));
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
QMutexLocker lock(&m_mutexTransceivers);
|
||||||
|
m_enabledTransceivers = enabledTransceivers;
|
||||||
|
}
|
||||||
|
|
||||||
|
// force update
|
||||||
|
this->onTimerUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAfvClient::getRxTx(bool &rx1, bool &tx1, bool &rx2, bool &tx2) const
|
||||||
|
{
|
||||||
|
rx1 = false;
|
||||||
|
rx2 = false;
|
||||||
|
tx1 = false;
|
||||||
|
tx2 = false;
|
||||||
|
|
||||||
|
const QSet<quint16> enabled = getEnabledTransceivers();
|
||||||
|
rx1 = enabled.contains(comUnitToTransceiverId(CComSystem::Com1));
|
||||||
|
rx2 = enabled.contains(comUnitToTransceiverId(CComSystem::Com2));
|
||||||
|
|
||||||
|
const QVector<TxTransceiverDto> transmits = getTransmittingTransceivers();
|
||||||
|
for (const TxTransceiverDto &dto : transmits)
|
||||||
|
{
|
||||||
|
if (dto.id == comUnitToTransceiverId(CComSystem::Com1)) { tx1 = true; }
|
||||||
|
if (dto.id == comUnitToTransceiverId(CComSystem::Com2)) { tx2 = true; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QVector<TransceiverDto> CAfvClient::getTransceivers() const
|
QVector<TransceiverDto> CAfvClient::getTransceivers() const
|
||||||
{
|
{
|
||||||
QMutexLocker lock(&m_mutexTransceivers);
|
QMutexLocker lock(&m_mutexTransceivers);
|
||||||
@@ -873,7 +927,7 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
QStringList coms;
|
QStringList coms;
|
||||||
QMutexLocker lock(&m_mutexSampleProviders);
|
QMutexLocker lock(&m_mutexSampleProviders);
|
||||||
if (!m_soundcardSampleProvider) { return {{ QString(), QString()}}; }
|
if (!m_soundcardSampleProvider) { return {{ QString(), QString() }}; }
|
||||||
coms << m_soundcardSampleProvider->getReceivingCallsignsString(comUnitToTransceiverId(CComSystem::Com1));
|
coms << m_soundcardSampleProvider->getReceivingCallsignsString(comUnitToTransceiverId(CComSystem::Com1));
|
||||||
coms << m_soundcardSampleProvider->getReceivingCallsignsString(comUnitToTransceiverId(CComSystem::Com2));
|
coms << m_soundcardSampleProvider->getReceivingCallsignsString(comUnitToTransceiverId(CComSystem::Com2));
|
||||||
return coms;
|
return coms;
|
||||||
@@ -1000,18 +1054,13 @@ namespace BlackCore
|
|||||||
transceiverCom1.frequencyHz = this->getAliasFrequencyHz(f1);
|
transceiverCom1.frequencyHz = this->getAliasFrequencyHz(f1);
|
||||||
transceiverCom2.frequencyHz = this->getAliasFrequencyHz(f2);
|
transceiverCom2.frequencyHz = this->getAliasFrequencyHz(f2);
|
||||||
|
|
||||||
bool tx1 = true;
|
QVector<TransceiverDto> newEnabledTransceivers;
|
||||||
bool rx1 = true;
|
|
||||||
bool tx2 = false;
|
|
||||||
bool rx2 = true;
|
|
||||||
|
|
||||||
if (m_integratedComUnit)
|
if (m_integratedComUnit)
|
||||||
{
|
{
|
||||||
tx1 = com1.isTransmitEnabled();
|
const bool tx1 = com1.isTransmitEnabled();
|
||||||
rx1 = com1.isReceiveEnabled();
|
const bool rx1 = com1.isReceiveEnabled();
|
||||||
tx2 = com2.isTransmitEnabled(); // we only allow one (1) transmit
|
const bool tx2 = com2.isTransmitEnabled(); // we only allow one (1) transmit
|
||||||
rx2 = com2.isReceiveEnabled();
|
const bool rx2 = com2.isReceiveEnabled();
|
||||||
}
|
|
||||||
|
|
||||||
// enable, we currently treat receive as enable
|
// enable, we currently treat receive as enable
|
||||||
// flight sim cockpits normally use rx and tx
|
// flight sim cockpits normally use rx and tx
|
||||||
@@ -1020,9 +1069,8 @@ namespace BlackCore
|
|||||||
const bool e2 = rx2;
|
const bool e2 = rx2;
|
||||||
|
|
||||||
// transceivers
|
// transceivers
|
||||||
|
const QVector<TransceiverDto> newTransceivers { transceiverCom1, transceiverCom2 };
|
||||||
QSet<quint16> newEnabledTransceiverIds;
|
QSet<quint16> newEnabledTransceiverIds;
|
||||||
QVector<TransceiverDto> newTransceivers { transceiverCom1, transceiverCom2 };
|
|
||||||
QVector<TransceiverDto> newEnabledTransceivers;
|
|
||||||
QVector<TxTransceiverDto> newTransmittingTransceivers;
|
QVector<TxTransceiverDto> newTransmittingTransceivers;
|
||||||
if (e1) { newEnabledTransceivers.push_back(transceiverCom1); newEnabledTransceiverIds.insert(transceiverCom1.id); }
|
if (e1) { newEnabledTransceivers.push_back(transceiverCom1); newEnabledTransceiverIds.insert(transceiverCom1.id); }
|
||||||
if (e2) { newEnabledTransceivers.push_back(transceiverCom2); newEnabledTransceiverIds.insert(transceiverCom2.id); }
|
if (e2) { newEnabledTransceivers.push_back(transceiverCom2); newEnabledTransceiverIds.insert(transceiverCom2.id); }
|
||||||
@@ -1038,6 +1086,21 @@ namespace BlackCore
|
|||||||
m_enabledTransceivers = newEnabledTransceiverIds;
|
m_enabledTransceivers = newEnabledTransceiverIds;
|
||||||
m_transmittingTransceivers = newTransmittingTransceivers;
|
m_transmittingTransceivers = newTransmittingTransceivers;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// update position and frequencies, but keep enabled as it was
|
||||||
|
const QSet<quint16> ids = getEnabledTransceivers();
|
||||||
|
if (ids.contains(comUnitToTransceiverId(CComSystem::Com1)))
|
||||||
|
{
|
||||||
|
newEnabledTransceivers.push_back(transceiverCom1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ids.contains(comUnitToTransceiverId(CComSystem::Com2)))
|
||||||
|
{
|
||||||
|
newEnabledTransceivers.push_back(transceiverCom2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// in connection and soundcard only use the enabled tarnsceivers
|
// in connection and soundcard only use the enabled tarnsceivers
|
||||||
const QString callsign = this->getCallsign(); // threadsafe
|
const QString callsign = this->getCallsign(); // threadsafe
|
||||||
@@ -1112,12 +1175,12 @@ namespace BlackCore
|
|||||||
// change to aliased frequency if needed
|
// change to aliased frequency if needed
|
||||||
{
|
{
|
||||||
QMutexLocker lock(&m_mutex);
|
QMutexLocker lock(&m_mutex);
|
||||||
auto it = std::find_if(m_aliasedStations.begin(), m_aliasedStations.end(), [roundedFrequencyHz](const StationDto & d)
|
const auto it = std::find_if(m_aliasedStations.constBegin(), m_aliasedStations.constEnd(), [roundedFrequencyHz](const StationDto & d)
|
||||||
{
|
{
|
||||||
return d.frequencyAliasHz == roundedFrequencyHz;
|
return d.frequencyAliasHz == roundedFrequencyHz;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (it != m_aliasedStations.end())
|
if (it != m_aliasedStations.constEnd())
|
||||||
{
|
{
|
||||||
if (sApp && sApp->getIContextNetwork())
|
if (sApp && sApp->getIContextNetwork())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -168,6 +168,13 @@ namespace BlackCore
|
|||||||
bool isTransmittingdComUnit(BlackMisc::Aviation::CComSystem::ComUnit comUnit) const;
|
bool isTransmittingdComUnit(BlackMisc::Aviation::CComSystem::ComUnit comUnit) const;
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
|
//! Simplified enable/disable
|
||||||
|
//! \threadsafe
|
||||||
|
//! @{
|
||||||
|
void setRxTx(bool rx1, bool tx1, bool rx2, bool tx2);
|
||||||
|
void getRxTx(bool &rx1, bool &tx1, bool &rx2, bool &tx2) const;
|
||||||
|
//! @}
|
||||||
|
|
||||||
//! Get transceivers
|
//! Get transceivers
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
//! @{
|
//! @{
|
||||||
|
|||||||
@@ -252,6 +252,22 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CContextAudioBase::setRxTx(bool rx1, bool tx1, bool rx2, bool tx2)
|
||||||
|
{
|
||||||
|
if (m_voiceClient)
|
||||||
|
{
|
||||||
|
m_voiceClient->setRxTx(rx1, tx1, rx2, tx2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CContextAudioBase::getRxTx(bool &rx1, bool &tx1, bool &rx2, bool &tx2) const
|
||||||
|
{
|
||||||
|
if (m_voiceClient)
|
||||||
|
{
|
||||||
|
m_voiceClient->setRxTx(rx1, tx1, rx2, tx2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const CIdentifier &CContextAudioBase::audioRunsWhere() const
|
const CIdentifier &CContextAudioBase::audioRunsWhere() const
|
||||||
{
|
{
|
||||||
static const CIdentifier i("CContextAudioBaseImpl");
|
static const CIdentifier i("CContextAudioBaseImpl");
|
||||||
|
|||||||
@@ -148,6 +148,11 @@ namespace BlackCore
|
|||||||
void disableVoiceClient() { this->terminateVoiceClient(); }
|
void disableVoiceClient() { this->terminateVoiceClient(); }
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
|
//! Receive/transmit @{
|
||||||
|
void setRxTx(bool rx1, bool tx1, bool rx2, bool tx2);
|
||||||
|
void getRxTx(bool &rx1, bool &tx1, bool &rx2, bool &tx2) const;
|
||||||
|
//! @}
|
||||||
|
|
||||||
// -------- parts which can run in core and GUI, referring to local voice client ------------
|
// -------- parts which can run in core and GUI, referring to local voice client ------------
|
||||||
|
|
||||||
//! Audio devices
|
//! Audio devices
|
||||||
|
|||||||
Reference in New Issue
Block a user