mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-02-03 09:44:01 -05:00
PlutoSDR input: Make settings assignments atomic. Part of #1329
This commit is contained in:
parent
112d0594b5
commit
94a465b210
@ -94,7 +94,7 @@ void PlutoSDRInput::destroy()
|
||||
|
||||
void PlutoSDRInput::init()
|
||||
{
|
||||
applySettings(m_settings, true);
|
||||
applySettings(m_settings, QList<QString>(), true);
|
||||
}
|
||||
|
||||
bool PlutoSDRInput::start()
|
||||
@ -114,7 +114,7 @@ bool PlutoSDRInput::start()
|
||||
m_plutoSDRInputThread = new PlutoSDRInputThread(PLUTOSDR_BLOCKSIZE_SAMPLES, m_deviceShared.m_deviceParams->getBox(), &m_sampleFifo);
|
||||
qDebug("PlutoSDRInput::start: thread created");
|
||||
|
||||
applySettings(m_settings, true);
|
||||
applySettings(m_settings, QList<QString>(), true);
|
||||
|
||||
m_plutoSDRInputThread->setLog2Decimation(m_settings.m_log2Decim);
|
||||
m_plutoSDRInputThread->setIQOrder(m_settings.m_iqOrder);
|
||||
@ -154,12 +154,12 @@ bool PlutoSDRInput::deserialize(const QByteArray& data)
|
||||
success = false;
|
||||
}
|
||||
|
||||
MsgConfigurePlutoSDR* message = MsgConfigurePlutoSDR::create(m_settings, true);
|
||||
MsgConfigurePlutoSDR* message = MsgConfigurePlutoSDR::create(m_settings, QList<QString>(), true);
|
||||
m_inputMessageQueue.push(message);
|
||||
|
||||
if (m_guiMessageQueue)
|
||||
{
|
||||
MsgConfigurePlutoSDR* messageToGUI = MsgConfigurePlutoSDR::create(m_settings, true);
|
||||
MsgConfigurePlutoSDR* messageToGUI = MsgConfigurePlutoSDR::create(m_settings, QList<QString>(), true);
|
||||
m_guiMessageQueue->push(messageToGUI);
|
||||
}
|
||||
|
||||
@ -185,12 +185,12 @@ void PlutoSDRInput::setCenterFrequency(qint64 centerFrequency)
|
||||
PlutoSDRInputSettings settings = m_settings;
|
||||
settings.m_centerFrequency = centerFrequency;
|
||||
|
||||
MsgConfigurePlutoSDR* message = MsgConfigurePlutoSDR::create(settings, false);
|
||||
MsgConfigurePlutoSDR* message = MsgConfigurePlutoSDR::create(settings, QList<QString>{"centerFrequency"}, false);
|
||||
m_inputMessageQueue.push(message);
|
||||
|
||||
if (m_guiMessageQueue)
|
||||
{
|
||||
MsgConfigurePlutoSDR* messageToGUI = MsgConfigurePlutoSDR::create(settings, false);
|
||||
MsgConfigurePlutoSDR* messageToGUI = MsgConfigurePlutoSDR::create(settings, QList<QString>{"centerFrequency"}, false);
|
||||
m_guiMessageQueue->push(messageToGUI);
|
||||
}
|
||||
}
|
||||
@ -202,8 +202,7 @@ bool PlutoSDRInput::handleMessage(const Message& message)
|
||||
MsgConfigurePlutoSDR& conf = (MsgConfigurePlutoSDR&) message;
|
||||
qDebug() << "PlutoSDRInput::handleMessage: MsgConfigurePlutoSDR";
|
||||
|
||||
if (!applySettings(conf.getSettings(), conf.getForce()))
|
||||
{
|
||||
if (!applySettings(conf.getSettings(), conf.getSettingsKeys(), conf.getForce())) {
|
||||
qDebug("PlutoSDRInput::handleMessage config error");
|
||||
}
|
||||
|
||||
@ -241,7 +240,7 @@ bool PlutoSDRInput::handleMessage(const Message& message)
|
||||
m_settings.m_LOppmTenths = conf.getLoPPMTenths();
|
||||
PlutoSDRInputSettings newSettings = m_settings;
|
||||
newSettings.m_lpfFIREnable = conf.isLpfFirEnable();
|
||||
applySettings(newSettings);
|
||||
applySettings(newSettings, QList<QString>{"devSampleRate", "lpfFIRlog2Decim", "lpfFIRBW", "LOppmTenths", "lpfFIREnable"});
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -388,7 +387,7 @@ void PlutoSDRInput::resumeBuddies()
|
||||
}
|
||||
}
|
||||
|
||||
bool PlutoSDRInput::applySettings(const PlutoSDRInputSettings& settings, bool force)
|
||||
bool PlutoSDRInput::applySettings(const PlutoSDRInputSettings& settings, const QList<QString>& settingsKeys, bool force)
|
||||
{
|
||||
if (!m_open)
|
||||
{
|
||||
@ -404,88 +403,7 @@ bool PlutoSDRInput::applySettings(const PlutoSDRInputSettings& settings, bool fo
|
||||
QLocale loc;
|
||||
QList<QString> reverseAPIKeys;
|
||||
|
||||
qDebug().noquote() << "PlutoSDRInput::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_dcBlock: " << m_settings.m_dcBlock
|
||||
<< " m_iqCorrection: " << m_settings.m_iqCorrection
|
||||
<< " m_hwBBDCBlock: " << m_settings.m_hwBBDCBlock
|
||||
<< " m_hwRFDCBlock: " << m_settings.m_hwRFDCBlock
|
||||
<< " m_hwIQCorrection: " << m_settings.m_hwIQCorrection
|
||||
<< " m_lpfFIREnable: " << m_settings.m_lpfFIREnable
|
||||
<< " m_lpfFIRBW: " << loc.toString(m_settings.m_lpfFIRBW)
|
||||
<< " m_lpfFIRlog2Decim: " << m_settings.m_lpfFIRlog2Decim
|
||||
<< " m_lpfFIRGain: " << m_settings.m_lpfFIRGain
|
||||
<< " m_log2Decim: " << loc.toString(1<<m_settings.m_log2Decim)
|
||||
<< " m_fcPos: " << m_settings.m_fcPos
|
||||
<< " m_lpfBW: " << loc.toString(m_settings.m_lpfBW)
|
||||
<< " m_gain: " << m_settings.m_gain
|
||||
<< " m_antennaPath: " << (int) m_settings.m_antennaPath
|
||||
<< " m_gainMode: " << (int) m_settings.m_gainMode
|
||||
<< " m_transverterMode: " << m_settings.m_transverterMode
|
||||
<< " m_transverterDeltaFrequency: " << m_settings.m_transverterDeltaFrequency
|
||||
<< " force: " << force;
|
||||
|
||||
if ((m_settings.m_centerFrequency != settings.m_centerFrequency) || force) {
|
||||
reverseAPIKeys.append("centerFrequency");
|
||||
}
|
||||
if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || force) {
|
||||
reverseAPIKeys.append("devSampleRate");
|
||||
}
|
||||
if ((m_settings.m_LOppmTenths != settings.m_LOppmTenths) || force) {
|
||||
reverseAPIKeys.append("LOppmTenths");
|
||||
}
|
||||
if ((m_settings.m_dcBlock != settings.m_dcBlock) || force) {
|
||||
reverseAPIKeys.append("dcBlock");
|
||||
}
|
||||
if ((m_settings.m_iqCorrection != settings.m_iqCorrection) || force) {
|
||||
reverseAPIKeys.append("iqCorrection");
|
||||
}
|
||||
if ((m_settings.m_hwBBDCBlock != settings.m_hwBBDCBlock) || force) {
|
||||
reverseAPIKeys.append("hwBBDCBlock");
|
||||
}
|
||||
if ((m_settings.m_hwRFDCBlock != settings.m_hwRFDCBlock) || force) {
|
||||
reverseAPIKeys.append("hwRFDCBlock");
|
||||
}
|
||||
if ((m_settings.m_hwIQCorrection != settings.m_hwIQCorrection) || force) {
|
||||
reverseAPIKeys.append("hwIQCorrection");
|
||||
}
|
||||
if ((m_settings.m_lpfFIREnable != settings.m_lpfFIREnable) || force) {
|
||||
reverseAPIKeys.append("lpfFIREnable");
|
||||
}
|
||||
if ((m_settings.m_lpfFIRBW != settings.m_lpfFIRBW) || force) {
|
||||
reverseAPIKeys.append("lpfFIRBW");
|
||||
}
|
||||
if ((m_settings.m_lpfFIRlog2Decim != settings.m_lpfFIRlog2Decim) || force) {
|
||||
reverseAPIKeys.append("lpfFIRlog2Decim");
|
||||
}
|
||||
if ((m_settings.m_lpfFIRGain != settings.m_lpfFIRGain) || force) {
|
||||
reverseAPIKeys.append("lpfFIRGain");
|
||||
}
|
||||
if ((m_settings.m_log2Decim != settings.m_log2Decim) || force) {
|
||||
reverseAPIKeys.append("log2Decim");
|
||||
}
|
||||
if ((m_settings.m_fcPos != settings.m_fcPos) || force) {
|
||||
reverseAPIKeys.append("fcPos");
|
||||
}
|
||||
if ((m_settings.m_lpfBW != settings.m_lpfBW) || force) {
|
||||
reverseAPIKeys.append("lpfBW");
|
||||
}
|
||||
if ((m_settings.m_gain != settings.m_gain) || force) {
|
||||
reverseAPIKeys.append("gain");
|
||||
}
|
||||
if ((m_settings.m_antennaPath != settings.m_antennaPath) || force) {
|
||||
reverseAPIKeys.append("antennaPath");
|
||||
}
|
||||
if ((m_settings.m_gainMode != settings.m_gainMode) || force) {
|
||||
reverseAPIKeys.append("gainMode");
|
||||
}
|
||||
if ((m_settings.m_transverterMode != settings.m_transverterMode) || force) {
|
||||
reverseAPIKeys.append("transverterMode");
|
||||
}
|
||||
if ((m_settings.m_transverterDeltaFrequency != settings.m_transverterDeltaFrequency) || force) {
|
||||
reverseAPIKeys.append("transverterDeltaFrequency");
|
||||
}
|
||||
qDebug() << "PlutoSDRInput::applySettings: force: " << force << settings.getDebugString(settingsKeys, force);
|
||||
|
||||
// determine if buddies threads or own thread need to be suspended
|
||||
|
||||
@ -494,12 +412,12 @@ bool PlutoSDRInput::applySettings(const PlutoSDRInputSettings& settings, bool fo
|
||||
// - FIR filter is enabled or disabled
|
||||
// - FIR filter is changed
|
||||
// - LO correction is changed
|
||||
if ((m_settings.m_devSampleRate != settings.m_devSampleRate) ||
|
||||
(m_settings.m_lpfFIREnable != settings.m_lpfFIREnable) ||
|
||||
(m_settings.m_lpfFIRlog2Decim != settings.m_lpfFIRlog2Decim) ||
|
||||
(settings.m_lpfFIRBW != m_settings.m_lpfFIRBW) ||
|
||||
(settings.m_lpfFIRGain != m_settings.m_lpfFIRGain) ||
|
||||
(m_settings.m_LOppmTenths != settings.m_LOppmTenths) || force)
|
||||
if (settingsKeys.contains("devSampleRate") ||
|
||||
settingsKeys.contains("lpfFIREnable") ||
|
||||
settingsKeys.contains("lpfFIRlog2Decim") ||
|
||||
settingsKeys.contains("lpfFIRBW") ||
|
||||
settingsKeys.contains("lpfFIRGain") ||
|
||||
settingsKeys.contains("LOppmTenths") || force)
|
||||
{
|
||||
suspendAllOtherThreads = true;
|
||||
}
|
||||
@ -532,18 +450,18 @@ bool PlutoSDRInput::applySettings(const PlutoSDRInputSettings& settings, bool fo
|
||||
|
||||
// apply settings
|
||||
|
||||
if ((m_settings.m_dcBlock != settings.m_dcBlock) ||
|
||||
(m_settings.m_iqCorrection != settings.m_iqCorrection) || force)
|
||||
if (settingsKeys.contains("dcBlock") ||
|
||||
settingsKeys.contains("iqCorrection") || force)
|
||||
{
|
||||
m_deviceAPI->configureCorrections(settings.m_dcBlock, m_settings.m_iqCorrection);
|
||||
}
|
||||
|
||||
// Change affecting device sample rate chain and other buddies
|
||||
if ((m_settings.m_devSampleRate != settings.m_devSampleRate) ||
|
||||
(m_settings.m_lpfFIREnable != settings.m_lpfFIREnable) ||
|
||||
(m_settings.m_lpfFIRlog2Decim != settings.m_lpfFIRlog2Decim) ||
|
||||
(settings.m_lpfFIRBW != m_settings.m_lpfFIRBW) ||
|
||||
(settings.m_lpfFIRGain != m_settings.m_lpfFIRGain) || force)
|
||||
if (settingsKeys.contains("devSampleRate") ||
|
||||
settingsKeys.contains("lpfFIREnable") ||
|
||||
settingsKeys.contains("lpfFIRlog2Decim") ||
|
||||
settingsKeys.contains("lpfFIRBW") ||
|
||||
settingsKeys.contains("lpfFIRGain") || force)
|
||||
{
|
||||
plutoBox->setFIR(settings.m_devSampleRate, settings.m_lpfFIRlog2Decim, DevicePlutoSDRBox::USE_RX, settings.m_lpfFIRBW, settings.m_lpfFIRGain);
|
||||
plutoBox->setFIREnable(settings.m_lpfFIREnable); // eventually enable/disable FIR
|
||||
@ -561,7 +479,7 @@ bool PlutoSDRInput::applySettings(const PlutoSDRInputSettings& settings, bool fo
|
||||
forwardChangeOwnDSP = (m_settings.m_devSampleRate != settings.m_devSampleRate) || force;
|
||||
}
|
||||
|
||||
if ((m_settings.m_log2Decim != settings.m_log2Decim) || force)
|
||||
if (settingsKeys.contains("log2Decim") || force)
|
||||
{
|
||||
if (m_plutoSDRInputThread)
|
||||
{
|
||||
@ -572,14 +490,14 @@ bool PlutoSDRInput::applySettings(const PlutoSDRInputSettings& settings, bool fo
|
||||
forwardChangeOwnDSP = true;
|
||||
}
|
||||
|
||||
if ((m_settings.m_iqOrder != settings.m_iqOrder) || force)
|
||||
if (settingsKeys.contains("iqOrder") || force)
|
||||
{
|
||||
if (m_plutoSDRInputThread) {
|
||||
m_plutoSDRInputThread->setIQOrder(settings.m_iqOrder);
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_settings.m_LOppmTenths != settings.m_LOppmTenths) || force)
|
||||
if (settingsKeys.contains("LOppmTenths") || force)
|
||||
{
|
||||
plutoBox->setLOPPMTenths(settings.m_LOppmTenths);
|
||||
forwardChangeOtherDSP = true;
|
||||
@ -588,12 +506,12 @@ bool PlutoSDRInput::applySettings(const PlutoSDRInputSettings& settings, bool fo
|
||||
std::vector<std::string> params;
|
||||
bool paramsToSet = false;
|
||||
|
||||
if ((m_settings.m_centerFrequency != settings.m_centerFrequency)
|
||||
|| (m_settings.m_fcPos != settings.m_fcPos)
|
||||
|| (m_settings.m_log2Decim != settings.m_log2Decim)
|
||||
|| (m_settings.m_devSampleRate != settings.m_devSampleRate)
|
||||
|| (m_settings.m_transverterMode != settings.m_transverterMode)
|
||||
|| (m_settings.m_transverterDeltaFrequency != settings.m_transverterDeltaFrequency) || force)
|
||||
if (settingsKeys.contains("centerFrequency")
|
||||
|| settingsKeys.contains("fcPos")
|
||||
|| settingsKeys.contains("log2Decim")
|
||||
|| settingsKeys.contains("devSampleRate")
|
||||
|| settingsKeys.contains("transverterMode")
|
||||
|| settingsKeys.contains("transverterDeltaFrequency") || force)
|
||||
{
|
||||
qint64 deviceCenterFrequency = DeviceSampleSource::calculateDeviceCenterFrequency(
|
||||
settings.m_centerFrequency,
|
||||
@ -608,7 +526,7 @@ bool PlutoSDRInput::applySettings(const PlutoSDRInputSettings& settings, bool fo
|
||||
paramsToSet = true;
|
||||
forwardChangeOwnDSP = true;
|
||||
|
||||
if ((m_settings.m_fcPos != settings.m_fcPos) || force)
|
||||
if (settingsKeys.contains("fcPos") || force)
|
||||
{
|
||||
if (m_plutoSDRInputThread)
|
||||
{
|
||||
@ -618,13 +536,13 @@ bool PlutoSDRInput::applySettings(const PlutoSDRInputSettings& settings, bool fo
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_settings.m_lpfBW != settings.m_lpfBW) || force)
|
||||
if (settingsKeys.contains("lpfBW") || force)
|
||||
{
|
||||
params.push_back(QString(tr("in_voltage_rf_bandwidth=%1").arg(settings.m_lpfBW)).toStdString());
|
||||
paramsToSet = true;
|
||||
}
|
||||
|
||||
if ((m_settings.m_antennaPath != settings.m_antennaPath) || force)
|
||||
if (settingsKeys.contains("antennaPath") || force)
|
||||
{
|
||||
QString rfPortStr;
|
||||
PlutoSDRInputSettings::translateRFPath(settings.m_antennaPath, rfPortStr);
|
||||
@ -632,7 +550,7 @@ bool PlutoSDRInput::applySettings(const PlutoSDRInputSettings& settings, bool fo
|
||||
paramsToSet = true;
|
||||
}
|
||||
|
||||
if ((m_settings.m_gainMode != settings.m_gainMode) || force)
|
||||
if (settingsKeys.contains("gainMode") || force)
|
||||
{
|
||||
QString gainModeStr;
|
||||
PlutoSDRInputSettings::translateGainMode(settings.m_gainMode, gainModeStr);
|
||||
@ -640,25 +558,25 @@ bool PlutoSDRInput::applySettings(const PlutoSDRInputSettings& settings, bool fo
|
||||
paramsToSet = true;
|
||||
}
|
||||
|
||||
if ((m_settings.m_gain != settings.m_gain) || force)
|
||||
if (settingsKeys.contains("gain") || force)
|
||||
{
|
||||
params.push_back(QString(tr("in_voltage0_hardwaregain=%1").arg(settings.m_gain)).toStdString());
|
||||
paramsToSet = true;
|
||||
}
|
||||
|
||||
if ((m_settings.m_hwBBDCBlock != settings.m_hwBBDCBlock) || force)
|
||||
if (settingsKeys.contains("hwBBDCBlock") || force)
|
||||
{
|
||||
params.push_back(QString(tr("in_voltage_bb_dc_offset_tracking_en=%1").arg(settings.m_hwBBDCBlock ? 1 : 0)).toStdString());
|
||||
paramsToSet = true;
|
||||
}
|
||||
|
||||
if ((m_settings.m_hwRFDCBlock != settings.m_hwRFDCBlock) || force)
|
||||
if (settingsKeys.contains("hwRFDCBlock") || force)
|
||||
{
|
||||
params.push_back(QString(tr("in_voltage_rf_dc_offset_tracking_en=%1").arg(settings.m_hwRFDCBlock ? 1 : 0)).toStdString());
|
||||
paramsToSet = true;
|
||||
}
|
||||
|
||||
if ((m_settings.m_hwIQCorrection != settings.m_hwIQCorrection) || force)
|
||||
if (settingsKeys.contains("hwIQCorrection") || force)
|
||||
{
|
||||
params.push_back(QString(tr("in_voltage_quadrature_tracking_en=%1").arg(settings.m_hwIQCorrection ? 1 : 0)).toStdString());
|
||||
paramsToSet = true;
|
||||
@ -669,16 +587,20 @@ bool PlutoSDRInput::applySettings(const PlutoSDRInputSettings& settings, bool fo
|
||||
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) ||
|
||||
(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 (suspendAllOtherThreads)
|
||||
{
|
||||
@ -874,12 +796,12 @@ int PlutoSDRInput::webapiSettingsPutPatch(
|
||||
PlutoSDRInputSettings settings = m_settings;
|
||||
webapiUpdateDeviceSettings(settings, deviceSettingsKeys, response);
|
||||
|
||||
MsgConfigurePlutoSDR *msg = MsgConfigurePlutoSDR::create(settings, force);
|
||||
MsgConfigurePlutoSDR *msg = MsgConfigurePlutoSDR::create(settings, deviceSettingsKeys, force);
|
||||
m_inputMessageQueue.push(msg);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -1035,7 +957,7 @@ void PlutoSDRInput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& respo
|
||||
response.getPlutoSdrInputReport()->setTemperature(getTemperature());
|
||||
}
|
||||
|
||||
void PlutoSDRInput::webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const PlutoSDRInputSettings& settings, bool force)
|
||||
void PlutoSDRInput::webapiReverseSendSettings(const QList<QString>& deviceSettingsKeys, const PlutoSDRInputSettings& settings, bool force)
|
||||
{
|
||||
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
|
||||
swgDeviceSettings->setDirection(0); // single Rx
|
||||
|
@ -42,20 +42,22 @@ public:
|
||||
|
||||
public:
|
||||
const PlutoSDRInputSettings& getSettings() const { return m_settings; }
|
||||
const QList<QString>& getSettingsKeys() const { return m_settingsKeys; }
|
||||
bool getForce() const { return m_force; }
|
||||
|
||||
static MsgConfigurePlutoSDR* create(const PlutoSDRInputSettings& settings, bool force)
|
||||
{
|
||||
return new MsgConfigurePlutoSDR(settings, force);
|
||||
static MsgConfigurePlutoSDR* create(const PlutoSDRInputSettings& settings, const QList<QString>& settingsKeys, bool force) {
|
||||
return new MsgConfigurePlutoSDR(settings, settingsKeys, force);
|
||||
}
|
||||
|
||||
private:
|
||||
PlutoSDRInputSettings m_settings;
|
||||
QList<QString> m_settingsKeys;
|
||||
bool m_force;
|
||||
|
||||
MsgConfigurePlutoSDR(const PlutoSDRInputSettings& settings, bool force) :
|
||||
MsgConfigurePlutoSDR(const PlutoSDRInputSettings& settings, const QList<QString>& settingsKeys, bool force) :
|
||||
Message(),
|
||||
m_settings(settings),
|
||||
m_settingsKeys(settingsKeys),
|
||||
m_force(force)
|
||||
{ }
|
||||
};
|
||||
@ -158,9 +160,9 @@ public:
|
||||
void closeDevice();
|
||||
void suspendBuddies();
|
||||
void resumeBuddies();
|
||||
bool applySettings(const PlutoSDRInputSettings& settings, bool force = false);
|
||||
bool applySettings(const PlutoSDRInputSettings& settings, const QList<QString>& settingsKeys, bool force = false);
|
||||
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response);
|
||||
void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const PlutoSDRInputSettings& settings, bool force);
|
||||
void webapiReverseSendSettings(const QList<QString>& deviceSettingsKeys, const PlutoSDRInputSettings& settings, bool force);
|
||||
void webapiReverseSendStartStop(bool start);
|
||||
|
||||
private slots:
|
||||
|
@ -100,7 +100,10 @@ void PlutoSDRInputGui::destroy()
|
||||
|
||||
void PlutoSDRInputGui::resetToDefaults()
|
||||
{
|
||||
|
||||
m_settings.resetToDefaults();
|
||||
displaySettings();
|
||||
m_forceSettings = true;
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
QByteArray PlutoSDRInputGui::serialize() const
|
||||
@ -115,6 +118,7 @@ bool PlutoSDRInputGui::deserialize(const QByteArray& data)
|
||||
blockApplySettings(true);
|
||||
displaySettings();
|
||||
blockApplySettings(false);
|
||||
m_forceSettings = true;
|
||||
sendSettings(true);
|
||||
return true;
|
||||
}
|
||||
@ -136,7 +140,13 @@ bool PlutoSDRInputGui::handleMessage(const Message& message)
|
||||
if (PlutoSDRInput::MsgConfigurePlutoSDR::match(message))
|
||||
{
|
||||
const PlutoSDRInput::MsgConfigurePlutoSDR& cfg = (PlutoSDRInput::MsgConfigurePlutoSDR&) 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);
|
||||
@ -183,6 +193,7 @@ void PlutoSDRInputGui::on_startStop_toggled(bool checked)
|
||||
void PlutoSDRInputGui::on_centerFrequency_changed(quint64 value)
|
||||
{
|
||||
m_settings.m_centerFrequency = value * 1000;
|
||||
m_settingsKeys.append("centerFrequency");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
@ -190,36 +201,42 @@ void PlutoSDRInputGui::on_loPPM_valueChanged(int value)
|
||||
{
|
||||
ui->loPPMText->setText(QString("%1").arg(QString::number(value/10.0, 'f', 1)));
|
||||
m_settings.m_LOppmTenths = value;
|
||||
m_settingsKeys.append("LOppmTenths");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void PlutoSDRInputGui::on_dcOffset_toggled(bool checked)
|
||||
{
|
||||
m_settings.m_dcBlock = checked;
|
||||
m_settingsKeys.append("dcBlock");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void PlutoSDRInputGui::on_iqImbalance_toggled(bool checked)
|
||||
{
|
||||
m_settings.m_iqCorrection = checked;
|
||||
m_settingsKeys.append("iqCorrection");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void PlutoSDRInputGui::on_rfDCOffset_toggled(bool checked)
|
||||
{
|
||||
m_settings.m_hwRFDCBlock = checked;
|
||||
m_settingsKeys.append("hwRFDCBlock");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void PlutoSDRInputGui::on_bbDCOffset_toggled(bool checked)
|
||||
{
|
||||
m_settings.m_hwBBDCBlock = checked;
|
||||
m_settingsKeys.append("hwBBDCBlock");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void PlutoSDRInputGui::on_hwIQImbalance_toggled(bool checked)
|
||||
{
|
||||
m_settings.m_hwIQCorrection = checked;
|
||||
m_settingsKeys.append("hwIQCorrection");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
@ -234,6 +251,8 @@ void PlutoSDRInputGui::on_swDecim_currentIndexChanged(int index)
|
||||
m_settings.m_devSampleRate <<= m_settings.m_log2Decim;
|
||||
}
|
||||
|
||||
m_settingsKeys.append("log2Decim");
|
||||
m_settingsKeys.append("devSampleRate");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
@ -241,6 +260,7 @@ void PlutoSDRInputGui::on_fcPos_currentIndexChanged(int index)
|
||||
{
|
||||
m_settings.m_fcPos = (PlutoSDRInputSettings::fcPos_t) (index < (int) PlutoSDRInputSettings::FC_POS_END ? index : PlutoSDRInputSettings::FC_POS_CENTER);
|
||||
displayFcTooltip();
|
||||
m_settingsKeys.append("fcPos");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
@ -253,12 +273,14 @@ void PlutoSDRInputGui::on_sampleRate_changed(quint64 value)
|
||||
}
|
||||
|
||||
displayFcTooltip();
|
||||
m_settingsKeys.append("devSampleRate");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void PlutoSDRInputGui::on_lpf_changed(quint64 value)
|
||||
{
|
||||
m_settings.m_lpfBW = value * 1000;
|
||||
m_settingsKeys.append("lpfBW");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
@ -267,12 +289,14 @@ void PlutoSDRInputGui::on_lpFIREnable_toggled(bool checked)
|
||||
m_settings.m_lpfFIREnable = checked;
|
||||
ui->lpFIRDecimation->setEnabled(checked);
|
||||
ui->lpFIRGain->setEnabled(checked);
|
||||
m_settingsKeys.append("lpfFIREnable");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void PlutoSDRInputGui::on_lpFIR_changed(quint64 value)
|
||||
{
|
||||
m_settings.m_lpfFIRBW = value * 1000;
|
||||
m_settingsKeys.append("lpfFIRBW");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
@ -280,12 +304,14 @@ void PlutoSDRInputGui::on_lpFIRDecimation_currentIndexChanged(int index)
|
||||
{
|
||||
m_settings.m_lpfFIRlog2Decim = index > 2 ? 2 : index;
|
||||
setSampleRateLimits();
|
||||
m_settingsKeys.append("lpfFIRlog2Decim");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void PlutoSDRInputGui::on_lpFIRGain_currentIndexChanged(int index)
|
||||
{
|
||||
m_settings.m_lpfFIRGain = 6*(index > 3 ? 3 : index) - 12;
|
||||
m_settingsKeys.append("lpfFIRGain");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
@ -293,6 +319,7 @@ void PlutoSDRInputGui::on_gainMode_currentIndexChanged(int index)
|
||||
{
|
||||
m_settings.m_gainMode = (PlutoSDRInputSettings::GainMode) (index < PlutoSDRInputSettings::GAIN_END ? index : 0);
|
||||
ui->gain->setEnabled(m_settings.m_gainMode == PlutoSDRInputSettings::GAIN_MANUAL);
|
||||
m_settingsKeys.append("gainMode");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
@ -300,12 +327,14 @@ void PlutoSDRInputGui::on_gain_valueChanged(int value)
|
||||
{
|
||||
ui->gainText->setText(tr("%1").arg(value));
|
||||
m_settings.m_gain = value;
|
||||
m_settingsKeys.append("gain");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void PlutoSDRInputGui::on_antenna_currentIndexChanged(int index)
|
||||
{
|
||||
m_settings.m_antennaPath = (PlutoSDRInputSettings::RFPath) (index < PlutoSDRInputSettings::RFPATH_END ? index : 0);
|
||||
m_settingsKeys.append("antennaPath");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
@ -317,6 +346,10 @@ void PlutoSDRInputGui::on_transverter_clicked()
|
||||
qDebug("PlutoSDRInputGui::on_transverter_clicked: %lld Hz %s", m_settings.m_transverterDeltaFrequency, m_settings.m_transverterMode ? "on" : "off");
|
||||
updateFrequencyLimits();
|
||||
m_settings.m_centerFrequency = ui->centerFrequency->getValueNew()*1000;
|
||||
m_settingsKeys.append("transverterMode");
|
||||
m_settingsKeys.append("transverterDeltaFrequency");
|
||||
m_settingsKeys.append("iqOrder");
|
||||
m_settingsKeys.append("centerFrequency");
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
@ -417,9 +450,10 @@ void PlutoSDRInputGui::updateHardware()
|
||||
if (m_doApplySettings)
|
||||
{
|
||||
qDebug() << "PlutoSDRInputGui::updateHardware";
|
||||
PlutoSDRInput::MsgConfigurePlutoSDR* message = PlutoSDRInput::MsgConfigurePlutoSDR::create(m_settings, m_forceSettings);
|
||||
PlutoSDRInput::MsgConfigurePlutoSDR* message = PlutoSDRInput::MsgConfigurePlutoSDR::create(m_settings, m_settingsKeys, m_forceSettings);
|
||||
m_sampleSource->getInputMessageQueue()->push(message);
|
||||
m_forceSettings = false;
|
||||
m_settingsKeys.clear();
|
||||
m_updateTimer.stop();
|
||||
}
|
||||
}
|
||||
@ -583,6 +617,10 @@ void PlutoSDRInputGui::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();
|
||||
}
|
||||
|
@ -54,6 +54,7 @@ protected:
|
||||
private:
|
||||
Ui::PlutoSDRInputGUI* ui;
|
||||
PlutoSDRInputSettings m_settings;
|
||||
QList<QString> m_settingsKeys;
|
||||
bool m_sampleRateMode; //!< true: device, false: base band sample rate update mode
|
||||
bool m_forceSettings;
|
||||
QTimer m_updateTimer;
|
||||
|
@ -232,3 +232,165 @@ void PlutoSDRInputSettings::translateGainMode(GainMode mode, QString& s)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PlutoSDRInputSettings::applySettings(const QStringList& settingsKeys, const PlutoSDRInputSettings& settings)
|
||||
{
|
||||
if (settingsKeys.contains("centerFrequency")) {
|
||||
m_centerFrequency = settings.m_centerFrequency;
|
||||
}
|
||||
if (settingsKeys.contains("fcPos")) {
|
||||
m_fcPos = settings.m_fcPos;
|
||||
}
|
||||
if (settingsKeys.contains("LOppmTenths")) {
|
||||
m_LOppmTenths = settings.m_LOppmTenths;
|
||||
}
|
||||
if (settingsKeys.contains("log2Decim")) {
|
||||
m_log2Decim = settings.m_log2Decim;
|
||||
}
|
||||
if (settingsKeys.contains("devSampleRate")) {
|
||||
m_devSampleRate = settings.m_devSampleRate;
|
||||
}
|
||||
if (settingsKeys.contains("dcBlock")) {
|
||||
m_dcBlock = settings.m_dcBlock;
|
||||
}
|
||||
if (settingsKeys.contains("iqCorrection")) {
|
||||
m_iqCorrection = settings.m_iqCorrection;
|
||||
}
|
||||
if (settingsKeys.contains("hwBBDCBlock")) {
|
||||
m_hwBBDCBlock = settings.m_hwBBDCBlock;
|
||||
}
|
||||
if (settingsKeys.contains("hwRFDCBlock")) {
|
||||
m_hwRFDCBlock = settings.m_hwRFDCBlock;
|
||||
}
|
||||
if (settingsKeys.contains("hwIQCorrection")) {
|
||||
m_hwIQCorrection = settings.m_hwIQCorrection;
|
||||
}
|
||||
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("lpfFIRlog2Decim")) {
|
||||
m_lpfFIRlog2Decim = settings.m_lpfFIRlog2Decim;
|
||||
}
|
||||
if (settingsKeys.contains("lpfFIRGain")) {
|
||||
m_lpfFIRGain = settings.m_lpfFIRGain;
|
||||
}
|
||||
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("transverterMode")) {
|
||||
m_transverterMode = settings.m_transverterMode;
|
||||
}
|
||||
if (settingsKeys.contains("transverterDeltaFrequency")) {
|
||||
m_transverterDeltaFrequency = settings.m_transverterDeltaFrequency;
|
||||
}
|
||||
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 PlutoSDRInputSettings::getDebugString(const QStringList& settingsKeys, bool force) const
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
|
||||
if (settingsKeys.contains("centerFrequency") || force) {
|
||||
ostr << " m_centerFrequency: " << m_centerFrequency;
|
||||
}
|
||||
if (settingsKeys.contains("fcPos") || force) {
|
||||
ostr << " m_fcPos: " << m_fcPos;
|
||||
}
|
||||
if (settingsKeys.contains("LOppmTenths") || force) {
|
||||
ostr << " m_LOppmTenths: " << m_LOppmTenths;
|
||||
}
|
||||
if (settingsKeys.contains("log2Decim") || force) {
|
||||
ostr << " m_log2Decim: " << m_log2Decim;
|
||||
}
|
||||
if (settingsKeys.contains("devSampleRate") || force) {
|
||||
ostr << " m_devSampleRate: " << m_devSampleRate;
|
||||
}
|
||||
if (settingsKeys.contains("dcBlock") || force) {
|
||||
ostr << " m_dcBlock: " << m_dcBlock;
|
||||
}
|
||||
if (settingsKeys.contains("iqCorrection") || force) {
|
||||
ostr << " m_iqCorrection: " << m_iqCorrection;
|
||||
}
|
||||
if (settingsKeys.contains("hwBBDCBlock") || force) {
|
||||
ostr << " m_hwBBDCBlock: " << m_hwBBDCBlock;
|
||||
}
|
||||
if (settingsKeys.contains("hwRFDCBlock") || force) {
|
||||
ostr << " m_hwRFDCBlock: " << m_hwRFDCBlock;
|
||||
}
|
||||
if (settingsKeys.contains("hwIQCorrection") || force) {
|
||||
ostr << " m_hwIQCorrection: " << m_hwIQCorrection;
|
||||
}
|
||||
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("lpfFIRlog2Decim") || force) {
|
||||
ostr << " m_lpfFIRlog2Decim: " << m_lpfFIRlog2Decim;
|
||||
}
|
||||
if (settingsKeys.contains("lpfFIRGain") || force) {
|
||||
ostr << " m_lpfFIRGain: " << m_lpfFIRGain;
|
||||
}
|
||||
if (settingsKeys.contains("gain") || force) {
|
||||
ostr << " m_gain: " << m_gain;
|
||||
}
|
||||
if (settingsKeys.contains("antennaPath") || force) {
|
||||
ostr << " m_antennaPath: " << m_antennaPath;
|
||||
}
|
||||
if (settingsKeys.contains("gainMode") || force) {
|
||||
ostr << " m_gainMode: " << m_gainMode;
|
||||
}
|
||||
if (settingsKeys.contains("transverterMode") || force) {
|
||||
ostr << " m_transverterMode: " << m_transverterMode;
|
||||
}
|
||||
if (settingsKeys.contains("transverterDeltaFrequency") || force) {
|
||||
ostr << " m_transverterDeltaFrequency: " << m_transverterDeltaFrequency;
|
||||
}
|
||||
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());
|
||||
}
|
||||
|
@ -90,6 +90,8 @@ struct PlutoSDRInputSettings {
|
||||
bool deserialize(const QByteArray& data);
|
||||
static void translateRFPath(RFPath path, QString& s);
|
||||
static void translateGainMode(GainMode mod, QString& s);
|
||||
void applySettings(const QStringList& settingsKeys, const PlutoSDRInputSettings& settings);
|
||||
QString getDebugString(const QStringList& settingsKeys, bool force=false) const;
|
||||
};
|
||||
|
||||
#endif /* _PLUTOSDR_PLUTOSDRINPUTSETTINGS_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user