提交 334517de 编写于 作者: M manjaro

界面改进

上级 17d75488
...@@ -9,7 +9,10 @@ int main(int argc, char *argv[]) ...@@ -9,7 +9,10 @@ int main(int argc, char *argv[])
{ {
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
nice(0); nice(0);
#else
QThread::currentThread()->setPriority(QThread::HighestPriority);
#endif #endif
QApplication a(argc, argv); QApplication a(argc, argv);
//Install translators //Install translators
QTranslator qtTranslator; QTranslator qtTranslator;
......
...@@ -72,8 +72,8 @@ int gettimeofday(struct timeval * tp, struct timezone * tzp) ...@@ -72,8 +72,8 @@ int gettimeofday(struct timeval * tp, struct timezone * tzp)
#define CUR_CUT_DELTA 5 //cursor capture delta in pixels #define CUR_CUT_DELTA 5 //cursor capture delta in pixels
#define FFT_MIN_DB -160.0 #define FFT_MIN_DB -300.0
#define FFT_MAX_DB 0.0 #define FFT_MAX_DB 30.0
// Colors of type QRgb in 0xAARRGGBB format (unsigned int) // Colors of type QRgb in 0xAARRGGBB format (unsigned int)
#define PLOTTER_BGD_COLOR 0xFF1F1D1D #define PLOTTER_BGD_COLOR 0xFF1F1D1D
......
...@@ -699,7 +699,10 @@ void specWidget::on_comboBox_fftSize_activated(int index) ...@@ -699,7 +699,10 @@ void specWidget::on_comboBox_fftSize_activated(int index)
if (m_nFFTSize<128) if (m_nFFTSize<128)
m_nFFTSize = 128; m_nFFTSize = 128;
if (usrp) if (usrp)
resetProgram(); {
freeFFTW();
initFFTW();
}
saveSettings(); saveSettings();
} }
......
...@@ -38,6 +38,7 @@ uhd_device::uhd_device() ...@@ -38,6 +38,7 @@ uhd_device::uhd_device()
:stop_signal_called(false) :stop_signal_called(false)
,m_rx_streaming(false) ,m_rx_streaming(false)
,m_rx_points(0) ,m_rx_points(0)
,m_initThread (new uhd_io_thread(0))
{ {
m_data_iq_rx = new short [m_rx_bufsz+1024*1024][2]{{0,0}}; m_data_iq_rx = new short [m_rx_bufsz+1024*1024][2]{{0,0}};
m_data_iq_tx = new short [m_tx_bufsz+1024*1024][2]{{0,0}}; m_data_iq_tx = new short [m_tx_bufsz+1024*1024][2]{{0,0}};
...@@ -48,6 +49,7 @@ uhd_device::uhd_device(const std::string &args) ...@@ -48,6 +49,7 @@ uhd_device::uhd_device(const std::string &args)
,m_rx_streaming(false) ,m_rx_streaming(false)
,m_dev_args (args) ,m_dev_args (args)
,m_rx_points(0) ,m_rx_points(0)
,m_initThread (new uhd_io_thread(0))
{ {
m_data_iq_rx = new short [m_rx_bufsz+1024*1024][2]{{0,0}}; m_data_iq_rx = new short [m_rx_bufsz+1024*1024][2]{{0,0}};
...@@ -56,6 +58,8 @@ uhd_device::uhd_device(const std::string &args) ...@@ -56,6 +58,8 @@ uhd_device::uhd_device(const std::string &args)
uhd_device::~uhd_device() uhd_device::~uhd_device()
{ {
stop_signal_called = true; stop_signal_called = true;
m_initThread->terminate();
m_initThread->deleteLater();
while (m_rx_streaming) while (m_rx_streaming)
{ {
QThread::msleep(100); QThread::msleep(100);
...@@ -80,7 +84,7 @@ bool uhd_device::open_device() ...@@ -80,7 +84,7 @@ bool uhd_device::open_device()
{ {
string ref = "internal"; string ref = "internal";
std::atomic<bool> finished(false); std::atomic<bool> finished(false);
std::thread thr([&]()->void{ m_initThread->setRunner([&]()->void{
try{ try{
usrp = multi_usrp::make(m_dev_args); usrp = multi_usrp::make(m_dev_args);
} }
...@@ -91,12 +95,11 @@ bool uhd_device::open_device() ...@@ -91,12 +95,11 @@ bool uhd_device::open_device()
finished = true; finished = true;
}); });
while (!finished) m_initThread->start();
while (!m_initThread->wait(100))
{ {
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
QThread::msleep(20);
} }
thr.join();
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <atomic> #include <atomic>
#include <QThread> #include <QThread>
#include <string> #include <string>
#include <QAtomicInteger>
class uhd_io_thread: public QThread{ class uhd_io_thread: public QThread{
Q_OBJECT Q_OBJECT
public: public:
...@@ -40,6 +41,7 @@ public: ...@@ -40,6 +41,7 @@ public:
void run_RxIO(); void run_RxIO();
void run_TxIO(); void run_TxIO();
protected: protected:
uhd_io_thread * m_initThread;
std::atomic<bool> stop_signal_called; std::atomic<bool> stop_signal_called;
std::atomic<bool> m_rx_streaming; std::atomic<bool> m_rx_streaming;
std::atomic<bool> m_tx_streaming; std::atomic<bool> m_tx_streaming;
...@@ -53,11 +55,11 @@ protected: ...@@ -53,11 +55,11 @@ protected:
//初始化队列 //初始化队列
short (*m_data_iq_rx)[2] = nullptr; short (*m_data_iq_rx)[2] = nullptr;
short (*m_data_iq_tx)[2] = nullptr; short (*m_data_iq_tx)[2] = nullptr;
size_t m_rx_bufsz = 1024*1024*4; size_t m_rx_bufsz = 1024*1024;
size_t m_tx_bufsz = 1024*1024*4; size_t m_tx_bufsz = 1024*1024;
//收发计数 //收发计数
unsigned long long m_rx_points = 0; QAtomicInteger<unsigned long long> m_rx_points = 0;
unsigned long long m_tx_points = 0; QAtomicInteger<unsigned long long> m_tx_points = 0;
public: public:
quint64 set_rx_freq(const quint64 freq_in_hz); quint64 set_rx_freq(const quint64 freq_in_hz);
double set_rx_rate(const double sprate); double set_rx_rate(const double sprate);
......
...@@ -44,6 +44,7 @@ uhd_device::uhd_device() ...@@ -44,6 +44,7 @@ uhd_device::uhd_device()
:stop_signal_called(false) :stop_signal_called(false)
,m_rx_streaming(false) ,m_rx_streaming(false)
,m_rx_points(0) ,m_rx_points(0)
,m_initThread (new uhd_io_thread(0))
{ {
m_data_iq_rx = new short [m_rx_bufsz+1024*1024][2]{{0,0}}; m_data_iq_rx = new short [m_rx_bufsz+1024*1024][2]{{0,0}};
m_data_iq_tx = new short [m_tx_bufsz+1024*1024][2]{{0,0}}; m_data_iq_tx = new short [m_tx_bufsz+1024*1024][2]{{0,0}};
...@@ -54,7 +55,7 @@ uhd_device::uhd_device(const std::string &args) ...@@ -54,7 +55,7 @@ uhd_device::uhd_device(const std::string &args)
,m_rx_streaming(false) ,m_rx_streaming(false)
,m_dev_args (args) ,m_dev_args (args)
,m_rx_points(0) ,m_rx_points(0)
,m_initThread (new uhd_io_thread(0))
{ {
m_data_iq_rx = new short [m_rx_bufsz+1024*1024][2]{{0,0}}; m_data_iq_rx = new short [m_rx_bufsz+1024*1024][2]{{0,0}};
m_data_iq_tx = new short [m_tx_bufsz+1024*1024][2]{{0,0}}; m_data_iq_tx = new short [m_tx_bufsz+1024*1024][2]{{0,0}};
...@@ -62,6 +63,8 @@ uhd_device::uhd_device(const std::string &args) ...@@ -62,6 +63,8 @@ uhd_device::uhd_device(const std::string &args)
uhd_device::~uhd_device() uhd_device::~uhd_device()
{ {
stop_signal_called = true; stop_signal_called = true;
m_initThread->terminate();
m_initThread->deleteLater();
while (m_rx_streaming) while (m_rx_streaming)
{ {
QThread::msleep(100); QThread::msleep(100);
...@@ -86,8 +89,7 @@ std::string uhd_device::devArgs() const ...@@ -86,8 +89,7 @@ std::string uhd_device::devArgs() const
bool uhd_device::open_device() bool uhd_device::open_device()
{ {
string ref = "internal"; string ref = "internal";
std::atomic<bool> finished(false); m_initThread->setRunner([&]()->void{
std::thread thr([&]()->void{
try{ try{
UHD_DO(uhd_usrp_make(&usrp, m_dev_args.c_str())); UHD_DO(uhd_usrp_make(&usrp, m_dev_args.c_str()));
} }
...@@ -95,16 +97,13 @@ bool uhd_device::open_device() ...@@ -95,16 +97,13 @@ bool uhd_device::open_device()
{ {
fputs(er.c_str(),stderr); fputs(er.c_str(),stderr);
} }
finished = true;
}); });
while (!finished) m_initThread->start();
while (!m_initThread->wait(100))
{ {
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
QThread::msleep(20);
} }
thr.join();
if (!usrp) if (!usrp)
return false; return false;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include <atomic> #include <atomic>
#include <QThread> #include <QThread>
#include <uhd.h> #include <uhd.h>
#include <QAtomicInteger>
class uhd_io_thread: public QThread{ class uhd_io_thread: public QThread{
Q_OBJECT Q_OBJECT
public: public:
...@@ -44,14 +44,15 @@ protected: ...@@ -44,14 +44,15 @@ protected:
int m_rx_channel = 0; int m_rx_channel = 0;
int m_tx_channel = 0; int m_tx_channel = 0;
protected: protected:
uhd_io_thread * m_initThread;
//初始化队列 //初始化队列
short (*m_data_iq_rx)[2] = nullptr; short (*m_data_iq_rx)[2] = nullptr;
size_t m_rx_bufsz = 1024*1024*8; size_t m_rx_bufsz = 1024*1024;
short (*m_data_iq_tx)[2] = nullptr; short (*m_data_iq_tx)[2] = nullptr;
size_t m_tx_bufsz = 1024*1024*8; size_t m_tx_bufsz = 1024*1024;
//收发计数 //收发计数
unsigned long long m_rx_points = 0; QAtomicInteger<unsigned long long> m_rx_points = 0;
unsigned long long m_tx_points = 0; QAtomicInteger<unsigned long long> m_tx_points = 0;
public: public:
quint64 set_rx_freq(const quint64 freq_in_hz); quint64 set_rx_freq(const quint64 freq_in_hz);
double set_rx_rate(const double sprate); double set_rx_rate(const double sprate);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册