mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-26 17:58:43 -05:00
USRP input: Make settings assignments atomic. Part of #1329
This commit is contained in:
parent
922cfc695e
commit
d2fbdad736
@ -351,7 +351,7 @@ bool USRPInput::acquireChannel()
|
||||
|
||||
// Apply settings before creating stream
|
||||
// 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);
|
||||
|
||||
// set up the stream
|
||||
@ -409,7 +409,7 @@ void USRPInput::releaseChannel()
|
||||
|
||||
void USRPInput::init()
|
||||
{
|
||||
applySettings(m_settings, false, true);
|
||||
applySettings(m_settings, QList<QString>(), false, true);
|
||||
}
|
||||
|
||||
bool USRPInput::start()
|
||||
@ -471,12 +471,12 @@ bool USRPInput::deserialize(const QByteArray& data)
|
||||
success = false;
|
||||
}
|
||||
|
||||
MsgConfigureUSRP* message = MsgConfigureUSRP::create(m_settings, true);
|
||||
MsgConfigureUSRP* message = MsgConfigureUSRP::create(m_settings, QList<QString>(), true);
|
||||
m_inputMessageQueue.push(message);
|
||||
|
||||
if (m_guiMessageQueue)
|
||||
{
|
||||
MsgConfigureUSRP* messageToGUI = MsgConfigureUSRP::create(m_settings, true);
|
||||
MsgConfigureUSRP* messageToGUI = MsgConfigureUSRP::create(m_settings, QList<QString>(), true);
|
||||
m_guiMessageQueue->push(messageToGUI);
|
||||
}
|
||||
|
||||
@ -504,12 +504,12 @@ void USRPInput::setCenterFrequency(qint64 centerFrequency)
|
||||
USRPInputSettings settings = m_settings;
|
||||
settings.m_centerFrequency = centerFrequency;
|
||||
|
||||
MsgConfigureUSRP* message = MsgConfigureUSRP::create(settings, false);
|
||||
MsgConfigureUSRP* message = MsgConfigureUSRP::create(settings, QList<QString>{"centerFrequency"}, false);
|
||||
m_inputMessageQueue.push(message);
|
||||
|
||||
if (m_guiMessageQueue)
|
||||
{
|
||||
MsgConfigureUSRP* messageToGUI = MsgConfigureUSRP::create(settings, false);
|
||||
MsgConfigureUSRP* messageToGUI = MsgConfigureUSRP::create(settings, QList<QString>{"centerFrequency"}, false);
|
||||
m_guiMessageQueue->push(messageToGUI);
|
||||
}
|
||||
}
|
||||
@ -601,7 +601,7 @@ bool USRPInput::handleMessage(const Message& message)
|
||||
MsgConfigureUSRP& conf = (MsgConfigureUSRP&) message;
|
||||
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");
|
||||
}
|
||||
@ -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 forwardChangeRxDSP = false;
|
||||
bool forwardChangeAllDSP = false;
|
||||
bool forwardClockSource = false;
|
||||
bool reapplySomeSettings = false;
|
||||
bool checkRates = false;
|
||||
QList<QString> reverseAPIKeys;
|
||||
|
||||
try
|
||||
{
|
||||
@ -729,10 +729,8 @@ bool USRPInput::applySettings(const USRPInputSettings& settings, bool preGetStre
|
||||
|
||||
// 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))
|
||||
{
|
||||
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;
|
||||
|
||||
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)
|
||||
|| (m_settings.m_loOffset != settings.m_loOffset)
|
||||
|| (m_settings.m_transverterMode != settings.m_transverterMode)
|
||||
|| (m_settings.m_transverterDeltaFrequency != settings.m_transverterDeltaFrequency)
|
||||
if (settingsKeys.contains("centerFrequency")
|
||||
|| settingsKeys.contains("loOffset")
|
||||
|| settingsKeys.contains("transverterMode")
|
||||
|| settingsKeys.contains("transverterDeltaFrequency")
|
||||
|| force)
|
||||
{
|
||||
reverseAPIKeys.append("centerFrequency");
|
||||
reverseAPIKeys.append("transverterMode");
|
||||
reverseAPIKeys.append("transverterDeltaFrequency");
|
||||
forwardChangeRxDSP = true;
|
||||
|
||||
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))
|
||||
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))
|
||||
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 (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))
|
||||
{
|
||||
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)
|
||||
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;
|
||||
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))
|
||||
{
|
||||
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) ||
|
||||
(m_settings.m_reverseAPIAddress != settings.m_reverseAPIAddress) ||
|
||||
(m_settings.m_reverseAPIPort != settings.m_reverseAPIPort) ||
|
||||
(m_settings.m_reverseAPIDeviceIndex != settings.m_reverseAPIDeviceIndex);
|
||||
webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
|
||||
bool fullUpdate = (settingsKeys.contains("useReverseAPI") && settings.m_useReverseAPI) ||
|
||||
settingsKeys.contains("reverseAPIAddress") ||
|
||||
settingsKeys.contains("reverseAPIPort") ||
|
||||
settingsKeys.contains("reverseAPIDeviceIndex");
|
||||
webapiReverseSendSettings(settingsKeys, settings, fullUpdate || force);
|
||||
}
|
||||
|
||||
if (reapplySomeSettings)
|
||||
@ -925,7 +908,11 @@ bool USRPInput::applySettings(const USRPInputSettings& settings, bool preGetStre
|
||||
}
|
||||
}
|
||||
|
||||
m_settings = settings;
|
||||
if (force) {
|
||||
m_settings = settings;
|
||||
} else {
|
||||
m_settings.applySettings(settingsKeys, settings);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
catch (std::exception &e)
|
||||
@ -1102,12 +1074,12 @@ int USRPInput::webapiSettingsPutPatch(
|
||||
USRPInputSettings settings = m_settings;
|
||||
webapiUpdateDeviceSettings(settings, deviceSettingsKeys, response);
|
||||
|
||||
MsgConfigureUSRP *msg = MsgConfigureUSRP::create(settings, force);
|
||||
MsgConfigureUSRP *msg = MsgConfigureUSRP::create(settings, deviceSettingsKeys, force);
|
||||
m_inputMessageQueue.push(msg);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -1258,7 +1230,7 @@ void USRPInput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response)
|
||||
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();
|
||||
swgDeviceSettings->setDirection(0); // single Rx
|
||||
|
@ -45,20 +45,22 @@ public:
|
||||
|
||||
public:
|
||||
const USRPInputSettings& getSettings() const { return m_settings; }
|
||||
const QList<QString>& getSettingsKeys() const { return m_settingsKeys; }
|
||||
bool getForce() const { return m_force; }
|
||||
|
||||
static MsgConfigureUSRP* create(const USRPInputSettings& settings, bool force)
|
||||
{
|
||||
return new MsgConfigureUSRP(settings, force);
|
||||
static MsgConfigureUSRP* create(const USRPInputSettings& settings, const QList<QString>& settingsKeys, bool force) {
|
||||
return new MsgConfigureUSRP(settings, settingsKeys, force);
|
||||
}
|
||||
|
||||
private:
|
||||
USRPInputSettings m_settings;
|
||||
QList<QString> m_settingsKeys;
|
||||
bool m_force;
|
||||
|
||||
MsgConfigureUSRP(const USRPInputSettings& settings, bool force) :
|
||||
MsgConfigureUSRP(const USRPInputSettings& settings, const QList<QString>& settingsKeys, bool force) :
|
||||
Message(),
|
||||
m_settings(settings),
|
||||
m_settingsKeys(settingsKeys),
|
||||
m_force(force)
|
||||
{ }
|
||||
};
|
||||
@ -239,9 +241,9 @@ private:
|
||||
void resumeRxBuddies();
|
||||
void suspendTxBuddies();
|
||||
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 webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const USRPInputSettings& settings, bool force);
|
||||
void webapiReverseSendSettings(const QList<QString>& deviceSettingsKeys, const USRPInputSettings& settings, bool force);
|
||||
void webapiReverseSendStartStop(bool start);
|
||||
|
||||
private slots:
|
||||
|
@ -119,6 +119,7 @@ void USRPInputGUI::resetToDefaults()
|
||||
{
|
||||
m_settings.resetToDefaults();
|
||||
displaySettings();
|
||||
m_forceSettings = true;
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
@ -131,6 +132,7 @@ void USRPInputGUI::setCenterFrequency(qint64 centerFrequency)
|
||||
{
|
||||
m_settings.m_centerFrequency = centerFrequency;
|
||||
displaySettings();
|
||||
m_settingsKeys.append("centerFrequency");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
@ -166,7 +168,13 @@ bool USRPInputGUI::handleMessage(const Message& message)
|
||||
if (USRPInput::MsgConfigureUSRP::match(message))
|
||||
{
|
||||
const USRPInput::MsgConfigureUSRP& cfg = (USRPInput::MsgConfigureUSRP&) message;
|
||||
m_settings = cfg.getSettings();
|
||||
|
||||
if (cfg.getForce()) {
|
||||
m_settings = cfg.getSettings();
|
||||
} else {
|
||||
m_settings.applySettings(cfg.getSettingsKeys(), cfg.getSettings());
|
||||
}
|
||||
|
||||
blockApplySettings(true);
|
||||
displaySettings();
|
||||
blockApplySettings(false);
|
||||
@ -290,7 +298,13 @@ void USRPInputGUI::handleInputMessages()
|
||||
else if (USRPInput::MsgConfigureUSRP::match(*message))
|
||||
{
|
||||
const USRPInput::MsgConfigureUSRP& cfg = (USRPInput::MsgConfigureUSRP&) *message;
|
||||
m_settings = cfg.getSettings();
|
||||
|
||||
if (cfg.getForce()) {
|
||||
m_settings = cfg.getSettings();
|
||||
} else {
|
||||
m_settings.applySettings(cfg.getSettingsKeys(), cfg.getSettings());
|
||||
}
|
||||
|
||||
displaySettings();
|
||||
|
||||
delete message;
|
||||
@ -393,12 +407,9 @@ void USRPInputGUI::displaySettings()
|
||||
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ui->gain->setEnabled(true);
|
||||
}
|
||||
}
|
||||
@ -423,8 +434,9 @@ void USRPInputGUI::setCenterFrequencySetting(uint64_t kHzValue)
|
||||
|
||||
void USRPInputGUI::sendSettings()
|
||||
{
|
||||
if(!m_updateTimer.isActive())
|
||||
if (!m_updateTimer.isActive()) {
|
||||
m_updateTimer.start(100);
|
||||
}
|
||||
}
|
||||
|
||||
void USRPInputGUI::updateHardware()
|
||||
@ -432,9 +444,10 @@ void USRPInputGUI::updateHardware()
|
||||
if (m_doApplySettings)
|
||||
{
|
||||
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_forceSettings = false;
|
||||
m_settingsKeys.clear();
|
||||
m_updateTimer.stop();
|
||||
}
|
||||
}
|
||||
@ -511,18 +524,21 @@ void USRPInputGUI::on_startStop_toggled(bool checked)
|
||||
void USRPInputGUI::on_centerFrequency_changed(quint64 value)
|
||||
{
|
||||
setCenterFrequencySetting(value);
|
||||
m_settingsKeys.append("centerFrequency");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void USRPInputGUI::on_dcOffset_toggled(bool checked)
|
||||
{
|
||||
m_settings.m_dcBlock = checked;
|
||||
m_settingsKeys.append("dcBlock");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void USRPInputGUI::on_iqImbalance_toggled(bool checked)
|
||||
{
|
||||
m_settings.m_iqCorrection = checked;
|
||||
m_settingsKeys.append("iqCorrection");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
@ -535,6 +551,7 @@ void USRPInputGUI::on_sampleRate_changed(quint64 value)
|
||||
}
|
||||
|
||||
updateSampleRate();
|
||||
m_settingsKeys.append("devSampleRate");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
@ -545,6 +562,7 @@ void USRPInputGUI::on_swDecim_currentIndexChanged(int index)
|
||||
}
|
||||
|
||||
m_settings.m_log2SoftDecim = index;
|
||||
m_settingsKeys.append("log2SoftDecim");
|
||||
displaySampleRate();
|
||||
|
||||
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_settingsKeys.append("devSampleRate");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void USRPInputGUI::on_lpf_changed(quint64 value)
|
||||
{
|
||||
m_settings.m_lpfBW = value * 1000;
|
||||
m_settingsKeys.append("lpfBW");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void USRPInputGUI::on_loOffset_changed(qint64 value)
|
||||
{
|
||||
m_settings.m_loOffset = value * 1000;
|
||||
m_settingsKeys.append("loOffset");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void USRPInputGUI::on_gainMode_currentIndexChanged(int index)
|
||||
{
|
||||
m_settings.m_gainMode = (USRPInputSettings::GainMode) index;
|
||||
m_settingsKeys.append("gainMode");
|
||||
|
||||
if (index == 0)
|
||||
{
|
||||
if (index == 0) {
|
||||
ui->gain->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ui->gain->setEnabled(true);
|
||||
}
|
||||
|
||||
@ -588,6 +607,7 @@ void USRPInputGUI::on_gain_valueChanged(int value)
|
||||
{
|
||||
m_settings.m_gain = value;
|
||||
ui->gainText->setText(tr("%1").arg(m_settings.m_gain));
|
||||
m_settingsKeys.append("gain");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
@ -595,6 +615,7 @@ void USRPInputGUI::on_antenna_currentIndexChanged(int index)
|
||||
{
|
||||
(void) index;
|
||||
m_settings.m_antennaPath = ui->antenna->currentText();
|
||||
m_settingsKeys.append("antennaPath");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
@ -602,6 +623,7 @@ void USRPInputGUI::on_clockSource_currentIndexChanged(int index)
|
||||
{
|
||||
(void) index;
|
||||
m_settings.m_clockSource = ui->clockSource->currentText();
|
||||
m_settingsKeys.append("clockSource");
|
||||
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");
|
||||
updateFrequencyLimits();
|
||||
setCenterFrequencySetting(ui->centerFrequency->getValueNew());
|
||||
m_settingsKeys.append("transverterMode");
|
||||
m_settingsKeys.append("transverterDeltaFrequency");
|
||||
m_settingsKeys.append("centerFrequency");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
@ -638,6 +663,10 @@ void USRPInputGUI::openDeviceSettingsDialog(const QPoint& p)
|
||||
m_settings.m_reverseAPIAddress = dialog.getReverseAPIAddress();
|
||||
m_settings.m_reverseAPIPort = dialog.getReverseAPIPort();
|
||||
m_settings.m_reverseAPIDeviceIndex = dialog.getReverseAPIDeviceIndex();
|
||||
m_settingsKeys.append("useReverseAPI");
|
||||
m_settingsKeys.append("reverseAPIAddress");
|
||||
m_settingsKeys.append("reverseAPIPort");
|
||||
m_settingsKeys.append("reverseAPIDeviceIndex");
|
||||
|
||||
sendSettings();
|
||||
}
|
||||
|
@ -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
|
||||
USRPInputSettings m_settings;
|
||||
QList<QString> m_settingsKeys;
|
||||
bool m_sampleRateMode; //!< true: device, false: base band sample rate update mode
|
||||
QTimer m_updateTimer;
|
||||
QTimer m_statusTimer;
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -59,6 +59,8 @@ struct USRPInputSettings
|
||||
void resetToDefaults();
|
||||
QByteArray serialize() const;
|
||||
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_ */
|
||||
|
Loading…
Reference in New Issue
Block a user