1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-10 10:33:29 -05:00

USRP input: Make settings assignments atomic. Part of #1329

This commit is contained in:
f4exb 2022-10-29 19:54:14 +02:00
parent 922cfc695e
commit d2fbdad736
6 changed files with 210 additions and 84 deletions

View File

@ -351,7 +351,7 @@ bool USRPInput::acquireChannel()
// Apply settings before creating stream // Apply settings before creating stream
// However, don't set LPF to <10MHz at this stage, otherwise there is massive TX LO leakage // However, don't set LPF to <10MHz at this stage, otherwise there is massive TX LO leakage
applySettings(m_settings, true, true); applySettings(m_settings, QList<QString>(), true, true);
usrp->set_rx_bandwidth(56000000, m_deviceShared.m_channel); usrp->set_rx_bandwidth(56000000, m_deviceShared.m_channel);
// set up the stream // set up the stream
@ -409,7 +409,7 @@ void USRPInput::releaseChannel()
void USRPInput::init() void USRPInput::init()
{ {
applySettings(m_settings, false, true); applySettings(m_settings, QList<QString>(), false, true);
} }
bool USRPInput::start() bool USRPInput::start()
@ -471,12 +471,12 @@ bool USRPInput::deserialize(const QByteArray& data)
success = false; success = false;
} }
MsgConfigureUSRP* message = MsgConfigureUSRP::create(m_settings, true); MsgConfigureUSRP* message = MsgConfigureUSRP::create(m_settings, QList<QString>(), true);
m_inputMessageQueue.push(message); m_inputMessageQueue.push(message);
if (m_guiMessageQueue) if (m_guiMessageQueue)
{ {
MsgConfigureUSRP* messageToGUI = MsgConfigureUSRP::create(m_settings, true); MsgConfigureUSRP* messageToGUI = MsgConfigureUSRP::create(m_settings, QList<QString>(), true);
m_guiMessageQueue->push(messageToGUI); m_guiMessageQueue->push(messageToGUI);
} }
@ -504,12 +504,12 @@ void USRPInput::setCenterFrequency(qint64 centerFrequency)
USRPInputSettings settings = m_settings; USRPInputSettings settings = m_settings;
settings.m_centerFrequency = centerFrequency; settings.m_centerFrequency = centerFrequency;
MsgConfigureUSRP* message = MsgConfigureUSRP::create(settings, false); MsgConfigureUSRP* message = MsgConfigureUSRP::create(settings, QList<QString>{"centerFrequency"}, false);
m_inputMessageQueue.push(message); m_inputMessageQueue.push(message);
if (m_guiMessageQueue) if (m_guiMessageQueue)
{ {
MsgConfigureUSRP* messageToGUI = MsgConfigureUSRP::create(settings, false); MsgConfigureUSRP* messageToGUI = MsgConfigureUSRP::create(settings, QList<QString>{"centerFrequency"}, false);
m_guiMessageQueue->push(messageToGUI); m_guiMessageQueue->push(messageToGUI);
} }
} }
@ -601,7 +601,7 @@ bool USRPInput::handleMessage(const Message& message)
MsgConfigureUSRP& conf = (MsgConfigureUSRP&) message; MsgConfigureUSRP& conf = (MsgConfigureUSRP&) message;
qDebug() << "USRPInput::handleMessage: MsgConfigureUSRP"; qDebug() << "USRPInput::handleMessage: MsgConfigureUSRP";
if (!applySettings(conf.getSettings(), false, conf.getForce())) if (!applySettings(conf.getSettings(), conf.getSettingsKeys(), false, conf.getForce()))
{ {
qDebug("USRPInput::handleMessage config error"); qDebug("USRPInput::handleMessage config error");
} }
@ -711,15 +711,15 @@ bool USRPInput::handleMessage(const Message& message)
} }
} }
bool USRPInput::applySettings(const USRPInputSettings& settings, bool preGetStream, bool force) bool USRPInput::applySettings(const USRPInputSettings& settings, const QList<QString>& settingsKeys, bool preGetStream, bool force)
{ {
qDebug() << "USRPInput::applySettings: preGetStream:" << preGetStream << " force:" << force << settings.getDebugString(settingsKeys, force);
bool forwardChangeOwnDSP = false; bool forwardChangeOwnDSP = false;
bool forwardChangeRxDSP = false; bool forwardChangeRxDSP = false;
bool forwardChangeAllDSP = false; bool forwardChangeAllDSP = false;
bool forwardClockSource = false; bool forwardClockSource = false;
bool reapplySomeSettings = false; bool reapplySomeSettings = false;
bool checkRates = false; bool checkRates = false;
QList<QString> reverseAPIKeys;
try try
{ {
@ -729,10 +729,8 @@ bool USRPInput::applySettings(const USRPInputSettings& settings, bool preGetStre
// apply settings // apply settings
if ((m_settings.m_clockSource != settings.m_clockSource) || force) if (settingsKeys.contains("clockSource") || force)
{ {
reverseAPIKeys.append("clockSource");
if (m_deviceShared.m_deviceParams->getDevice() && (m_channelAcquired || preGetStream)) if (m_deviceShared.m_deviceParams->getDevice() && (m_channelAcquired || preGetStream))
{ {
try try
@ -759,9 +757,8 @@ bool USRPInput::applySettings(const USRPInputSettings& settings, bool preGetStre
} }
} }
if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || force) if (settingsKeys.contains("devSampleRate") || force)
{ {
reverseAPIKeys.append("devSampleRate");
forwardChangeAllDSP = true; forwardChangeAllDSP = true;
if (m_deviceShared.m_deviceParams->getDevice() && (m_channelAcquired || preGetStream)) if (m_deviceShared.m_deviceParams->getDevice() && (m_channelAcquired || preGetStream))
@ -773,15 +770,12 @@ bool USRPInput::applySettings(const USRPInputSettings& settings, bool preGetStre
} }
} }
if ((m_settings.m_centerFrequency != settings.m_centerFrequency) if (settingsKeys.contains("centerFrequency")
|| (m_settings.m_loOffset != settings.m_loOffset) || settingsKeys.contains("loOffset")
|| (m_settings.m_transverterMode != settings.m_transverterMode) || settingsKeys.contains("transverterMode")
|| (m_settings.m_transverterDeltaFrequency != settings.m_transverterDeltaFrequency) || settingsKeys.contains("transverterDeltaFrequency")
|| force) || force)
{ {
reverseAPIKeys.append("centerFrequency");
reverseAPIKeys.append("transverterMode");
reverseAPIKeys.append("transverterDeltaFrequency");
forwardChangeRxDSP = true; forwardChangeRxDSP = true;
if (m_deviceShared.m_deviceParams->getDevice() && (m_channelAcquired || preGetStream)) if (m_deviceShared.m_deviceParams->getDevice() && (m_channelAcquired || preGetStream))
@ -801,24 +795,20 @@ bool USRPInput::applySettings(const USRPInputSettings& settings, bool preGetStre
} }
} }
if ((m_settings.m_dcBlock != settings.m_dcBlock) || force) if (settingsKeys.contains("dcBlock") || force)
{ {
reverseAPIKeys.append("dcBlock");
if (m_deviceShared.m_deviceParams->getDevice() && (m_channelAcquired || preGetStream)) if (m_deviceShared.m_deviceParams->getDevice() && (m_channelAcquired || preGetStream))
m_deviceShared.m_deviceParams->getDevice()->set_rx_dc_offset(settings.m_dcBlock, m_deviceShared.m_channel); m_deviceShared.m_deviceParams->getDevice()->set_rx_dc_offset(settings.m_dcBlock, m_deviceShared.m_channel);
} }
if ((m_settings.m_iqCorrection != settings.m_iqCorrection) || force) if (settingsKeys.contains("iqCorrection") || force)
{ {
reverseAPIKeys.append("iqCorrection");
if (m_deviceShared.m_deviceParams->getDevice() && (m_channelAcquired || preGetStream)) if (m_deviceShared.m_deviceParams->getDevice() && (m_channelAcquired || preGetStream))
m_deviceShared.m_deviceParams->getDevice()->set_rx_iq_balance(settings.m_iqCorrection, m_deviceShared.m_channel); m_deviceShared.m_deviceParams->getDevice()->set_rx_iq_balance(settings.m_iqCorrection, m_deviceShared.m_channel);
} }
if ((m_settings.m_gainMode != settings.m_gainMode) || force) if (settingsKeys.contains("gainMode") || force)
{ {
reverseAPIKeys.append("gainMode");
if (m_deviceShared.m_deviceParams->getDevice() && (m_channelAcquired || preGetStream)) if (m_deviceShared.m_deviceParams->getDevice() && (m_channelAcquired || preGetStream))
{ {
if (settings.m_gainMode == USRPInputSettings::GAIN_AUTO) if (settings.m_gainMode == USRPInputSettings::GAIN_AUTO)
@ -846,10 +836,8 @@ bool USRPInput::applySettings(const USRPInputSettings& settings, bool preGetStre
} }
} }
if ((m_settings.m_gain != settings.m_gain) || force) if (settingsKeys.contains("gain") || force)
{ {
reverseAPIKeys.append("gain");
if ((settings.m_gainMode != USRPInputSettings::GAIN_AUTO) && m_deviceShared.m_deviceParams->getDevice() && (m_channelAcquired || preGetStream)) if ((settings.m_gainMode != USRPInputSettings::GAIN_AUTO) && m_deviceShared.m_deviceParams->getDevice() && (m_channelAcquired || preGetStream))
{ {
m_deviceShared.m_deviceParams->getDevice()->set_rx_gain(settings.m_gain, m_deviceShared.m_channel); m_deviceShared.m_deviceParams->getDevice()->set_rx_gain(settings.m_gain, m_deviceShared.m_channel);
@ -857,10 +845,8 @@ bool USRPInput::applySettings(const USRPInputSettings& settings, bool preGetStre
} }
} }
if ((m_settings.m_lpfBW != settings.m_lpfBW) || force) if (settingsKeys.contains("lpfBW") || force)
{ {
reverseAPIKeys.append("lpfBW");
// Don't set bandwidth before get_rx_stream (See above) // Don't set bandwidth before get_rx_stream (See above)
if (m_deviceShared.m_deviceParams->getDevice() && m_channelAcquired) if (m_deviceShared.m_deviceParams->getDevice() && m_channelAcquired)
{ {
@ -869,9 +855,8 @@ bool USRPInput::applySettings(const USRPInputSettings& settings, bool preGetStre
} }
} }
if ((m_settings.m_log2SoftDecim != settings.m_log2SoftDecim) || force) if (settingsKeys.contains("log2SoftDecim") || force)
{ {
reverseAPIKeys.append("log2SoftDecim");
forwardChangeOwnDSP = true; forwardChangeOwnDSP = true;
m_deviceShared.m_log2Soft = settings.m_log2SoftDecim; // for buddies m_deviceShared.m_log2Soft = settings.m_log2SoftDecim; // for buddies
@ -882,10 +867,8 @@ bool USRPInput::applySettings(const USRPInputSettings& settings, bool preGetStre
} }
} }
if ((m_settings.m_antennaPath != settings.m_antennaPath) || force) if (settingsKeys.contains("antennaPath") || force)
{ {
reverseAPIKeys.append("antennaPath");
if (m_deviceShared.m_deviceParams->getDevice() && (m_channelAcquired || preGetStream)) if (m_deviceShared.m_deviceParams->getDevice() && (m_channelAcquired || preGetStream))
{ {
m_deviceShared.m_deviceParams->getDevice()->set_rx_antenna(settings.m_antennaPath.toStdString(), m_deviceShared.m_channel); m_deviceShared.m_deviceParams->getDevice()->set_rx_antenna(settings.m_antennaPath.toStdString(), m_deviceShared.m_channel);
@ -893,13 +876,13 @@ bool USRPInput::applySettings(const USRPInputSettings& settings, bool preGetStre
} }
} }
if (settings.m_useReverseAPI) if (settingsKeys.contains("useReverseAPI"))
{ {
bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) || bool fullUpdate = (settingsKeys.contains("useReverseAPI") && settings.m_useReverseAPI) ||
(m_settings.m_reverseAPIAddress != settings.m_reverseAPIAddress) || settingsKeys.contains("reverseAPIAddress") ||
(m_settings.m_reverseAPIPort != settings.m_reverseAPIPort) || settingsKeys.contains("reverseAPIPort") ||
(m_settings.m_reverseAPIDeviceIndex != settings.m_reverseAPIDeviceIndex); settingsKeys.contains("reverseAPIDeviceIndex");
webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force); webapiReverseSendSettings(settingsKeys, settings, fullUpdate || force);
} }
if (reapplySomeSettings) if (reapplySomeSettings)
@ -925,7 +908,11 @@ bool USRPInput::applySettings(const USRPInputSettings& settings, bool preGetStre
} }
} }
if (force) {
m_settings = settings; m_settings = settings;
} else {
m_settings.applySettings(settingsKeys, settings);
}
if (checkRates) if (checkRates)
{ {
@ -1057,21 +1044,6 @@ bool USRPInput::applySettings(const USRPInputSettings& settings, bool preGetStre
} }
} }
QLocale loc;
qDebug().noquote() << "USRPInput::applySettings: center freq: " << m_settings.m_centerFrequency << " Hz"
<< " m_transverterMode: " << m_settings.m_transverterMode
<< " m_transverterDeltaFrequency: " << m_settings.m_transverterDeltaFrequency
<< " deviceCenterFrequency: " << deviceCenterFrequency
<< " device stream sample rate: " << loc.toString(m_settings.m_devSampleRate) << "S/s"
<< " sample rate with soft decimation: " << loc.toString( m_settings.m_devSampleRate/(1<<m_settings.m_log2SoftDecim)) << "S/s"
<< " m_log2SoftDecim: " << m_settings.m_log2SoftDecim
<< " m_gain: " << m_settings.m_gain
<< " m_lpfBW: " << loc.toString(static_cast<int>(m_settings.m_lpfBW))
<< " m_antennaPath: " << m_settings.m_antennaPath
<< " m_clockSource: " << m_settings.m_clockSource
<< " force: " << force;
return true; return true;
} }
catch (std::exception &e) catch (std::exception &e)
@ -1102,12 +1074,12 @@ int USRPInput::webapiSettingsPutPatch(
USRPInputSettings settings = m_settings; USRPInputSettings settings = m_settings;
webapiUpdateDeviceSettings(settings, deviceSettingsKeys, response); webapiUpdateDeviceSettings(settings, deviceSettingsKeys, response);
MsgConfigureUSRP *msg = MsgConfigureUSRP::create(settings, force); MsgConfigureUSRP *msg = MsgConfigureUSRP::create(settings, deviceSettingsKeys, force);
m_inputMessageQueue.push(msg); m_inputMessageQueue.push(msg);
if (m_guiMessageQueue) // forward to GUI if any if (m_guiMessageQueue) // forward to GUI if any
{ {
MsgConfigureUSRP *msgToGUI = MsgConfigureUSRP::create(settings, force); MsgConfigureUSRP *msgToGUI = MsgConfigureUSRP::create(settings, deviceSettingsKeys, force);
m_guiMessageQueue->push(msgToGUI); m_guiMessageQueue->push(msgToGUI);
} }
@ -1258,7 +1230,7 @@ void USRPInput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response)
response.getUsrpInputReport()->setTimeoutCount(timeouts); response.getUsrpInputReport()->setTimeoutCount(timeouts);
} }
void USRPInput::webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const USRPInputSettings& settings, bool force) void USRPInput::webapiReverseSendSettings(const QList<QString>& deviceSettingsKeys, const USRPInputSettings& settings, bool force)
{ {
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings(); SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
swgDeviceSettings->setDirection(0); // single Rx swgDeviceSettings->setDirection(0); // single Rx

View File

@ -45,20 +45,22 @@ public:
public: public:
const USRPInputSettings& getSettings() const { return m_settings; } const USRPInputSettings& getSettings() const { return m_settings; }
const QList<QString>& getSettingsKeys() const { return m_settingsKeys; }
bool getForce() const { return m_force; } bool getForce() const { return m_force; }
static MsgConfigureUSRP* create(const USRPInputSettings& settings, bool force) static MsgConfigureUSRP* create(const USRPInputSettings& settings, const QList<QString>& settingsKeys, bool force) {
{ return new MsgConfigureUSRP(settings, settingsKeys, force);
return new MsgConfigureUSRP(settings, force);
} }
private: private:
USRPInputSettings m_settings; USRPInputSettings m_settings;
QList<QString> m_settingsKeys;
bool m_force; bool m_force;
MsgConfigureUSRP(const USRPInputSettings& settings, bool force) : MsgConfigureUSRP(const USRPInputSettings& settings, const QList<QString>& settingsKeys, bool force) :
Message(), Message(),
m_settings(settings), m_settings(settings),
m_settingsKeys(settingsKeys),
m_force(force) m_force(force)
{ } { }
}; };
@ -239,9 +241,9 @@ private:
void resumeRxBuddies(); void resumeRxBuddies();
void suspendTxBuddies(); void suspendTxBuddies();
void resumeTxBuddies(); void resumeTxBuddies();
bool applySettings(const USRPInputSettings& settings, bool preGetStream, bool force = false); bool applySettings(const USRPInputSettings& settings, const QList<QString>& settingsKeys, bool preGetStream, bool force = false);
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response); void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response);
void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const USRPInputSettings& settings, bool force); void webapiReverseSendSettings(const QList<QString>& deviceSettingsKeys, const USRPInputSettings& settings, bool force);
void webapiReverseSendStartStop(bool start); void webapiReverseSendStartStop(bool start);
private slots: private slots:

View File

@ -119,6 +119,7 @@ void USRPInputGUI::resetToDefaults()
{ {
m_settings.resetToDefaults(); m_settings.resetToDefaults();
displaySettings(); displaySettings();
m_forceSettings = true;
sendSettings(); sendSettings();
} }
@ -131,6 +132,7 @@ void USRPInputGUI::setCenterFrequency(qint64 centerFrequency)
{ {
m_settings.m_centerFrequency = centerFrequency; m_settings.m_centerFrequency = centerFrequency;
displaySettings(); displaySettings();
m_settingsKeys.append("centerFrequency");
sendSettings(); sendSettings();
} }
@ -166,7 +168,13 @@ bool USRPInputGUI::handleMessage(const Message& message)
if (USRPInput::MsgConfigureUSRP::match(message)) if (USRPInput::MsgConfigureUSRP::match(message))
{ {
const USRPInput::MsgConfigureUSRP& cfg = (USRPInput::MsgConfigureUSRP&) message; const USRPInput::MsgConfigureUSRP& cfg = (USRPInput::MsgConfigureUSRP&) message;
if (cfg.getForce()) {
m_settings = cfg.getSettings(); m_settings = cfg.getSettings();
} else {
m_settings.applySettings(cfg.getSettingsKeys(), cfg.getSettings());
}
blockApplySettings(true); blockApplySettings(true);
displaySettings(); displaySettings();
blockApplySettings(false); blockApplySettings(false);
@ -290,7 +298,13 @@ void USRPInputGUI::handleInputMessages()
else if (USRPInput::MsgConfigureUSRP::match(*message)) else if (USRPInput::MsgConfigureUSRP::match(*message))
{ {
const USRPInput::MsgConfigureUSRP& cfg = (USRPInput::MsgConfigureUSRP&) *message; const USRPInput::MsgConfigureUSRP& cfg = (USRPInput::MsgConfigureUSRP&) *message;
if (cfg.getForce()) {
m_settings = cfg.getSettings(); m_settings = cfg.getSettings();
} else {
m_settings.applySettings(cfg.getSettingsKeys(), cfg.getSettings());
}
displaySettings(); displaySettings();
delete message; delete message;
@ -393,12 +407,9 @@ void USRPInputGUI::displaySettings()
ui->gainMode->setCurrentIndex((int) m_settings.m_gainMode); ui->gainMode->setCurrentIndex((int) m_settings.m_gainMode);
if (m_settings.m_gainMode == USRPInputSettings::GAIN_AUTO) if (m_settings.m_gainMode == USRPInputSettings::GAIN_AUTO) {
{
ui->gain->setEnabled(false); ui->gain->setEnabled(false);
} } else {
else
{
ui->gain->setEnabled(true); ui->gain->setEnabled(true);
} }
} }
@ -423,8 +434,9 @@ void USRPInputGUI::setCenterFrequencySetting(uint64_t kHzValue)
void USRPInputGUI::sendSettings() void USRPInputGUI::sendSettings()
{ {
if(!m_updateTimer.isActive()) if (!m_updateTimer.isActive()) {
m_updateTimer.start(100); m_updateTimer.start(100);
}
} }
void USRPInputGUI::updateHardware() void USRPInputGUI::updateHardware()
@ -432,9 +444,10 @@ void USRPInputGUI::updateHardware()
if (m_doApplySettings) if (m_doApplySettings)
{ {
qDebug() << "USRPInputGUI::updateHardware"; qDebug() << "USRPInputGUI::updateHardware";
USRPInput::MsgConfigureUSRP* message = USRPInput::MsgConfigureUSRP::create(m_settings, m_forceSettings); USRPInput::MsgConfigureUSRP* message = USRPInput::MsgConfigureUSRP::create(m_settings, m_settingsKeys, m_forceSettings);
m_usrpInput->getInputMessageQueue()->push(message); m_usrpInput->getInputMessageQueue()->push(message);
m_forceSettings = false; m_forceSettings = false;
m_settingsKeys.clear();
m_updateTimer.stop(); m_updateTimer.stop();
} }
} }
@ -511,18 +524,21 @@ void USRPInputGUI::on_startStop_toggled(bool checked)
void USRPInputGUI::on_centerFrequency_changed(quint64 value) void USRPInputGUI::on_centerFrequency_changed(quint64 value)
{ {
setCenterFrequencySetting(value); setCenterFrequencySetting(value);
m_settingsKeys.append("centerFrequency");
sendSettings(); sendSettings();
} }
void USRPInputGUI::on_dcOffset_toggled(bool checked) void USRPInputGUI::on_dcOffset_toggled(bool checked)
{ {
m_settings.m_dcBlock = checked; m_settings.m_dcBlock = checked;
m_settingsKeys.append("dcBlock");
sendSettings(); sendSettings();
} }
void USRPInputGUI::on_iqImbalance_toggled(bool checked) void USRPInputGUI::on_iqImbalance_toggled(bool checked)
{ {
m_settings.m_iqCorrection = checked; m_settings.m_iqCorrection = checked;
m_settingsKeys.append("iqCorrection");
sendSettings(); sendSettings();
} }
@ -535,6 +551,7 @@ void USRPInputGUI::on_sampleRate_changed(quint64 value)
} }
updateSampleRate(); updateSampleRate();
m_settingsKeys.append("devSampleRate");
sendSettings(); sendSettings();
} }
@ -545,6 +562,7 @@ void USRPInputGUI::on_swDecim_currentIndexChanged(int index)
} }
m_settings.m_log2SoftDecim = index; m_settings.m_log2SoftDecim = index;
m_settingsKeys.append("log2SoftDecim");
displaySampleRate(); displaySampleRate();
if (m_sampleRateMode) { if (m_sampleRateMode) {
@ -553,31 +571,32 @@ void USRPInputGUI::on_swDecim_currentIndexChanged(int index)
m_settings.m_devSampleRate = ui->sampleRate->getValueNew() * (1 << m_settings.m_log2SoftDecim); m_settings.m_devSampleRate = ui->sampleRate->getValueNew() * (1 << m_settings.m_log2SoftDecim);
} }
m_settingsKeys.append("devSampleRate");
sendSettings(); sendSettings();
} }
void USRPInputGUI::on_lpf_changed(quint64 value) void USRPInputGUI::on_lpf_changed(quint64 value)
{ {
m_settings.m_lpfBW = value * 1000; m_settings.m_lpfBW = value * 1000;
m_settingsKeys.append("lpfBW");
sendSettings(); sendSettings();
} }
void USRPInputGUI::on_loOffset_changed(qint64 value) void USRPInputGUI::on_loOffset_changed(qint64 value)
{ {
m_settings.m_loOffset = value * 1000; m_settings.m_loOffset = value * 1000;
m_settingsKeys.append("loOffset");
sendSettings(); sendSettings();
} }
void USRPInputGUI::on_gainMode_currentIndexChanged(int index) void USRPInputGUI::on_gainMode_currentIndexChanged(int index)
{ {
m_settings.m_gainMode = (USRPInputSettings::GainMode) index; m_settings.m_gainMode = (USRPInputSettings::GainMode) index;
m_settingsKeys.append("gainMode");
if (index == 0) if (index == 0) {
{
ui->gain->setEnabled(false); ui->gain->setEnabled(false);
} } else {
else
{
ui->gain->setEnabled(true); ui->gain->setEnabled(true);
} }
@ -588,6 +607,7 @@ void USRPInputGUI::on_gain_valueChanged(int value)
{ {
m_settings.m_gain = value; m_settings.m_gain = value;
ui->gainText->setText(tr("%1").arg(m_settings.m_gain)); ui->gainText->setText(tr("%1").arg(m_settings.m_gain));
m_settingsKeys.append("gain");
sendSettings(); sendSettings();
} }
@ -595,6 +615,7 @@ void USRPInputGUI::on_antenna_currentIndexChanged(int index)
{ {
(void) index; (void) index;
m_settings.m_antennaPath = ui->antenna->currentText(); m_settings.m_antennaPath = ui->antenna->currentText();
m_settingsKeys.append("antennaPath");
sendSettings(); sendSettings();
} }
@ -602,6 +623,7 @@ void USRPInputGUI::on_clockSource_currentIndexChanged(int index)
{ {
(void) index; (void) index;
m_settings.m_clockSource = ui->clockSource->currentText(); m_settings.m_clockSource = ui->clockSource->currentText();
m_settingsKeys.append("clockSource");
sendSettings(); sendSettings();
} }
@ -612,6 +634,9 @@ void USRPInputGUI::on_transverter_clicked()
qDebug("USRPInputGUI::on_transverter_clicked: %lld Hz %s", m_settings.m_transverterDeltaFrequency, m_settings.m_transverterMode ? "on" : "off"); qDebug("USRPInputGUI::on_transverter_clicked: %lld Hz %s", m_settings.m_transverterDeltaFrequency, m_settings.m_transverterMode ? "on" : "off");
updateFrequencyLimits(); updateFrequencyLimits();
setCenterFrequencySetting(ui->centerFrequency->getValueNew()); setCenterFrequencySetting(ui->centerFrequency->getValueNew());
m_settingsKeys.append("transverterMode");
m_settingsKeys.append("transverterDeltaFrequency");
m_settingsKeys.append("centerFrequency");
sendSettings(); sendSettings();
} }
@ -638,6 +663,10 @@ void USRPInputGUI::openDeviceSettingsDialog(const QPoint& p)
m_settings.m_reverseAPIAddress = dialog.getReverseAPIAddress(); m_settings.m_reverseAPIAddress = dialog.getReverseAPIAddress();
m_settings.m_reverseAPIPort = dialog.getReverseAPIPort(); m_settings.m_reverseAPIPort = dialog.getReverseAPIPort();
m_settings.m_reverseAPIDeviceIndex = dialog.getReverseAPIDeviceIndex(); m_settings.m_reverseAPIDeviceIndex = dialog.getReverseAPIDeviceIndex();
m_settingsKeys.append("useReverseAPI");
m_settingsKeys.append("reverseAPIAddress");
m_settingsKeys.append("reverseAPIPort");
m_settingsKeys.append("reverseAPIDeviceIndex");
sendSettings(); sendSettings();
} }

View File

@ -59,6 +59,7 @@ private:
USRPInput* m_usrpInput; //!< Same object as above but gives easy access to USRPInput methods and attributes that are used intensively USRPInput* m_usrpInput; //!< Same object as above but gives easy access to USRPInput methods and attributes that are used intensively
USRPInputSettings m_settings; USRPInputSettings m_settings;
QList<QString> m_settingsKeys;
bool m_sampleRateMode; //!< true: device, false: base band sample rate update mode bool m_sampleRateMode; //!< true: device, false: base band sample rate update mode
QTimer m_updateTimer; QTimer m_updateTimer;
QTimer m_statusTimer; QTimer m_statusTimer;

View File

@ -120,3 +120,123 @@ bool USRPInputSettings::deserialize(const QByteArray& data)
} }
} }
void USRPInputSettings::applySettings(const QStringList& settingsKeys, const USRPInputSettings& settings)
{
if (settingsKeys.contains("masterClockRate")) {
m_masterClockRate = settings.m_masterClockRate;
}
if (settingsKeys.contains("centerFrequency")) {
m_centerFrequency = settings.m_centerFrequency;
}
if (settingsKeys.contains("devSampleRate")) {
m_devSampleRate = settings.m_devSampleRate;
}
if (settingsKeys.contains("loOffset")) {
m_loOffset = settings.m_loOffset;
}
if (settingsKeys.contains("dcBlock")) {
m_dcBlock = settings.m_dcBlock;
}
if (settingsKeys.contains("iqCorrection")) {
m_iqCorrection = settings.m_iqCorrection;
}
if (settingsKeys.contains("log2SoftDecim")) {
m_log2SoftDecim = settings.m_log2SoftDecim;
}
if (settingsKeys.contains("lpfBW")) {
m_lpfBW = settings.m_lpfBW;
}
if (settingsKeys.contains("gain")) {
m_gain = settings.m_gain;
}
if (settingsKeys.contains("antennaPath")) {
m_antennaPath = settings.m_antennaPath;
}
if (settingsKeys.contains("gainMode")) {
m_gainMode = settings.m_gainMode;
}
if (settingsKeys.contains("clockSource")) {
m_clockSource = settings.m_clockSource;
}
if (settingsKeys.contains("transverterMode")) {
m_transverterMode = settings.m_transverterMode;
}
if (settingsKeys.contains("transverterDeltaFrequency")) {
m_transverterDeltaFrequency = settings.m_transverterDeltaFrequency;
}
if (settingsKeys.contains("useReverseAPI")) {
m_useReverseAPI = settings.m_useReverseAPI;
}
if (settingsKeys.contains("reverseAPIAddress")) {
m_reverseAPIAddress = settings.m_reverseAPIAddress;
}
if (settingsKeys.contains("reverseAPIPort")) {
m_reverseAPIPort = settings.m_reverseAPIPort;
}
if (settingsKeys.contains("reverseAPIDeviceIndex")) {
m_reverseAPIDeviceIndex = settings.m_reverseAPIDeviceIndex;
}
}
QString USRPInputSettings::getDebugString(const QStringList& settingsKeys, bool force) const
{
std::ostringstream ostr;
if (settingsKeys.contains("masterClockRate") || force) {
ostr << " m_masterClockRate: " << m_masterClockRate;
}
if (settingsKeys.contains("centerFrequency") || force) {
ostr << " m_centerFrequency: " << m_centerFrequency;
}
if (settingsKeys.contains("devSampleRate") || force) {
ostr << " m_devSampleRate: " << m_devSampleRate;
}
if (settingsKeys.contains("loOffset") || force) {
ostr << " m_loOffset: " << m_loOffset;
}
if (settingsKeys.contains("dcBlock") || force) {
ostr << " m_dcBlock: " << m_dcBlock;
}
if (settingsKeys.contains("iqCorrection") || force) {
ostr << " m_iqCorrection: " << m_iqCorrection;
}
if (settingsKeys.contains("log2SoftDecim") || force) {
ostr << " m_log2SoftDecim: " << m_log2SoftDecim;
}
if (settingsKeys.contains("lpfBW") || force) {
ostr << " m_lpfBW: " << m_lpfBW;
}
if (settingsKeys.contains("gain") || force) {
ostr << " m_gain: " << m_gain;
}
if (settingsKeys.contains("antennaPath") || force) {
ostr << " m_antennaPath: " << m_antennaPath.toStdString();
}
if (settingsKeys.contains("gainMode") || force) {
ostr << " m_gainMode: " << m_gainMode;
}
if (settingsKeys.contains("clockSource") || force) {
ostr << " m_clockSource: " << m_clockSource.toStdString();
}
if (settingsKeys.contains("transverterMode") || force) {
ostr << " m_transverterMode: " << m_transverterMode;
}
if (settingsKeys.contains("transverterDeltaFrequency") || force) {
ostr << " m_transverterDeltaFrequency: " << m_transverterDeltaFrequency;
}
if (settingsKeys.contains("useReverseAPI") || force) {
ostr << " m_useReverseAPI: " << m_useReverseAPI;
}
if (settingsKeys.contains("reverseAPIAddress") || force) {
ostr << " m_reverseAPIAddress: " << m_reverseAPIAddress.toStdString();
}
if (settingsKeys.contains("reverseAPIPort") || force) {
ostr << " m_reverseAPIPort: " << m_reverseAPIPort;
}
if (settingsKeys.contains("reverseAPIDeviceIndex") || force) {
ostr << " m_reverseAPIDeviceIndex: " << m_reverseAPIDeviceIndex;
}
return QString(ostr.str().c_str());
}

View File

@ -59,6 +59,8 @@ struct USRPInputSettings
void resetToDefaults(); void resetToDefaults();
QByteArray serialize() const; QByteArray serialize() const;
bool deserialize(const QByteArray& data); bool deserialize(const QByteArray& data);
void applySettings(const QStringList& settingsKeys, const USRPInputSettings& settings);
QString getDebugString(const QStringList& settingsKeys, bool force=false) const;
}; };
#endif /* PLUGINS_SAMPLESOURCE_USRPINPUT_USRPINPUTSETTINGS_H_ */ #endif /* PLUGINS_SAMPLESOURCE_USRPINPUT_USRPINPUTSETTINGS_H_ */