mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-01 21:54:55 -04:00
SoapySDR support: input: antenna selection GUI
This commit is contained in:
@@ -209,6 +209,24 @@ const SoapySDR::RangeList& SoapySDRInput::getRateRanges()
|
||||
return channelSettings->m_ratesRanges;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& SoapySDRInput::getAntennas()
|
||||
{
|
||||
const DeviceSoapySDRParams::ChannelSettings* channelSettings = m_deviceShared.m_deviceParams->getRxChannelSettings(m_deviceShared.m_channel);
|
||||
return channelSettings->m_antennas;
|
||||
}
|
||||
|
||||
int SoapySDRInput::getAntennaIndex(const std::string& antenna)
|
||||
{
|
||||
const std::vector<std::string>& antennaList = getAntennas();
|
||||
std::vector<std::string>::const_iterator it = std::find(antennaList.begin(), antennaList.end(), antenna);
|
||||
|
||||
if (it == antennaList.end()) {
|
||||
return -1;
|
||||
} else {
|
||||
return it - antennaList.begin();
|
||||
}
|
||||
}
|
||||
|
||||
void SoapySDRInput::init()
|
||||
{
|
||||
applySettings(m_settings, true);
|
||||
@@ -745,6 +763,23 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_settings.m_antenna != settings.m_antenna) || force)
|
||||
{
|
||||
if (dev != 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
dev->setAntenna(SOAPY_SDR_RX, requestedChannel, settings.m_antenna.toStdString());
|
||||
qDebug("SoapySDRInput::applySettings: set antenna to %s", settings.m_antenna.toStdString().c_str());
|
||||
}
|
||||
catch (const std::exception &ex)
|
||||
{
|
||||
qCritical("SoapySDRInput::applySettings: cannot set antenna to %s: %s",
|
||||
settings.m_antenna.toStdString().c_str(), ex.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (forwardChangeOwnDSP)
|
||||
{
|
||||
int sampleRate = settings.m_devSampleRate/(1<<settings.m_log2Decim);
|
||||
@@ -793,7 +828,8 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
|
||||
<< " m_fcPos: " << m_settings.m_fcPos
|
||||
<< " m_devSampleRate: " << m_settings.m_devSampleRate
|
||||
<< " m_dcBlock: " << m_settings.m_dcBlock
|
||||
<< " m_iqCorrection: " << m_settings.m_iqCorrection;
|
||||
<< " m_iqCorrection: " << m_settings.m_iqCorrection
|
||||
<< " m_antenna: " << m_settings.m_antenna;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -122,6 +122,8 @@ public:
|
||||
|
||||
void getFrequencyRange(uint64_t& min, uint64_t& max);
|
||||
const SoapySDR::RangeList& getRateRanges();
|
||||
const std::vector<std::string>& getAntennas();
|
||||
int getAntennaIndex(const std::string& antenna);
|
||||
|
||||
private:
|
||||
DeviceSourceAPI *m_deviceAPI;
|
||||
|
||||
@@ -49,6 +49,7 @@ SoapySDRInputGui::SoapySDRInputGui(DeviceUISet *deviceUISet, QWidget* parent) :
|
||||
ui->centerFrequency->setValueRange(7, f_min/1000, f_max/1000);
|
||||
|
||||
createRangesControl(m_sampleSource->getRateRanges(), "SR", "kS/s");
|
||||
createAntennasControl(m_sampleSource->getAntennas());
|
||||
|
||||
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
|
||||
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
|
||||
@@ -92,7 +93,7 @@ void SoapySDRInputGui::createRangesControl(const SoapySDR::RangeList& rangeList,
|
||||
|
||||
if (rangeDiscrete)
|
||||
{
|
||||
DiscreteRangeGUI *rangeGUI = new DiscreteRangeGUI(ui->scrollAreaWidgetContents);
|
||||
DiscreteRangeGUI *rangeGUI = new DiscreteRangeGUI(this);
|
||||
rangeGUI->setLabel(text);
|
||||
rangeGUI->setUnits(unit);
|
||||
|
||||
@@ -101,6 +102,9 @@ void SoapySDRInputGui::createRangesControl(const SoapySDR::RangeList& rangeList,
|
||||
}
|
||||
|
||||
m_sampleRateGUI = rangeGUI;
|
||||
QVBoxLayout *layout = (QVBoxLayout *) ui->scrollAreaWidgetContents->layout();
|
||||
layout->addWidget(rangeGUI);
|
||||
|
||||
connect(m_sampleRateGUI, SIGNAL(valueChanged(double)), this, SLOT(sampleRateChanged(double)));
|
||||
// QHBoxLayout *layout = new QHBoxLayout();
|
||||
// QLabel *rangeLabel = new QLabel();
|
||||
@@ -140,10 +144,29 @@ void SoapySDRInputGui::createRangesControl(const SoapySDR::RangeList& rangeList,
|
||||
rangeGUI->reset();
|
||||
|
||||
m_sampleRateGUI = rangeGUI;
|
||||
QVBoxLayout *layout = (QVBoxLayout *) ui->scrollAreaWidgetContents->layout();
|
||||
layout->addWidget(rangeGUI);
|
||||
|
||||
connect(m_sampleRateGUI, SIGNAL(valueChanged(double)), this, SLOT(sampleRateChanged(double)));
|
||||
}
|
||||
}
|
||||
|
||||
void SoapySDRInputGui::createAntennasControl(const std::vector<std::string>& antennaList)
|
||||
{
|
||||
m_antennas = new StringRangeGUI(this);
|
||||
m_antennas->setLabel(QString("Antenna"));
|
||||
m_antennas->setUnits(QString("Port"));
|
||||
|
||||
for (const auto &it : antennaList) {
|
||||
m_antennas->addItem(QString(it.c_str()), it);
|
||||
}
|
||||
|
||||
QVBoxLayout *layout = (QVBoxLayout *) ui->scrollAreaWidgetContents->layout();
|
||||
layout->addWidget(m_antennas);
|
||||
|
||||
connect(m_antennas, SIGNAL(valueChanged()), this, SLOT(antennasChanged()));
|
||||
}
|
||||
|
||||
void SoapySDRInputGui::setName(const QString& name)
|
||||
{
|
||||
setObjectName(name);
|
||||
@@ -252,6 +275,14 @@ void SoapySDRInputGui::sampleRateChanged(double sampleRate)
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void SoapySDRInputGui::antennasChanged()
|
||||
{
|
||||
const std::string& antennaStr = m_antennas->getCurrentValue();
|
||||
m_settings.m_antenna = QString(antennaStr.c_str());
|
||||
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void SoapySDRInputGui::on_centerFrequency_changed(quint64 value)
|
||||
{
|
||||
m_settings.m_centerFrequency = value * 1000;
|
||||
@@ -346,6 +377,8 @@ void SoapySDRInputGui::displaySettings()
|
||||
ui->LOppm->setValue(m_settings.m_LOppmTenths);
|
||||
ui->LOppmText->setText(QString("%1").arg(QString::number(m_settings.m_LOppmTenths/10.0, 'f', 1)));
|
||||
|
||||
m_antennas->setValue(m_settings.m_antenna.toStdString());
|
||||
|
||||
blockApplySettings(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,12 +17,13 @@
|
||||
#ifndef PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_SOAPYSDRINPUTGUI_H_
|
||||
#define PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_SOAPYSDRINPUTGUI_H_
|
||||
|
||||
#include <soapygui/stringrangegui.h>
|
||||
#include <QTimer>
|
||||
#include <QWidget>
|
||||
#include <QComboBox>
|
||||
|
||||
#include "plugin/plugininstancegui.h"
|
||||
#include "util/messagequeue.h"
|
||||
|
||||
#include "soapysdrinput.h"
|
||||
|
||||
class DeviceUISet;
|
||||
@@ -53,6 +54,8 @@ public:
|
||||
|
||||
private:
|
||||
void createRangesControl(const SoapySDR::RangeList& rangeList, const QString& text, const QString& unit);
|
||||
void createAntennasControl(const std::vector<std::string>& antennaList);
|
||||
|
||||
Ui::SoapySDRInputGui* ui;
|
||||
|
||||
DeviceUISet* m_deviceUISet;
|
||||
@@ -68,6 +71,7 @@ private:
|
||||
MessageQueue m_inputMessageQueue;
|
||||
|
||||
ItemSettingGUI *m_sampleRateGUI;
|
||||
StringRangeGUI *m_antennas;
|
||||
|
||||
void displaySettings();
|
||||
void sendSettings();
|
||||
@@ -81,6 +85,7 @@ private slots:
|
||||
void on_centerFrequency_changed(quint64 value);
|
||||
void on_LOppm_valueChanged(int value);
|
||||
void sampleRateChanged(double sampleRate);
|
||||
void antennasChanged();
|
||||
void on_dcOffset_toggled(bool checked);
|
||||
void on_iqImbalance_toggled(bool checked);
|
||||
void on_decim_currentIndexChanged(int index);
|
||||
|
||||
@@ -382,8 +382,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>304</width>
|
||||
<height>120</height>
|
||||
<width>318</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
@@ -402,143 +402,6 @@
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Data1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Kiki</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="horizontalSlider">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>0.0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Tata</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Zozo</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_2"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
@@ -35,6 +35,7 @@ void SoapySDRInputSettings::resetToDefaults()
|
||||
m_transverterMode = false;
|
||||
m_transverterDeltaFrequency = 0;
|
||||
m_fileRecordName = "";
|
||||
m_antenna = "NONE";
|
||||
}
|
||||
|
||||
QByteArray SoapySDRInputSettings::serialize() const
|
||||
@@ -49,6 +50,7 @@ QByteArray SoapySDRInputSettings::serialize() const
|
||||
s.writeS32(6, m_LOppmTenths);
|
||||
s.writeBool(7, m_transverterMode);
|
||||
s.writeS64(8, m_transverterDeltaFrequency);
|
||||
s.writeString(9, m_antenna);
|
||||
|
||||
return s.final();
|
||||
}
|
||||
@@ -76,6 +78,7 @@ bool SoapySDRInputSettings::deserialize(const QByteArray& data)
|
||||
d.readS32(6, &m_LOppmTenths);
|
||||
d.readBool(7, &m_transverterMode, false);
|
||||
d.readS64(8, &m_transverterDeltaFrequency, 0);
|
||||
d.readString(9, &m_antenna, "NONE");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ struct SoapySDRInputSettings {
|
||||
bool m_transverterMode;
|
||||
qint64 m_transverterDeltaFrequency;
|
||||
QString m_fileRecordName;
|
||||
QString m_antenna;
|
||||
|
||||
SoapySDRInputSettings();
|
||||
void resetToDefaults();
|
||||
|
||||
Reference in New Issue
Block a user