mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-26 09:48:45 -05:00
SoapySDR support: output: manage global and individual gains coupling
This commit is contained in:
parent
9d014d841b
commit
59c8ecd2d0
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
MESSAGE_CLASS_DEFINITION(SoapySDROutput::MsgConfigureSoapySDROutput, Message)
|
MESSAGE_CLASS_DEFINITION(SoapySDROutput::MsgConfigureSoapySDROutput, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(SoapySDROutput::MsgStartStop, Message)
|
MESSAGE_CLASS_DEFINITION(SoapySDROutput::MsgStartStop, Message)
|
||||||
|
MESSAGE_CLASS_DEFINITION(SoapySDROutput::MsgReportGainChange, Message)
|
||||||
|
|
||||||
SoapySDROutput::SoapySDROutput(DeviceSinkAPI *deviceAPI) :
|
SoapySDROutput::SoapySDROutput(DeviceSinkAPI *deviceAPI) :
|
||||||
m_deviceAPI(deviceAPI),
|
m_deviceAPI(deviceAPI),
|
||||||
@ -36,6 +37,7 @@ SoapySDROutput::SoapySDROutput(DeviceSinkAPI *deviceAPI) :
|
|||||||
m_thread(0)
|
m_thread(0)
|
||||||
{
|
{
|
||||||
openDevice();
|
openDevice();
|
||||||
|
initGainSettings(m_settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
SoapySDROutput::~SoapySDROutput()
|
SoapySDROutput::~SoapySDROutput()
|
||||||
@ -230,6 +232,19 @@ const std::vector<DeviceSoapySDRParams::GainSetting>& SoapySDROutput::getIndivid
|
|||||||
return channelSettings->m_gainSettings;
|
return channelSettings->m_gainSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SoapySDROutput::initGainSettings(SoapySDROutputSettings& settings)
|
||||||
|
{
|
||||||
|
const DeviceSoapySDRParams::ChannelSettings* channelSettings = m_deviceShared.m_deviceParams->getTxChannelSettings(m_deviceShared.m_channel);
|
||||||
|
settings.m_individualGains.clear();
|
||||||
|
settings.m_globalGain = 0;
|
||||||
|
|
||||||
|
for (const auto &it : channelSettings->m_gainSettings) {
|
||||||
|
settings.m_individualGains[QString(it.m_name.c_str())] = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateGains(m_deviceShared.m_device, m_deviceShared.m_channel, settings);
|
||||||
|
}
|
||||||
|
|
||||||
void SoapySDROutput::init()
|
void SoapySDROutput::init()
|
||||||
{
|
{
|
||||||
applySettings(m_settings, true);
|
applySettings(m_settings, true);
|
||||||
@ -585,6 +600,19 @@ bool SoapySDROutput::setDeviceCenterFrequency(SoapySDR::Device *dev, int request
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SoapySDROutput::updateGains(SoapySDR::Device *dev, int requestedChannel, SoapySDROutputSettings& settings)
|
||||||
|
{
|
||||||
|
if (dev == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
settings.m_globalGain = round(dev->getGain(SOAPY_SDR_TX, requestedChannel));
|
||||||
|
|
||||||
|
for (const auto &name : settings.m_individualGains.keys()) {
|
||||||
|
settings.m_individualGains[name] = dev->getGain(SOAPY_SDR_TX, requestedChannel, name.toStdString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool SoapySDROutput::handleMessage(const Message& message)
|
bool SoapySDROutput::handleMessage(const Message& message)
|
||||||
{
|
{
|
||||||
if (MsgConfigureSoapySDROutput::match(message))
|
if (MsgConfigureSoapySDROutput::match(message))
|
||||||
@ -656,6 +684,8 @@ bool SoapySDROutput::applySettings(const SoapySDROutputSettings& settings, bool
|
|||||||
{
|
{
|
||||||
bool forwardChangeOwnDSP = false;
|
bool forwardChangeOwnDSP = false;
|
||||||
bool forwardChangeToBuddies = false;
|
bool forwardChangeToBuddies = false;
|
||||||
|
bool globalGainChanged = false;
|
||||||
|
bool individualGainsChanged = false;
|
||||||
|
|
||||||
SoapySDR::Device *dev = m_deviceShared.m_device;
|
SoapySDR::Device *dev = m_deviceShared.m_device;
|
||||||
SoapySDROutputThread *outputThread = findThread();
|
SoapySDROutputThread *outputThread = findThread();
|
||||||
@ -822,6 +852,7 @@ bool SoapySDROutput::applySettings(const SoapySDROutputSettings& settings, bool
|
|||||||
{
|
{
|
||||||
dev->setGain(SOAPY_SDR_TX, requestedChannel, settings.m_globalGain);
|
dev->setGain(SOAPY_SDR_TX, requestedChannel, settings.m_globalGain);
|
||||||
qDebug("SoapySDROutput::applySettings: set global gain to %d", settings.m_globalGain);
|
qDebug("SoapySDROutput::applySettings: set global gain to %d", settings.m_globalGain);
|
||||||
|
globalGainChanged = true;
|
||||||
}
|
}
|
||||||
catch (const std::exception &ex)
|
catch (const std::exception &ex)
|
||||||
{
|
{
|
||||||
@ -835,7 +866,7 @@ bool SoapySDROutput::applySettings(const SoapySDROutputSettings& settings, bool
|
|||||||
{
|
{
|
||||||
auto nvalue = settings.m_individualGains.find(oname);
|
auto nvalue = settings.m_individualGains.find(oname);
|
||||||
|
|
||||||
if (nvalue != settings.m_individualGains.end() && (m_settings.m_individualGains[oname] != *nvalue))
|
if (nvalue != settings.m_individualGains.end() && ((m_settings.m_individualGains[oname] != *nvalue) || force))
|
||||||
{
|
{
|
||||||
if (dev != 0)
|
if (dev != 0)
|
||||||
{
|
{
|
||||||
@ -844,6 +875,7 @@ bool SoapySDROutput::applySettings(const SoapySDROutputSettings& settings, bool
|
|||||||
dev->setGain(SOAPY_SDR_TX, requestedChannel, oname.toStdString(), *nvalue);
|
dev->setGain(SOAPY_SDR_TX, requestedChannel, oname.toStdString(), *nvalue);
|
||||||
qDebug("SoapySDROutput::applySettings: individual gain %s set to %lf",
|
qDebug("SoapySDROutput::applySettings: individual gain %s set to %lf",
|
||||||
oname.toStdString().c_str(), *nvalue);
|
oname.toStdString().c_str(), *nvalue);
|
||||||
|
individualGainsChanged = true;
|
||||||
}
|
}
|
||||||
catch (const std::exception &ex)
|
catch (const std::exception &ex)
|
||||||
{
|
{
|
||||||
@ -894,6 +926,19 @@ bool SoapySDROutput::applySettings(const SoapySDROutputSettings& settings, bool
|
|||||||
|
|
||||||
m_settings = settings;
|
m_settings = settings;
|
||||||
|
|
||||||
|
if (globalGainChanged || individualGainsChanged)
|
||||||
|
{
|
||||||
|
if (dev) {
|
||||||
|
updateGains(dev, requestedChannel, m_settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getMessageQueueToGUI())
|
||||||
|
{
|
||||||
|
MsgReportGainChange *report = MsgReportGainChange::create(m_settings, individualGainsChanged, globalGainChanged);
|
||||||
|
getMessageQueueToGUI()->push(report);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
qDebug() << "SoapySDROutput::applySettings: "
|
qDebug() << "SoapySDROutput::applySettings: "
|
||||||
<< " m_transverterMode: " << m_settings.m_transverterMode
|
<< " m_transverterMode: " << m_settings.m_transverterMode
|
||||||
<< " m_transverterDeltaFrequency: " << m_settings.m_transverterDeltaFrequency
|
<< " m_transverterDeltaFrequency: " << m_settings.m_transverterDeltaFrequency
|
||||||
|
@ -59,6 +59,32 @@ public:
|
|||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class MsgReportGainChange : public Message {
|
||||||
|
MESSAGE_CLASS_DECLARATION
|
||||||
|
|
||||||
|
public:
|
||||||
|
const SoapySDROutputSettings& getSettings() const { return m_settings; }
|
||||||
|
bool getGlobalGain() const { return m_globalGain; }
|
||||||
|
bool getIndividualGains() const { return m_individualGains; }
|
||||||
|
|
||||||
|
static MsgReportGainChange* create(const SoapySDROutputSettings& settings, bool globalGain, bool individualGains)
|
||||||
|
{
|
||||||
|
return new MsgReportGainChange(settings, globalGain, individualGains);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
SoapySDROutputSettings m_settings;
|
||||||
|
bool m_globalGain;
|
||||||
|
bool m_individualGains;
|
||||||
|
|
||||||
|
MsgReportGainChange(const SoapySDROutputSettings& settings, bool globalGain, bool individualGains) :
|
||||||
|
Message(),
|
||||||
|
m_settings(settings),
|
||||||
|
m_globalGain(globalGain),
|
||||||
|
m_individualGains(individualGains)
|
||||||
|
{ }
|
||||||
|
};
|
||||||
|
|
||||||
class MsgStartStop : public Message {
|
class MsgStartStop : public Message {
|
||||||
MESSAGE_CLASS_DECLARATION
|
MESSAGE_CLASS_DECLARATION
|
||||||
|
|
||||||
@ -106,6 +132,7 @@ public:
|
|||||||
const SoapySDR::RangeList& getBandwidthRanges();
|
const SoapySDR::RangeList& getBandwidthRanges();
|
||||||
const std::vector<DeviceSoapySDRParams::FrequencySetting>& getTunableElements();
|
const std::vector<DeviceSoapySDRParams::FrequencySetting>& getTunableElements();
|
||||||
const std::vector<DeviceSoapySDRParams::GainSetting>& getIndividualGainsRanges();
|
const std::vector<DeviceSoapySDRParams::GainSetting>& getIndividualGainsRanges();
|
||||||
|
void initGainSettings(SoapySDROutputSettings& settings);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DeviceSinkAPI *m_deviceAPI;
|
DeviceSinkAPI *m_deviceAPI;
|
||||||
@ -122,6 +149,7 @@ private:
|
|||||||
void moveThreadToBuddy();
|
void moveThreadToBuddy();
|
||||||
bool applySettings(const SoapySDROutputSettings& settings, bool force = false);
|
bool applySettings(const SoapySDROutputSettings& settings, bool force = false);
|
||||||
bool setDeviceCenterFrequency(SoapySDR::Device *dev, int requestedChannel, quint64 freq_hz, int loPpmTenths);
|
bool setDeviceCenterFrequency(SoapySDR::Device *dev, int requestedChannel, quint64 freq_hz, int loPpmTenths);
|
||||||
|
void updateGains(SoapySDR::Device *dev, int requestedChannel, SoapySDROutputSettings& settings);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,6 +59,7 @@ SoapySDROutputGui::SoapySDROutputGui(DeviceUISet *deviceUISet, QWidget* parent)
|
|||||||
createTunableElementsControl(m_sampleSink->getTunableElements());
|
createTunableElementsControl(m_sampleSink->getTunableElements());
|
||||||
createGlobalGainControl();
|
createGlobalGainControl();
|
||||||
createIndividualGainsControl(m_sampleSink->getIndividualGainsRanges());
|
createIndividualGainsControl(m_sampleSink->getIndividualGainsRanges());
|
||||||
|
m_sampleSink->initGainSettings(m_settings);
|
||||||
|
|
||||||
if (m_sampleRateGUI) {
|
if (m_sampleRateGUI) {
|
||||||
connect(m_sampleRateGUI, SIGNAL(valueChanged(double)), this, SLOT(sampleRateChanged(double)));
|
connect(m_sampleRateGUI, SIGNAL(valueChanged(double)), this, SLOT(sampleRateChanged(double)));
|
||||||
@ -282,6 +283,24 @@ bool SoapySDROutputGui::handleMessage(const Message& message)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if (SoapySDROutput::MsgReportGainChange::match(message))
|
||||||
|
{
|
||||||
|
const SoapySDROutput::MsgReportGainChange& report = (SoapySDROutput::MsgReportGainChange&) message;
|
||||||
|
const SoapySDROutputSettings& gainSettings = report.getSettings();
|
||||||
|
|
||||||
|
if (report.getGlobalGain()) {
|
||||||
|
m_settings.m_globalGain = gainSettings.m_globalGain;
|
||||||
|
}
|
||||||
|
if (report.getIndividualGains()) {
|
||||||
|
m_settings.m_individualGains = gainSettings.m_individualGains;
|
||||||
|
}
|
||||||
|
|
||||||
|
blockApplySettings(true);
|
||||||
|
displaySettings();
|
||||||
|
blockApplySettings(false);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
else if (SoapySDROutput::MsgStartStop::match(message))
|
else if (SoapySDROutput::MsgStartStop::match(message))
|
||||||
{
|
{
|
||||||
SoapySDROutput::MsgStartStop& notif = (SoapySDROutput::MsgStartStop&) message;
|
SoapySDROutput::MsgStartStop& notif = (SoapySDROutput::MsgStartStop&) message;
|
||||||
|
Loading…
Reference in New Issue
Block a user