1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 16:08:39 -05:00

PlutoSDR output: Make settings assignments atomic. Part of #1329

This commit is contained in:
f4exb 2022-10-31 10:56:05 +01:00
parent 3449293b6a
commit 79b174bf36
7 changed files with 212 additions and 108 deletions

View File

@ -94,7 +94,7 @@ void PlutoSDROutput::destroy()
void PlutoSDROutput::init() void PlutoSDROutput::init()
{ {
applySettings(m_settings, true); applySettings(m_settings, QList<QString>(), true);
} }
bool PlutoSDROutput::start() bool PlutoSDROutput::start()
@ -114,7 +114,7 @@ bool PlutoSDROutput::start()
m_plutoSDROutputThread = new PlutoSDROutputThread(PLUTOSDR_BLOCKSIZE_SAMPLES, m_deviceShared.m_deviceParams->getBox(), &m_sampleSourceFifo); m_plutoSDROutputThread = new PlutoSDROutputThread(PLUTOSDR_BLOCKSIZE_SAMPLES, m_deviceShared.m_deviceParams->getBox(), &m_sampleSourceFifo);
qDebug("PlutoSDROutput::start: thread created"); qDebug("PlutoSDROutput::start: thread created");
applySettings(m_settings, true); applySettings(m_settings, QList<QString>(), true);
m_plutoSDROutputThread->setLog2Interpolation(m_settings.m_log2Interp); m_plutoSDROutputThread->setLog2Interpolation(m_settings.m_log2Interp);
m_plutoSDROutputThread->startWork(); m_plutoSDROutputThread->startWork();
@ -153,12 +153,12 @@ bool PlutoSDROutput::deserialize(const QByteArray& data)
success = false; success = false;
} }
MsgConfigurePlutoSDR* message = MsgConfigurePlutoSDR::create(m_settings, true); MsgConfigurePlutoSDR* message = MsgConfigurePlutoSDR::create(m_settings, QList<QString>(), true);
m_inputMessageQueue.push(message); m_inputMessageQueue.push(message);
if (m_guiMessageQueue) if (m_guiMessageQueue)
{ {
MsgConfigurePlutoSDR* messageToGUI = MsgConfigurePlutoSDR::create(m_settings, true); MsgConfigurePlutoSDR* messageToGUI = MsgConfigurePlutoSDR::create(m_settings, QList<QString>(), true);
m_guiMessageQueue->push(messageToGUI); m_guiMessageQueue->push(messageToGUI);
} }
@ -184,12 +184,12 @@ void PlutoSDROutput::setCenterFrequency(qint64 centerFrequency)
PlutoSDROutputSettings settings = m_settings; PlutoSDROutputSettings settings = m_settings;
settings.m_centerFrequency = centerFrequency; settings.m_centerFrequency = centerFrequency;
MsgConfigurePlutoSDR* message = MsgConfigurePlutoSDR::create(settings, false); MsgConfigurePlutoSDR* message = MsgConfigurePlutoSDR::create(settings, QList<QString>{"centerFrequency"}, false);
m_inputMessageQueue.push(message); m_inputMessageQueue.push(message);
if (m_guiMessageQueue) if (m_guiMessageQueue)
{ {
MsgConfigurePlutoSDR* messageToGUI = MsgConfigurePlutoSDR::create(settings, false); MsgConfigurePlutoSDR* messageToGUI = MsgConfigurePlutoSDR::create(settings, QList<QString>{"centerFrequency"}, false);
m_guiMessageQueue->push(messageToGUI); m_guiMessageQueue->push(messageToGUI);
} }
} }
@ -201,8 +201,7 @@ bool PlutoSDROutput::handleMessage(const Message& message)
MsgConfigurePlutoSDR& conf = (MsgConfigurePlutoSDR&) message; MsgConfigurePlutoSDR& conf = (MsgConfigurePlutoSDR&) message;
qDebug() << "PlutoSDROutput::handleMessage: MsgConfigurePlutoSDR"; qDebug() << "PlutoSDROutput::handleMessage: MsgConfigurePlutoSDR";
if (!applySettings(conf.getSettings(), conf.getForce())) if (!applySettings(conf.getSettings(), conf.getSettingsKeys(), conf.getForce())) {
{
qDebug("PlutoSDROutput::handleMessage config error"); qDebug("PlutoSDROutput::handleMessage config error");
} }
@ -217,7 +216,8 @@ bool PlutoSDROutput::handleMessage(const Message& message)
m_settings.m_LOppmTenths = conf.getLoPPMTenths(); m_settings.m_LOppmTenths = conf.getLoPPMTenths();
PlutoSDROutputSettings newSettings = m_settings; PlutoSDROutputSettings newSettings = m_settings;
newSettings.m_lpfFIREnable = conf.isLpfFirEnable(); newSettings.m_lpfFIREnable = conf.isLpfFirEnable();
applySettings(newSettings);
applySettings(newSettings, QList<QString>{"lpfFIREnable"});
return true; return true;
} }
@ -228,8 +228,7 @@ bool PlutoSDROutput::handleMessage(const Message& message)
if (cmd.getStartStop()) if (cmd.getStartStop())
{ {
if (m_deviceAPI->initDeviceEngine()) if (m_deviceAPI->initDeviceEngine()) {
{
m_deviceAPI->startDeviceEngine(); m_deviceAPI->startDeviceEngine();
} }
} }
@ -379,7 +378,7 @@ void PlutoSDROutput::resumeBuddies()
} }
} }
bool PlutoSDROutput::applySettings(const PlutoSDROutputSettings& settings, bool force) bool PlutoSDROutput::applySettings(const PlutoSDROutputSettings& settings, const QList<QString>& settingsKeys, bool force)
{ {
if (!m_open) if (!m_open)
{ {
@ -387,47 +386,14 @@ bool PlutoSDROutput::applySettings(const PlutoSDROutputSettings& settings, bool
return false; return false;
} }
qDebug().noquote() << "PlutoSDROutput::applySettings: force:" << force << settings.getDebugString(settingsKeys, force);
bool forwardChangeOwnDSP = false; bool forwardChangeOwnDSP = false;
bool forwardChangeOtherDSP = false; bool forwardChangeOtherDSP = false;
bool ownThreadWasRunning = false; bool ownThreadWasRunning = false;
bool suspendAllOtherThreads = false; // All others means Rx in fact bool suspendAllOtherThreads = false; // All others means Rx in fact
DevicePlutoSDRBox *plutoBox = m_deviceShared.m_deviceParams->getBox(); DevicePlutoSDRBox *plutoBox = m_deviceShared.m_deviceParams->getBox();
QLocale loc; QLocale loc;
QList<QString> reverseAPIKeys;
qDebug().noquote() << "PlutoSDROutput::applySettings: center freq: " << m_settings.m_centerFrequency << " Hz"
<< " m_devSampleRate: " << loc.toString(m_settings.m_devSampleRate) << "S/s"
<< " m_LOppmTenths: " << m_settings.m_LOppmTenths
<< " m_lpfFIREnable: " << m_settings.m_lpfFIREnable
<< " m_lpfFIRBW: " << loc.toString(m_settings.m_lpfFIRBW)
<< " m_lpfFIRlog2Interp: " << m_settings.m_lpfFIRlog2Interp
<< " m_lpfFIRGain: " << m_settings.m_lpfFIRGain
<< " m_log2Interp: " << loc.toString(1<<m_settings.m_log2Interp)
<< " m_lpfBW: " << loc.toString(m_settings.m_lpfBW)
<< " m_att: " << m_settings.m_att
<< " m_antennaPath: " << (int) m_settings.m_antennaPath
<< " m_transverterMode: " << m_settings.m_transverterMode
<< " m_transverterDeltaFrequency: " << m_settings.m_transverterDeltaFrequency
<< " force: " << force;
if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || force) {
reverseAPIKeys.append("devSampleRate");
}
if ((m_settings.m_lpfFIREnable != settings.m_lpfFIREnable) || force) {
reverseAPIKeys.append("lpfFIREnable");
}
if ((m_settings.m_lpfFIRlog2Interp != settings.m_lpfFIRlog2Interp) || force) {
reverseAPIKeys.append("lpfFIRlog2Interp");
}
if ((m_settings.m_lpfFIRBW != settings.m_lpfFIRBW) || force) {
reverseAPIKeys.append("lpfFIRBW");
}
if ((m_settings.m_lpfFIRGain != settings.m_lpfFIRGain) || force) {
reverseAPIKeys.append("lpfFIRGain");
}
if ((m_settings.m_LOppmTenths != settings.m_LOppmTenths) || force) {
reverseAPIKeys.append("LOppmTenths");
}
// determine if buddies threads or own thread need to be suspended // determine if buddies threads or own thread need to be suspended
@ -436,12 +402,12 @@ bool PlutoSDROutput::applySettings(const PlutoSDROutputSettings& settings, bool
// - FIR filter is enabled or disabled // - FIR filter is enabled or disabled
// - FIR filter is changed // - FIR filter is changed
// - LO correction is changed // - LO correction is changed
if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || if (settingsKeys.contains("devSampleRate") ||
(m_settings.m_lpfFIREnable != settings.m_lpfFIREnable) || settingsKeys.contains("lpfFIREnable") ||
(m_settings.m_lpfFIRlog2Interp != settings.m_lpfFIRlog2Interp) || settingsKeys.contains("lpfFIRlog2Interp") ||
(settings.m_lpfFIRBW != m_settings.m_lpfFIRBW) || settingsKeys.contains("lpfFIRBW") ||
(settings.m_lpfFIRGain != m_settings.m_lpfFIRGain) || settingsKeys.contains("lpfFIRGain") ||
(m_settings.m_LOppmTenths != settings.m_LOppmTenths) || force) settingsKeys.contains("LOppmTenths") || force)
{ {
suspendAllOtherThreads = true; suspendAllOtherThreads = true;
} }
@ -475,11 +441,11 @@ bool PlutoSDROutput::applySettings(const PlutoSDROutputSettings& settings, bool
// apply settings // apply settings
// Change affecting device sample rate chain and other buddies // Change affecting device sample rate chain and other buddies
if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || if (settingsKeys.contains("devSampleRate") ||
(m_settings.m_lpfFIREnable != settings.m_lpfFIREnable) || settingsKeys.contains("lpfFIREnable") ||
(m_settings.m_lpfFIRlog2Interp != settings.m_lpfFIRlog2Interp) || settingsKeys.contains("lpfFIRlog2Interp") ||
(settings.m_lpfFIRBW != m_settings.m_lpfFIRBW) || settingsKeys.contains("lpfFIRBW") ||
(settings.m_lpfFIRGain != m_settings.m_lpfFIRGain) || force) settingsKeys.contains("lpfFIRGain") || force)
{ {
plutoBox->setFIR(settings.m_devSampleRate, settings.m_lpfFIRlog2Interp, DevicePlutoSDRBox::USE_TX, settings.m_lpfFIRBW, settings.m_lpfFIRGain); plutoBox->setFIR(settings.m_devSampleRate, settings.m_lpfFIRlog2Interp, DevicePlutoSDRBox::USE_TX, settings.m_lpfFIRBW, settings.m_lpfFIRGain);
plutoBox->setFIREnable(settings.m_lpfFIREnable); // eventually enable/disable FIR plutoBox->setFIREnable(settings.m_lpfFIREnable); // eventually enable/disable FIR
@ -497,7 +463,8 @@ bool PlutoSDROutput::applySettings(const PlutoSDROutputSettings& settings, bool
forwardChangeOwnDSP = (m_settings.m_devSampleRate != settings.m_devSampleRate) || force; forwardChangeOwnDSP = (m_settings.m_devSampleRate != settings.m_devSampleRate) || force;
} }
if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || (m_settings.m_log2Interp != settings.m_log2Interp) || force) if (settingsKeys.contains("devSampleRate") ||
settingsKeys.contains("log2Interp") || force)
{ {
unsigned int fifoRate = std::max( unsigned int fifoRate = std::max(
(unsigned int) settings.m_devSampleRate / (1<<settings.m_log2Interp), (unsigned int) settings.m_devSampleRate / (1<<settings.m_log2Interp),
@ -505,10 +472,8 @@ bool PlutoSDROutput::applySettings(const PlutoSDROutputSettings& settings, bool
m_sampleSourceFifo.resize(SampleSourceFifo::getSizePolicy(fifoRate)); m_sampleSourceFifo.resize(SampleSourceFifo::getSizePolicy(fifoRate));
} }
if ((m_settings.m_log2Interp != settings.m_log2Interp) || force) if (settingsKeys.contains("log2Interp") || force)
{ {
reverseAPIKeys.append("log2Interp");
if (m_plutoSDROutputThread != 0) if (m_plutoSDROutputThread != 0)
{ {
m_plutoSDROutputThread->setLog2Interpolation(settings.m_log2Interp); m_plutoSDROutputThread->setLog2Interpolation(settings.m_log2Interp);
@ -518,7 +483,7 @@ bool PlutoSDROutput::applySettings(const PlutoSDROutputSettings& settings, bool
forwardChangeOwnDSP = true; forwardChangeOwnDSP = true;
} }
if ((m_settings.m_LOppmTenths != settings.m_LOppmTenths) || force) if (settingsKeys.contains("LOppmTenths") || force)
{ {
plutoBox->setLOPPMTenths(settings.m_LOppmTenths); plutoBox->setLOPPMTenths(settings.m_LOppmTenths);
forwardChangeOtherDSP = true; forwardChangeOtherDSP = true;
@ -527,20 +492,9 @@ bool PlutoSDROutput::applySettings(const PlutoSDROutputSettings& settings, bool
std::vector<std::string> params; std::vector<std::string> params;
bool paramsToSet = false; bool paramsToSet = false;
if ((m_settings.m_centerFrequency != settings.m_centerFrequency) || force) { if (force || settingsKeys.contains("centerFrequency")
reverseAPIKeys.append("centerFrequency"); || settingsKeys.contains("transverterMode")
} || settingsKeys.contains("transverterDeltaFrequency"))
if ((m_settings.m_transverterMode != settings.m_transverterMode) || force) {
reverseAPIKeys.append("transverterMode");
}
if ((m_settings.m_transverterDeltaFrequency != settings.m_transverterDeltaFrequency) || force) {
reverseAPIKeys.append("transverterDeltaFrequency");
}
if (force || (m_settings.m_centerFrequency != settings.m_centerFrequency)
|| (m_settings.m_transverterMode != settings.m_transverterMode)
|| (m_settings.m_transverterDeltaFrequency != settings.m_transverterDeltaFrequency))
{ {
qint64 deviceCenterFrequency = settings.m_centerFrequency; qint64 deviceCenterFrequency = settings.m_centerFrequency;
deviceCenterFrequency -= settings.m_transverterMode ? settings.m_transverterDeltaFrequency : 0; deviceCenterFrequency -= settings.m_transverterMode ? settings.m_transverterDeltaFrequency : 0;
@ -556,45 +510,45 @@ bool PlutoSDROutput::applySettings(const PlutoSDROutputSettings& settings, bool
} }
if ((m_settings.m_lpfBW != settings.m_lpfBW) || force) if (settingsKeys.contains("lpfBW") || force)
{ {
reverseAPIKeys.append("lpfBW");
params.push_back(QString(tr("out_voltage_rf_bandwidth=%1").arg(settings.m_lpfBW)).toStdString()); params.push_back(QString(tr("out_voltage_rf_bandwidth=%1").arg(settings.m_lpfBW)).toStdString());
paramsToSet = true; paramsToSet = true;
} }
if ((m_settings.m_antennaPath != settings.m_antennaPath) || force) if (settingsKeys.contains("antennaPath") || force)
{ {
reverseAPIKeys.append("antennaPath");
QString rfPortStr; QString rfPortStr;
PlutoSDROutputSettings::translateRFPath(settings.m_antennaPath, rfPortStr); PlutoSDROutputSettings::translateRFPath(settings.m_antennaPath, rfPortStr);
params.push_back(QString(tr("out_voltage0_rf_port_select=%1").arg(rfPortStr)).toStdString()); params.push_back(QString(tr("out_voltage0_rf_port_select=%1").arg(rfPortStr)).toStdString());
paramsToSet = true; paramsToSet = true;
} }
if ((m_settings.m_att != settings.m_att) || force) if (settingsKeys.contains("att") || force)
{ {
reverseAPIKeys.append("att");
float attF = settings.m_att * 0.25f; float attF = settings.m_att * 0.25f;
params.push_back(QString(tr("out_voltage0_hardwaregain=%1").arg(attF)).toStdString()); params.push_back(QString(tr("out_voltage0_hardwaregain=%1").arg(attF)).toStdString());
paramsToSet = true; paramsToSet = true;
} }
if (paramsToSet) if (paramsToSet) {
{
plutoBox->set_params(DevicePlutoSDRBox::DEVICE_PHY, params); plutoBox->set_params(DevicePlutoSDRBox::DEVICE_PHY, params);
} }
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);
} }
m_settings = settings; if (force) {
m_settings = settings;
} else {
m_settings.applySettings(settingsKeys, settings);
}
if (suspendAllOtherThreads) if (suspendAllOtherThreads)
{ {
@ -774,12 +728,12 @@ int PlutoSDROutput::webapiSettingsPutPatch(
PlutoSDROutputSettings settings = m_settings; PlutoSDROutputSettings settings = m_settings;
webapiUpdateDeviceSettings(settings, deviceSettingsKeys, response); webapiUpdateDeviceSettings(settings, deviceSettingsKeys, response);
MsgConfigurePlutoSDR *msg = MsgConfigurePlutoSDR::create(settings, force); MsgConfigurePlutoSDR *msg = MsgConfigurePlutoSDR::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
{ {
MsgConfigurePlutoSDR *msgToGUI = MsgConfigurePlutoSDR::create(settings, force); MsgConfigurePlutoSDR *msgToGUI = MsgConfigurePlutoSDR::create(settings, deviceSettingsKeys, force);
m_guiMessageQueue->push(msgToGUI); m_guiMessageQueue->push(msgToGUI);
} }
@ -895,7 +849,7 @@ void PlutoSDROutput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& resp
response.getPlutoSdrOutputReport()->setTemperature(getTemperature()); response.getPlutoSdrOutputReport()->setTemperature(getTemperature());
} }
void PlutoSDROutput::webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const PlutoSDROutputSettings& settings, bool force) void PlutoSDROutput::webapiReverseSendSettings(const QList<QString>& deviceSettingsKeys, const PlutoSDROutputSettings& settings, bool force)
{ {
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings(); SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
swgDeviceSettings->setDirection(1); // single Tx swgDeviceSettings->setDirection(1); // single Tx

View File

@ -41,20 +41,22 @@ public:
public: public:
const PlutoSDROutputSettings& getSettings() const { return m_settings; } const PlutoSDROutputSettings& 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 MsgConfigurePlutoSDR* create(const PlutoSDROutputSettings& settings, bool force) static MsgConfigurePlutoSDR* create(const PlutoSDROutputSettings& settings, const QList<QString>& settingsKeys, bool force) {
{ return new MsgConfigurePlutoSDR(settings, settingsKeys, force);
return new MsgConfigurePlutoSDR(settings, force);
} }
private: private:
PlutoSDROutputSettings m_settings; PlutoSDROutputSettings m_settings;
QList<QString> m_settingsKeys;
bool m_force; bool m_force;
MsgConfigurePlutoSDR(const PlutoSDROutputSettings& settings, bool force) : MsgConfigurePlutoSDR(const PlutoSDROutputSettings& settings, const QList<QString>& settingsKeys, bool force) :
Message(), Message(),
m_settings(settings), m_settings(settings),
m_settingsKeys(settingsKeys),
m_force(force) m_force(force)
{ } { }
}; };
@ -156,9 +158,9 @@ public:
void closeDevice(); void closeDevice();
void suspendBuddies(); void suspendBuddies();
void resumeBuddies(); void resumeBuddies();
bool applySettings(const PlutoSDROutputSettings& settings, bool force = false); bool applySettings(const PlutoSDROutputSettings& settings, const QList<QString>& settingsKeys, bool force = false);
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response); void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response);
void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const PlutoSDROutputSettings& settings, bool force); void webapiReverseSendSettings(const QList<QString>& deviceSettingsKeys, const PlutoSDROutputSettings& settings, bool force);
void webapiReverseSendStartStop(bool start); void webapiReverseSendStartStop(bool start);
private slots: private slots:

View File

@ -98,7 +98,9 @@ void PlutoSDROutputGUI::destroy()
void PlutoSDROutputGUI::resetToDefaults() void PlutoSDROutputGUI::resetToDefaults()
{ {
m_settings.resetToDefaults();
displaySettings();
sendSettings(true);
} }
QByteArray PlutoSDROutputGUI::serialize() const QByteArray PlutoSDROutputGUI::serialize() const
@ -135,7 +137,13 @@ bool PlutoSDROutputGUI::handleMessage(const Message& message)
if (PlutoSDROutput::MsgConfigurePlutoSDR::match(message)) if (PlutoSDROutput::MsgConfigurePlutoSDR::match(message))
{ {
const PlutoSDROutput::MsgConfigurePlutoSDR& cfg = (PlutoSDROutput::MsgConfigurePlutoSDR&) message; const PlutoSDROutput::MsgConfigurePlutoSDR& cfg = (PlutoSDROutput::MsgConfigurePlutoSDR&) message;
m_settings = cfg.getSettings();
if (cfg.getForce()) {
m_settings = cfg.getSettings();
} else {
m_settings.applySettings(cfg.getSettingsKeys(), cfg.getSettings());
}
blockApplySettings(true); blockApplySettings(true);
displaySettings(); displaySettings();
blockApplySettings(false); blockApplySettings(false);
@ -181,6 +189,7 @@ void PlutoSDROutputGUI::on_startStop_toggled(bool checked)
void PlutoSDROutputGUI::on_centerFrequency_changed(quint64 value) void PlutoSDROutputGUI::on_centerFrequency_changed(quint64 value)
{ {
m_settings.m_centerFrequency = value * 1000; m_settings.m_centerFrequency = value * 1000;
m_settingsKeys.append("centerFrequency");
sendSettings(); sendSettings();
} }
@ -188,6 +197,7 @@ void PlutoSDROutputGUI::on_loPPM_valueChanged(int value)
{ {
ui->loPPMText->setText(QString("%1").arg(QString::number(value/10.0, 'f', 1))); ui->loPPMText->setText(QString("%1").arg(QString::number(value/10.0, 'f', 1)));
m_settings.m_LOppmTenths = value; m_settings.m_LOppmTenths = value;
m_settingsKeys.append("LOppmTenths");
sendSettings(); sendSettings();
} }
@ -201,6 +211,8 @@ void PlutoSDROutputGUI::on_swInterp_currentIndexChanged(int index)
m_settings.m_devSampleRate <<= m_settings.m_log2Interp; m_settings.m_devSampleRate <<= m_settings.m_log2Interp;
} }
m_settingsKeys.append("log2Interp");
m_settingsKeys.append("devSampleRate");
sendSettings(); sendSettings();
} }
@ -212,12 +224,14 @@ void PlutoSDROutputGUI::on_sampleRate_changed(quint64 value)
m_settings.m_devSampleRate <<= m_settings.m_log2Interp; m_settings.m_devSampleRate <<= m_settings.m_log2Interp;
} }
m_settingsKeys.append("devSampleRate");
sendSettings(); sendSettings();
} }
void PlutoSDROutputGUI::on_lpf_changed(quint64 value) void PlutoSDROutputGUI::on_lpf_changed(quint64 value)
{ {
m_settings.m_lpfBW = value * 1000; m_settings.m_lpfBW = value * 1000;
m_settingsKeys.append("lpfBW");
sendSettings(); sendSettings();
} }
@ -226,18 +240,21 @@ void PlutoSDROutputGUI::on_lpFIREnable_toggled(bool checked)
m_settings.m_lpfFIREnable = checked; m_settings.m_lpfFIREnable = checked;
ui->lpFIRInterpolation->setEnabled(checked); ui->lpFIRInterpolation->setEnabled(checked);
ui->lpFIRGain->setEnabled(checked); ui->lpFIRGain->setEnabled(checked);
m_settingsKeys.append("lpfFIREnable");
sendSettings(); sendSettings();
} }
void PlutoSDROutputGUI::on_lpFIR_changed(quint64 value) void PlutoSDROutputGUI::on_lpFIR_changed(quint64 value)
{ {
m_settings.m_lpfFIRBW = value * 1000; m_settings.m_lpfFIRBW = value * 1000;
m_settingsKeys.append("lpfFIRBW");
sendSettings(); sendSettings();
} }
void PlutoSDROutputGUI::on_lpFIRInterpolation_currentIndexChanged(int index) void PlutoSDROutputGUI::on_lpFIRInterpolation_currentIndexChanged(int index)
{ {
m_settings.m_lpfFIRlog2Interp = index > 2 ? 2 : index; m_settings.m_lpfFIRlog2Interp = index > 2 ? 2 : index;
m_settingsKeys.append("lpfFIRlog2Interp");
setSampleRateLimits(); setSampleRateLimits();
sendSettings(); sendSettings();
} }
@ -245,6 +262,7 @@ void PlutoSDROutputGUI::on_lpFIRInterpolation_currentIndexChanged(int index)
void PlutoSDROutputGUI::on_lpFIRGain_currentIndexChanged(int index) void PlutoSDROutputGUI::on_lpFIRGain_currentIndexChanged(int index)
{ {
m_settings.m_lpfFIRGain = 6*(index > 1 ? 1 : index) - 6; m_settings.m_lpfFIRGain = 6*(index > 1 ? 1 : index) - 6;
m_settingsKeys.append("lpfFIRGain");
sendSettings(); sendSettings();
} }
@ -252,12 +270,14 @@ void PlutoSDROutputGUI::on_att_valueChanged(int value)
{ {
ui->attText->setText(QString("%1 dB").arg(QString::number(value*0.25, 'f', 2))); ui->attText->setText(QString("%1 dB").arg(QString::number(value*0.25, 'f', 2)));
m_settings.m_att = value; m_settings.m_att = value;
m_settingsKeys.append("att");
sendSettings(); sendSettings();
} }
void PlutoSDROutputGUI::on_antenna_currentIndexChanged(int index) void PlutoSDROutputGUI::on_antenna_currentIndexChanged(int index)
{ {
m_settings.m_antennaPath = (PlutoSDROutputSettings::RFPath) (index < PlutoSDROutputSettings::RFPATH_END ? index : 0); m_settings.m_antennaPath = (PlutoSDROutputSettings::RFPath) (index < PlutoSDROutputSettings::RFPATH_END ? index : 0);
m_settingsKeys.append("antennaPath");
sendSettings(); sendSettings();
} }
@ -268,6 +288,9 @@ void PlutoSDROutputGUI::on_transverter_clicked()
qDebug("PlutoSDROutputGUI::on_transverter_clicked: %lld Hz %s", m_settings.m_transverterDeltaFrequency, m_settings.m_transverterMode ? "on" : "off"); qDebug("PlutoSDROutputGUI::on_transverter_clicked: %lld Hz %s", m_settings.m_transverterDeltaFrequency, m_settings.m_transverterMode ? "on" : "off");
updateFrequencyLimits(); updateFrequencyLimits();
m_settings.m_centerFrequency = ui->centerFrequency->getValueNew()*1000; m_settings.m_centerFrequency = ui->centerFrequency->getValueNew()*1000;
m_settingsKeys.append("transverterMode");
m_settingsKeys.append("transverterDeltaFrequency");
m_settingsKeys.append("centerFrequency");
sendSettings(); sendSettings();
} }
@ -340,7 +363,10 @@ void PlutoSDROutputGUI::displaySettings()
void PlutoSDROutputGUI::sendSettings(bool forceSettings) void PlutoSDROutputGUI::sendSettings(bool forceSettings)
{ {
m_forceSettings = forceSettings; m_forceSettings = forceSettings;
if(!m_updateTimer.isActive()) { m_updateTimer.start(100); }
if (!m_updateTimer.isActive()) {
m_updateTimer.start(100);
}
} }
void PlutoSDROutputGUI::updateHardware() void PlutoSDROutputGUI::updateHardware()
@ -348,9 +374,10 @@ void PlutoSDROutputGUI::updateHardware()
if (m_doApplySettings) if (m_doApplySettings)
{ {
qDebug() << "PlutoSDROutputGUI::updateHardware"; qDebug() << "PlutoSDROutputGUI::updateHardware";
PlutoSDROutput::MsgConfigurePlutoSDR* message = PlutoSDROutput::MsgConfigurePlutoSDR::create(m_settings, m_forceSettings); PlutoSDROutput::MsgConfigurePlutoSDR* message = PlutoSDROutput::MsgConfigurePlutoSDR::create(m_settings, m_settingsKeys, m_forceSettings);
m_sampleSink->getInputMessageQueue()->push(message); m_sampleSink->getInputMessageQueue()->push(message);
m_forceSettings = false; m_forceSettings = false;
m_settingsKeys.clear();
m_updateTimer.stop(); m_updateTimer.stop();
} }
} }
@ -511,6 +538,10 @@ void PlutoSDROutputGUI::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

@ -54,6 +54,7 @@ protected:
private: private:
Ui::PlutoSDROutputGUI* ui; Ui::PlutoSDROutputGUI* ui;
PlutoSDROutputSettings m_settings; PlutoSDROutputSettings 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
bool m_forceSettings; bool m_forceSettings;
QTimer m_updateTimer; QTimer m_updateTimer;

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>360</width> <width>360</width>
<height>197</height> <height>246</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -19,13 +19,13 @@
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>360</width> <width>360</width>
<height>197</height> <height>240</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>380</width> <width>380</width>
<height>250</height> <height>246</height>
</size> </size>
</property> </property>
<property name="font"> <property name="font">

View File

@ -129,6 +129,120 @@ bool PlutoSDROutputSettings::deserialize(const QByteArray& data)
} }
} }
void PlutoSDROutputSettings::applySettings(const QStringList& settingsKeys, const PlutoSDROutputSettings& settings)
{
if (settingsKeys.contains("centerFrequency")) {
m_centerFrequency = settings.m_centerFrequency;
}
if (settingsKeys.contains("LOppmTenths")) {
m_LOppmTenths = settings.m_LOppmTenths;
}
if (settingsKeys.contains("log2Interp")) {
m_log2Interp = settings.m_log2Interp;
}
if (settingsKeys.contains("devSampleRate")) {
m_devSampleRate = settings.m_devSampleRate;
}
if (settingsKeys.contains("lpfBW")) {
m_lpfBW = settings.m_lpfBW;
}
if (settingsKeys.contains("lpfFIREnable")) {
m_lpfFIREnable = settings.m_lpfFIREnable;
}
if (settingsKeys.contains("lpfFIRBW")) {
m_lpfFIRBW = settings.m_lpfFIRBW;
}
if (settingsKeys.contains("lpfFIRlog2Interp")) {
m_lpfFIRlog2Interp = settings.m_lpfFIRlog2Interp;
}
if (settingsKeys.contains("lpfFIRGain")) {
m_lpfFIRGain = settings.m_lpfFIRGain;
}
if (settingsKeys.contains("att")) {
m_att = settings.m_att;
}
if (settingsKeys.contains("antennaPath")) {
m_antennaPath = settings.m_antennaPath;
}
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 PlutoSDROutputSettings::getDebugString(const QStringList& settingsKeys, bool force) const
{
std::ostringstream ostr;
if (settingsKeys.contains("centerFrequency") || force) {
ostr << " m_centerFrequency: " << m_centerFrequency;
}
if (settingsKeys.contains("LOppmTenths") || force) {
ostr << " m_LOppmTenths: " << m_LOppmTenths;
}
if (settingsKeys.contains("log2Interp") || force) {
ostr << " m_log2Interp: " << m_log2Interp;
}
if (settingsKeys.contains("devSampleRate") || force) {
ostr << " m_devSampleRate: " << m_devSampleRate;
}
if (settingsKeys.contains("lpfBW") || force) {
ostr << " m_lpfBW: " << m_lpfBW;
}
if (settingsKeys.contains("lpfFIREnable") || force) {
ostr << " m_lpfFIREnable: " << m_lpfFIREnable;
}
if (settingsKeys.contains("lpfFIRBW") || force) {
ostr << " m_lpfFIRBW: " << m_lpfFIRBW;
}
if (settingsKeys.contains("lpfFIRlog2Interp") || force) {
ostr << " m_lpfFIRlog2Interp: " << m_lpfFIRlog2Interp;
}
if (settingsKeys.contains("lpfFIRGain") || force) {
ostr << " m_lpfFIRGain: " << m_lpfFIRGain;
}
if (settingsKeys.contains("att") || force) {
ostr << " m_att: " << m_att;
}
if (settingsKeys.contains("antennaPath") || force) {
ostr << " m_antennaPath: " << m_antennaPath;
}
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());
}
void PlutoSDROutputSettings::translateRFPath(RFPath path, QString& s) void PlutoSDROutputSettings::translateRFPath(RFPath path, QString& s)
{ {
switch(path) switch(path)

View File

@ -56,6 +56,8 @@ struct PlutoSDROutputSettings {
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 PlutoSDROutputSettings& settings);
QString getDebugString(const QStringList& settingsKeys, bool force=false) const;
static void translateRFPath(RFPath path, QString& s); static void translateRFPath(RFPath path, QString& s);
}; };