提交 86388722 编写于 作者: M manjaro

Add channel selection

上级 a0742c64
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
specWidget::specWidget(QWidget *parent) : specWidget::specWidget(QWidget *parent) :
QWidget(parent), QWidget(parent),
ui(new Ui::specWidget), ui(new Ui::specWidget),
m_runth(new uhd_io_thread(this)) m_runth(new uhd_io_thread(this)),
m_attenMod(new QStandardItemModel(this))
{ {
ui->setupUi(this); ui->setupUi(this);
Bookmarks::create(); Bookmarks::create();
...@@ -20,13 +21,15 @@ specWidget::specWidget(QWidget *parent) : ...@@ -20,13 +21,15 @@ specWidget::specWidget(QWidget *parent) :
//选择带宽 //选择带宽
ui->plotter->setFilterBoxEnabled(true); ui->plotter->setFilterBoxEnabled(true);
//中心频率
//ui->plotter->setCenterFreq(101700000);
//选择频率
//ui->plotter->setDemodCenterFreq(102300000);
ui->plotter->setTooltipsEnabled(true); ui->plotter->setTooltipsEnabled(true);
ui->plotter->setPeakDetection(false,128.0); ui->plotter->setPeakDetection(false,128.0);
m_attenMod->appendRow(new QStandardItem("TX/RX"));
m_attenMod->appendRow(new QStandardItem("RX2"));
m_attenMod->appendRow(new QStandardItem("RX"));
m_attenMod->appendRow(new QStandardItem("TX"));
ui->comboBox_atn->setModel(m_attenMod);
//连接 //连接
//connect (ui->plotter,&CPlotter::newDemodFreq,ui->freqCtrl,&CFreqCtrl::setFrequency); //connect (ui->plotter,&CPlotter::newDemodFreq,ui->freqCtrl,&CFreqCtrl::setFrequency);
...@@ -199,8 +202,22 @@ bool specWidget::saveWaterfall(const QString & filename) ...@@ -199,8 +202,22 @@ bool specWidget::saveWaterfall(const QString & filename)
void specWidget::on_pushButton_reset_clicked() void specWidget::on_pushButton_reset_clicked()
{ {
saveSettings(); saveSettings();
loadSettings(); if (m_runth->isRunning())
resetFFT(); {
if (m_nTimerID>=0)
killTimer(m_nTimerID);
if (usrp)
{
close_device();
}
ui->pushButton_reset->setText(tr("Start"));
}
else
{
loadSettings();
resetFFT();
}
} }
void specWidget::loadSettings() void specWidget::loadSettings()
...@@ -286,6 +303,8 @@ void specWidget::freeFFT() ...@@ -286,6 +303,8 @@ void specWidget::freeFFT()
} }
void specWidget::resetFFT() void specWidget::resetFFT()
{ {
ui->pushButton_reset->setText(tr("Start"));
m_channel = ui->spinBox_chan->value();
freeFFT(); freeFFT();
m_pFFTIn = (fftw_complex *) fftw_malloc(sizeof(fftw_complex) * m_nFFTSize); m_pFFTIn = (fftw_complex *) fftw_malloc(sizeof(fftw_complex) * m_nFFTSize);
m_pFFTOut = (fftw_complex *) fftw_malloc(sizeof(fftw_complex) * m_nFFTSize); m_pFFTOut = (fftw_complex *) fftw_malloc(sizeof(fftw_complex) * m_nFFTSize);
...@@ -312,7 +331,9 @@ void specWidget::resetFFT() ...@@ -312,7 +331,9 @@ void specWidget::resetFFT()
setSampleRate(getSampleRate()); setSampleRate(getSampleRate());
setCenterFreq(ui->plotter->getCenterFreq()); setCenterFreq(ui->plotter->getCenterFreq());
QString atn = ui->comboBox_atn->currentText();
if (atn.size())
usrp->set_rx_antenna(atn.toStdString(),m_channel);
if (m_runth->isRunning()) if (m_runth->isRunning())
{ {
stop_signal_called = true; stop_signal_called = true;
...@@ -324,7 +345,7 @@ void specWidget::resetFFT() ...@@ -324,7 +345,7 @@ void specWidget::resetFFT()
}); });
m_runth->start(); m_runth->start();
m_nTimerID = startTimer(updateIntelv); m_nTimerID = startTimer(updateIntelv);
ui->pushButton_reset->setText(tr("Stop"));
} }
void specWidget::appendWavComplex(const double (* pWav)[2], const int count, double voltage_ref) void specWidget::appendWavComplex(const double (* pWav)[2], const int count, double voltage_ref)
...@@ -390,7 +411,15 @@ void specWidget::timerEvent(QTimerEvent * e) ...@@ -390,7 +411,15 @@ void specWidget::timerEvent(QTimerEvent * e)
ui->sMeter->setLevel(m_dFFTAmp[m_nCurrentCenter]); ui->sMeter->setLevel(m_dFFTAmp[m_nCurrentCenter]);
//ui->sMeter->setSqlLevel(m_dFFTAmp[m_nCurrentCenter]); //ui->sMeter->setSqlLevel(m_dFFTAmp[m_nCurrentCenter]);
} }
static int ccct = 0;
if (++ccct % 10==0)
{
if (!m_runth->isRunning())
ui->pushButton_reset->setText(tr("Start"));
else
ui->pushButton_reset->setText(tr("Stop"));
}
} }
} }
...@@ -437,3 +466,17 @@ void specWidget::on_doubleSpinBox_range_min_valueChanged(double arg1) ...@@ -437,3 +466,17 @@ void specWidget::on_doubleSpinBox_range_min_valueChanged(double arg1)
{ {
ui->plotter->setWaterfallRange(ui->doubleSpinBox_range_min->value(),ui->doubleSpinBox_range_max->value()); ui->plotter->setWaterfallRange(ui->doubleSpinBox_range_min->value(),ui->doubleSpinBox_range_max->value());
} }
void specWidget::on_comboBox_atn_currentIndexChanged(const QString &arg1)
{
if (arg1.size())
{
if (usrp)
usrp->set_rx_antenna(arg1.toStdString(),m_channel);
}
}
void specWidget::on_spinBox_chan_valueChanged(int arg1)
{
m_channel = arg1;
}
...@@ -103,6 +103,10 @@ private slots: ...@@ -103,6 +103,10 @@ private slots:
void on_doubleSpinBox_range_min_valueChanged(double arg1); void on_doubleSpinBox_range_min_valueChanged(double arg1);
void on_comboBox_atn_currentIndexChanged(const QString &arg1);
void on_spinBox_chan_valueChanged(int arg1);
private: private:
void loadSettings(); void loadSettings();
void saveSettings(); void saveSettings();
...@@ -110,6 +114,7 @@ private: ...@@ -110,6 +114,7 @@ private:
void freeFFT(); void freeFFT();
private: private:
Ui::specWidget *ui = nullptr; Ui::specWidget *ui = nullptr;
QStandardItemModel * m_attenMod = nullptr;
private: private:
int m_nFFTSize = 16384; int m_nFFTSize = 16384;
std::vector<double> m_dHammingWnd; std::vector<double> m_dHammingWnd;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>738</width> <width>787</width>
<height>466</height> <height>466</height>
</rect> </rect>
</property> </property>
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
<item> <item>
<widget class="QPushButton" name="pushButton_reset"> <widget class="QPushButton" name="pushButton_reset">
<property name="text"> <property name="text">
<string>Apply</string> <string>Start</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset> <iconset>
...@@ -241,14 +241,14 @@ ...@@ -241,14 +241,14 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>310</width> <width>310</width>
<height>380</height> <height>348</height>
</rect> </rect>
</property> </property>
<attribute name="label"> <attribute name="label">
<string>Radio</string> <string>Radio</string>
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<item row="4" column="1"> <item row="7" column="1">
<spacer name="verticalSpacer_2"> <spacer name="verticalSpacer_2">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
...@@ -261,7 +261,26 @@ ...@@ -261,7 +261,26 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="1" column="1"> <item row="0" column="1">
<widget class="QLineEdit" name="lineEdit_dev"/>
</item>
<item row="4" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_spr">
<property name="decimals">
<number>6</number>
</property>
<property name="minimum">
<double>0.000001000000000</double>
</property>
<property name="maximum">
<double>1024.000000000000000</double>
</property>
<property name="value">
<double>10.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_center"> <widget class="QDoubleSpinBox" name="doubleSpinBox_center">
<property name="decimals"> <property name="decimals">
<number>6</number> <number>6</number>
...@@ -277,36 +296,41 @@ ...@@ -277,36 +296,41 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="5" column="0">
<widget class="QLineEdit" name="lineEdit_dev"/> <widget class="QLabel" name="label_5">
<property name="text">
<string>Gain</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QSpinBox" name="spinBox_gain"/>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="spinBox_chan">
<property name="maximum">
<number>1</number>
</property>
</widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_6">
<property name="text"> <property name="text">
<string>Center Freq(Mhz)</string> <string>Channel</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="4" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>Sample Rate(Mhz)</string> <string>Sample Rate(Mhz)</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="3" column="0">
<widget class="QDoubleSpinBox" name="doubleSpinBox_spr"> <widget class="QLabel" name="label_2">
<property name="decimals"> <property name="text">
<number>6</number> <string>Center Freq(Mhz)</string>
</property>
<property name="minimum">
<double>0.000001000000000</double>
</property>
<property name="maximum">
<double>1024.000000000000000</double>
</property>
<property name="value">
<double>10.000000000000000</double>
</property> </property>
</widget> </widget>
</item> </item>
...@@ -317,15 +341,19 @@ ...@@ -317,15 +341,19 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="2" column="0">
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="label_10">
<property name="text"> <property name="text">
<string>Gain</string> <string>Antenna</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="2" column="1">
<widget class="QSpinBox" name="spinBox_gain"/> <widget class="QComboBox" name="comboBox_atn">
<property name="editable">
<bool>false</bool>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
...@@ -493,6 +521,19 @@ ...@@ -493,6 +521,19 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="save">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>310</width>
<height>348</height>
</rect>
</property>
<attribute name="label">
<string>Save</string>
</attribute>
</widget>
</widget> </widget>
</item> </item>
</layout> </layout>
......
...@@ -108,7 +108,7 @@ void uhd_device::run_IO() ...@@ -108,7 +108,7 @@ void uhd_device::run_IO()
{ {
//创建流对象实例 //创建流对象实例
uhd::stream_args_t stream_args_rx("sc16", "sc16"); uhd::stream_args_t stream_args_rx("sc16", "sc16");
stream_args_rx.channels.push_back(0); stream_args_rx.channels.push_back(m_channel);
rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args_rx); rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args_rx);
rx_count = 0; rx_count = 0;
......
...@@ -3,7 +3,7 @@ QT += core gui network ...@@ -3,7 +3,7 @@ QT += core gui network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11 CONFIG += c++11
CONFIG += console
# The following define makes your compiler emit warnings if you use # The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings # any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the # depend on your compiler). Please consult the documentation of the
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册