1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 01:55:48 -05:00

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

This commit is contained in:
f4exb 2022-10-30 11:36:39 +01:00
parent 6499608195
commit 77b5d4d5ae
6 changed files with 241 additions and 123 deletions

View File

@ -375,7 +375,7 @@ void LimeSDROutput::releaseChannel()
void LimeSDROutput::init()
{
applySettings(m_settings, true, false);
applySettings(m_settings, QList<QString>(), true, false);
}
bool LimeSDROutput::start()
@ -396,10 +396,9 @@ bool LimeSDROutput::start()
m_limeSDROutputThread = new LimeSDROutputThread(&m_streamId, &m_sampleSourceFifo);
qDebug("LimeSDROutput::start: thread created");
applySettings(m_settings, true);
applySettings(m_settings, QList<QString>(), true);
m_limeSDROutputThread->setLog2Interpolation(m_settings.m_log2SoftInterp);
m_limeSDROutputThread->startWork();
m_deviceShared.m_thread = m_limeSDROutputThread;
@ -440,12 +439,12 @@ bool LimeSDROutput::deserialize(const QByteArray& data)
success = false;
}
MsgConfigureLimeSDR* message = MsgConfigureLimeSDR::create(m_settings, true);
MsgConfigureLimeSDR* message = MsgConfigureLimeSDR::create(m_settings, QList<QString>(), true);
m_inputMessageQueue.push(message);
if (m_guiMessageQueue)
{
MsgConfigureLimeSDR* messageToGUI = MsgConfigureLimeSDR::create(m_settings, true);
MsgConfigureLimeSDR* messageToGUI = MsgConfigureLimeSDR::create(m_settings, QList<QString>(), true);
m_guiMessageQueue->push(messageToGUI);
}
@ -473,12 +472,12 @@ void LimeSDROutput::setCenterFrequency(qint64 centerFrequency)
LimeSDROutputSettings settings = m_settings;
settings.m_centerFrequency = centerFrequency - (m_settings.m_ncoEnable ? m_settings.m_ncoFrequency : 0);
MsgConfigureLimeSDR* message = MsgConfigureLimeSDR::create(settings, false);
MsgConfigureLimeSDR* message = MsgConfigureLimeSDR::create(settings, QList<QString>{"centerFrequency"}, false);
m_inputMessageQueue.push(message);
if (m_guiMessageQueue)
{
MsgConfigureLimeSDR* messageToGUI = MsgConfigureLimeSDR::create(settings, false);
MsgConfigureLimeSDR* messageToGUI = MsgConfigureLimeSDR::create(settings, QList<QString>{"centerFrequency"}, false);
m_guiMessageQueue->push(messageToGUI);
}
}
@ -533,8 +532,7 @@ bool LimeSDROutput::handleMessage(const Message& message)
MsgConfigureLimeSDR& conf = (MsgConfigureLimeSDR&) message;
qDebug() << "LimeSDROutput::handleMessage: MsgConfigureLimeSDR";
if (!applySettings(conf.getSettings(), conf.getForce()))
{
if (!applySettings(conf.getSettings(), conf.getSettingsKeys(), conf.getForce())) {
qDebug("LimeSDROutput::handleMessage config error");
}
@ -547,8 +545,7 @@ bool LimeSDROutput::handleMessage(const Message& message)
if (cmd.getStartStop())
{
if (m_deviceAPI->initDeviceEngine())
{
if (m_deviceAPI->initDeviceEngine()) {
m_deviceAPI->startDeviceEngine();
}
}
@ -566,6 +563,7 @@ bool LimeSDROutput::handleMessage(const Message& message)
else if (DeviceLimeSDRShared::MsgReportBuddyChange::match(message))
{
DeviceLimeSDRShared::MsgReportBuddyChange& report = (DeviceLimeSDRShared::MsgReportBuddyChange&) message;
QList<QString> settingsKeys;
if (report.getRxElseTx() && m_running)
{
@ -585,6 +583,8 @@ bool LimeSDROutput::handleMessage(const Message& message)
m_settings.m_devSampleRate = roundf(host_Hz);
int hard = roundf(rf_Hz) / m_settings.m_devSampleRate;
m_settings.m_log2HardInterp = log2(hard);
settingsKeys.append("devSampleRate");
settingsKeys.append("log2HardInterp");
qDebug() << "LimeSDROutput::handleMessage: MsgReportBuddyChange:"
<< " host_Hz: " << host_Hz
@ -600,11 +600,14 @@ bool LimeSDROutput::handleMessage(const Message& message)
m_settings.m_devSampleRate = report.getDevSampleRate();
m_settings.m_log2HardInterp = report.getLog2HardDecimInterp();
m_settings.m_centerFrequency = report.getCenterFrequency();
settingsKeys.append("devSampleRate");
settingsKeys.append("log2HardInterp");
settingsKeys.append("centerFrequency");
}
if (m_settings.m_ncoEnable) // need to reset NCO after sample rate change
{
applySettings(m_settings, false, true);
applySettings(m_settings, settingsKeys, false, true);
}
int ncoShift = m_settings.m_ncoEnable ? m_settings.m_ncoFrequency : 0;
@ -640,7 +643,7 @@ bool LimeSDROutput::handleMessage(const Message& message)
{
DeviceLimeSDRShared::MsgReportGPIOChange& report = (DeviceLimeSDRShared::MsgReportGPIOChange&) message;
m_settings.m_gpioDir = report.getGPIODir();
m_settings.m_gpioDir = report.getGPIODir();
m_settings.m_gpioPins = report.getGPIOPins();
// no GUI for the moment only REST API
@ -747,8 +750,11 @@ bool LimeSDROutput::handleMessage(const Message& message)
}
}
bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool force, bool forceNCOFrequency)
bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, const QList<QString>& settingsKeys, bool force, bool forceNCOFrequency)
{
qDebug().noquote() << "LimeSDROutput::applySettings: force:" << force
<< " forceNCOFrequency:" << forceNCOFrequency
<< settings.getDebugString(settingsKeys, force);
bool forwardChangeOwnDSP = false;
bool forwardChangeTxDSP = false;
bool forwardChangeAllDSP = false;
@ -758,28 +764,22 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo
bool doCalibration = false;
bool doLPCalibration = false;
double clockGenFreq = 0.0;
QList<QString> reverseAPIKeys;
// QMutexLocker mutexLocker(&m_mutex);
qint64 deviceCenterFrequency = settings.m_centerFrequency;
deviceCenterFrequency -= settings.m_transverterMode ? settings.m_transverterDeltaFrequency : 0;
deviceCenterFrequency = deviceCenterFrequency < 0 ? 0 : deviceCenterFrequency;
if (LMS_GetClockFreq(m_deviceShared.m_deviceParams->getDevice(), LMS_CLOCK_CGEN, &clockGenFreq) != 0)
{
if (LMS_GetClockFreq(m_deviceShared.m_deviceParams->getDevice(), LMS_CLOCK_CGEN, &clockGenFreq) != 0) {
qCritical("LimeSDROutput::applySettings: could not get clock gen frequency");
}
else
{
} else {
qDebug() << "LimeSDROutput::applySettings: clock gen frequency: " << clockGenFreq;
}
// apply settings
if ((m_settings.m_gain != settings.m_gain) || force)
if (settingsKeys.contains("gain") || force)
{
reverseAPIKeys.append("gain");
if (m_deviceShared.m_deviceParams->getDevice() && m_channelAcquired)
{
if (LMS_SetGaindB(m_deviceShared.m_deviceParams->getDevice(),
@ -797,11 +797,9 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo
}
}
if ((m_settings.m_devSampleRate != settings.m_devSampleRate)
|| (m_settings.m_log2HardInterp != settings.m_log2HardInterp) || force)
if (settingsKeys.contains("devSampleRate")
|| settingsKeys.contains("log2HardInterp") || force)
{
reverseAPIKeys.append("devSampleRate");
reverseAPIKeys.append("log2HardInterp");
forwardChangeAllDSP = true; //m_settings.m_devSampleRate != settings.m_devSampleRate;
if (m_deviceShared.m_deviceParams->getDevice())
@ -828,12 +826,9 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo
}
}
if ((m_settings.m_devSampleRate != settings.m_devSampleRate)
|| (m_settings.m_log2SoftInterp != settings.m_log2SoftInterp) || force)
if (settingsKeys.contains("devSampleRate")
|| settingsKeys.contains("log2SoftInterp") || force)
{
reverseAPIKeys.append("devSampleRate");
reverseAPIKeys.append("log2SoftInterp");
#if defined(_MSC_VER)
unsigned int fifoRate = (unsigned int) settings.m_devSampleRate / (1<<settings.m_log2SoftInterp);
fifoRate = fifoRate < 48000U ? 48000U : fifoRate;
@ -846,22 +841,16 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo
qDebug("LimeSDROutput::applySettings: resize FIFO: rate %u", fifoRate);
}
if ((m_settings.m_lpfBW != settings.m_lpfBW) || force)
if (settingsKeys.contains("lpfBW") || force)
{
reverseAPIKeys.append("lpfBW");
if (m_deviceShared.m_deviceParams->getDevice() && m_channelAcquired)
{
if (m_deviceShared.m_deviceParams->getDevice() && m_channelAcquired) {
doLPCalibration = true;
}
}
if ((m_settings.m_lpfFIRBW != settings.m_lpfFIRBW) ||
(m_settings.m_lpfFIREnable != settings.m_lpfFIREnable) || force)
if (settingsKeys.contains("lpfFIRBW") ||
settingsKeys.contains("lpfFIREnable") || force)
{
reverseAPIKeys.append("lpfFIRBW");
reverseAPIKeys.append("lpfFIREnable");
if (m_deviceShared.m_deviceParams->getDevice() && m_channelAcquired)
{
if (LMS_SetGFIRLPF(m_deviceShared.m_deviceParams->getDevice(),
@ -884,11 +873,9 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo
}
}
if ((m_settings.m_ncoFrequency != settings.m_ncoFrequency) ||
(m_settings.m_ncoEnable != settings.m_ncoEnable) || force || forceNCOFrequency)
if (settingsKeys.contains("ncoFrequency") ||
settingsKeys.contains("ncoEnable") || force || forceNCOFrequency)
{
reverseAPIKeys.append("ncoFrequency");
reverseAPIKeys.append("ncoEnable");
forwardChangeOwnDSP = true;
if (m_deviceShared.m_deviceParams->getDevice() && m_channelAcquired)
@ -914,9 +901,8 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo
}
}
if ((m_settings.m_log2SoftInterp != settings.m_log2SoftInterp) || force)
if (settingsKeys.contains("log2SoftInterp") || force)
{
reverseAPIKeys.append("log2SoftInterp");
forwardChangeOwnDSP = true;
m_deviceShared.m_log2Soft = settings.m_log2SoftInterp; // for buddies
@ -927,10 +913,8 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo
}
}
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)
{
if (DeviceLimeSDR::setTxAntennaPath(m_deviceShared.m_deviceParams->getDevice(),
@ -949,14 +933,11 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo
}
}
if ((m_settings.m_centerFrequency != settings.m_centerFrequency)
|| (m_settings.m_transverterMode != settings.m_transverterMode)
|| (m_settings.m_transverterDeltaFrequency != settings.m_transverterDeltaFrequency)
if (settingsKeys.contains("centerFrequency")
|| settingsKeys.contains("transverterMode")
|| settingsKeys.contains("transverterDeltaFrequency")
|| force)
{
reverseAPIKeys.append("centerFrequency");
reverseAPIKeys.append("transverterMode");
reverseAPIKeys.append("transverterDeltaFrequency");
forwardChangeTxDSP = true;
if (m_deviceShared.m_deviceParams->getDevice() && m_channelAcquired)
@ -974,12 +955,9 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo
}
}
if ((m_settings.m_extClock != settings.m_extClock) ||
(settings.m_extClock && (m_settings.m_extClockFreq != settings.m_extClockFreq)) || force)
if (settingsKeys.contains("extClock") ||
settingsKeys.contains("extClockFreq") || force)
{
reverseAPIKeys.append("extClock");
reverseAPIKeys.append("extClockFreq");
if (DeviceLimeSDR::setClockSource(m_deviceShared.m_deviceParams->getDevice(),
settings.m_extClock,
settings.m_extClockFreq))
@ -1001,10 +979,8 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo
if ((m_deviceShared.m_deviceParams->m_type != DeviceLimeSDRParams::LimeMini)
&& (m_deviceShared.m_deviceParams->m_type != DeviceLimeSDRParams::LimeUndefined))
{
if ((m_settings.m_gpioDir != settings.m_gpioDir) || force)
if (settingsKeys.contains("gpioDir") || force)
{
reverseAPIKeys.append("gpioDir");
if (LMS_GPIODirWrite(m_deviceShared.m_deviceParams->getDevice(), &settings.m_gpioDir, 1) != 0)
{
qCritical("LimeSDROutput::applySettings: could not set GPIO directions to %u", settings.m_gpioDir);
@ -1016,10 +992,8 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo
}
}
if ((m_settings.m_gpioPins != settings.m_gpioPins) || force)
if (settingsKeys.contains("gpioPins") || force)
{
reverseAPIKeys.append("gpioPins");
if (LMS_GPIOWrite(m_deviceShared.m_deviceParams->getDevice(), &settings.m_gpioPins, 1) != 0)
{
qCritical("LimeSDROutput::applySettings: could not set GPIO pins to %u", settings.m_gpioPins);
@ -1032,16 +1006,21 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo
}
}
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 (force) {
m_settings = settings;
} else {
m_settings.applySettings(settingsKeys, settings);
}
m_settings = settings;
double clockGenFreqAfter;
if (LMS_GetClockFreq(m_deviceShared.m_deviceParams->getDevice(), LMS_CLOCK_CGEN, &clockGenFreqAfter) != 0)
@ -1223,33 +1202,6 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo
}
}
QLocale loc;
qDebug().noquote() << "LimeSDROutput::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 interpolation: " << loc.toString( m_settings.m_devSampleRate/(1<<m_settings.m_log2SoftInterp)) << "S/s"
<< " DAC sample rate with hard interpolation: " << loc.toString(m_settings.m_devSampleRate*(1<<m_settings.m_log2HardInterp)) << "S/s"
<< " m_log2HardInterp: " << m_settings.m_log2HardInterp
<< " m_log2SoftInterp: " << m_settings.m_log2SoftInterp
<< " m_gain: " << m_settings.m_gain
<< " m_lpfBW: " << loc.toString(static_cast<int>(m_settings.m_lpfBW))
<< " m_lpfFIRBW: " << loc.toString(static_cast<int>(m_settings.m_lpfFIRBW))
<< " m_lpfFIREnable: " << m_settings.m_lpfFIREnable
<< " m_ncoEnable: " << m_settings.m_ncoEnable
<< " m_ncoFrequency: " << loc.toString(m_settings.m_ncoFrequency)
<< " m_antennaPath: " << m_settings.m_antennaPath
<< " m_extClock: " << m_settings.m_extClock
<< " m_extClockFreq: " << loc.toString(m_settings.m_extClockFreq)
<< " m_gpioDir: " << m_settings.m_gpioDir
<< " m_gpioPins: " << m_settings.m_gpioPins
<< " force: " << force
<< " forceNCOFrequency: " << forceNCOFrequency
<< " doCalibration: " << doCalibration
<< " doLPCalibration: " << doLPCalibration;
return true;
}
@ -1274,12 +1226,12 @@ int LimeSDROutput::webapiSettingsPutPatch(
LimeSDROutputSettings settings = m_settings;
webapiUpdateDeviceSettings(settings, deviceSettingsKeys, response);
MsgConfigureLimeSDR *msg = MsgConfigureLimeSDR::create(settings, force);
MsgConfigureLimeSDR *msg = MsgConfigureLimeSDR::create(settings, deviceSettingsKeys, force);
m_inputMessageQueue.push(msg);
if (m_guiMessageQueue) // forward to GUI if any
{
MsgConfigureLimeSDR *msgToGUI = MsgConfigureLimeSDR::create(settings, force);
MsgConfigureLimeSDR *msgToGUI = MsgConfigureLimeSDR::create(settings, deviceSettingsKeys, force);
m_guiMessageQueue->push(msgToGUI);
}
@ -1466,7 +1418,7 @@ void LimeSDROutput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& respo
response.getLimeSdrOutputReport()->setGpioPins(gpioPins);
}
void LimeSDROutput::webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const LimeSDROutputSettings& settings, bool force)
void LimeSDROutput::webapiReverseSendSettings(const QList<QString>& deviceSettingsKeys, const LimeSDROutputSettings& settings, bool force)
{
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
swgDeviceSettings->setDirection(1); // single Tx

View File

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

View File

@ -115,6 +115,7 @@ void LimeSDROutputGUI::resetToDefaults()
{
m_settings.resetToDefaults();
displaySettings();
m_forceSettings = true;
sendSettings();
}
@ -176,7 +177,13 @@ bool LimeSDROutputGUI::handleMessage(const Message& message)
if (LimeSDROutput::MsgConfigureLimeSDR::match(message))
{
const LimeSDROutput::MsgConfigureLimeSDR& cfg = (LimeSDROutput::MsgConfigureLimeSDR&) 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);
@ -294,14 +301,6 @@ void LimeSDROutputGUI::handleInputMessages()
delete message;
}
else if (LimeSDROutput::MsgConfigureLimeSDR::match(*message))
{
const LimeSDROutput::MsgConfigureLimeSDR& cfg = (LimeSDROutput::MsgConfigureLimeSDR&) *message;
m_settings = cfg.getSettings();
displaySettings();
delete message;
}
else if (LimeSDROutput::MsgStartStop::match(*message))
{
LimeSDROutput::MsgStartStop& notif = (LimeSDROutput::MsgStartStop&) *message;
@ -470,8 +469,9 @@ void LimeSDROutputGUI::setCenterFrequencySetting(uint64_t kHzValue)
void LimeSDROutputGUI::sendSettings()
{
if(!m_updateTimer.isActive())
if (!m_updateTimer.isActive()) {
m_updateTimer.start(100);
}
}
void LimeSDROutputGUI::updateHardware()
@ -479,9 +479,10 @@ void LimeSDROutputGUI::updateHardware()
if (m_doApplySettings)
{
qDebug() << "LimeSDROutputGUI::updateHardware";
LimeSDROutput::MsgConfigureLimeSDR* message = LimeSDROutput::MsgConfigureLimeSDR::create(m_settings, m_forceSettings);
LimeSDROutput::MsgConfigureLimeSDR* message = LimeSDROutput::MsgConfigureLimeSDR::create(m_settings, m_settingsKeys, m_forceSettings);
m_limeSDROutput->getInputMessageQueue()->push(message);
m_forceSettings = false;
m_settingsKeys.clear();
m_updateTimer.stop();
}
}
@ -558,6 +559,7 @@ void LimeSDROutputGUI::on_startStop_toggled(bool checked)
void LimeSDROutputGUI::on_centerFrequency_changed(quint64 value)
{
setCenterFrequencySetting(value);
m_settingsKeys.append("centerFrequency");
sendSettings();
}
@ -566,6 +568,7 @@ void LimeSDROutputGUI::on_ncoFrequency_changed(qint64 value)
m_settings.m_ncoFrequency = value;
updateFrequencyLimits();
setCenterFrequencyDisplay();
m_settingsKeys.append("ncoFrequency");
sendSettings();
}
@ -574,6 +577,7 @@ void LimeSDROutputGUI::on_ncoEnable_toggled(bool checked)
m_settings.m_ncoEnable = checked;
updateFrequencyLimits();
setCenterFrequencyDisplay();
m_settingsKeys.append("ncoEnable");
sendSettings();
}
@ -587,15 +591,19 @@ void LimeSDROutputGUI::on_sampleRate_changed(quint64 value)
updateDACRate();
setNCODisplay();
m_settingsKeys.append("devSampleRate");
sendSettings();}
void LimeSDROutputGUI::on_hwInterp_currentIndexChanged(int index)
{
if ((index <0) || (index > 5))
if ((index <0) || (index > 5)) {
return;
}
m_settings.m_log2HardInterp = index;
updateDACRate();
setNCODisplay();
m_settingsKeys.append("log2HardInterp");
sendSettings();
}
@ -614,6 +622,8 @@ void LimeSDROutputGUI::on_swInterp_currentIndexChanged(int index)
m_settings.m_devSampleRate = ui->sampleRate->getValueNew() * (1 << m_settings.m_log2SoftInterp);
}
m_settingsKeys.append("log2SoftInterp");
m_settingsKeys.append("devSampleRate");
sendSettings();
}
@ -621,18 +631,21 @@ void LimeSDROutputGUI::on_lpf_changed(quint64 value)
{
m_settings.m_lpfBW = value * 1000;
checkLPF();
m_settingsKeys.append("lpfBW");
sendSettings();
}
void LimeSDROutputGUI::on_lpFIREnable_toggled(bool checked)
{
m_settings.m_lpfFIREnable = checked;
m_settingsKeys.append("lpfFIREnable");
sendSettings();
}
void LimeSDROutputGUI::on_lpFIR_changed(quint64 value)
{
m_settings.m_lpfFIRBW = value * 1000;
m_settingsKeys.append("lpfFIRBW");
sendSettings();
}
@ -640,12 +653,14 @@ void LimeSDROutputGUI::on_gain_valueChanged(int value)
{
m_settings.m_gain = value;
ui->gainText->setText(tr("%1dB").arg(m_settings.m_gain));
m_settingsKeys.append("gain");
sendSettings();
}
void LimeSDROutputGUI::on_antenna_currentIndexChanged(int index)
{
m_settings.m_antennaPath = (LimeSDROutputSettings::PathRFE) index;
m_settingsKeys.append("antennaPath");
sendSettings();
}
@ -654,6 +669,8 @@ void LimeSDROutputGUI::on_extClock_clicked()
m_settings.m_extClock = ui->extClock->getExternalClockActive();
m_settings.m_extClockFreq = ui->extClock->getExternalClockFrequency();
qDebug("LimeSDROutputGUI::on_extClock_clicked: %u Hz %s", m_settings.m_extClockFreq, m_settings.m_extClock ? "on" : "off");
m_settingsKeys.append("extClock");
m_settingsKeys.append("extClockFreq");
sendSettings();
}
@ -664,6 +681,9 @@ void LimeSDROutputGUI::on_transverter_clicked()
qDebug("LimeSDRInputGUI::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();
}
@ -690,6 +710,10 @@ void LimeSDROutputGUI::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();
}

View File

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

View File

@ -131,7 +131,144 @@ bool LimeSDROutputSettings::deserialize(const QByteArray& data)
resetToDefaults();
return false;
}
}
void LimeSDROutputSettings::applySettings(const QStringList& settingsKeys, const LimeSDROutputSettings& settings)
{
if (settingsKeys.contains("centerFrequency")) {
m_centerFrequency = settings.m_centerFrequency;
}
if (settingsKeys.contains("devSampleRate")) {
m_devSampleRate = settings.m_devSampleRate;
}
if (settingsKeys.contains("log2HardInterp")) {
m_log2HardInterp = settings.m_log2HardInterp;
}
if (settingsKeys.contains("log2SoftInterp")) {
m_log2SoftInterp = settings.m_log2SoftInterp;
}
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("gain")) {
m_gain = settings.m_gain;
}
if (settingsKeys.contains("ncoEnable")) {
m_ncoEnable = settings.m_ncoEnable;
}
if (settingsKeys.contains("ncoFrequency")) {
m_ncoFrequency = settings.m_ncoFrequency;
}
if (settingsKeys.contains("antennaPath")) {
m_antennaPath = settings.m_antennaPath;
}
if (settingsKeys.contains("extClock")) {
m_extClock = settings.m_extClock;
}
if (settingsKeys.contains("extClockFreq")) {
m_extClockFreq = settings.m_extClockFreq;
}
if (settingsKeys.contains("transverterMode")) {
m_transverterMode = settings.m_transverterMode;
}
if (settingsKeys.contains("transverterDeltaFrequency")) {
m_transverterDeltaFrequency = settings.m_transverterDeltaFrequency;
}
if (settingsKeys.contains("gpioDir")) {
m_gpioDir = settings.m_gpioDir;
}
if (settingsKeys.contains("gpioPins")) {
m_gpioPins = settings.m_gpioPins;
}
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 LimeSDROutputSettings::getDebugString(const QStringList& settingsKeys, bool force) const
{
std::ostringstream ostr;
if (settingsKeys.contains("centerFrequency") || force) {
ostr << " m_centerFrequency: " << m_centerFrequency;
}
if (settingsKeys.contains("devSampleRate") || force) {
ostr << " m_devSampleRate: " << m_devSampleRate;
}
if (settingsKeys.contains("log2HardInterp") || force) {
ostr << " m_log2HardInterp: " << m_log2HardInterp;
}
if (settingsKeys.contains("log2SoftInterp") || force) {
ostr << " m_log2SoftInterp: " << m_log2SoftInterp;
}
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("gain") || force) {
ostr << " m_gain: " << m_gain;
}
if (settingsKeys.contains("ncoEnable") || force) {
ostr << " m_ncoEnable: " << m_ncoEnable;
}
if (settingsKeys.contains("ncoFrequency") || force) {
ostr << " m_ncoFrequency: " << m_ncoFrequency;
}
if (settingsKeys.contains("antennaPath") || force) {
ostr << " m_antennaPath: " << m_antennaPath;
}
if (settingsKeys.contains("extClock") || force) {
ostr << " m_extClock: " << m_extClock;
}
if (settingsKeys.contains("extClockFreq") || force) {
ostr << " m_extClockFreq: " << m_extClockFreq;
}
if (settingsKeys.contains("transverterMode") || force) {
ostr << " m_transverterMode: " << m_transverterMode;
}
if (settingsKeys.contains("transverterDeltaFrequency") || force) {
ostr << " m_transverterDeltaFrequency: " << m_transverterDeltaFrequency;
}
if (settingsKeys.contains("gpioDir") || force) {
ostr << " m_gpioDir: " << m_gpioDir;
}
if (settingsKeys.contains("gpioPins") || force) {
ostr << " m_gpioPins: " << m_gpioPins;
}
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

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