specwidget.h 4.1 KB
Newer Older
丁劲犇's avatar
丁劲犇 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
/* -*- c++ -*- */
/*
 * Gqrx SDR: Software defined radio receiver powered by GNU Radio and Qt
 *           http://gqrx.dk/
 *
 * Copyright 2013 Christian Lindner DL2VCL, Stefano Leucci.
 *
 * Gqrx is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3, or (at your option)
 * any later version.
 *
 * Gqrx is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Gqrx; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street,
 * Boston, MA 02110-1301, USA.
 */
#ifndef SPECWIDGET_H
#define SPECWIDGET_H

#include <QWidget>
#include <QVariant>
#include <fftw3.h>
#include <vector>
#include <QStandardItemModel>
31 32 33 34 35

#ifdef Q_OS_WINDOWS
#include "uhd_device_win32.h"
#endif
#ifdef Q_OS_LINUX
M
manjaro 已提交
36
#include "uhd_device.h"
37 38
#endif
#include "stdout_watcher.h"
丁劲犇's avatar
丁劲犇 已提交
39 40 41 42
namespace Ui {
	class specWidget;
}

M
manjaro 已提交
43
class specWidget : public QWidget, public uhd_device
丁劲犇's avatar
丁劲犇 已提交
44 45 46 47 48
{
	Q_OBJECT
public:
	explicit specWidget(QWidget *parent = nullptr);
	~specWidget();
M
manjaro-xfce 已提交
49
	void setRxRate(double rate);
丁劲犇's avatar
丁劲犇 已提交
50 51
protected:
	void timerEvent(QTimerEvent * e) override;
M
manjaro 已提交
52
public slots:
丁劲犇's avatar
丁劲犇 已提交
53
	void slot_newDemodFreq(qint64 freq, qint64 delta); /* delta is the offset from the center */
54
	void slot_msg(QByteArray , bool);
丁劲犇's avatar
丁劲犇 已提交
55 56 57
public:
	void appendWavComplex(const double (* pWav)[2], const int count, double voltage_ref = 16384);
public:
M
manjaro 已提交
58
	void setCenterFreq(quint64 f);	
丁劲犇's avatar
丁劲犇 已提交
59
private slots:
M
manjaro-xfce 已提交
60
	void slot_YAxisRangeChanged(double minv, double maxv);
丁劲犇's avatar
丁劲犇 已提交
61
	void on_comboBox_fftSize_activated(int index);
M
manjaro 已提交
62 63 64 65
	void on_doubleSpinBox_center_valueChanged(double arg1);
	void on_spinBox_gain_valueChanged(int arg1);
	void on_doubleSpinBox_range_max_valueChanged(double arg1);
	void on_doubleSpinBox_range_min_valueChanged(double arg1);
M
manjaro 已提交
66 67
	void on_comboBox_atn_currentIndexChanged(const QString &arg1);
	void on_spinBox_chan_valueChanged(int arg1);
M
manjaro 已提交
68 69
	void on_toolButton_br_clicked();
	void on_checkBox_save_stateChanged(int arg1);
70 71
	void on_spinBox_bw_valueChanged(int arg1);
	void on_toolButton_br_play_clicked();
M
manjaro-xfce 已提交
72
	void on_checkBox_tx_stateChanged(int arg1);
73 74 75 76
	void on_doubleSpinBox_center_tx_valueChanged(double arg1);
	void on_spinBox_chan_tx_valueChanged(int arg1);
	void on_spinBox_gain_tx_valueChanged(int arg1);
	void on_spinBox_bw_tx_valueChanged(int arg1);
M
manjaro-xfce 已提交
77 78 79 80 81
	void on_pushButton_connect_toggled(bool checked);
	void on_checkBox_rx_toggled(bool checked);
	void on_doubleSpinBox_spr_tx_valueChanged(double arg1);
	void on_checkBox_tx_toggled(bool checked);
	void on_checkBox_rxagc_toggled(bool checked);
M
manjaro-xfce 已提交
82
	void on_spinBox_ui_percent_top_valueChanged(int arg1);
M
manjaro 已提交
83

丁劲犇's avatar
丁劲犇 已提交
84 85 86
private:
	void loadSettings();
	void saveSettings();
M
manjaro-xfce 已提交
87 88 89 90 91 92 93
	void update_Info();
private:
	void enumDevices();
	void connect_usrp();
	void disconnect_usrp();
	void do_rx(bool start);
	void do_tx(bool start);
94 95 96 97 98 99 100
private:
	void initFFTW();
	void freeFFTW();
	void initRx();
	void initTx();
	void freeRx();
	void freeTx();
丁劲犇's avatar
丁劲犇 已提交
101 102
private:
	Ui::specWidget *ui = nullptr;
M
manjaro-xfce 已提交
103
	QStandardItemModel * m_pDevMod = nullptr;
M
manjaro 已提交
104
	QStandardItemModel * m_attenMod = nullptr;
M
manjaro-xfce 已提交
105 106 107 108
	QStandardItemModel * m_attenTxMod = nullptr;
	//Gains
	QStandardItemModel * m_pModRXGain = nullptr;
	QStandardItemModel * m_pModTXGain = nullptr;
丁劲犇's avatar
丁劲犇 已提交
109
private:
M
manjaro-xfce 已提交
110
	//FFT
丁劲犇's avatar
丁劲犇 已提交
111 112 113 114 115 116 117 118 119
	int	m_nFFTSize = 16384;
	std::vector<double> m_dHammingWnd;
	std::vector<double> m_dFFTAmp;
	fftw_plan m_pFFTPlan = nullptr;
	fftw_complex * m_pFFTIn = nullptr;
	fftw_complex * m_pFFTOut = nullptr;
	int m_nTimerID = -1;
	int m_nCurrentCenter = 0;
	double m_dManuAdd = 0;
M
manjaro 已提交
120
	//Thread
121
	uhd_io_thread * m_rxth = nullptr;
M
manjaro 已提交
122
	uhd_io_thread * m_saveth = nullptr;
123 124 125 126
	uhd_io_thread * m_txth = nullptr;
	uhd_io_thread * m_readth = nullptr;
	unsigned long long save_count;
	unsigned long long read_count;
M
manjaro 已提交
127
	std::atomic<bool> m_bSaveToFile;
128
	std::atomic<bool> m_bPlayFromFile;
129
	std::atomic<bool> m_dataproduce_ok;
M
manjaro 已提交
130
	QString m_strFolder;
131 132 133
	QString m_strFolderPlay;
	//stdout reader
	stdout_watcher * watcher = nullptr;
丁劲犇's avatar
丁劲犇 已提交
134 135 136
};

#endif // SPECWIDGET_H