mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 09:15:34 +08:00
Ref T730, AFV client fixes
* correct quint32 for frequency * make sure frequencies are not updated twice, only update position * re-init transceivers if stopped and started again
This commit is contained in:
committed by
Mat Sutcliffe
parent
5c56715c28
commit
91b65fa2b6
@@ -49,8 +49,19 @@ namespace BlackCore
|
|||||||
m_output = new Output(this);
|
m_output = new Output(this);
|
||||||
connect(m_output, &Output::outputVolumeStream, this, &CAfvClient::outputVolumeStream);
|
connect(m_output, &Output::outputVolumeStream, this, &CAfvClient::outputVolumeStream);
|
||||||
connect(m_connection, &CClientConnection::audioReceived, this, &CAfvClient::audioOutDataAvailable);
|
connect(m_connection, &CClientConnection::audioReceived, this, &CAfvClient::audioOutDataAvailable);
|
||||||
connect(&m_voiceServerPositionTimer, &QTimer::timeout, this, qOverload<>(&CAfvClient::updateTransceivers));
|
connect(&m_voiceServerPositionTimer, &QTimer::timeout, this, &CAfvClient::onPositionUpdateTimer);
|
||||||
|
|
||||||
|
// transceivers
|
||||||
|
this->initTransceivers();
|
||||||
|
|
||||||
|
// init by settings
|
||||||
|
this->onSettingsChanged();
|
||||||
|
|
||||||
|
CLogMessage(this).info(u"UserClient instantiated");
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAfvClient::initTransceivers()
|
||||||
|
{
|
||||||
m_transceivers =
|
m_transceivers =
|
||||||
{
|
{
|
||||||
{ 0, UniCom, 48.5, 11.5, 1000.0, 1000.0 },
|
{ 0, UniCom, 48.5, 11.5, 1000.0, 1000.0 },
|
||||||
@@ -60,10 +71,8 @@ namespace BlackCore
|
|||||||
m_enabledTransceivers = { 0, 1 };
|
m_enabledTransceivers = { 0, 1 };
|
||||||
m_transmittingTransceivers = { { 0 } }; // TxTransceiverDto
|
m_transmittingTransceivers = { { 0 } }; // TxTransceiverDto
|
||||||
|
|
||||||
// init by settings
|
// init with context values
|
||||||
this->onSettingsChanged();
|
this->initWithContext();
|
||||||
|
|
||||||
CLogMessage(this).info(u"UserClient instantiated");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAfvClient::initWithContext()
|
void CAfvClient::initWithContext()
|
||||||
@@ -79,7 +88,7 @@ namespace BlackCore
|
|||||||
this->initWithContext();
|
this->initWithContext();
|
||||||
m_callsign = callsign;
|
m_callsign = callsign;
|
||||||
m_connection->connectTo(cid, password, callsign);
|
m_connection->connectTo(cid, password, callsign);
|
||||||
this->updateTransceivers();
|
this->updateTransceivers(); // uses context if available
|
||||||
|
|
||||||
if (m_connection->isConnected()) { emit this->connectionStatusChanged(Connected); }
|
if (m_connection->isConnected()) { emit this->connectionStatusChanged(Connected); }
|
||||||
else { emit this->connectionStatusChanged(Disconnected); }
|
else { emit this->connectionStatusChanged(Disconnected); }
|
||||||
@@ -136,6 +145,8 @@ namespace BlackCore
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->initTransceivers();
|
||||||
|
|
||||||
soundcardSampleProvider = new CSoundcardSampleProvider(SampleRate, transceiverIDs, this);
|
soundcardSampleProvider = new CSoundcardSampleProvider(SampleRate, transceiverIDs, this);
|
||||||
connect(soundcardSampleProvider, &CSoundcardSampleProvider::receivingCallsignsChanged, this, &CAfvClient::receivingCallsignsChanged);
|
connect(soundcardSampleProvider, &CSoundcardSampleProvider::receivingCallsignsChanged, this, &CAfvClient::receivingCallsignsChanged);
|
||||||
outputSampleProvider = new CVolumeSampleProvider(soundcardSampleProvider, this);
|
outputSampleProvider = new CVolumeSampleProvider(soundcardSampleProvider, this);
|
||||||
@@ -171,11 +182,11 @@ namespace BlackCore
|
|||||||
m_connection->setReceiveAudio(false);
|
m_connection->setReceiveAudio(false);
|
||||||
|
|
||||||
m_transceivers.clear();
|
m_transceivers.clear();
|
||||||
updateTransceivers();
|
this->updateTransceivers(false);
|
||||||
|
|
||||||
m_input->stop();
|
m_input->stop();
|
||||||
m_output->stop();
|
m_output->stop();
|
||||||
CLogMessage(this).info(u"Client NOT stopped");
|
CLogMessage(this).info(u"Client stopped");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAfvClient::enableTransceiver(quint16 id, bool enable)
|
void CAfvClient::enableTransceiver(quint16 id, bool enable)
|
||||||
@@ -183,7 +194,7 @@ namespace BlackCore
|
|||||||
if (enable) { m_enabledTransceivers.insert(id); }
|
if (enable) { m_enabledTransceivers.insert(id); }
|
||||||
else { m_enabledTransceivers.remove(id); }
|
else { m_enabledTransceivers.remove(id); }
|
||||||
|
|
||||||
updateTransceivers();
|
this->updateTransceivers();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAfvClient::enableComUnit(CComSystem::ComUnit comUnit, bool enable)
|
void CAfvClient::enableComUnit(CComSystem::ComUnit comUnit, bool enable)
|
||||||
@@ -219,14 +230,14 @@ namespace BlackCore
|
|||||||
if (m_transceivers[id].frequencyHz != roundedFrequencyHz)
|
if (m_transceivers[id].frequencyHz != roundedFrequencyHz)
|
||||||
{
|
{
|
||||||
m_transceivers[id].frequencyHz = roundedFrequencyHz;
|
m_transceivers[id].frequencyHz = roundedFrequencyHz;
|
||||||
updateTransceivers();
|
this->updateTransceivers(false); // no frequency update
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAfvClient::updateComFrequency(CComSystem::ComUnit comUnit, const CFrequency &comFrequency)
|
void CAfvClient::updateComFrequency(CComSystem::ComUnit comUnit, const CFrequency &comFrequency)
|
||||||
{
|
{
|
||||||
const quint16 freqHz = static_cast<quint16>(comFrequency.valueInteger(CFrequencyUnit::Hz()));
|
const quint32 freqHz = static_cast<quint32>(comFrequency.valueInteger(CFrequencyUnit::Hz()));
|
||||||
this->updateComFrequency(comUnitToTransceiverId(comUnit), freqHz);
|
this->updateComFrequency(comUnitToTransceiverId(comUnit), freqHz);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,17 +257,21 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAfvClient::updateTransceivers()
|
void CAfvClient::updateTransceivers(bool updateFrequencies)
|
||||||
{
|
{
|
||||||
if (!m_connection->isConnected()) { return; }
|
if (!m_connection->isConnected()) { return; }
|
||||||
if (hasContext())
|
if (hasContext())
|
||||||
{
|
{
|
||||||
const CSimulatedAircraft ownAircraft = sApp->getIContextOwnAircraft()->getOwnAircraft();
|
const CSimulatedAircraft ownAircraft = sApp->getIContextOwnAircraft()->getOwnAircraft();
|
||||||
updatePosition(ownAircraft.latitude().value(CAngleUnit::deg()),
|
this->updatePosition(ownAircraft.latitude().value(CAngleUnit::deg()),
|
||||||
ownAircraft.longitude().value(CAngleUnit::deg()),
|
ownAircraft.longitude().value(CAngleUnit::deg()),
|
||||||
ownAircraft.getAltitude().value(CLengthUnit::ft()));
|
ownAircraft.getAltitude().value(CLengthUnit::ft()));
|
||||||
this->updateComFrequency(CComSystem::Com1, ownAircraft.getCom1System());
|
|
||||||
this->updateComFrequency(CComSystem::Com2, ownAircraft.getCom2System());
|
if (updateFrequencies)
|
||||||
|
{
|
||||||
|
this->updateComFrequency(CComSystem::Com1, ownAircraft.getCom1System());
|
||||||
|
this->updateComFrequency(CComSystem::Com2, ownAircraft.getCom2System());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<TransceiverDto> enabledTransceivers;
|
QVector<TransceiverDto> enabledTransceivers;
|
||||||
@@ -477,6 +492,11 @@ namespace BlackCore
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CAfvClient::onPositionUpdateTimer()
|
||||||
|
{
|
||||||
|
this->updateTransceivers();
|
||||||
|
}
|
||||||
|
|
||||||
void CAfvClient::onSettingsChanged()
|
void CAfvClient::onSettingsChanged()
|
||||||
{
|
{
|
||||||
const CSettings audioSettings = m_audioSettings.get();
|
const CSettings audioSettings = m_audioSettings.get();
|
||||||
|
|||||||
@@ -186,10 +186,12 @@ namespace BlackCore
|
|||||||
QString getReceivingCallsignsCom1();
|
QString getReceivingCallsignsCom1();
|
||||||
QString getReceivingCallsignsCom2();
|
QString getReceivingCallsignsCom2();
|
||||||
|
|
||||||
void input_OpusDataAvailable();
|
void inputOpusDataAvailable();
|
||||||
|
|
||||||
|
void onPositionUpdateTimer();
|
||||||
void onSettingsChanged();
|
void onSettingsChanged();
|
||||||
|
|
||||||
void updateTransceivers();
|
void updateTransceivers(bool updateFrequencies = true);
|
||||||
void updateTransceiversFromContext(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const BlackMisc::CIdentifier &originator);
|
void updateTransceiversFromContext(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const BlackMisc::CIdentifier &originator);
|
||||||
|
|
||||||
static constexpr int SampleRate = 48000;
|
static constexpr int SampleRate = 48000;
|
||||||
@@ -234,6 +236,7 @@ namespace BlackCore
|
|||||||
Audio::InputVolumeStreamArgs m_inputVolumeStream;
|
Audio::InputVolumeStreamArgs m_inputVolumeStream;
|
||||||
Audio::OutputVolumeStreamArgs m_outputVolumeStream;
|
Audio::OutputVolumeStreamArgs m_outputVolumeStream;
|
||||||
|
|
||||||
|
void initTransceivers();
|
||||||
void initWithContext();
|
void initWithContext();
|
||||||
static bool hasContext();
|
static bool hasContext();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user