mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-22 08:04:49 -05:00
SDRPlay: Make settings assignments atomic. Part of #1329
This commit is contained in:
parent
b129349b02
commit
b3539c9292
@ -103,6 +103,7 @@ void SDRPlayGui::resetToDefaults()
|
||||
{
|
||||
m_settings.resetToDefaults();
|
||||
displaySettings();
|
||||
m_forceSettings = true;
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
@ -138,7 +139,13 @@ bool SDRPlayGui::handleMessage(const Message& message)
|
||||
if (SDRPlayInput::MsgConfigureSDRPlay::match(message))
|
||||
{
|
||||
const SDRPlayInput::MsgConfigureSDRPlay& cfg = (SDRPlayInput::MsgConfigureSDRPlay&) 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);
|
||||
@ -204,8 +211,7 @@ void SDRPlayGui::handleInputMessages()
|
||||
}
|
||||
else
|
||||
{
|
||||
if (handleMessage(*message))
|
||||
{
|
||||
if (handleMessage(*message)) {
|
||||
delete message;
|
||||
}
|
||||
}
|
||||
@ -274,16 +280,18 @@ void SDRPlayGui::displaySettings()
|
||||
|
||||
void SDRPlayGui::sendSettings()
|
||||
{
|
||||
if(!m_updateTimer.isActive())
|
||||
if (!m_updateTimer.isActive()) {
|
||||
m_updateTimer.start(100);
|
||||
}
|
||||
}
|
||||
|
||||
void SDRPlayGui::updateHardware()
|
||||
{
|
||||
qDebug() << "SDRPlayGui::updateHardware";
|
||||
SDRPlayInput::MsgConfigureSDRPlay* message = SDRPlayInput::MsgConfigureSDRPlay::create( m_settings, m_forceSettings);
|
||||
SDRPlayInput::MsgConfigureSDRPlay* message = SDRPlayInput::MsgConfigureSDRPlay::create( m_settings, m_settingsKeys, m_forceSettings);
|
||||
m_sampleSource->getInputMessageQueue()->push(message);
|
||||
m_forceSettings = false;
|
||||
m_settingsKeys.clear();
|
||||
m_updateTimer.stop();
|
||||
}
|
||||
|
||||
@ -319,6 +327,7 @@ void SDRPlayGui::updateStatus()
|
||||
void SDRPlayGui::on_centerFrequency_changed(quint64 value)
|
||||
{
|
||||
m_settings.m_centerFrequency = value * 1000;
|
||||
m_settingsKeys.append("centerFrequency");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
@ -326,6 +335,7 @@ void SDRPlayGui::on_ppm_valueChanged(int value)
|
||||
{
|
||||
m_settings.m_LOppmTenths = value;
|
||||
ui->ppmText->setText(QString("%1").arg(QString::number(m_settings.m_LOppmTenths/10.0, 'f', 1)));
|
||||
m_settingsKeys.append("LOppmTenths");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
@ -333,12 +343,14 @@ void SDRPlayGui::on_dcOffset_toggled(bool checked)
|
||||
{
|
||||
qDebug("SDRPlayGui::on_dcOffset_toggled: %s", checked ? "on" : "off");
|
||||
m_settings.m_dcBlock = checked;
|
||||
m_settingsKeys.append("dcBlock");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void SDRPlayGui::on_iqImbalance_toggled(bool checked)
|
||||
{
|
||||
m_settings.m_iqCorrection = checked;
|
||||
m_settingsKeys.append("iqCorrection");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
@ -352,6 +364,8 @@ void SDRPlayGui::on_fBand_currentIndexChanged(int index)
|
||||
ui->centerFrequency->setValue((SDRPlayBands::getBandLow(index)+SDRPlayBands::getBandHigh(index)) / 2);
|
||||
m_settings.m_centerFrequency = (SDRPlayBands::getBandLow(index)+SDRPlayBands::getBandHigh(index)) * 500;
|
||||
m_settings.m_frequencyBandIndex = index;
|
||||
m_settingsKeys.append("centerFrequency");
|
||||
m_settingsKeys.append("frequencyBandIndex");
|
||||
|
||||
sendSettings();
|
||||
}
|
||||
@ -359,30 +373,35 @@ void SDRPlayGui::on_fBand_currentIndexChanged(int index)
|
||||
void SDRPlayGui::on_bandwidth_currentIndexChanged(int index)
|
||||
{
|
||||
m_settings.m_bandwidthIndex = index;
|
||||
m_settingsKeys.append("bandwidthIndex");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void SDRPlayGui::on_samplerate_currentIndexChanged(int index)
|
||||
{
|
||||
m_settings.m_devSampleRateIndex = index;
|
||||
m_settingsKeys.append("devSampleRateIndex");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void SDRPlayGui::on_ifFrequency_currentIndexChanged(int index)
|
||||
{
|
||||
m_settings.m_ifFrequencyIndex = index;
|
||||
m_settingsKeys.append("ifFrequencyIndex");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void SDRPlayGui::on_decim_currentIndexChanged(int index)
|
||||
{
|
||||
m_settings.m_log2Decim = index;
|
||||
m_settingsKeys.append("log2Decim");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void SDRPlayGui::on_fcPos_currentIndexChanged(int index)
|
||||
{
|
||||
m_settings.m_fcPos = (SDRPlaySettings::fcPos_t) index;
|
||||
m_settingsKeys.append("fcPos");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
@ -390,6 +409,7 @@ void SDRPlayGui::on_gainTunerOn_toggled(bool checked)
|
||||
{
|
||||
qDebug("SDRPlayGui::on_gainTunerOn_toggled: %s", checked ? "on" : "off");
|
||||
m_settings.m_tunerGainMode = true;
|
||||
m_settingsKeys.append("tunerGainMode");
|
||||
ui->gainTuner->setEnabled(true);
|
||||
ui->gainLNA->setEnabled(false);
|
||||
ui->gainMixer->setEnabled(false);
|
||||
@ -402,7 +422,9 @@ void SDRPlayGui::on_gainTuner_valueChanged(int value)
|
||||
{
|
||||
int gain = value;
|
||||
QString gainText = QStringLiteral("%1").arg(gain, 3, 10, QLatin1Char('0'));
|
||||
ui->gainTunerText->setText(gainText);
|
||||
m_settings.m_tunerGain = gain;
|
||||
m_settingsKeys.append("tunerGain");
|
||||
|
||||
sendSettings();
|
||||
}
|
||||
@ -411,6 +433,7 @@ void SDRPlayGui::on_gainManualOn_toggled(bool checked)
|
||||
{
|
||||
qDebug("SDRPlayGui::on_gainManualOn_toggled: %s", checked ? "on" : "off");
|
||||
m_settings.m_tunerGainMode = false;
|
||||
m_settingsKeys.append("tunerGainMode");
|
||||
ui->gainTuner->setEnabled(false);
|
||||
ui->gainLNA->setEnabled(true);
|
||||
ui->gainMixer->setEnabled(true);
|
||||
@ -422,18 +445,21 @@ void SDRPlayGui::on_gainManualOn_toggled(bool checked)
|
||||
void SDRPlayGui::on_gainLNA_toggled(bool checked)
|
||||
{
|
||||
m_settings.m_lnaOn = checked ? 1 : 0;
|
||||
m_settingsKeys.append("lnaOn");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void SDRPlayGui::on_gainMixer_toggled(bool checked)
|
||||
{
|
||||
m_settings.m_mixerAmpOn = checked ? 1 : 0;
|
||||
m_settingsKeys.append("mixerAmpOn");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void SDRPlayGui::on_gainBaseband_valueChanged(int value)
|
||||
{
|
||||
m_settings.m_basebandGain = value;
|
||||
m_settingsKeys.append("basebandGain");
|
||||
|
||||
QString gainText = QStringLiteral("%1").arg(value, 2, 10, QLatin1Char('0'));
|
||||
ui->gainBasebandText->setText(gainText);
|
||||
@ -467,6 +493,10 @@ void SDRPlayGui::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();
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ private:
|
||||
bool m_doApplySettings;
|
||||
bool m_forceSettings;
|
||||
SDRPlaySettings m_settings;
|
||||
QList<QString> m_settingsKeys;
|
||||
QTimer m_updateTimer;
|
||||
QTimer m_statusTimer;
|
||||
DeviceSampleSource* m_sampleSource;
|
||||
|
@ -108,7 +108,7 @@ bool SDRPlayInput::openDevice()
|
||||
qCritical("SDRPlayInput::openDevice: could not open SDRPlay #%d: %s", m_devNumber, strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if ((res = mirisdr_set_hw_flavour(m_dev, MIRISDR_HW_SDRPLAY)) < 0)
|
||||
{
|
||||
qCritical("SDRPlayInput::openDevice: failed to set HW flavour: %s", strerror(errno));
|
||||
@ -199,7 +199,7 @@ bool SDRPlayInput::start()
|
||||
|
||||
// mutexLocker.unlock();
|
||||
|
||||
applySettings(m_settings, true, true);
|
||||
applySettings(m_settings, QList<QString>(), true, true);
|
||||
m_running = true;
|
||||
|
||||
return true;
|
||||
@ -218,7 +218,7 @@ void SDRPlayInput::closeDevice()
|
||||
|
||||
void SDRPlayInput::init()
|
||||
{
|
||||
applySettings(m_settings, true, true);
|
||||
applySettings(m_settings, QList<QString>(), true, true);
|
||||
}
|
||||
|
||||
void SDRPlayInput::stop()
|
||||
@ -250,12 +250,12 @@ bool SDRPlayInput::deserialize(const QByteArray& data)
|
||||
success = false;
|
||||
}
|
||||
|
||||
MsgConfigureSDRPlay* message = MsgConfigureSDRPlay::create(m_settings, true);
|
||||
MsgConfigureSDRPlay* message = MsgConfigureSDRPlay::create(m_settings, QList<QString>(), true);
|
||||
m_inputMessageQueue.push(message);
|
||||
|
||||
if (m_guiMessageQueue)
|
||||
{
|
||||
MsgConfigureSDRPlay* messageToGUI = MsgConfigureSDRPlay::create(m_settings, true);
|
||||
MsgConfigureSDRPlay* messageToGUI = MsgConfigureSDRPlay::create(m_settings, QList<QString>(), true);
|
||||
m_guiMessageQueue->push(messageToGUI);
|
||||
}
|
||||
|
||||
@ -283,12 +283,12 @@ void SDRPlayInput::setCenterFrequency(qint64 centerFrequency)
|
||||
SDRPlaySettings settings = m_settings;
|
||||
settings.m_centerFrequency = centerFrequency;
|
||||
|
||||
MsgConfigureSDRPlay* message = MsgConfigureSDRPlay::create(settings, false);
|
||||
MsgConfigureSDRPlay* message = MsgConfigureSDRPlay::create(settings, QList<QString>{"centerFrequency"}, false);
|
||||
m_inputMessageQueue.push(message);
|
||||
|
||||
if (m_guiMessageQueue)
|
||||
{
|
||||
MsgConfigureSDRPlay* messageToGUI = MsgConfigureSDRPlay::create(settings, false);
|
||||
MsgConfigureSDRPlay* messageToGUI = MsgConfigureSDRPlay::create(settings, QList<QString>{"centerFrequency"}, false);
|
||||
m_guiMessageQueue->push(messageToGUI);
|
||||
}
|
||||
}
|
||||
@ -299,21 +299,24 @@ bool SDRPlayInput::handleMessage(const Message& message)
|
||||
{
|
||||
MsgConfigureSDRPlay& conf = (MsgConfigureSDRPlay&) message;
|
||||
qDebug() << "SDRPlayInput::handleMessage: MsgConfigureSDRPlay";
|
||||
const SDRPlaySettings& settings = conf.getSettings();
|
||||
|
||||
// change of sample rate needs full stop / start sequence that includes the standard apply settings
|
||||
// only if in started state (iff m_dev != 0)
|
||||
if ((m_dev != 0) && (m_settings.m_devSampleRateIndex != settings.m_devSampleRateIndex))
|
||||
if ((m_dev != 0) && conf.getSettingsKeys().contains("devSampleRateIndex"))
|
||||
{
|
||||
m_settings = settings;
|
||||
if (conf.getForce()) {
|
||||
m_settings = conf.getSettings();
|
||||
} else {
|
||||
m_settings.applySettings(conf.getSettingsKeys(), conf.getSettings());
|
||||
}
|
||||
|
||||
stop();
|
||||
start();
|
||||
}
|
||||
// standard changes
|
||||
else
|
||||
{
|
||||
if (!applySettings(settings, false, conf.getForce()))
|
||||
{
|
||||
if (!applySettings(conf.getSettings(), conf.getSettingsKeys(), false, conf.getForce())) {
|
||||
qDebug("SDRPlayInput::handleMessage: config error");
|
||||
}
|
||||
}
|
||||
@ -327,8 +330,7 @@ bool SDRPlayInput::handleMessage(const Message& message)
|
||||
|
||||
if (cmd.getStartStop())
|
||||
{
|
||||
if (m_deviceAPI->initDeviceEngine())
|
||||
{
|
||||
if (m_deviceAPI->initDeviceEngine()) {
|
||||
m_deviceAPI->startDeviceEngine();
|
||||
}
|
||||
}
|
||||
@ -349,44 +351,34 @@ bool SDRPlayInput::handleMessage(const Message& message)
|
||||
}
|
||||
}
|
||||
|
||||
bool SDRPlayInput::applySettings(const SDRPlaySettings& settings, bool forwardChange, bool force)
|
||||
bool SDRPlayInput::applySettings(const SDRPlaySettings& settings, const QList<QString>& settingsKeys, bool forwardChange, bool force)
|
||||
{
|
||||
qDebug() << "SDRPlayInput::applySettings: forwardChange: " << forwardChange << " force: " << force << settings.getDebugString(settingsKeys, force);
|
||||
bool forceGainSetting = false;
|
||||
QList<QString> reverseAPIKeys;
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
|
||||
if ((m_settings.m_dcBlock != settings.m_dcBlock) || force)
|
||||
{
|
||||
reverseAPIKeys.append("dcBlock");
|
||||
m_deviceAPI->configureCorrections(settings.m_dcBlock, settings.m_iqCorrection);
|
||||
}
|
||||
|
||||
if ((m_settings.m_iqCorrection != settings.m_iqCorrection) || force)
|
||||
{
|
||||
reverseAPIKeys.append("iqCorrection");
|
||||
if (settingsKeys.contains("dcBlock") || settingsKeys.contains("iqCorrection") || force) {
|
||||
m_deviceAPI->configureCorrections(settings.m_dcBlock, settings.m_iqCorrection);
|
||||
}
|
||||
|
||||
// gains processing
|
||||
|
||||
if ((m_settings.m_tunerGainMode != settings.m_tunerGainMode) || force)
|
||||
{
|
||||
reverseAPIKeys.append("tunerGainMode");
|
||||
if (settingsKeys.contains("tunerGainMode") || force) {
|
||||
forceGainSetting = true;
|
||||
}
|
||||
|
||||
if ((m_settings.m_tunerGain != settings.m_tunerGain) || force) {
|
||||
reverseAPIKeys.append("tunerGain");
|
||||
}
|
||||
if ((m_settings.m_lnaOn != settings.m_lnaOn) || force) {
|
||||
reverseAPIKeys.append("lnaOn");
|
||||
}
|
||||
bool tunerGainMode = settingsKeys.contains("tunerGainMode") ?
|
||||
settings.m_tunerGainMode :
|
||||
m_settings.m_tunerGainMode;
|
||||
uint32_t frequencyBandIndex = settingsKeys.contains("frequencyBandIndex") ?
|
||||
settings.m_frequencyBandIndex :
|
||||
m_settings.m_frequencyBandIndex;
|
||||
|
||||
if (settings.m_tunerGainMode) // auto
|
||||
if (tunerGainMode) // auto
|
||||
{
|
||||
if ((m_settings.m_tunerGain != settings.m_tunerGain) || forceGainSetting)
|
||||
if (settingsKeys.contains("tunerGain") || forceGainSetting)
|
||||
{
|
||||
if(m_dev != 0)
|
||||
if (m_dev != 0)
|
||||
{
|
||||
int r = mirisdr_set_tuner_gain(m_dev, settings.m_tunerGain);
|
||||
|
||||
@ -398,12 +390,9 @@ bool SDRPlayInput::applySettings(const SDRPlaySettings& settings, bool forwardCh
|
||||
{
|
||||
int lnaGain;
|
||||
|
||||
if (settings.m_frequencyBandIndex < 3) // bands using AM mode
|
||||
{
|
||||
if (frequencyBandIndex < 3) { // bands using AM mode
|
||||
lnaGain = mirisdr_get_mixbuffer_gain(m_dev);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
lnaGain = mirisdr_get_lna_gain(m_dev);
|
||||
}
|
||||
|
||||
@ -425,11 +414,11 @@ bool SDRPlayInput::applySettings(const SDRPlaySettings& settings, bool forwardCh
|
||||
{
|
||||
bool anyChange = false;
|
||||
|
||||
if ((m_settings.m_lnaOn != settings.m_lnaOn) || forceGainSetting)
|
||||
if (settingsKeys.contains("lnaOn") || forceGainSetting)
|
||||
{
|
||||
if (m_dev != 0)
|
||||
{
|
||||
if (settings.m_frequencyBandIndex < 3) // bands using AM mode
|
||||
if (frequencyBandIndex < 3) // bands using AM mode
|
||||
{
|
||||
int r = mirisdr_set_mixbuffer_gain(m_dev, settings.m_lnaOn ? 0 : 1); // mirisdr_set_mixbuffer_gain takes gain reduction
|
||||
|
||||
@ -452,10 +441,8 @@ bool SDRPlayInput::applySettings(const SDRPlaySettings& settings, bool forwardCh
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_settings.m_mixerAmpOn != settings.m_mixerAmpOn) || forceGainSetting)
|
||||
if (settingsKeys.contains("mixerAmpOn") || forceGainSetting)
|
||||
{
|
||||
reverseAPIKeys.append("mixerAmpOn");
|
||||
|
||||
if (m_dev != 0)
|
||||
{
|
||||
int r = mirisdr_set_mixer_gain(m_dev, settings.m_mixerAmpOn ? 0 : 1); // mirisdr_set_lna_gain takes gain reduction
|
||||
@ -468,10 +455,8 @@ bool SDRPlayInput::applySettings(const SDRPlaySettings& settings, bool forwardCh
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_settings.m_basebandGain != settings.m_basebandGain) || forceGainSetting)
|
||||
if (settingsKeys.contains("basebandGain") || forceGainSetting)
|
||||
{
|
||||
reverseAPIKeys.append("basebandGain");
|
||||
|
||||
if (m_dev != 0)
|
||||
{
|
||||
int r = mirisdr_set_baseband_gain(m_dev, settings.m_basebandGain);
|
||||
@ -488,7 +473,7 @@ bool SDRPlayInput::applySettings(const SDRPlaySettings& settings, bool forwardCh
|
||||
{
|
||||
int lnaGain;
|
||||
|
||||
if (settings.m_frequencyBandIndex < 3) { // bands using AM mode
|
||||
if (frequencyBandIndex < 3) { // bands using AM mode
|
||||
lnaGain = mirisdr_get_mixbuffer_gain(m_dev);
|
||||
} else {
|
||||
lnaGain = mirisdr_get_lna_gain(m_dev);
|
||||
@ -507,10 +492,8 @@ bool SDRPlayInput::applySettings(const SDRPlaySettings& settings, bool forwardCh
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_settings.m_log2Decim != settings.m_log2Decim) || force)
|
||||
if (settingsKeys.contains("log2Decim") || force)
|
||||
{
|
||||
reverseAPIKeys.append("log2Decim");
|
||||
|
||||
if (m_sdrPlayThread)
|
||||
{
|
||||
m_sdrPlayThread->setLog2Decimation(settings.m_log2Decim);
|
||||
@ -518,10 +501,8 @@ bool SDRPlayInput::applySettings(const SDRPlaySettings& settings, bool forwardCh
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_settings.m_fcPos != settings.m_fcPos) || force)
|
||||
if (settingsKeys.contains("fcPos") || force)
|
||||
{
|
||||
reverseAPIKeys.append("fcPos");
|
||||
|
||||
if (m_sdrPlayThread)
|
||||
{
|
||||
m_sdrPlayThread->setFcPos((int) settings.m_fcPos);
|
||||
@ -529,10 +510,8 @@ bool SDRPlayInput::applySettings(const SDRPlaySettings& settings, bool forwardCh
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_settings.m_iqOrder != settings.m_iqOrder) || force)
|
||||
if (settingsKeys.contains("iqOrder") || force)
|
||||
{
|
||||
reverseAPIKeys.append("iqOrder");
|
||||
|
||||
if (m_sdrPlayThread)
|
||||
{
|
||||
m_sdrPlayThread->setIQOrder((int) settings.m_iqOrder);
|
||||
@ -540,17 +519,10 @@ bool SDRPlayInput::applySettings(const SDRPlaySettings& settings, bool forwardCh
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_settings.m_centerFrequency != settings.m_centerFrequency) || force) {
|
||||
reverseAPIKeys.append("centerFrequency");
|
||||
}
|
||||
if ((m_settings.m_LOppmTenths != settings.m_LOppmTenths) || force) {
|
||||
reverseAPIKeys.append("LOppmTenths");
|
||||
}
|
||||
|
||||
if ((m_settings.m_centerFrequency != settings.m_centerFrequency)
|
||||
|| (m_settings.m_LOppmTenths != settings.m_LOppmTenths)
|
||||
|| (m_settings.m_fcPos != settings.m_fcPos)
|
||||
|| (m_settings.m_log2Decim != settings.m_log2Decim) || force)
|
||||
if (settingsKeys.contains("centerFrequency")
|
||||
|| settingsKeys.contains("LOppmTenths")
|
||||
|| settingsKeys.contains("fcPos")
|
||||
|| settingsKeys.contains("log2Decim") || force)
|
||||
{
|
||||
qint64 deviceCenterFrequency = DeviceSampleSource::calculateDeviceCenterFrequency(
|
||||
settings.m_centerFrequency,
|
||||
@ -571,9 +543,8 @@ bool SDRPlayInput::applySettings(const SDRPlaySettings& settings, bool forwardCh
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_settings.m_bandwidthIndex != settings.m_bandwidthIndex) || force)
|
||||
if (settingsKeys.contains("bandwidthIndex") || force)
|
||||
{
|
||||
reverseAPIKeys.append("bandwidthIndex");
|
||||
int bandwidth = SDRPlayBandwidths::getBandwidth(settings.m_bandwidthIndex);
|
||||
int r = mirisdr_set_bandwidth(m_dev, bandwidth);
|
||||
|
||||
@ -584,9 +555,8 @@ bool SDRPlayInput::applySettings(const SDRPlaySettings& settings, bool forwardCh
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_settings.m_ifFrequencyIndex != settings.m_ifFrequencyIndex) || force)
|
||||
if (settingsKeys.contains("ifFrequencyIndex") || force)
|
||||
{
|
||||
reverseAPIKeys.append("ifFrequencyIndex");
|
||||
int iFFrequency = SDRPlayIF::getIF(settings.m_ifFrequencyIndex);
|
||||
int r = mirisdr_set_if_freq(m_dev, iFFrequency);
|
||||
|
||||
@ -597,16 +567,20 @@ bool SDRPlayInput::applySettings(const SDRPlaySettings& settings, bool forwardCh
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
m_settings = settings;
|
||||
if (force) {
|
||||
m_settings = settings;
|
||||
} else {
|
||||
m_settings.applySettings(settingsKeys, settings);
|
||||
}
|
||||
|
||||
if (forwardChange)
|
||||
{
|
||||
@ -686,12 +660,12 @@ int SDRPlayInput::webapiSettingsPutPatch(
|
||||
SDRPlaySettings settings = m_settings;
|
||||
webapiUpdateDeviceSettings(settings, deviceSettingsKeys, response);
|
||||
|
||||
MsgConfigureSDRPlay *msg = MsgConfigureSDRPlay::create(settings, force);
|
||||
MsgConfigureSDRPlay *msg = MsgConfigureSDRPlay::create(settings, deviceSettingsKeys, force);
|
||||
m_inputMessageQueue.push(msg);
|
||||
|
||||
if (m_guiMessageQueue) // forward to GUI if any
|
||||
{
|
||||
MsgConfigureSDRPlay *msgToGUI = MsgConfigureSDRPlay::create(settings, force);
|
||||
MsgConfigureSDRPlay *msgToGUI = MsgConfigureSDRPlay::create(settings, deviceSettingsKeys, force);
|
||||
m_guiMessageQueue->push(msgToGUI);
|
||||
}
|
||||
|
||||
@ -848,7 +822,7 @@ void SDRPlayInput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& respon
|
||||
}
|
||||
}
|
||||
|
||||
void SDRPlayInput::webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const SDRPlaySettings& settings, bool force)
|
||||
void SDRPlayInput::webapiReverseSendSettings(const QList<QString>& deviceSettingsKeys, const SDRPlaySettings& settings, bool force)
|
||||
{
|
||||
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
|
||||
swgDeviceSettings->setDirection(0); // single Rx
|
||||
|
@ -49,20 +49,22 @@ public:
|
||||
|
||||
public:
|
||||
const SDRPlaySettings& getSettings() const { return m_settings; }
|
||||
const QList<QString>& getSettingsKeys() const { return m_settingsKeys; }
|
||||
bool getForce() const { return m_force; }
|
||||
|
||||
static MsgConfigureSDRPlay* create(const SDRPlaySettings& settings, bool force)
|
||||
{
|
||||
return new MsgConfigureSDRPlay(settings, force);
|
||||
static MsgConfigureSDRPlay* create(const SDRPlaySettings& settings, const QList<QString>& settingsKeys, bool force) {
|
||||
return new MsgConfigureSDRPlay(settings, settingsKeys, force);
|
||||
}
|
||||
|
||||
private:
|
||||
SDRPlaySettings m_settings;
|
||||
QList<QString> m_settingsKeys;
|
||||
bool m_force;
|
||||
|
||||
MsgConfigureSDRPlay(const SDRPlaySettings& settings, bool force) :
|
||||
MsgConfigureSDRPlay(const SDRPlaySettings& settings, const QList<QString>& settingsKeys, bool force) :
|
||||
Message(),
|
||||
m_settings(settings),
|
||||
m_settingsKeys(settingsKeys),
|
||||
m_force(force)
|
||||
{ }
|
||||
};
|
||||
@ -184,10 +186,10 @@ private:
|
||||
|
||||
bool openDevice();
|
||||
void closeDevice();
|
||||
bool applySettings(const SDRPlaySettings& settings, bool forwardChange, bool force);
|
||||
bool applySettings(const SDRPlaySettings& settings, const QList<QString>& settingsKeys, bool forwardChange, bool force);
|
||||
bool setDeviceCenterFrequency(quint64 freq);
|
||||
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response);
|
||||
void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const SDRPlaySettings& settings, bool force);
|
||||
void webapiReverseSendSettings(const QList<QString>& deviceSettingsKeys, const SDRPlaySettings& settings, bool force);
|
||||
void webapiReverseSendStartStop(bool start);
|
||||
|
||||
private slots:
|
||||
|
@ -128,3 +128,132 @@ bool SDRPlaySettings::deserialize(const QByteArray& data)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void SDRPlaySettings::applySettings(const QStringList& settingsKeys, const SDRPlaySettings& settings)
|
||||
{
|
||||
if (settingsKeys.contains("centerFrequency")) {
|
||||
m_centerFrequency = settings.m_centerFrequency;
|
||||
}
|
||||
if (settingsKeys.contains("tunerGain")) {
|
||||
m_tunerGain = settings.m_tunerGain;
|
||||
}
|
||||
if (settingsKeys.contains("LOppmTenths")) {
|
||||
m_LOppmTenths = settings.m_LOppmTenths;
|
||||
}
|
||||
if (settingsKeys.contains("ifFrequencyIndex")) {
|
||||
m_ifFrequencyIndex = settings.m_ifFrequencyIndex;
|
||||
}
|
||||
if (settingsKeys.contains("bandwidthIndex")) {
|
||||
m_bandwidthIndex = settings.m_bandwidthIndex;
|
||||
}
|
||||
if (settingsKeys.contains("devSampleRateIndex")) {
|
||||
m_devSampleRateIndex = settings.m_devSampleRateIndex;
|
||||
}
|
||||
if (settingsKeys.contains("log2Decim")) {
|
||||
m_log2Decim = settings.m_log2Decim;
|
||||
}
|
||||
if (settingsKeys.contains("fcPos")) {
|
||||
m_fcPos = settings.m_fcPos;
|
||||
}
|
||||
if (settingsKeys.contains("dcBlock")) {
|
||||
m_dcBlock = settings.m_dcBlock;
|
||||
}
|
||||
if (settingsKeys.contains("iqCorrection")) {
|
||||
m_iqCorrection = settings.m_iqCorrection;
|
||||
}
|
||||
if (settingsKeys.contains("tunerGainMode")) {
|
||||
m_tunerGainMode = settings.m_tunerGainMode;
|
||||
}
|
||||
if (settingsKeys.contains("lnaOn")) {
|
||||
m_lnaOn = settings.m_lnaOn;
|
||||
}
|
||||
if (settingsKeys.contains("mixerAmpOn")) {
|
||||
m_mixerAmpOn = settings.m_mixerAmpOn;
|
||||
}
|
||||
if (settingsKeys.contains("basebandGain")) {
|
||||
m_basebandGain = settings.m_basebandGain;
|
||||
}
|
||||
if (settingsKeys.contains("iqOrder")) {
|
||||
m_iqOrder = settings.m_iqOrder;
|
||||
}
|
||||
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 SDRPlaySettings::getDebugString(const QStringList& settingsKeys, bool force) const
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
|
||||
if (settingsKeys.contains("centerFrequency") || force) {
|
||||
ostr << " m_centerFrequency: " << m_centerFrequency;
|
||||
}
|
||||
if (settingsKeys.contains("tunerGain") || force) {
|
||||
ostr << " m_tunerGain: " << m_tunerGain;
|
||||
}
|
||||
if (settingsKeys.contains("LOppmTenths") || force) {
|
||||
ostr << " m_LOppmTenths: " << m_LOppmTenths;
|
||||
}
|
||||
if (settingsKeys.contains("frequencyBandIndex") || force) {
|
||||
ostr << " m_frequencyBandIndex: " << m_frequencyBandIndex;
|
||||
}
|
||||
if (settingsKeys.contains("ifFrequencyIndex") || force) {
|
||||
ostr << " m_ifFrequencyIndex: " << m_ifFrequencyIndex;
|
||||
}
|
||||
if (settingsKeys.contains("bandwidthIndex") || force) {
|
||||
ostr << " m_bandwidthIndex: " << m_bandwidthIndex;
|
||||
}
|
||||
if (settingsKeys.contains("devSampleRateIndex") || force) {
|
||||
ostr << " m_devSampleRateIndex: " << m_devSampleRateIndex;
|
||||
}
|
||||
if (settingsKeys.contains("log2Decim") || force) {
|
||||
ostr << " m_log2Decim: " << m_log2Decim;
|
||||
}
|
||||
if (settingsKeys.contains("fcPos") || force) {
|
||||
ostr << " m_fcPos: " << m_fcPos;
|
||||
}
|
||||
if (settingsKeys.contains("dcBlock") || force) {
|
||||
ostr << " m_dcBlock: " << m_dcBlock;
|
||||
}
|
||||
if (settingsKeys.contains("iqCorrection") || force) {
|
||||
ostr << " m_iqCorrection: " << m_iqCorrection;
|
||||
}
|
||||
if (settingsKeys.contains("tunerGainMode") || force) {
|
||||
ostr << " m_tunerGainMode: " << m_tunerGainMode;
|
||||
}
|
||||
if (settingsKeys.contains("lnaOn") || force) {
|
||||
ostr << " m_lnaOn: " << m_lnaOn;
|
||||
}
|
||||
if (settingsKeys.contains("mixerAmpOn") || force) {
|
||||
ostr << " m_mixerAmpOn: " << m_mixerAmpOn;
|
||||
}
|
||||
if (settingsKeys.contains("basebandGain") || force) {
|
||||
ostr << " m_basebandGain: " << m_basebandGain;
|
||||
}
|
||||
if (settingsKeys.contains("iqOrder") || force) {
|
||||
ostr << " m_iqOrder: " << m_iqOrder;
|
||||
}
|
||||
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());
|
||||
}
|
||||
|
@ -55,26 +55,8 @@ struct SDRPlaySettings {
|
||||
void resetToDefaults();
|
||||
QByteArray serialize() const;
|
||||
bool deserialize(const QByteArray& data);
|
||||
|
||||
void debug(const char *title) const
|
||||
{
|
||||
qDebug() << QString(title)
|
||||
<< ": m_centerFrequency: " << m_centerFrequency
|
||||
<< " m_tunerGain: " << m_tunerGain
|
||||
<< " m_LOppmTenths: " << m_LOppmTenths
|
||||
<< " m_frequencyBandIndex: " << m_frequencyBandIndex
|
||||
<< " m_ifFrequencyIndex: " << m_ifFrequencyIndex
|
||||
<< " m_bandwidthIndex: " << m_bandwidthIndex
|
||||
<< " m_devSampleRateIndex: " << m_devSampleRateIndex
|
||||
<< " m_log2Decim: " << m_log2Decim
|
||||
<< " m_fcPos: " << m_fcPos
|
||||
<< " m_dcBlock: " << m_dcBlock
|
||||
<< " m_iqCorrection: " << m_iqCorrection
|
||||
<< " m_tunerGainMode: " << m_tunerGainMode
|
||||
<< " m_lnaOn: " << m_lnaOn
|
||||
<< " m_mixerAmpOn: " << m_mixerAmpOn
|
||||
<< " m_basebandGain: " << m_basebandGain;
|
||||
}
|
||||
void applySettings(const QStringList& settingsKeys, const SDRPlaySettings& settings);
|
||||
QString getDebugString(const QStringList& settingsKeys, bool force=false) const;
|
||||
};
|
||||
|
||||
#endif /* _SDRPLAY_SDRPLAYSETTINGS_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user