def get_qtsink(self): snk = qtgui.freq_sink_c(self._npts, self._wintype, self._fc, 1.0, self._name, self._ncons) snk.enable_autoscale(True) return snk
def __init__(self): gr.top_block.__init__(self) Rs = 8000 f1 = 1000 f2 = 2000 npts = 2048 self.qapp = QtGui.QApplication(sys.argv) self.filt_taps = [1,] src1 = analog.sig_source_c(Rs, analog.GR_SIN_WAVE, f1, 0.1, 0) src2 = analog.sig_source_c(Rs, analog.GR_SIN_WAVE, f2, 0.1, 0) src = blocks.add_cc() channel = channels.channel_model(0.01) self.filt = filter.fft_filter_ccc(1, self.filt_taps) thr = blocks.throttle(gr.sizeof_gr_complex, 100*npts) self.snk1 = qtgui.freq_sink_c(npts, filter.firdes.WIN_BLACKMAN_hARRIS, 0, Rs, "Complex Freq Example", 1) self.connect(src1, (src,0)) self.connect(src2, (src,1)) self.connect(src, channel, thr, self.filt, (self.snk1, 0)) # Get the reference pointer to the SpectrumDisplayForm QWidget pyQt = self.snk1.pyqwidget() # Wrap the pointer as a PyQt SIP object # This can now be manipulated as a PyQt4.QtGui.QWidget pyWin = sip.wrapinstance(pyQt, QtGui.QWidget) pyWin.show()
def __init__(self): gr.top_block.__init__(self) Rs = 8000 f1 = 100 f2 = 200 npts = 2048 self.qapp = QtWidgets.QApplication(sys.argv) ss = open(gr.prefix() + '/share/gnuradio/themes/dark.qss') sstext = ss.read() ss.close() self.qapp.setStyleSheet(sstext) src1 = analog.sig_source_c(Rs, analog.GR_SIN_WAVE, f1, 0.1, 0) src2 = analog.sig_source_c(Rs, analog.GR_SIN_WAVE, f2, 0.1, 0) src = blocks.add_cc() channel = channels.channel_model(0.01) thr = blocks.throttle(gr.sizeof_gr_complex, 100*npts) self.snk1 = qtgui.freq_sink_c(npts, filter.firdes.WIN_BLACKMAN_hARRIS, 0, Rs, "Complex Freq Example", 3) self.connect(src1, (src,0)) self.connect(src2, (src,1)) self.connect(src, channel, thr, (self.snk1, 0)) self.connect(src1, (self.snk1, 1)) self.connect(src2, (self.snk1, 2)) self.ctrl_win = control_box() self.ctrl_win.attach_signal1(src1) self.ctrl_win.attach_signal2(src2) # Get the reference pointer to the SpectrumDisplayForm QWidget pyQt = self.snk1.pyqwidget() # Wrap the pointer as a PyQt SIP object # This can now be manipulated as a PyQt5.QtWidgets.QWidget pyWin = sip.wrapinstance(pyQt, QtWidgets.QWidget) #pyWin.show() self.main_box = dialog_box(pyWin, self.ctrl_win) self.main_box.show()
def __init__(self): gr.top_block.__init__(self) Rs = 8000 f1 = 100 f2 = 200 npts = 2048 self.qapp = QtGui.QApplication(sys.argv) src1 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0) src2 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0) src = gr.add_cc() channel = filter.channel_model(0.01) thr = gr.throttle(gr.sizeof_gr_complex, 100*npts) self.snk1 = qtgui.freq_sink_c(npts, gr.firdes.WIN_BLACKMAN_hARRIS, 0, Rs, "Complex Freq Example", 3) self.connect(src1, (src,0)) self.connect(src2, (src,1)) self.connect(src, channel, thr, (self.snk1, 0)) self.connect(src1, (self.snk1, 1)) self.connect(src2, (self.snk1, 2)) self.ctrl_win = control_box() self.ctrl_win.attach_signal1(src1) self.ctrl_win.attach_signal2(src2) # Get the reference pointer to the SpectrumDisplayForm QWidget pyQt = self.snk1.pyqwidget() # Wrap the pointer as a PyQt SIP object # This can now be manipulated as a PyQt4.QtGui.QWidget pyWin = sip.wrapinstance(pyQt, QtGui.QWidget) #pyWin.show() self.main_box = dialog_box(pyWin, self.ctrl_win) self.main_box.show()
def __init__(self, instance=0, loopback="bb_txvga1_rxlpf", rx_bandwidth=1.5e6, rx_buflen=4096, rx_frequency=915e6, rx_lna_gain=6, rx_num_buffers=16, rx_num_xfers=8, rx_sample_rate=3e6, rx_vga_gain=20, serial="", tx_bandwidth=1.5e6, tx_buflen=4096, tx_frequency=915e6, tx_num_buffers=16, tx_num_xfers=8, tx_sample_rate=3e6, tx_vga1=-18, tx_vga2=0, verbosity="info"): gr.top_block.__init__(self, "bladeRF loopback example") Qt.QWidget.__init__(self) self.setWindowTitle("bladeRF loopback example") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "bladeRF_loopback") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.instance = instance self.loopback = loopback self.rx_bandwidth = rx_bandwidth self.rx_buflen = rx_buflen self.rx_frequency = rx_frequency self.rx_lna_gain = rx_lna_gain self.rx_num_buffers = rx_num_buffers self.rx_num_xfers = rx_num_xfers self.rx_sample_rate = rx_sample_rate self.rx_vga_gain = rx_vga_gain self.serial = serial self.tx_bandwidth = tx_bandwidth self.tx_buflen = tx_buflen self.tx_frequency = tx_frequency self.tx_num_buffers = tx_num_buffers self.tx_num_xfers = tx_num_xfers self.tx_sample_rate = tx_sample_rate self.tx_vga1 = tx_vga1 self.tx_vga2 = tx_vga2 self.verbosity = verbosity ################################################## # Variables ################################################## self.bladerf_selection = bladerf_selection = str(instance) if serial == "" else serial self.bladerf_tx_args = bladerf_tx_args = "bladerf=" + bladerf_selection + ",buffers=" + str(tx_num_buffers) + ",buflen=" + str(tx_buflen) + ",num_xfers=" + str(tx_num_xfers) + ",verbosity="+verbosity self.bladerf_rx_args = bladerf_rx_args = "bladerf=" + bladerf_selection + ",loopback=" + loopback + ",buffers=" + str(rx_num_buffers) + ",buflen=" + str(rx_buflen) + ",num_xfers=" + str(rx_num_xfers) + ",verbosity="+verbosity self.gui_tx_vga2 = gui_tx_vga2 = tx_vga2 self.gui_tx_vga1 = gui_tx_vga1 = tx_vga1 self.gui_tx_sample_rate = gui_tx_sample_rate = tx_sample_rate self.gui_tx_frequency = gui_tx_frequency = tx_frequency self.gui_tx_bandwidth = gui_tx_bandwidth = tx_bandwidth self.gui_rx_vga_gain = gui_rx_vga_gain = rx_vga_gain self.gui_rx_sample_rate = gui_rx_sample_rate = rx_sample_rate self.gui_rx_lna_gain = gui_rx_lna_gain = rx_lna_gain self.gui_rx_frequency = gui_rx_frequency = rx_frequency self.gui_rx_bandwidth = gui_rx_bandwidth = rx_bandwidth self.gui_bladerf_tx_args = gui_bladerf_tx_args = bladerf_tx_args self.gui_bladerf_rx_args = gui_bladerf_rx_args = bladerf_rx_args ################################################## # Blocks ################################################## self.tabs = Qt.QTabWidget() self.tabs_widget_0 = Qt.QWidget() self.tabs_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_0) self.tabs_grid_layout_0 = Qt.QGridLayout() self.tabs_layout_0.addLayout(self.tabs_grid_layout_0) self.tabs.addTab(self.tabs_widget_0, "RX") self.tabs_widget_1 = Qt.QWidget() self.tabs_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_1) self.tabs_grid_layout_1 = Qt.QGridLayout() self.tabs_layout_1.addLayout(self.tabs_grid_layout_1) self.tabs.addTab(self.tabs_widget_1, "TX") self.top_layout.addWidget(self.tabs) self._gui_tx_vga2_range = Range(0, 25, 1, tx_vga2, 200) self._gui_tx_vga2_win = RangeWidget(self._gui_tx_vga2_range, self.set_gui_tx_vga2, "VGA2 Gain", "counter_slider", float) self.tabs_grid_layout_1 .addWidget(self._gui_tx_vga2_win, 0, 7, 1, 2) self._gui_tx_vga1_range = Range(-35, -4, 1, tx_vga1, 200) self._gui_tx_vga1_win = RangeWidget(self._gui_tx_vga1_range, self.set_gui_tx_vga1, "VGA1 Gain", "counter_slider", float) self.tabs_grid_layout_1 .addWidget(self._gui_tx_vga1_win, 0, 5, 1, 2) self._gui_tx_sample_rate_range = Range(1.5e6, 40e6, 500e3, tx_sample_rate, 200) self._gui_tx_sample_rate_win = RangeWidget(self._gui_tx_sample_rate_range, self.set_gui_tx_sample_rate, "Sample Rate", "counter_slider", float) self.tabs_grid_layout_1 .addWidget(self._gui_tx_sample_rate_win, 1, 0, 1, 2) self._gui_tx_frequency_range = Range(0, 3.8e9, 1e6, tx_frequency, 200) self._gui_tx_frequency_win = RangeWidget(self._gui_tx_frequency_range, self.set_gui_tx_frequency, "Frequency", "counter_slider", float) self.tabs_grid_layout_1 .addWidget(self._gui_tx_frequency_win, 0, 0, 1, 5) self._gui_tx_bandwidth_range = Range(1.5e6, 28e6, 0.5e6, tx_bandwidth, 200) self._gui_tx_bandwidth_win = RangeWidget(self._gui_tx_bandwidth_range, self.set_gui_tx_bandwidth, "Bandwidth", "counter_slider", float) self.tabs_grid_layout_1 .addWidget(self._gui_tx_bandwidth_win, 1, 2, 1, 2) self._gui_rx_vga_gain_range = Range(5, 60, 1, rx_vga_gain, 200) self._gui_rx_vga_gain_win = RangeWidget(self._gui_rx_vga_gain_range, self.set_gui_rx_vga_gain, "RX VGA1 + VGA2 Gain", "counter_slider", float) self.tabs_grid_layout_0 .addWidget(self._gui_rx_vga_gain_win, 0, 5, 1, 4) self._gui_rx_sample_rate_range = Range(1.5e6, 40e6, 500e3, rx_sample_rate, 200) self._gui_rx_sample_rate_win = RangeWidget(self._gui_rx_sample_rate_range, self.set_gui_rx_sample_rate, "Sample Rate", "counter_slider", float) self.tabs_grid_layout_0 .addWidget(self._gui_rx_sample_rate_win, 1, 0, 1, 2) self._gui_rx_lna_gain_options = (0, 3, 6, ) self._gui_rx_lna_gain_labels = ("0 dB", "3 dB", "6 dB", ) self._gui_rx_lna_gain_tool_bar = Qt.QToolBar(self) self._gui_rx_lna_gain_tool_bar.addWidget(Qt.QLabel("LNA Gain"+": ")) self._gui_rx_lna_gain_combo_box = Qt.QComboBox() self._gui_rx_lna_gain_tool_bar.addWidget(self._gui_rx_lna_gain_combo_box) for label in self._gui_rx_lna_gain_labels: self._gui_rx_lna_gain_combo_box.addItem(label) self._gui_rx_lna_gain_callback = lambda i: Qt.QMetaObject.invokeMethod(self._gui_rx_lna_gain_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._gui_rx_lna_gain_options.index(i))) self._gui_rx_lna_gain_callback(self.gui_rx_lna_gain) self._gui_rx_lna_gain_combo_box.currentIndexChanged.connect( lambda i: self.set_gui_rx_lna_gain(self._gui_rx_lna_gain_options[i])) self.tabs_grid_layout_0 .addWidget(self._gui_rx_lna_gain_tool_bar, 0, 9, 1, 1) self._gui_rx_frequency_range = Range(0, 3.8e9, 1e6, rx_frequency, 200) self._gui_rx_frequency_win = RangeWidget(self._gui_rx_frequency_range, self.set_gui_rx_frequency, "Frequency", "counter_slider", float) self.tabs_grid_layout_0 .addWidget(self._gui_rx_frequency_win, 0, 0, 1, 5) self._gui_rx_bandwidth_range = Range(1.5e6, 28e6, 0.5e6, rx_bandwidth, 200) self._gui_rx_bandwidth_win = RangeWidget(self._gui_rx_bandwidth_range, self.set_gui_rx_bandwidth, "Bandwidth", "counter_slider", float) self.tabs_grid_layout_0 .addWidget(self._gui_rx_bandwidth_win, 1, 2, 1, 2) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c( 8192, #size tx_sample_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2*1): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_1 .addWidget(self._qtgui_time_sink_x_0_0_win, 7, 0, 3, 10) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 8192, #size rx_sample_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2*1): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_0 .addWidget(self._qtgui_time_sink_x_0_win, 7, 0, 3, 10) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 8192, #size firdes.WIN_BLACKMAN_hARRIS, #wintype gui_tx_frequency, #fc gui_tx_sample_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_1 .addWidget(self._qtgui_freq_sink_x_0_0_win, 2, 0, 5, 5) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 8192, #size firdes.WIN_BLACKMAN_hARRIS, #wintype gui_rx_frequency, #fc gui_rx_sample_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_0 .addWidget(self._qtgui_freq_sink_x_0_win, 2, 0, 5, 5) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + bladerf_rx_args ) self.osmosdr_source_0.set_sample_rate(gui_rx_sample_rate) self.osmosdr_source_0.set_center_freq(gui_rx_frequency, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(1, 0) self.osmosdr_source_0.set_iq_balance_mode(1, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(gui_rx_lna_gain, 0) self.osmosdr_source_0.set_if_gain(0, 0) self.osmosdr_source_0.set_bb_gain(gui_rx_vga_gain, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(gui_rx_bandwidth, 0) self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + bladerf_tx_args ) self.osmosdr_sink_0.set_sample_rate(gui_tx_sample_rate) self.osmosdr_sink_0.set_center_freq(gui_tx_frequency, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(gui_tx_vga2, 0) self.osmosdr_sink_0.set_if_gain(0, 0) self.osmosdr_sink_0.set_bb_gain(gui_tx_vga1, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(gui_tx_bandwidth, 0) self._gui_bladerf_tx_args_tool_bar = Qt.QToolBar(self) if None: self._gui_bladerf_tx_args_formatter = None else: self._gui_bladerf_tx_args_formatter = lambda x: x self._gui_bladerf_tx_args_tool_bar.addWidget(Qt.QLabel("bladeRF TX arguments"+": ")) self._gui_bladerf_tx_args_label = Qt.QLabel(str(self._gui_bladerf_tx_args_formatter(self.gui_bladerf_tx_args))) self._gui_bladerf_tx_args_tool_bar.addWidget(self._gui_bladerf_tx_args_label) self.tabs_grid_layout_1.addWidget(self._gui_bladerf_tx_args_tool_bar, 11, 0, 1, 10) self._gui_bladerf_rx_args_tool_bar = Qt.QToolBar(self) if None: self._gui_bladerf_rx_args_formatter = None else: self._gui_bladerf_rx_args_formatter = lambda x: x self._gui_bladerf_rx_args_tool_bar.addWidget(Qt.QLabel("bladeRF RX arguments"+": ")) self._gui_bladerf_rx_args_label = Qt.QLabel(str(self._gui_bladerf_rx_args_formatter(self.gui_bladerf_rx_args))) self._gui_bladerf_rx_args_tool_bar.addWidget(self._gui_bladerf_rx_args_label) self.tabs_grid_layout_0 .addWidget(self._gui_bladerf_rx_args_tool_bar, 11, 0, 1, 10) self.digital_psk_mod_0 = digital.psk.psk_mod( constellation_points=4, mod_code="none", differential=True, samples_per_symbol=8, excess_bw=0.35, verbose=False, log=False, ) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.3, )) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 1, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_psk_mod_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.digital_psk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.qtgui_time_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Fm Channelizer") Qt.QWidget.__init__(self) self.setWindowTitle("Fm Channelizer") try: self.setWindowIcon(Qt.QIcon.fromTheme("gnuradio-grc")) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "fm_channelizer") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.synth_channels = synth_channels = 6 self.channels = channels = 10 self.ch_rate = ch_rate = 100e3 self.samp_rate = samp_rate = ch_rate * channels self.gain = gain = 20 self.fm_quad_rate = fm_quad_rate = ch_rate * synth_channels self.ch_tb = ch_tb = 20e3 self.ch_bw = ch_bw = ch_rate / 2 self.audio_rate = audio_rate = 60e3 self.atten = atten = 80 self.volume = volume = 0.1 self.tun_gain = tun_gain = gain self.pfb_taps = pfb_taps = firdes.low_pass_2(1, samp_rate, ch_bw, ch_tb, atten, firdes.WIN_BLACKMAN_HARRIS) self.pfb_synth_taps = pfb_synth_taps = firdes.low_pass_2( channels / 2, synth_channels * ch_rate, ch_bw, ch_tb, atten, firdes.WIN_BLACKMAN_HARRIS ) self.freq_corr = freq_corr = 0 self.fm_audio_decim = fm_audio_decim = int(fm_quad_rate / audio_rate) * 2 self.channel = channel = 0 self.center_freq = center_freq = 101.1e6 + 0e3 self.address = address = "" ################################################## # Blocks ################################################## self._volume_layout = Qt.QVBoxLayout() self._volume_tool_bar = Qt.QToolBar(self) self._volume_layout.addWidget(self._volume_tool_bar) self._volume_tool_bar.addWidget(Qt.QLabel("Volume" + ": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot("double") def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._volume_counter = qwt_counter_pyslot() self._volume_counter.setRange(0, 10, 0.1) self._volume_counter.setNumButtons(2) self._volume_counter.setValue(self.volume) self._volume_tool_bar.addWidget(self._volume_counter) self._volume_counter.valueChanged.connect(self.set_volume) self._volume_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._volume_slider.setRange(0, 10, 0.1) self._volume_slider.setValue(self.volume) self._volume_slider.setMinimumWidth(200) self._volume_slider.valueChanged.connect(self.set_volume) self._volume_layout.addWidget(self._volume_slider) self.top_grid_layout.addLayout(self._volume_layout, 3, 0, 1, 1) self._tun_gain_layout = Qt.QVBoxLayout() self._tun_gain_tool_bar = Qt.QToolBar(self) self._tun_gain_layout.addWidget(self._tun_gain_tool_bar) self._tun_gain_tool_bar.addWidget(Qt.QLabel("Gain (dB)" + ": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot("double") def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._tun_gain_counter = qwt_counter_pyslot() self._tun_gain_counter.setRange(0, 70, 1) self._tun_gain_counter.setNumButtons(2) self._tun_gain_counter.setValue(self.tun_gain) self._tun_gain_tool_bar.addWidget(self._tun_gain_counter) self._tun_gain_counter.valueChanged.connect(self.set_tun_gain) self._tun_gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._tun_gain_slider.setRange(0, 70, 1) self._tun_gain_slider.setValue(self.tun_gain) self._tun_gain_slider.setMinimumWidth(200) self._tun_gain_slider.valueChanged.connect(self.set_tun_gain) self._tun_gain_layout.addWidget(self._tun_gain_slider) self.top_grid_layout.addLayout(self._tun_gain_layout, 2, 1, 1, 1) self._freq_corr_layout = Qt.QVBoxLayout() self._freq_corr_tool_bar = Qt.QToolBar(self) self._freq_corr_layout.addWidget(self._freq_corr_tool_bar) self._freq_corr_tool_bar.addWidget(Qt.QLabel("Frequency Correction" + ": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot("double") def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._freq_corr_counter = qwt_counter_pyslot() self._freq_corr_counter.setRange(-40e3, 40e3, 100) self._freq_corr_counter.setNumButtons(2) self._freq_corr_counter.setValue(self.freq_corr) self._freq_corr_tool_bar.addWidget(self._freq_corr_counter) self._freq_corr_counter.valueChanged.connect(self.set_freq_corr) self._freq_corr_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._freq_corr_slider.setRange(-40e3, 40e3, 100) self._freq_corr_slider.setValue(self.freq_corr) self._freq_corr_slider.setMinimumWidth(200) self._freq_corr_slider.valueChanged.connect(self.set_freq_corr) self._freq_corr_layout.addWidget(self._freq_corr_slider) self.top_grid_layout.addLayout(self._freq_corr_layout, 3, 1, 1, 1) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join((address, "")), uhd.stream_args(cpu_format="fc32", channels=range(1)) ) self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(center_freq + freq_corr, 0) self.uhd_usrp_source_0.set_gain(tun_gain, 0) self.uhd_usrp_source_0.set_antenna("RX2", 0) self.qtgui_freq_sink_x_0_0_0 = qtgui.freq_sink_c( 1024, # size firdes.WIN_FLATTOP, # wintype 0, # fc ch_rate * synth_channels, # bw "QT GUI Plot", # name 1, # number of inputs ) self.qtgui_freq_sink_x_0_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0_0.set_fft_average(1.0) if complex == type(float()): self.qtgui_freq_sink_x_0_0_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_0_win, 1, 1, 1, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, # size firdes.WIN_BLACKMAN_hARRIS, # wintype 0, # fc samp_rate, # bw "QT GUI Plot", # name 1, # number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) if complex == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 1, 2) self.pfb_synthesizer_ccf_0 = filter.pfb_synthesizer_ccf(synth_channels, (pfb_synth_taps), True) self.pfb_synthesizer_ccf_0.set_channel_map(([10, 11, 0, 1, 2, 3])) self.pfb_synthesizer_ccf_0.declare_sample_delay(0) self.pfb_channelizer_ccf_0 = pfb.channelizer_ccf(channels, (pfb_taps), 2.0, atten) self.pfb_channelizer_ccf_0.set_channel_map(()) self.pfb_channelizer_ccf_0.declare_sample_delay(0) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_fff( 44.1e3 / (fm_quad_rate / fm_audio_decim), taps=None, flt_size=32 ) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.fir_filter_xxx_0 = filter.fir_filter_ccc( 2, (firdes.low_pass_2(1, ch_rate * synth_channels, 250e3, 300e3, 40, firdes.WIN_BLACKMAN_HARRIS)) ) self.fir_filter_xxx_0.declare_sample_delay(0) self._channel_layout = Qt.QVBoxLayout() self._channel_tool_bar = Qt.QToolBar(self) self._channel_layout.addWidget(self._channel_tool_bar) self._channel_tool_bar.addWidget(Qt.QLabel("Output Channel" + ": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot("double") def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._channel_counter = qwt_counter_pyslot() self._channel_counter.setRange(0, channels - 1, 1) self._channel_counter.setNumButtons(2) self._channel_counter.setValue(self.channel) self._channel_tool_bar.addWidget(self._channel_counter) self._channel_counter.valueChanged.connect(self.set_channel) self._channel_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._channel_slider.setRange(0, channels - 1, 1) self._channel_slider.setValue(self.channel) self._channel_slider.setMinimumWidth(200) self._channel_slider.valueChanged.connect(self.set_channel) self._channel_layout.addWidget(self._channel_slider) self.top_grid_layout.addLayout(self._channel_layout, 2, 0, 1, 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_multiply_const_vxx = blocks.multiply_const_vff((volume,)) self.audio_sink = audio.sink(44100, "", True) self.analog_wfm_rcv = analog.wfm_rcv(quad_rate=fm_quad_rate, audio_decimation=fm_audio_decim) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.pfb_channelizer_ccf_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.analog_wfm_rcv, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_const_vxx, 0), (self.audio_sink, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.analog_wfm_rcv, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0_0_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx, 0)) self.connect((self.pfb_channelizer_ccf_0, 6), (self.blocks_null_sink_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 7), (self.blocks_null_sink_0, 1)) self.connect((self.pfb_channelizer_ccf_0, 8), (self.blocks_null_sink_0, 2)) self.connect((self.pfb_channelizer_ccf_0, 9), (self.blocks_null_sink_0, 3)) self.connect((self.pfb_channelizer_ccf_0, 0), (self.pfb_synthesizer_ccf_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 1), (self.pfb_synthesizer_ccf_0, 1)) self.connect((self.pfb_channelizer_ccf_0, 2), (self.pfb_synthesizer_ccf_0, 2)) self.connect((self.pfb_channelizer_ccf_0, 3), (self.pfb_synthesizer_ccf_0, 3)) self.connect((self.pfb_channelizer_ccf_0, 4), (self.pfb_synthesizer_ccf_0, 4)) self.connect((self.pfb_channelizer_ccf_0, 5), (self.pfb_synthesizer_ccf_0, 5)) self.connect((self.pfb_synthesizer_ccf_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.analog_agc2_xx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Gfskdemod") Qt.QWidget.__init__(self) self.setWindowTitle("Gfskdemod") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "GFSKDemod") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2e6 self.freq = freq = 101.7e6 ################################################## # Blocks ################################################## self._samp_rate_layout = Qt.QVBoxLayout() self._samp_rate_label = Qt.QLabel("samp_rate") self._samp_rate_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._samp_rate_slider.setRange(0, 2.7e6, 1e5) self._samp_rate_slider.setValue(self.samp_rate) self._samp_rate_slider.setMinimumWidth(200) self._samp_rate_slider.valueChanged.connect(self.set_samp_rate) self._samp_rate_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._samp_rate_layout.addWidget(self._samp_rate_label) self._samp_rate_layout.addWidget(self._samp_rate_slider) self.top_grid_layout.addLayout(self._samp_rate_layout, 5,5,3,3) self.main_tab = Qt.QTabWidget() self.main_tab_widget_0 = Qt.QWidget() self.main_tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.main_tab_widget_0) self.main_tab_grid_layout_0 = Qt.QGridLayout() self.main_tab_layout_0.addLayout(self.main_tab_grid_layout_0) self.main_tab.addTab(self.main_tab_widget_0, "PSD") self.main_tab_widget_1 = Qt.QWidget() self.main_tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.main_tab_widget_1) self.main_tab_grid_layout_1 = Qt.QGridLayout() self.main_tab_layout_1.addLayout(self.main_tab_grid_layout_1) self.main_tab.addTab(self.main_tab_widget_1, "Waterfall") self.top_grid_layout.addWidget(self.main_tab, 5,5,2,1) self._freq_tool_bar = Qt.QToolBar(self) self._freq_tool_bar.addWidget(Qt.QLabel("freq"+": ")) self._freq_line_edit = Qt.QLineEdit(str(self.freq)) self._freq_tool_bar.addWidget(self._freq_line_edit) self._freq_line_edit.returnPressed.connect( lambda: self.set_freq(eng_notation.str_to_num(self._freq_line_edit.text().toAscii()))) self.top_grid_layout.addWidget(self._freq_tool_bar, 5,5,3,1) self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_clock_source("external", 0) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(True, 0) self.rtlsdr_source_0.set_gain(10, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) if complex == type(float()): self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [5, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.main_tab_layout_1.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) if complex == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.main_tab_layout_0.addWidget(self._qtgui_freq_sink_x_0_win) ################################################## # Connections ################################################## self.connect((self.rtlsdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "AM") Qt.QWidget.__init__(self) self.setWindowTitle("AM") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "am") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.radio_freq = radio_freq = 100 self.volume = volume = 5 self.squelch = squelch = -30 self.samp_rate = samp_rate = 240e4 self.rf_gain = rf_gain = 10 self.freq = freq = radio_freq * 1000000 ################################################## # Blocks ################################################## self._volume_range = Range(0, 10, 1, 5, 200) self._volume_win = RangeWidget(self._volume_range, self.set_volume, "Volume", "counter_slider", float) self.top_layout.addWidget(self._volume_win) self._squelch_range = Range(-70, 0, 10, -30, 200) self._squelch_win = RangeWidget(self._squelch_range, self.set_squelch, "Squelch", "counter_slider", int) self.top_layout.addWidget(self._squelch_win) self._rf_gain_range = Range(0, 50, 1, 10, 200) self._rf_gain_win = RangeWidget(self._rf_gain_range, self.set_rf_gain, "RF Gain", "counter_slider", float) self.top_layout.addWidget(self._rf_gain_win) self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(rf_gain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=2, decimation=75, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=3, decimation=4, taps=None, fractional_bw=None, ) self._radio_freq_tool_bar = Qt.QToolBar(self) self._radio_freq_tool_bar.addWidget(Qt.QLabel("Frequency (MHz)"+": ")) self._radio_freq_line_edit = Qt.QLineEdit(str(self.radio_freq)) self._radio_freq_tool_bar.addWidget(self._radio_freq_line_edit) self._radio_freq_line_edit.returnPressed.connect( lambda: self.set_radio_freq(eng_notation.str_to_num(str(self._radio_freq_line_edit.text().toAscii())))) self.top_layout.addWidget(self._radio_freq_tool_bar) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if complex == type(float()): self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if complex == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, 64000, 5000, 100, firdes.WIN_HAMMING, 6.76)) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((volume, )) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(squelch, 1e-4, 0, True) self.analog_agc2_xx_0 = analog.agc2_ff(6.25e-4, 1e-5, .2, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.low_pass_filter_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Meteor M2 Receiver 4 USRP (QT) ") Qt.QWidget.__init__(self) self.setWindowTitle("Meteor M2 Receiver 4 USRP (QT) ") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 72000 self.signal_samp_rate = signal_samp_rate = 140e3 self.path_to_save_dir = path_to_save_dir = os.path.expanduser("~/Desktop") self.decim_factor = decim_factor = 4 self.usrp_samp_rate = usrp_samp_rate = signal_samp_rate*decim_factor self.samp_per_sec = samp_per_sec = (signal_samp_rate * 1.0) / (symbol_rate * 1.0) self.rx_freq_old = rx_freq_old = 137.1e6 self.rx_freq = rx_freq = 137.1e6 self.rf_gain = rf_gain = 20 self.record = record = False self.pll_alpha = pll_alpha = 0.015 self.file_path = file_path = path_to_save_dir + "/LRPT_" + datetime.now().strftime("%d%m%Y_%H%M")+".s" self.clock_alpha = clock_alpha = 0.001 ################################################## # Blocks ################################################## self.qtgui_tab_widget_0 = Qt.QTabWidget() self.qtgui_tab_widget_0_widget_0 = Qt.QWidget() self.qtgui_tab_widget_0_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_0_widget_0) self.qtgui_tab_widget_0_grid_layout_0 = Qt.QGridLayout() self.qtgui_tab_widget_0_layout_0.addLayout(self.qtgui_tab_widget_0_grid_layout_0) self.qtgui_tab_widget_0.addTab(self.qtgui_tab_widget_0_widget_0, 'Reception') self.qtgui_tab_widget_0_widget_1 = Qt.QWidget() self.qtgui_tab_widget_0_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_0_widget_1) self.qtgui_tab_widget_0_grid_layout_1 = Qt.QGridLayout() self.qtgui_tab_widget_0_layout_1.addLayout(self.qtgui_tab_widget_0_grid_layout_1) self.qtgui_tab_widget_0.addTab(self.qtgui_tab_widget_0_widget_1, 'Demodulation') self.qtgui_tab_widget_0_widget_2 = Qt.QWidget() self.qtgui_tab_widget_0_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_0_widget_2) self.qtgui_tab_widget_0_grid_layout_2 = Qt.QGridLayout() self.qtgui_tab_widget_0_layout_2.addLayout(self.qtgui_tab_widget_0_grid_layout_2) self.qtgui_tab_widget_0.addTab(self.qtgui_tab_widget_0_widget_2, 'Decoding') self.top_grid_layout.addWidget(self.qtgui_tab_widget_0) self._rx_freq_options = (137.1e6, 137.9e6, 101.8e6, ) self._rx_freq_labels = ('137.1 MHz', '137.9 MHz', 'Test FM', ) self._rx_freq_tool_bar = Qt.QToolBar(self) self._rx_freq_tool_bar.addWidget(Qt.QLabel('RX Frequency'+": ")) self._rx_freq_combo_box = Qt.QComboBox() self._rx_freq_tool_bar.addWidget(self._rx_freq_combo_box) for label in self._rx_freq_labels: self._rx_freq_combo_box.addItem(label) self._rx_freq_callback = lambda i: Qt.QMetaObject.invokeMethod(self._rx_freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._rx_freq_options.index(i))) self._rx_freq_callback(self.rx_freq) self._rx_freq_combo_box.currentIndexChanged.connect( lambda i: self.set_rx_freq(self._rx_freq_options[i])) self.qtgui_tab_widget_0_grid_layout_0.addWidget(self._rx_freq_tool_bar, 0, 2, 1, 1) for r in range(0, 1): self.qtgui_tab_widget_0_grid_layout_0.setRowStretch(r, 1) for c in range(2, 3): self.qtgui_tab_widget_0_grid_layout_0.setColumnStretch(c, 1) self._rf_gain_range = Range(0, 65, 5, 20, 200) self._rf_gain_win = RangeWidget(self._rf_gain_range, self.set_rf_gain, 'RF input gain', "counter_slider", float) self.qtgui_tab_widget_0_grid_layout_0.addWidget(self._rf_gain_win, 0, 0, 1, 2) for r in range(0, 1): self.qtgui_tab_widget_0_grid_layout_0.setRowStretch(r, 1) for c in range(0, 2): self.qtgui_tab_widget_0_grid_layout_0.setColumnStretch(c, 1) _record_check_box = Qt.QCheckBox('Raw I/Q Record') self._record_choices = {True: True, False: False} self._record_choices_inv = dict((v,k) for k,v in self._record_choices.iteritems()) self._record_callback = lambda i: Qt.QMetaObject.invokeMethod(_record_check_box, "setChecked", Qt.Q_ARG("bool", self._record_choices_inv[i])) self._record_callback(self.record) _record_check_box.stateChanged.connect(lambda i: self.set_record(self._record_choices[bool(i)])) self.qtgui_tab_widget_0_grid_layout_0.addWidget(_record_check_box, 0, 3, 1, 1) for r in range(0, 1): self.qtgui_tab_widget_0_grid_layout_0.setRowStretch(r, 1) for c in range(3, 4): self.qtgui_tab_widget_0_grid_layout_0.setColumnStretch(c, 1) self._pll_alpha_range = Range(0.001, 0.100, 0.001, 0.015, 200) self._pll_alpha_win = RangeWidget(self._pll_alpha_range, self.set_pll_alpha, 'PLL alpha', "counter_slider", float) self.qtgui_tab_widget_0_grid_layout_2.addWidget(self._pll_alpha_win, 4, 0, 1, 1) for r in range(4, 5): self.qtgui_tab_widget_0_grid_layout_2.setRowStretch(r, 1) for c in range(0, 1): self.qtgui_tab_widget_0_grid_layout_2.setColumnStretch(c, 1) self._clock_alpha_range = Range(0.001, 0.01, 0.001, 0.001, 200) self._clock_alpha_win = RangeWidget(self._clock_alpha_range, self.set_clock_alpha, 'Clock alpha', "counter_slider", float) self.qtgui_tab_widget_0_grid_layout_2.addWidget(self._clock_alpha_win, 3, 0, 1, 1) for r in range(3, 4): self.qtgui_tab_widget_0_grid_layout_2.setRowStretch(r, 1) for c in range(0, 1): self.qtgui_tab_widget_0_grid_layout_2.setColumnStretch(c, 1) self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(1, firdes.root_raised_cosine( 1, signal_samp_rate, symbol_rate, 0.6, 361)) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim_factor, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc signal_samp_rate, #bw 'Shifted signal', #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(True) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [6, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-100, -30) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.qtgui_tab_widget_0_grid_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_win, 2, 0, 1, 4) for r in range(2, 3): self.qtgui_tab_widget_0_grid_layout_0.setRowStretch(r, 1) for c in range(0, 4): self.qtgui_tab_widget_0_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq+signal_samp_rate, #fc usrp_samp_rate, #bw 'Centered on RAW signal', #name 3 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 0) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(True) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1.enable_control_panel(True) if not True: self.qtgui_freq_sink_x_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1.set_plot_pos_half(not True) labels = ['Filtered', 'Shifted', 'RAW', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "black", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(3): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.qtgui_tab_widget_0_grid_layout_0.addWidget(self._qtgui_freq_sink_x_1_win, 1, 0, 1, 4) for r in range(1, 2): self.qtgui_tab_widget_0_grid_layout_0.setRowStretch(r, 1) for c in range(0, 4): self.qtgui_tab_widget_0_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc signal_samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.qtgui_tab_widget_0_grid_layout_1.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 1, 1) for r in range(0, 1): self.qtgui_tab_widget_0_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.qtgui_tab_widget_0_grid_layout_1.setColumnStretch(c, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(1.0 / symbol_rate) self.qtgui_const_sink_x_0.set_y_axis(-1, 1) self.qtgui_const_sink_x_0.set_x_axis(-1, 1) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.qtgui_tab_widget_0_grid_layout_2.addWidget(self._qtgui_const_sink_x_0_win, 0, 0, 3, 1) for r in range(0, 3): self.qtgui_tab_widget_0_grid_layout_2.setRowStretch(r, 1) for c in range(0, 1): self.qtgui_tab_widget_0_grid_layout_2.setColumnStretch(c, 1) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 2, usrp_samp_rate, signal_samp_rate, 25e3, firdes.WIN_HAMMING, 6.76)) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(pll_alpha, 4, False) self.digital_constellation_soft_decoder_cf_0 = digital.constellation_soft_decoder_cf(digital.constellation_calcdist(([-1-1j, -1+1j, 1+1j, 1-1j]), ([0, 1, 3, 2]), 4, 1).base()) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc(samp_per_sec, clock_alpha**2/4.0, 0.5, clock_alpha, 0.005) self.blocks_wavfile_sink_1 = blocks.wavfile_sink(file_path+"_rawIQ.wav", 2, int(usrp_samp_rate/decim_factor), 8) self.blocks_mute_xx_0 = blocks.mute_cc(bool(record)) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_float_to_char_0 = blocks.float_to_char(1, 127) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, file_path, False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.analog_sig_source_x_0 = analog.sig_source_c(usrp_samp_rate, analog.GR_COS_WAVE, signal_samp_rate, 1, 0) self.analog_rail_ff_0 = analog.rail_ff(-1, 1) self.analog_agc_xx_0 = analog.agc_cc(100e-3, 500e-3, 1.0) self.analog_agc_xx_0.set_max_gain(4e3) self.USRP = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", args='peak=0.003906', channels=range(1), ), ) self.USRP.set_samp_rate(usrp_samp_rate) self.USRP.set_center_freq(rx_freq+signal_samp_rate, 0) self.USRP.set_gain(rf_gain, 0) self.USRP.set_antenna('TX/RX', 0) self.USRP.set_bandwidth(usrp_samp_rate, 0) self.USRP.set_auto_dc_offset(True, 0) self.USRP.set_auto_iq_balance(True, 0) ################################################## # Connections ################################################## self.connect((self.USRP, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.USRP, 0), (self.blocks_mute_xx_0, 0)) self.connect((self.USRP, 0), (self.qtgui_freq_sink_x_1, 2)) self.connect((self.analog_agc_xx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.analog_rail_ff_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_wavfile_sink_1, 1)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_wavfile_sink_1, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_freq_sink_x_1, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.blocks_mute_xx_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_constellation_soft_decoder_cf_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_constellation_soft_decoder_cf_0, 0), (self.analog_rail_ff_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_costas_loop_cc_0, 0))
def __init__(self): gr.top_block.__init__(self, "Demo Phase Noise") Qt.QWidget.__init__(self) self.setWindowTitle("Demo Phase Noise") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "demo_phase_noise") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1000000 self.signal_amp = signal_amp = 0 self.sigfreq = sigfreq = samp_rate/10.0 self.phase_noise = phase_noise = 0 self.noise_amp = noise_amp = -150 ################################################## # Blocks ################################################## self._signal_amp_layout = Qt.QVBoxLayout() self._signal_amp_tool_bar = Qt.QToolBar(self) self._signal_amp_layout.addWidget(self._signal_amp_tool_bar) self._signal_amp_tool_bar.addWidget(Qt.QLabel("Singal Power"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._signal_amp_counter = qwt_counter_pyslot() self._signal_amp_counter.setRange(-150, 10, 5) self._signal_amp_counter.setNumButtons(2) self._signal_amp_counter.setValue(self.signal_amp) self._signal_amp_tool_bar.addWidget(self._signal_amp_counter) self._signal_amp_counter.valueChanged.connect(self.set_signal_amp) self._signal_amp_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._signal_amp_slider.setRange(-150, 10, 5) self._signal_amp_slider.setValue(self.signal_amp) self._signal_amp_slider.setMinimumWidth(200) self._signal_amp_slider.valueChanged.connect(self.set_signal_amp) self._signal_amp_layout.addWidget(self._signal_amp_slider) self.top_grid_layout.addLayout(self._signal_amp_layout, 2,0,1,1) self._sigfreq_layout = Qt.QVBoxLayout() self._sigfreq_tool_bar = Qt.QToolBar(self) self._sigfreq_layout.addWidget(self._sigfreq_tool_bar) self._sigfreq_tool_bar.addWidget(Qt.QLabel("Signal Freq"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._sigfreq_counter = qwt_counter_pyslot() self._sigfreq_counter.setRange(0, samp_rate/2, 1000) self._sigfreq_counter.setNumButtons(2) self._sigfreq_counter.setValue(self.sigfreq) self._sigfreq_tool_bar.addWidget(self._sigfreq_counter) self._sigfreq_counter.valueChanged.connect(self.set_sigfreq) self._sigfreq_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._sigfreq_slider.setRange(0, samp_rate/2, 1000) self._sigfreq_slider.setValue(self.sigfreq) self._sigfreq_slider.setMinimumWidth(200) self._sigfreq_slider.valueChanged.connect(self.set_sigfreq) self._sigfreq_layout.addWidget(self._sigfreq_slider) self.top_grid_layout.addLayout(self._sigfreq_layout, 3,0,1,1) self._phase_noise_layout = Qt.QVBoxLayout() self._phase_noise_tool_bar = Qt.QToolBar(self) self._phase_noise_layout.addWidget(self._phase_noise_tool_bar) self._phase_noise_tool_bar.addWidget(Qt.QLabel("Phase Noise"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._phase_noise_counter = qwt_counter_pyslot() self._phase_noise_counter.setRange(0, 1, 0.001) self._phase_noise_counter.setNumButtons(2) self._phase_noise_counter.setValue(self.phase_noise) self._phase_noise_tool_bar.addWidget(self._phase_noise_counter) self._phase_noise_counter.valueChanged.connect(self.set_phase_noise) self._phase_noise_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._phase_noise_slider.setRange(0, 1, 0.001) self._phase_noise_slider.setValue(self.phase_noise) self._phase_noise_slider.setMinimumWidth(200) self._phase_noise_slider.valueChanged.connect(self.set_phase_noise) self._phase_noise_layout.addWidget(self._phase_noise_slider) self.top_grid_layout.addLayout(self._phase_noise_layout, 3,1,1,1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_FLATTOP, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-200, 0) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0,0,1,2) self._noise_amp_layout = Qt.QVBoxLayout() self._noise_amp_tool_bar = Qt.QToolBar(self) self._noise_amp_layout.addWidget(self._noise_amp_tool_bar) self._noise_amp_tool_bar.addWidget(Qt.QLabel("Noise Power"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._noise_amp_counter = qwt_counter_pyslot() self._noise_amp_counter.setRange(-150, 0, 5) self._noise_amp_counter.setNumButtons(2) self._noise_amp_counter.setValue(self.noise_amp) self._noise_amp_tool_bar.addWidget(self._noise_amp_counter) self._noise_amp_counter.valueChanged.connect(self.set_noise_amp) self._noise_amp_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._noise_amp_slider.setRange(-150, 0, 5) self._noise_amp_slider.setValue(self.noise_amp) self._noise_amp_slider.setMinimumWidth(200) self._noise_amp_slider.valueChanged.connect(self.set_noise_amp) self._noise_amp_layout.addWidget(self._noise_amp_slider) self.top_grid_layout.addLayout(self._noise_amp_layout, 2,1,1,1) self.channels_phase_noise_gen_0 = channels.phase_noise_gen(phase_noise, 0.1) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, sigfreq, pow(10.0,signal_amp/20.0), 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.channels_phase_noise_gen_0, 0)) self.connect((self.channels_phase_noise_gen_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "FM Receiver") Qt.QWidget.__init__(self) self.setWindowTitle("FM Receiver") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "fm_receiver") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 4e6 self.lpf_decim = lpf_decim = 40 self.freq = freq = 0 self.audio_samp_rate = audio_samp_rate = 96000 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=int(samp_rate / lpf_decim / 1000), decimation=96, taps=None, fractional_bw=None, ) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "From Air", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_AUTO, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(True) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.05) if complex == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.low_pass_filter_0 = filter.fir_filter_ccf( lpf_decim, firdes.low_pass(1, samp_rate, 100e3, 10e3, firdes.WIN_HAMMING, 6.76)) self._freq_layout = Qt.QVBoxLayout() self._freq_tool_bar = Qt.QToolBar(self) self._freq_layout.addWidget(self._freq_tool_bar) self._freq_tool_bar.addWidget(Qt.QLabel("Frequency" + ": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._freq_counter = qwt_counter_pyslot() self._freq_counter.setRange(-2e6, 2e6, 1) self._freq_counter.setNumButtons(2) self._freq_counter.setValue(self.freq) self._freq_tool_bar.addWidget(self._freq_counter) self._freq_counter.valueChanged.connect(self.set_freq) self._freq_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._freq_slider.setRange(-2e6, 2e6, 1) self._freq_slider.setValue(self.freq) self._freq_slider.setMinimumWidth(200) self._freq_slider.valueChanged.connect(self.set_freq) self._freq_layout.addWidget(self._freq_slider) self.top_layout.addLayout(self._freq_layout) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, "/home/surligas/radio_capture_complex_96MHz.dat", True) self.audio_sink_0 = audio.sink(audio_samp_rate, "", True) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=samp_rate / lpf_decim, audio_decimation=1, ) ################################################## # Connections ################################################## self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.occupied_carriers = occupied_carriers = ( range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27), ) self.length_tag_key = length_tag_key = "packet_len" self.sync_word2 = sync_word2 = [ 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 0, 0, 0, 0, 0 ] self.sync_word1 = sync_word1 = [ 0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0. ] self.samp_rate = samp_rate = 5000000 self.rolloff = rolloff = 0 self.pilot_symbols = pilot_symbols = (( 1, 1, 1, -1, ), ) self.pilot_carriers = pilot_carriers = (( -21, -7, 7, 21, ), ) self.payload_mod = payload_mod = digital.constellation_qpsk() self.packet_len = packet_len = 96 self.header_mod = header_mod = digital.constellation_bpsk() self.header_formatter = header_formatter = digital.packet_header_ofdm( occupied_carriers, 1, length_tag_key) self.fft_len = fft_len = 64 ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(1.9e9, 0) self.uhd_usrp_source_0.set_gain(30, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.uhd_usrp_source_0.set_bandwidth(80e9, 0) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw 'FFT Plot', #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(True) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.hydra_hydra_source_0 = hydra.hydra_source(2, 1024, 1.9e9, 80000000, ( (1.87e9, samp_rate), (1.93e9, samp_rate), )) self.digital_ofdm_rx_0_0 = digital.ofdm_rx( fft_len=fft_len, cp_len=fft_len / 4, frame_length_tag_key='frame_' + "length", packet_length_tag_key="length", occupied_carriers=occupied_carriers, pilot_carriers=pilot_carriers, pilot_symbols=pilot_symbols, sync_word1=sync_word1, sync_word2=sync_word2, bps_header=1, bps_payload=2, debug_log=False, scramble_bits=False) self.digital_ofdm_rx_0 = digital.ofdm_rx( fft_len=fft_len, cp_len=fft_len / 4, frame_length_tag_key='frame_' + "length", packet_length_tag_key="length", occupied_carriers=occupied_carriers, pilot_carriers=pilot_carriers, pilot_symbols=pilot_symbols, sync_word1=sync_word1, sync_word2=sync_word2, bps_header=1, bps_payload=2, debug_log=False, scramble_bits=False) self.channels_channel_model_0_0 = channels.channel_model( noise_voltage=0.0, frequency_offset=0.0, epsilon=1.0, taps=(1.0 + 1.0j, ), noise_seed=0, block_tags=True) self.channels_channel_model_0 = channels.channel_model( noise_voltage=0.0, frequency_offset=0.0, epsilon=1.0, taps=(1.0 + 1.0j, ), noise_seed=0, block_tags=True) self.blocks_file_sink_0_0 = blocks.file_sink( gr.sizeof_char * 1, '/home/maliksaad84/Desktop/newRofdm2.txt', False) self.blocks_file_sink_0_0.set_unbuffered(True) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_char * 1, '/home/maliksaad84/newR1.txt', False) self.blocks_file_sink_0.set_unbuffered(True) ################################################## # Connections ################################################## self.connect((self.channels_channel_model_0, 0), (self.digital_ofdm_rx_0, 0)) self.connect((self.channels_channel_model_0_0, 0), (self.digital_ofdm_rx_0_0, 0)) self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.digital_ofdm_rx_0_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.hydra_hydra_source_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.hydra_hydra_source_0, 1), (self.channels_channel_model_0_0, 0)) self.connect((self.hydra_hydra_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.hydra_hydra_source_0, 0))
def __init__(self, symbol_sync_bw=0.01): gr.hier_block2.__init__( self, "QO-100 32APSK+pilot demodulator (GUI)", gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), gr.io_signature.makev( 2, 2, [gr.sizeof_gr_complex * 1, gr.sizeof_gr_complex * 1]), ) Qt.QWidget.__init__(self) self.top_layout = Qt.QVBoxLayout() self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.setLayout(self.top_layout) ################################################## # Parameters ################################################## self.symbol_sync_bw = symbol_sync_bw ################################################## # Blocks ################################################## self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 12, #size constants.baudrate * (constants.tdm_rate - 1) / constants.tdm_rate * 5 * 1e-4, #samp_rate "", #name 1, #number of inputs None # parent ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(0, 50) self.qtgui_time_sink_x_1.set_y_label('BER %', "") self.qtgui_time_sink_x_1.enable_tags(False) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) self.qtgui_time_sink_x_1.enable_stem_plot(False) self.qtgui_time_sink_x_1.disable_legend() labels = [ 'BER', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [0, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance( self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.qtgui_time_sink_x_0_2 = qtgui.time_sink_c( len(constants.pilot_prbs) * 3, #size constants.baudrate / constants.tdm_rate, #samp_rate 'BPSK pilots', #name 1, #number of inputs None # parent ) self.qtgui_time_sink_x_0_2.set_update_time(0.10) self.qtgui_time_sink_x_0_2.set_y_axis(-3, 3) self.qtgui_time_sink_x_0_2.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_2.enable_tags(True) self.qtgui_time_sink_x_0_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_2.enable_autoscale(False) self.qtgui_time_sink_x_0_2.enable_grid(False) self.qtgui_time_sink_x_0_2.enable_axis_labels(True) self.qtgui_time_sink_x_0_2.enable_control_panel(False) self.qtgui_time_sink_x_0_2.enable_stem_plot(False) labels = [ 'I', 'Q', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [0, 0, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0_2.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_2.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_2.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_2.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_2.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_2.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_2.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_2.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_2_win = sip.wrapinstance( self.qtgui_time_sink_x_0_2.pyqwidget(), Qt.QWidget) self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f( constants.baudrate, #size constants.baudrate, #samp_rate "", #name 1, #number of inputs None # parent ) self.qtgui_time_sink_x_0_1.set_update_time(0.10) self.qtgui_time_sink_x_0_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_1.enable_tags(True) self.qtgui_time_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_1.enable_autoscale(False) self.qtgui_time_sink_x_0_1.enable_grid(False) self.qtgui_time_sink_x_0_1.enable_axis_labels(True) self.qtgui_time_sink_x_0_1.enable_control_panel(False) self.qtgui_time_sink_x_0_1.enable_stem_plot(False) labels = [ 'TED error', 'Average symbol period', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_1_win = sip.wrapinstance( self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( constants.tdm_rate * len(constants.pilot_prbs) * 3, #size constants.samp_rate, #samp_rate "", #name 1, #number of inputs None # parent ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(0, 1.2e5) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( constants.baudrate, #size constants.baudrate, #samp_rate "", #name 2, #number of inputs None # parent ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(constants.sps * 0.999, constants.sps * 1.001) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) labels = [ 'Instant symbol period', 'Average symbol period', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1, None # parent ) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title('BER %') labels = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in range(1): self.qtgui_number_sink_0.set_min(i, 0) self.qtgui_number_sink_0.set_max(i, 50) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size window.WIN_BLACKMAN_hARRIS, #wintype 0, #fc constants.samp_rate, #bw 'Received spectrum', #name 2, None # parent ) self.qtgui_freq_sink_x_0.set_update_time(0.1) self.qtgui_freq_sink_x_0.set_y_axis(-65, -25) self.qtgui_freq_sink_x_0.set_y_label('PSD', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) self.qtgui_freq_sink_x_0.set_fft_window_normalized(False) labels = [ 'Spectrum', 'Mirrored spectrum', '', '', '', '', '', '', '', '' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( int(constants.baudrate * (constants.tdm_rate - 1) / constants.tdm_rate), #size "", #name 2, #number of inputs None # parent ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) labels = ['32APSK data', 'BPSK pilot', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(2): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.qtgui_tab_widget_0 = Qt.QTabWidget() self.qtgui_tab_widget_0_widget_0 = Qt.QWidget() self.qtgui_tab_widget_0_layout_0 = Qt.QBoxLayout( Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_0_widget_0) self.qtgui_tab_widget_0_grid_layout_0 = Qt.QGridLayout() self.qtgui_tab_widget_0_layout_0.addLayout( self.qtgui_tab_widget_0_grid_layout_0) self.qtgui_tab_widget_0.addTab(self.qtgui_tab_widget_0_widget_0, 'Spectrum') self.qtgui_tab_widget_0_widget_1 = Qt.QWidget() self.qtgui_tab_widget_0_layout_1 = Qt.QBoxLayout( Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_0_widget_1) self.qtgui_tab_widget_0_grid_layout_1 = Qt.QGridLayout() self.qtgui_tab_widget_0_layout_1.addLayout( self.qtgui_tab_widget_0_grid_layout_1) self.qtgui_tab_widget_0.addTab(self.qtgui_tab_widget_0_widget_1, 'Clock recovery') self.qtgui_tab_widget_0_widget_2 = Qt.QWidget() self.qtgui_tab_widget_0_layout_2 = Qt.QBoxLayout( Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_0_widget_2) self.qtgui_tab_widget_0_grid_layout_2 = Qt.QGridLayout() self.qtgui_tab_widget_0_layout_2.addLayout( self.qtgui_tab_widget_0_grid_layout_2) self.qtgui_tab_widget_0.addTab(self.qtgui_tab_widget_0_widget_2, 'Constellation') self.qtgui_tab_widget_0_widget_3 = Qt.QWidget() self.qtgui_tab_widget_0_layout_3 = Qt.QBoxLayout( Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_0_widget_3) self.qtgui_tab_widget_0_grid_layout_3 = Qt.QGridLayout() self.qtgui_tab_widget_0_layout_3.addLayout( self.qtgui_tab_widget_0_grid_layout_3) self.qtgui_tab_widget_0.addTab(self.qtgui_tab_widget_0_widget_3, 'Synchronization') self.qtgui_tab_widget_0_widget_4 = Qt.QWidget() self.qtgui_tab_widget_0_layout_4 = Qt.QBoxLayout( Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_0_widget_4) self.qtgui_tab_widget_0_grid_layout_4 = Qt.QGridLayout() self.qtgui_tab_widget_0_layout_4.addLayout( self.qtgui_tab_widget_0_grid_layout_4) self.qtgui_tab_widget_0.addTab(self.qtgui_tab_widget_0_widget_4, 'BER') self.top_layout.addWidget(self.qtgui_tab_widget_0) self.variable_qtgui_msg_push_button_0 = _variable_qtgui_msg_push_button_0_toggle_button = qtgui.MsgPushButton( 'Resync', 'pressed', 1, "default", "default") self.variable_qtgui_msg_push_button_0 = _variable_qtgui_msg_push_button_0_toggle_button self.top_layout.addWidget( _variable_qtgui_msg_push_button_0_toggle_button) self.qo100_demodulator_0 = qo100_demodulator( symbol_sync_bw=symbol_sync_bw, ) self.blocks_repeat_1 = blocks.repeat(gr.sizeof_float * 1, 100) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex * 1, constants.tdm_rate - 1) self.blocks_conjugate_cc_0 = blocks.conjugate_cc() self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.ber_calc_0 = ber_calc() self.qtgui_tab_widget_0_grid_layout_4.addWidget( self._qtgui_time_sink_x_1_win, 1, 0, 1, 1) for r in range(1, 2): self.qtgui_tab_widget_0_grid_layout_4.setRowStretch(r, 1) for c in range(0, 1): self.qtgui_tab_widget_0_grid_layout_4.setColumnStretch(c, 1) self.qtgui_tab_widget_0_grid_layout_3.addWidget( self._qtgui_time_sink_x_0_2_win, 1, 0, 1, 1) for r in range(1, 2): self.qtgui_tab_widget_0_grid_layout_3.setRowStretch(r, 1) for c in range(0, 1): self.qtgui_tab_widget_0_grid_layout_3.setColumnStretch(c, 1) self.qtgui_tab_widget_0_grid_layout_1.addWidget( self._qtgui_time_sink_x_0_1_win, 1, 0, 1, 1) for r in range(1, 2): self.qtgui_tab_widget_0_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.qtgui_tab_widget_0_grid_layout_1.setColumnStretch(c, 1) self.qtgui_tab_widget_0_grid_layout_3.addWidget( self._qtgui_time_sink_x_0_0_win, 0, 0, 1, 1) for r in range(0, 1): self.qtgui_tab_widget_0_grid_layout_3.setRowStretch(r, 1) for c in range(0, 1): self.qtgui_tab_widget_0_grid_layout_3.setColumnStretch(c, 1) self.qtgui_tab_widget_0_grid_layout_1.addWidget( self._qtgui_time_sink_x_0_win, 0, 0, 1, 1) for r in range(0, 1): self.qtgui_tab_widget_0_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.qtgui_tab_widget_0_grid_layout_1.setColumnStretch(c, 1) self.qtgui_tab_widget_0_grid_layout_4.addWidget( self._qtgui_number_sink_0_win, 0, 0, 1, 1) for r in range(0, 1): self.qtgui_tab_widget_0_grid_layout_4.setRowStretch(r, 1) for c in range(0, 1): self.qtgui_tab_widget_0_grid_layout_4.setColumnStretch(c, 1) self.qtgui_tab_widget_0_layout_0.addWidget( self._qtgui_freq_sink_x_0_win) self.qtgui_tab_widget_0_layout_2.addWidget( self._qtgui_const_sink_x_0_win) ################################################## # Connections ################################################## self.msg_connect((self.variable_qtgui_msg_push_button_0, 'pressed'), (self.qo100_demodulator_0, 'resync')) self.connect((self.ber_calc_0, 0), (self.blocks_repeat_1, 0)) self.connect((self.ber_calc_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_conjugate_cc_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.blocks_repeat_0, 0), (self.qtgui_const_sink_x_0, 1)) self.connect((self.blocks_repeat_1, 0), (self.qtgui_number_sink_0, 0)) self.connect((self, 0), (self.blocks_conjugate_cc_0, 0)) self.connect((self, 0), (self.qo100_demodulator_0, 0)) self.connect((self, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.qo100_demodulator_0, 0), (self.ber_calc_0, 0)) self.connect((self.qo100_demodulator_0, 5), (self.blocks_complex_to_mag_0, 0)) self.connect((self.qo100_demodulator_0, 1), (self.blocks_repeat_0, 0)) self.connect((self.qo100_demodulator_0, 0), (self, 0)) self.connect((self.qo100_demodulator_0, 1), (self, 1)) self.connect((self.qo100_demodulator_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.qo100_demodulator_0, 3), (self.qtgui_time_sink_x_0, 0)) self.connect((self.qo100_demodulator_0, 4), (self.qtgui_time_sink_x_0, 1)) self.connect((self.qo100_demodulator_0, 2), (self.qtgui_time_sink_x_0_1, 0)) self.connect((self.qo100_demodulator_0, 1), (self.qtgui_time_sink_x_0_2, 0))
def __init__(self, inputfile='', outputfile='0'): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.inputfile = inputfile self.outputfile = outputfile ################################################## # Variables ################################################## self.decimation = decimation = 1 self.symb_rate = symb_rate = 72e3 self.samp_rate = samp_rate = 0.900001e6 / decimation self.ted_gain = ted_gain = 1 self.sps = sps = (samp_rate) / symb_rate self.qpsk = qpsk = digital.constellation_calcdist( ([-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j]), ([0, 1, 3, 2]), 4, 1).base() self.loop_bw = loop_bw = 0.002 self.fft_min = fft_min = -160 self.fft_max = fft_max = -15 self.dec_taps = dec_taps = firdes.low_pass(1.0, samp_rate, 141e3, 20e3, firdes.WIN_HAMMING, 6.76) self.d_factor = d_factor = 2 ################################################## # Blocks ################################################## self._ted_gain_range = Range(0.1, 2, 0.1, 1, 200) self._ted_gain_win = RangeWidget(self._ted_gain_range, self.set_ted_gain, "ted_gain", "counter_slider", float) self.top_grid_layout.addWidget(self._ted_gain_win, 0, 2, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self._loop_bw_range = Range(0.001, 0.1, 0.001, 0.002, 200) self._loop_bw_win = RangeWidget(self._loop_bw_range, self.set_loop_bw, "loop_bw", "counter_slider", float) self.top_grid_layout.addWidget(self._loop_bw_win, 0, 0, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._d_factor_range = Range(0.1, 2, 0.1, 2, 200) self._d_factor_win = RangeWidget(self._d_factor_range, self.set_d_factor, "d_factor", "counter_slider", float) self.top_grid_layout.addWidget(self._d_factor_win, 0, 1, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.root_raised_cosine_filter_0 = filter.fir_filter_ccf( 1, firdes.root_raised_cosine(1, samp_rate, symb_rate, 3, 300)) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 3 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(9, 13) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['error', 't_inst', 't_avg', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(3): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 2, 0, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 100e3, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(fft_min, fft_max) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(True) self.qtgui_freq_sink_x_0_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "red", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 2, 1, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-1.5, 1.5) self.qtgui_const_sink_x_0_0.set_x_axis(-1.5, 1.5) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(True) self.qtgui_const_sink_x_0_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win, 2, 2, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.fir_filter_xxx_0 = filter.fir_filter_ccf(decimation, (dec_taps)) self.fir_filter_xxx_0.declare_sample_delay(0) self.digital_symbol_sync_xx_0 = digital.symbol_sync_cc( digital.TED_MUELLER_AND_MULLER, sps, loop_bw, d_factor, ted_gain, 1, 1, digital.constellation_bpsk().base(), digital.IR_MMSE_8TAP, 128, ([])) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( loop_bw, 4, False) self.digital_constellation_soft_decoder_cf_1 = digital.constellation_soft_decoder_cf( digital.constellation_calcdist( ([-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j]), ([0, 1, 3, 2]), 4, 1).base()) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate * 25 * decimation, True) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_float_to_char_0 = blocks.float_to_char(1, 127) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_float * 1, '/home/nacho/Desktop/Proyecto-Final/data/gqrx_20190914_121650_137100000_900001_fc.raw', False) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_file_sink_0_0 = blocks.file_sink( gr.sizeof_char * 1, '/home/nacho/Desktop/Proyecto-Final/data/2019_09_14.s', False) self.blocks_file_sink_0_0.set_unbuffered(False) self.blocks_deinterleave_0 = blocks.deinterleave( gr.sizeof_float * 1, 1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((10, )) self.analog_rail_ff_0 = analog.rail_ff(-1, 1) self.analog_agc_xx_0_0_0 = analog.agc_ff(1e-5, 1, 0.5) self.analog_agc_xx_0_0_0.set_max_gain(4e3) self.analog_agc_xx_0_0 = analog.agc_ff(1e-5, 1, 0.5) self.analog_agc_xx_0_0.set_max_gain(4e3) self.analog_agc_xx_0 = analog.agc_cc(1e-5, 1, 1) self.analog_agc_xx_0.set_max_gain(4e3) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.analog_agc_xx_0_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.analog_agc_xx_0_0_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.analog_rail_ff_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_deinterleave_0, 0), (self.analog_agc_xx_0_0, 0)) self.connect((self.blocks_deinterleave_0, 1), (self.analog_agc_xx_0_0_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_deinterleave_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.digital_constellation_soft_decoder_cf_1, 0), (self.analog_rail_ff_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_constellation_soft_decoder_cf_1, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.digital_symbol_sync_xx_0, 1), (self.blocks_add_const_vxx_0, 0)) self.connect((self.digital_symbol_sync_xx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_symbol_sync_xx_0, 3), (self.qtgui_time_sink_x_0, 2)) self.connect((self.digital_symbol_sync_xx_0, 2), (self.qtgui_time_sink_x_0, 1)) self.connect((self.fir_filter_xxx_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_symbol_sync_xx_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.qtgui_freq_sink_x_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Test Qtgui Msg") Qt.QWidget.__init__(self) self.setWindowTitle("Test Qtgui Msg") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "test_qtgui_msg") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 2, 0, 1, 2) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 1, 0, 1, 2) self.qtgui_edit_box_msg_0_0_0 = qtgui.edit_box_msg( qtgui.INT_VEC, '', '', False, False, '') self._qtgui_edit_box_msg_0_0_0_win = sip.wrapinstance( self.qtgui_edit_box_msg_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_edit_box_msg_0_0_0_win, 3, 0, 1, 1) self.qtgui_edit_box_msg_0_0 = qtgui.edit_box_msg( qtgui.INT_VEC, '', '', False, False, '') self._qtgui_edit_box_msg_0_0_win = sip.wrapinstance( self.qtgui_edit_box_msg_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_edit_box_msg_0_0_win, 3, 1, 1, 1) self.qtgui_edit_box_msg_0 = qtgui.edit_box_msg(qtgui.FLOAT, '', 'Frequency', True, True, 'freq') self._qtgui_edit_box_msg_0_win = sip.wrapinstance( self.qtgui_edit_box_msg_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_edit_box_msg_0_win, 0, 0, 1, 1) self.blocks_message_debug_0 = blocks.message_debug() self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 1000, 1, 0) ################################################## # Connections ################################################## self.msg_connect((self.qtgui_edit_box_msg_0, 'msg'), (self.qtgui_freq_sink_x_0, 'freq')) self.msg_connect((self.qtgui_edit_box_msg_0, 'msg'), (self.qtgui_waterfall_sink_x_0, 'freq')) self.msg_connect((self.qtgui_edit_box_msg_0_0, 'msg'), (self.qtgui_edit_box_msg_0_0_0, 'val')) self.msg_connect((self.qtgui_edit_box_msg_0_0_0, 'msg'), (self.blocks_message_debug_0, 'print')) self.msg_connect((self.qtgui_edit_box_msg_0_0_0, 'msg'), (self.qtgui_edit_box_msg_0_0, 'val')) self.msg_connect((self.qtgui_freq_sink_x_0, 'freq'), (self.qtgui_edit_box_msg_0, 'val')) self.msg_connect((self.qtgui_freq_sink_x_0, 'freq'), (self.qtgui_freq_sink_x_0, 'freq')) self.msg_connect((self.qtgui_waterfall_sink_x_0, 'freq'), (self.qtgui_edit_box_msg_0, 'val')) self.msg_connect((self.qtgui_waterfall_sink_x_0, 'freq'), (self.qtgui_waterfall_sink_x_0, 'freq')) self.connect((self.analog_sig_source_x_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "FM Receiver") Qt.QWidget.__init__(self) self.setWindowTitle("FM Receiver") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "fm_rds_alternate") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.symbols_per_bit = symbols_per_bit = 2 self.rds_bit_rate = rds_bit_rate = 1187.5 self.x_decimation = x_decimation = 4 self.samples_per_symbol = samples_per_symbol = 8 self.samp_rate = samp_rate = 2.e6 self.rds_symbol_rate = rds_symbol_rate = symbols_per_bit * rds_bit_rate self.x_samp_rate = x_samp_rate = samp_rate / x_decimation self.rrc_decim = rrc_decim = 2 self.rds_sample_rate = rds_sample_rate = samples_per_symbol * rds_symbol_rate self.baseband_decim = baseband_decim = 2 self.variable_constellation_rect_0 = variable_constellation_rect_0 = digital.constellation_rect( [-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j], [0, 1, 3, 2], 4, 2, 2, 1, 1).base() self.rrc_sample_rate = rrc_sample_rate = rds_sample_rate * rrc_decim self.rds_decim = rds_decim = 4 self.fm_freq = fm_freq = 101.2e6 self.excess_bw = excess_bw = .48 self.dgain = dgain = 30 self.baseband_sample_rate = baseband_sample_rate = x_samp_rate / baseband_decim self.audio_rate = audio_rate = 48e3 ################################################## # Blocks ################################################## self.tabs = Qt.QTabWidget() self.tabs_widget_0 = Qt.QWidget() self.tabs_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_0) self.tabs_grid_layout_0 = Qt.QGridLayout() self.tabs_layout_0.addLayout(self.tabs_grid_layout_0) self.tabs.addTab(self.tabs_widget_0, 'RF Properties') self.tabs_widget_1 = Qt.QWidget() self.tabs_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_1) self.tabs_grid_layout_1 = Qt.QGridLayout() self.tabs_layout_1.addLayout(self.tabs_grid_layout_1) self.tabs.addTab(self.tabs_widget_1, 'FM Band') self.tabs_widget_2 = Qt.QWidget() self.tabs_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_2) self.tabs_grid_layout_2 = Qt.QGridLayout() self.tabs_layout_2.addLayout(self.tabs_grid_layout_2) self.tabs.addTab(self.tabs_widget_2, 'RDS') self.tabs_widget_3 = Qt.QWidget() self.tabs_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_3) self.tabs_grid_layout_3 = Qt.QGridLayout() self.tabs_layout_3.addLayout(self.tabs_grid_layout_3) self.tabs.addTab(self.tabs_widget_3, 'Audio') self.top_grid_layout.addWidget(self.tabs, 1, 0, 9, 9) for r in range(1, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 9): self.top_grid_layout.setColumnStretch(c, 1) self._fm_freq_range = Range(87.5e6, 108.e6, 1e5, 101.2e6, 200) self._fm_freq_win = RangeWidget(self._fm_freq_range, self.set_fm_freq, 'FM Carrier Frequency', "counter_slider", float) self.top_grid_layout.addWidget(self._fm_freq_win, 0, 4, 1, 5) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 9): self.top_grid_layout.setColumnStretch(c, 1) self.root_raised_cosine_filter_0 = filter.fir_filter_ccf( rrc_decim, firdes.root_raised_cosine(1, rrc_sample_rate, rds_symbol_rate, 1, 100)) self.rds_parser_0 = rds.parser(False, False, 0) self.rds_panel_0 = rds.rdsPanel(0) self._rds_panel_0_win = self.rds_panel_0 self.top_grid_layout.addWidget(self._rds_panel_0_win) self.rds_decoder_0 = rds.decoder(False, False) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=int(rrc_sample_rate), decimation=int(baseband_sample_rate / rds_decim), taps=None, fractional_bw=None) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 128, #size baseband_sample_rate, #samp_rate "2x Pilot Tone", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_3.addWidget(self._qtgui_time_sink_x_0_win, 4, 4, 4, 4) for r in range(4, 8): self.tabs_grid_layout_3.setRowStretch(r, 1) for c in range(4, 8): self.tabs_grid_layout_3.setColumnStretch(c, 1) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc rrc_sample_rate, #bw "RDS Spectrum", #name 2) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(True) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1.enable_control_panel(False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance( self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_2.addWidget(self._qtgui_freq_sink_x_1_win, 0, 0, 5, 5) for r in range(0, 5): self.tabs_grid_layout_2.setRowStretch(r, 1) for c in range(0, 5): self.tabs_grid_layout_2.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0_0_1_0_1 = qtgui.freq_sink_f( 1024, #size firdes.WIN_RECTANGULAR, #wintype 0.0, #fc baseband_sample_rate, #bw "DSB-SC Spectrum", #name 1) self.qtgui_freq_sink_x_0_0_0_1_0_1.set_update_time(0.10) self.qtgui_freq_sink_x_0_0_0_1_0_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0_0_1_0_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0_0_1_0_1.set_trigger_mode( qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0_0_1_0_1.enable_autoscale(True) self.qtgui_freq_sink_x_0_0_0_1_0_1.enable_grid(False) self.qtgui_freq_sink_x_0_0_0_1_0_1.set_fft_average(0.05) self.qtgui_freq_sink_x_0_0_0_1_0_1.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0_0_1_0_1.enable_control_panel(False) self.qtgui_freq_sink_x_0_0_0_1_0_1.disable_legend() self.qtgui_freq_sink_x_0_0_0_1_0_1.set_plot_pos_half(not False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0_0_1_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0_0_1_0_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0_0_1_0_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0_0_1_0_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0_0_1_0_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_0_1_0_1_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0_0_1_0_1.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_3.addWidget( self._qtgui_freq_sink_x_0_0_0_1_0_1_win, 4, 0, 4, 4) for r in range(4, 8): self.tabs_grid_layout_3.setRowStretch(r, 1) for c in range(0, 4): self.tabs_grid_layout_3.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0_0_1_0_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_RECTANGULAR, #wintype 0.0, #fc baseband_sample_rate / 5, #bw "L-R Spectrum", #name 1) self.qtgui_freq_sink_x_0_0_0_1_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0_0_1_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0_0_1_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0_0_1_0_0.set_trigger_mode( qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0_0_1_0_0.enable_autoscale(True) self.qtgui_freq_sink_x_0_0_0_1_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0_0_1_0_0.set_fft_average(0.05) self.qtgui_freq_sink_x_0_0_0_1_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0_0_1_0_0.enable_control_panel(False) self.qtgui_freq_sink_x_0_0_0_1_0_0.disable_legend() self.qtgui_freq_sink_x_0_0_0_1_0_0.set_plot_pos_half(not False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0_0_1_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0_0_1_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0_0_1_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0_0_1_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0_0_1_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_0_1_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0_0_1_0_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_3.addWidget( self._qtgui_freq_sink_x_0_0_0_1_0_0_win, 0, 4, 4, 4) for r in range(0, 4): self.tabs_grid_layout_3.setRowStretch(r, 1) for c in range(4, 8): self.tabs_grid_layout_3.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0_0_1_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_RECTANGULAR, #wintype 0.0, #fc baseband_sample_rate / 5, #bw "L+R Spectrum", #name 1) self.qtgui_freq_sink_x_0_0_0_1_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0_0_1_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0_0_1_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0_0_1_0.set_trigger_mode( qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0_0_1_0.enable_autoscale(True) self.qtgui_freq_sink_x_0_0_0_1_0.enable_grid(False) self.qtgui_freq_sink_x_0_0_0_1_0.set_fft_average(0.05) self.qtgui_freq_sink_x_0_0_0_1_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0_0_1_0.enable_control_panel(False) self.qtgui_freq_sink_x_0_0_0_1_0.disable_legend() self.qtgui_freq_sink_x_0_0_0_1_0.set_plot_pos_half(not False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0_0_1_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0_0_1_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0_0_1_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0_0_1_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0_0_1_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_0_1_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0_0_1_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_3.addWidget( self._qtgui_freq_sink_x_0_0_0_1_0_win, 0, 0, 4, 4) for r in range(0, 4): self.tabs_grid_layout_3.setRowStretch(r, 1) for c in range(0, 4): self.tabs_grid_layout_3.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0_0_1 = qtgui.freq_sink_f( 4096, #size firdes.WIN_RECTANGULAR, #wintype 0.0, #fc baseband_sample_rate, #bw "FM demodulated spectrum", #name 1) self.qtgui_freq_sink_x_0_0_0_1.set_update_time(0.10) self.qtgui_freq_sink_x_0_0_0_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0_0_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0_0_1.set_trigger_mode( qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0_0_1.enable_autoscale(True) self.qtgui_freq_sink_x_0_0_0_1.enable_grid(False) self.qtgui_freq_sink_x_0_0_0_1.set_fft_average(0.1) self.qtgui_freq_sink_x_0_0_0_1.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0_0_1.enable_control_panel(True) self.qtgui_freq_sink_x_0_0_0_1.disable_legend() self.qtgui_freq_sink_x_0_0_0_1.set_plot_pos_half(not False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0_0_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0_0_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0_0_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0_0_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_0_1_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0_0_1.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_1.addWidget(self._qtgui_freq_sink_x_0_0_0_1_win, 0, 0, 8, 9) for r in range(0, 8): self.tabs_grid_layout_1.setRowStretch(r, 1) for c in range(0, 9): self.tabs_grid_layout_1.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype fm_freq, #fc samp_rate / x_decimation, #bw "Radio Spectrum", #name 1) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(True) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(True) self.qtgui_freq_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 8, 9) for r in range(0, 8): self.tabs_grid_layout_0.setRowStretch(r, 1) for c in range(0, 9): self.tabs_grid_layout_0.setColumnStretch(c, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 256, #size "RDS Constellation", #name 2 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(True) self.qtgui_const_sink_x_0.enable_grid(True) self.qtgui_const_sink_x_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(2): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_2.addWidget(self._qtgui_const_sink_x_0_win, 0, 5, 4, 4) for r in range(0, 4): self.tabs_grid_layout_2.setRowStretch(r, 1) for c in range(5, 9): self.tabs_grid_layout_2.setColumnStretch(c, 1) self.freq_xlating_fir_filter_xxx_1 = filter.freq_xlating_fir_filter_fcc( rds_decim, firdes.low_pass(2500.0, baseband_sample_rate, 2.2e3, 2e3, firdes.WIN_HAMMING), 57e3, baseband_sample_rate) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( x_decimation, firdes.low_pass(1, samp_rate, 100e3, 100e3), 0, samp_rate) self.fm_stereo_audio_decoder_0 = fm_stereo_audio_decoder( audio_rate=audio_rate, baseband_rate=baseband_sample_rate, volume=-15., ) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( samples_per_symbol, 2 * 6.28 / 100, firdes.root_raised_cosine(32, 32 * 7, 1.0, excess_bw, 11 * 7 * 32), 32, 16, 1.5, 1) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc( samples_per_symbol, excess_bw, 55, .3 * 6.28 / 100) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb( digital.constellation_bpsk().base(), 4 * 6.28 / 100, -.25, .25) self._dgain_range = Range(0, 50, 1, 30, 200) self._dgain_win = RangeWidget(self._dgain_range, self.set_dgain, 'RF Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._dgain_win, 0, 0, 1, 4) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.blocks_null_source_0 = blocks.null_source(gr.sizeof_gr_complex * 1) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_char * 1, symbols_per_bit) self.audio_sink_0_0 = audio.sink(int(audio_rate), '', True) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=x_samp_rate, audio_decimation=baseband_decim, ) self.analog_agc2_xx_0 = analog.agc2_cc(.6e-1, 1e-3, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect((self.rds_decoder_0, 'out'), (self.rds_parser_0, 'in')) self.msg_connect((self.rds_parser_0, 'out'), (self.rds_panel_0, 'in')) self.connect((self.analog_agc2_xx_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.fm_stereo_audio_decoder_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.freq_xlating_fir_filter_xxx_1, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.qtgui_freq_sink_x_0_0_0_1, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.blocks_null_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 3), (self.blocks_null_sink_0_0, 2)) self.connect((self.digital_constellation_receiver_cb_0, 2), (self.blocks_null_sink_0_0, 1)) self.connect((self.digital_constellation_receiver_cb_0, 1), (self.blocks_null_sink_0_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 4), (self.qtgui_const_sink_x_0, 1)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.rds_decoder_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.qtgui_freq_sink_x_1, 1)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_constellation_receiver_cb_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.fm_stereo_audio_decoder_0, 1), (self.audio_sink_0_0, 1)) self.connect((self.fm_stereo_audio_decoder_0, 0), (self.audio_sink_0_0, 0)) self.connect((self.fm_stereo_audio_decoder_0, 4), (self.qtgui_freq_sink_x_0_0_0_1_0, 0)) self.connect((self.fm_stereo_audio_decoder_0, 5), (self.qtgui_freq_sink_x_0_0_0_1_0_0, 0)) self.connect((self.fm_stereo_audio_decoder_0, 2), (self.qtgui_freq_sink_x_0_0_0_1_0_1, 0)) self.connect((self.fm_stereo_audio_decoder_0, 3), (self.qtgui_time_sink_x_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.qtgui_freq_sink_x_1, 0))
def __init__(self): gr.top_block.__init__(self, "2M Multi-RX -- 7 simultaneous channels") Qt.QWidget.__init__(self) self.setWindowTitle("2M Multi-RX -- 7 simultaneous channels") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "noaa_demo") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.noaa_num_chans = noaa_num_chans = 7 self.noaa_chan_width = noaa_chan_width = int(15e3) self.noaa_band_start = noaa_band_start = 146.475e6 self.oversampled_width = oversampled_width = noaa_chan_width * ( noaa_num_chans + 1) self.noaa_fm_dev = noaa_fm_dev = int(5e3) self.noaa_band_center = noaa_band_center = noaa_band_start + ( noaa_num_chans / 2 * noaa_chan_width) self.hardware_rate = hardware_rate = int(1e6) self.tuner_freq = tuner_freq = 146.4e6 self.target_freq = target_freq = noaa_band_center self.ppm = ppm = 0 self.pfb_taps = pfb_taps = firdes.low_pass(2.0, oversampled_width, noaa_fm_dev * 2, 1000, firdes.WIN_HAMMING, 6.76) self.lpf_taps = lpf_taps = firdes.low_pass(1.0, hardware_rate, oversampled_width / 2, noaa_chan_width, firdes.WIN_HAMMING, 6.76) self.channel_map = channel_map = range(0, noaa_num_chans) self.volume = volume = 0.4 self.tuner_offset = tuner_offset = target_freq - tuner_freq self.squelch = squelch = -55 self.sq_ramp = sq_ramp = 10 self.sq_alpha = sq_alpha = 0.005 self.ppm_corr = ppm_corr = tuner_freq * (ppm / 1e6) self.pfb_sizeof_taps = pfb_sizeof_taps = len(pfb_taps) self.noaa_band_width = noaa_band_width = noaa_chan_width * noaa_num_chans self.noaa_band_end = noaa_band_end = noaa_band_start + ( noaa_num_chans * noaa_chan_width) self.lpf_sizeof_taps = lpf_sizeof_taps = len(lpf_taps) self.fftwidth = fftwidth = 512 self.fft_interval = fft_interval = 1.0 / 20 self.decimation = decimation = hardware_rate / oversampled_width self.channelizer_map = channelizer_map = 5, 6, 7, 0, 1, 2, 3 self.channel_names = channel_names = map( lambda x: "%.3fMHz" % (146.475 + (x * 0.015)), channel_map) self.ch6_mute = ch6_mute = 1 self.ch5_mute = ch5_mute = 1 self.ch4_mute = ch4_mute = 1 self.ch3_mute = ch3_mute = 1 self.ch2_mute = ch2_mute = 1 self.ch1_mute = ch1_mute = 1 self.ch0_mute = ch0_mute = 1 self.audio_rate = audio_rate = 15000 ################################################## # Blocks ################################################## self._volume_range = Range(0, 1, 0.01, 0.4, 50) self._volume_win = RangeWidget(self._volume_range, self.set_volume, "volume", "slider", float) self.top_grid_layout.addWidget(self._volume_win, 0, 0, 1, 3) self._squelch_range = Range(-70, -30, 2, -55, 50) self._squelch_win = RangeWidget(self._squelch_range, self.set_squelch, "squelch", "slider", float) self.top_grid_layout.addWidget(self._squelch_win, 0, 3, 1, 3) self._ch6_mute_options = ( 0, 1, ) self._ch6_mute_labels = ( "Mute", "Unmute", ) self._ch6_mute_group_box = Qt.QGroupBox("Ch6") self._ch6_mute_box = Qt.QVBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._ch6_mute_button_group = variable_chooser_button_group() self._ch6_mute_group_box.setLayout(self._ch6_mute_box) for i, label in enumerate(self._ch6_mute_labels): radio_button = Qt.QRadioButton(label) self._ch6_mute_box.addWidget(radio_button) self._ch6_mute_button_group.addButton(radio_button, i) self._ch6_mute_callback = lambda i: Qt.QMetaObject.invokeMethod( self._ch6_mute_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._ch6_mute_options.index(i))) self._ch6_mute_callback(self.ch6_mute) self._ch6_mute_button_group.buttonClicked[int].connect( lambda i: self.set_ch6_mute(self._ch6_mute_options[i])) self.top_grid_layout.addWidget(self._ch6_mute_group_box, 1, 6, 1, 1) self._ch5_mute_options = ( 0, 1, ) self._ch5_mute_labels = ( "Mute", "Unmute", ) self._ch5_mute_group_box = Qt.QGroupBox("Ch5") self._ch5_mute_box = Qt.QVBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._ch5_mute_button_group = variable_chooser_button_group() self._ch5_mute_group_box.setLayout(self._ch5_mute_box) for i, label in enumerate(self._ch5_mute_labels): radio_button = Qt.QRadioButton(label) self._ch5_mute_box.addWidget(radio_button) self._ch5_mute_button_group.addButton(radio_button, i) self._ch5_mute_callback = lambda i: Qt.QMetaObject.invokeMethod( self._ch5_mute_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._ch5_mute_options.index(i))) self._ch5_mute_callback(self.ch5_mute) self._ch5_mute_button_group.buttonClicked[int].connect( lambda i: self.set_ch5_mute(self._ch5_mute_options[i])) self.top_grid_layout.addWidget(self._ch5_mute_group_box, 1, 5, 1, 1) self._ch4_mute_options = ( 0, 1, ) self._ch4_mute_labels = ( "Mute", "Unmute", ) self._ch4_mute_group_box = Qt.QGroupBox("Ch4") self._ch4_mute_box = Qt.QVBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._ch4_mute_button_group = variable_chooser_button_group() self._ch4_mute_group_box.setLayout(self._ch4_mute_box) for i, label in enumerate(self._ch4_mute_labels): radio_button = Qt.QRadioButton(label) self._ch4_mute_box.addWidget(radio_button) self._ch4_mute_button_group.addButton(radio_button, i) self._ch4_mute_callback = lambda i: Qt.QMetaObject.invokeMethod( self._ch4_mute_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._ch4_mute_options.index(i))) self._ch4_mute_callback(self.ch4_mute) self._ch4_mute_button_group.buttonClicked[int].connect( lambda i: self.set_ch4_mute(self._ch4_mute_options[i])) self.top_grid_layout.addWidget(self._ch4_mute_group_box, 1, 4, 1, 1) self._ch2_mute_options = ( 0, 1, ) self._ch2_mute_labels = ( "Mute", "Unmute", ) self._ch2_mute_group_box = Qt.QGroupBox("Ch2") self._ch2_mute_box = Qt.QVBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._ch2_mute_button_group = variable_chooser_button_group() self._ch2_mute_group_box.setLayout(self._ch2_mute_box) for i, label in enumerate(self._ch2_mute_labels): radio_button = Qt.QRadioButton(label) self._ch2_mute_box.addWidget(radio_button) self._ch2_mute_button_group.addButton(radio_button, i) self._ch2_mute_callback = lambda i: Qt.QMetaObject.invokeMethod( self._ch2_mute_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._ch2_mute_options.index(i))) self._ch2_mute_callback(self.ch2_mute) self._ch2_mute_button_group.buttonClicked[int].connect( lambda i: self.set_ch2_mute(self._ch2_mute_options[i])) self.top_grid_layout.addWidget(self._ch2_mute_group_box, 1, 2, 1, 1) self._ch1_mute_options = ( 0, 1, ) self._ch1_mute_labels = ( "Mute", "Unmute", ) self._ch1_mute_group_box = Qt.QGroupBox("Ch1") self._ch1_mute_box = Qt.QVBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._ch1_mute_button_group = variable_chooser_button_group() self._ch1_mute_group_box.setLayout(self._ch1_mute_box) for i, label in enumerate(self._ch1_mute_labels): radio_button = Qt.QRadioButton(label) self._ch1_mute_box.addWidget(radio_button) self._ch1_mute_button_group.addButton(radio_button, i) self._ch1_mute_callback = lambda i: Qt.QMetaObject.invokeMethod( self._ch1_mute_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._ch1_mute_options.index(i))) self._ch1_mute_callback(self.ch1_mute) self._ch1_mute_button_group.buttonClicked[int].connect( lambda i: self.set_ch1_mute(self._ch1_mute_options[i])) self.top_grid_layout.addWidget(self._ch1_mute_group_box, 1, 1, 1, 1) self._ch0_mute_options = ( 0, 1, ) self._ch0_mute_labels = ( "Mute", "Unmute", ) self._ch0_mute_group_box = Qt.QGroupBox("Ch0") self._ch0_mute_box = Qt.QVBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._ch0_mute_button_group = variable_chooser_button_group() self._ch0_mute_group_box.setLayout(self._ch0_mute_box) for i, label in enumerate(self._ch0_mute_labels): radio_button = Qt.QRadioButton(label) self._ch0_mute_box.addWidget(radio_button) self._ch0_mute_button_group.addButton(radio_button, i) self._ch0_mute_callback = lambda i: Qt.QMetaObject.invokeMethod( self._ch0_mute_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._ch0_mute_options.index(i))) self._ch0_mute_callback(self.ch0_mute) self._ch0_mute_button_group.buttonClicked[int].connect( lambda i: self.set_ch0_mute(self._ch0_mute_options[i])) self.top_grid_layout.addWidget(self._ch0_mute_group_box, 1, 0, 1, 1) self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "") self.rtlsdr_source_0.set_clock_source("internal", 0) self.rtlsdr_source_0.set_sample_rate(hardware_rate) self.rtlsdr_source_0.set_center_freq(tuner_freq, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(10, 0) self.rtlsdr_source_0.set_if_gain(30, 0) self.rtlsdr_source_0.set_bb_gain(40, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.rational_resampler_xxx_0_0_0 = filter.rational_resampler_fff( interpolation=48, decimation=15, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0_0_0 = qtgui.waterfall_sink_c( fftwidth, #size firdes.WIN_BLACKMAN_hARRIS, #wintype target_freq, #fc oversampled_width, #bw "Band Monitor", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0_0_0.set_update_time(fft_interval) self.qtgui_waterfall_sink_x_0_0_0.enable_grid(True) if not True: self.qtgui_waterfall_sink_x_0_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0_0_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [5, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0_0_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0_0_0.set_intensity_range(-100, 0) self._qtgui_waterfall_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_0_0_win, 2, 0, 1, 9) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( fftwidth, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc noaa_chan_width, #bw "Channelizer Output", #name noaa_num_chans #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(fft_interval) self.qtgui_freq_sink_x_0.set_y_axis(-100, 0) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = [ channel_names[0], channel_names[1], channel_names[2], channel_names[3], channel_names[4], channel_names[5], channel_names[6], "channel_names[7]", "", "" ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "dark red", "dark green", "dark blue", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(noaa_num_chans): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 3, 0, 1, 9) self._ppm_range = Range(-60, 60, 1, 0, 50) self._ppm_win = RangeWidget(self._ppm_range, self.set_ppm, "ppm", "slider", float) self.top_grid_layout.addWidget(self._ppm_win, 0, 6, 1, 3) self.pfb_channelizer_ccf_0 = pfb.channelizer_ccf( noaa_num_chans + 1, (pfb_taps), 1, 1) self.pfb_channelizer_ccf_0.set_channel_map((channelizer_map)) self.pfb_channelizer_ccf_0.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc( int(decimation), (lpf_taps), tuner_offset + ppm_corr, hardware_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) self._ch3_mute_options = ( 0, 1, ) self._ch3_mute_labels = ( "Mute", "Unmute", ) self._ch3_mute_group_box = Qt.QGroupBox("Ch3") self._ch3_mute_box = Qt.QVBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._ch3_mute_button_group = variable_chooser_button_group() self._ch3_mute_group_box.setLayout(self._ch3_mute_box) for i, label in enumerate(self._ch3_mute_labels): radio_button = Qt.QRadioButton(label) self._ch3_mute_box.addWidget(radio_button) self._ch3_mute_button_group.addButton(radio_button, i) self._ch3_mute_callback = lambda i: Qt.QMetaObject.invokeMethod( self._ch3_mute_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._ch3_mute_options.index(i))) self._ch3_mute_callback(self.ch3_mute) self._ch3_mute_button_group.buttonClicked[int].connect( lambda i: self.set_ch3_mute(self._ch3_mute_options[i])) self.top_grid_layout.addWidget(self._ch3_mute_group_box, 1, 3, 1, 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_multiply_const_vxx_1_2_0_1 = blocks.multiply_const_vcc( (ch6_mute, )) self.blocks_multiply_const_vxx_1_2_0_0 = blocks.multiply_const_vcc( (ch5_mute, )) self.blocks_multiply_const_vxx_1_2_0 = blocks.multiply_const_vcc( (ch4_mute, )) self.blocks_multiply_const_vxx_1_1_0 = blocks.multiply_const_vcc( (ch2_mute, )) self.blocks_multiply_const_vxx_1_1 = blocks.multiply_const_vcc( (ch2_mute, )) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vcc( (ch1_mute, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc( (ch0_mute, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (volume, )) self.blocks_add_xx_0_0 = blocks.add_vff(1) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_pwr_squelch_xx_0_2_0_1 = analog.pwr_squelch_cc( squelch, sq_alpha, sq_ramp, False) self.analog_pwr_squelch_xx_0_2_0_0 = analog.pwr_squelch_cc( squelch, sq_alpha, sq_ramp, False) self.analog_pwr_squelch_xx_0_2_0 = analog.pwr_squelch_cc( squelch, sq_alpha, sq_ramp, False) self.analog_pwr_squelch_xx_0_2 = analog.pwr_squelch_cc( squelch, sq_alpha, sq_ramp, False) self.analog_pwr_squelch_xx_0_1 = analog.pwr_squelch_cc( squelch, sq_alpha, sq_ramp, False) self.analog_pwr_squelch_xx_0_0 = analog.pwr_squelch_cc( squelch, sq_alpha, sq_ramp, False) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc( squelch, sq_alpha, sq_ramp, False) self.analog_nbfm_rx_0_2_0_1 = analog.nbfm_rx( audio_rate=audio_rate, quad_rate=noaa_chan_width, tau=75e-6, max_dev=noaa_fm_dev, ) self.analog_nbfm_rx_0_2_0_0 = analog.nbfm_rx( audio_rate=audio_rate, quad_rate=noaa_chan_width, tau=75e-6, max_dev=noaa_fm_dev, ) self.analog_nbfm_rx_0_2_0 = analog.nbfm_rx( audio_rate=audio_rate, quad_rate=noaa_chan_width, tau=75e-6, max_dev=noaa_fm_dev, ) self.analog_nbfm_rx_0_2 = analog.nbfm_rx( audio_rate=audio_rate, quad_rate=noaa_chan_width, tau=75e-6, max_dev=noaa_fm_dev, ) self.analog_nbfm_rx_0_1 = analog.nbfm_rx( audio_rate=audio_rate, quad_rate=noaa_chan_width, tau=75e-6, max_dev=noaa_fm_dev, ) self.analog_nbfm_rx_0_0 = analog.nbfm_rx( audio_rate=audio_rate, quad_rate=noaa_chan_width, tau=75e-6, max_dev=noaa_fm_dev, ) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=audio_rate, quad_rate=noaa_chan_width, tau=75e-6, max_dev=noaa_fm_dev, ) ################################################## # Connections ################################################## self.connect((self.analog_nbfm_rx_0, 0), (self.blocks_add_xx_0_0, 0)) self.connect((self.analog_nbfm_rx_0_0, 0), (self.blocks_add_xx_0_0, 1)) self.connect((self.analog_nbfm_rx_0_1, 0), (self.blocks_add_xx_0_0, 2)) self.connect((self.analog_nbfm_rx_0_2, 0), (self.blocks_add_xx_0_0, 3)) self.connect((self.analog_nbfm_rx_0_2_0, 0), (self.blocks_add_xx_0_0, 4)) self.connect((self.analog_nbfm_rx_0_2_0_0, 0), (self.blocks_add_xx_0_0, 5)) self.connect((self.analog_nbfm_rx_0_2_0_1, 0), (self.blocks_add_xx_0_0, 6)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.analog_pwr_squelch_xx_0_0, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.analog_pwr_squelch_xx_0_1, 0), (self.blocks_multiply_const_vxx_1_1, 0)) self.connect((self.analog_pwr_squelch_xx_0_2, 0), (self.blocks_multiply_const_vxx_1_1_0, 0)) self.connect((self.analog_pwr_squelch_xx_0_2_0, 0), (self.blocks_multiply_const_vxx_1_2_0, 0)) self.connect((self.analog_pwr_squelch_xx_0_2_0_0, 0), (self.blocks_multiply_const_vxx_1_2_0_0, 0)) self.connect((self.analog_pwr_squelch_xx_0_2_0_1, 0), (self.blocks_multiply_const_vxx_1_2_0_1, 0)) self.connect((self.blocks_add_xx_0_0, 0), (self.rational_resampler_xxx_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.analog_nbfm_rx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.analog_nbfm_rx_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_1, 0), (self.analog_nbfm_rx_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_1_1_0, 0), (self.analog_nbfm_rx_0_2, 0)) self.connect((self.blocks_multiply_const_vxx_1_2_0, 0), (self.analog_nbfm_rx_0_2_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_2_0_0, 0), (self.analog_nbfm_rx_0_2_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_2_0_1, 0), (self.analog_nbfm_rx_0_2_0_1, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.pfb_channelizer_ccf_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.qtgui_waterfall_sink_x_0_0_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 1), (self.analog_pwr_squelch_xx_0_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 2), (self.analog_pwr_squelch_xx_0_1, 0)) self.connect((self.pfb_channelizer_ccf_0, 3), (self.analog_pwr_squelch_xx_0_2, 0)) self.connect((self.pfb_channelizer_ccf_0, 4), (self.analog_pwr_squelch_xx_0_2_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 5), (self.analog_pwr_squelch_xx_0_2_0_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 6), (self.analog_pwr_squelch_xx_0_2_0_1, 0)) self.connect((self.pfb_channelizer_ccf_0, 7), (self.blocks_null_sink_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 1), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.pfb_channelizer_ccf_0, 2), (self.qtgui_freq_sink_x_0, 2)) self.connect((self.pfb_channelizer_ccf_0, 3), (self.qtgui_freq_sink_x_0, 3)) self.connect((self.pfb_channelizer_ccf_0, 4), (self.qtgui_freq_sink_x_0, 4)) self.connect((self.pfb_channelizer_ccf_0, 5), (self.qtgui_freq_sink_x_0, 5)) self.connect((self.pfb_channelizer_ccf_0, 6), (self.qtgui_freq_sink_x_0, 6)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.vector = vector = (88.1e6, 89.1e6, 89.7e6, 90.1e6, 90.5e6, 90.9e6, 91.3e6, 92.1e6, 92.5e6, 92.9e6, 93.7e6, 94.1e6, 94.7e6, 95.3e6, 95.7e6, 96.1e6, 96.5e6, 96.9e6, 97.3e6, 97.7e6, 98.1e6, 98.5e6, 98.9e6, 99.3e6, 100.1e6, 100.9e6, 101.3e6, 101.5e6, 101.7e6, 102.1e6, 102.5e6, 103.3e6, 104.1e6, 104.3e6, 104.7e6, 105.1e6, 105.7e6, 106.3e6, 106.9e6, 107.3e6, 107.9e6) self.indice = indice = 0 self.ajuste = ajuste = 0 self.samp_rate = samp_rate = 2.4e6 self.freq_Passa_Faixa_REAL = freq_Passa_Faixa_REAL = vector[indice] + ( vector[indice + 1] - vector[indice]) + ajuste self.freq_Passa_Faixa = freq_Passa_Faixa = vector[indice + 1] self.freq_Passa_Baixa = freq_Passa_Baixa = vector[indice] self.down_rate = down_rate = 25e4 self.bw = bw = 100e3 self.Update_Interval = Update_Interval = 0.1 self.OutputDir = OutputDir = "/home/iris/Desktop/medidas/" self.FileNameCP = FileNameCP = "CP_" + str(indice) + "_" + str( vector[indice]) + ".bin" self.FileNameCAS = FileNameCAS = "CAS_" + str(indice + 1) + "_" + str( vector[indice + 1]) + ".bin" ################################################## # Blocks ################################################## self._indice_range = Range(0, 40, 1, 0, 2) self._indice_win = RangeWidget(self._indice_range, self.set_indice, "indice", "counter", int) self.top_grid_layout.addWidget(self._indice_win, 2, 3, 1, 3) self._ajuste_range = Range(-600e3, 600e3, 100, 0, 300) self._ajuste_win = RangeWidget(self._ajuste_range, self.set_ajuste, "ajuste", "counter_slider", float) self.top_grid_layout.addWidget(self._ajuste_win, 2, 0, 1, 3) self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + '') self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(vector[indice], 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(70, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.qtgui_freq_sink_x_1_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype vector[indice], #fc samp_rate, #bw 'Filtro Passa Baixa', #name 1 #number of inputs ) self.qtgui_freq_sink_x_1_1.set_update_time(0.10) self.qtgui_freq_sink_x_1_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1_1.set_y_label('Ganho Relativo', 'dB') self.qtgui_freq_sink_x_1_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1_1.enable_autoscale(False) self.qtgui_freq_sink_x_1_1.enable_grid(False) self.qtgui_freq_sink_x_1_1.set_fft_average(0.1) self.qtgui_freq_sink_x_1_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1_1.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1_1.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_1_win = sip.wrapinstance( self.qtgui_freq_sink_x_1_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_1_win, 6, 0, 1, 3) self.qtgui_freq_sink_x_1_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype vector[indice] + (vector[indice + 1] - vector[indice]) + ajuste, #fc samp_rate, #bw 'Filtro Passa Faixa', #name 1 #number of inputs ) self.qtgui_freq_sink_x_1_0.set_update_time(Update_Interval / 10) self.qtgui_freq_sink_x_1_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1_0.set_y_label('Ganho Relativo', 'dB') self.qtgui_freq_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1_0.enable_autoscale(False) self.qtgui_freq_sink_x_1_0.enable_grid(False) self.qtgui_freq_sink_x_1_0.set_fft_average(0.1) self.qtgui_freq_sink_x_1_0.enable_axis_labels(True) self.qtgui_freq_sink_x_1_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_0_win, 6, 4, 1, 3) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype vector[indice], #fc samp_rate, #bw 'antes de filtrar', #name 1 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(Update_Interval / 10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(0.05) self.qtgui_freq_sink_x_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance( self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 5, 0, 1, 6) self.low_pass_filter_0_1 = filter.fir_filter_ccf( 8, firdes.low_pass(2, samp_rate, 100e3, 10e3, firdes.WIN_HAMMING, 6.76)) self._freq_Passa_Faixa_REAL_tool_bar = Qt.QToolBar(self) if None: self._freq_Passa_Faixa_REAL_formatter = None else: self._freq_Passa_Faixa_REAL_formatter = lambda x: eng_notation.num_to_str( x) self._freq_Passa_Faixa_REAL_tool_bar.addWidget( Qt.QLabel('Freq (Chanel +1) + ajuste (PF)' + ": ")) self._freq_Passa_Faixa_REAL_label = Qt.QLabel( str( self._freq_Passa_Faixa_REAL_formatter( self.freq_Passa_Faixa_REAL))) self._freq_Passa_Faixa_REAL_tool_bar.addWidget( self._freq_Passa_Faixa_REAL_label) self.top_grid_layout.addWidget(self._freq_Passa_Faixa_REAL_tool_bar, 3, 5, 1, 3) self._freq_Passa_Faixa_tool_bar = Qt.QToolBar(self) if None: self._freq_Passa_Faixa_formatter = None else: self._freq_Passa_Faixa_formatter = lambda x: eng_notation.num_to_str( x) self._freq_Passa_Faixa_tool_bar.addWidget( Qt.QLabel('Freq(chanel + 1)' + ": ")) self._freq_Passa_Faixa_label = Qt.QLabel( str(self._freq_Passa_Faixa_formatter(self.freq_Passa_Faixa))) self._freq_Passa_Faixa_tool_bar.addWidget(self._freq_Passa_Faixa_label) self.top_grid_layout.addWidget(self._freq_Passa_Faixa_tool_bar, 3, 3, 1, 3) self._freq_Passa_Baixa_tool_bar = Qt.QToolBar(self) if None: self._freq_Passa_Baixa_formatter = None else: self._freq_Passa_Baixa_formatter = lambda x: eng_notation.num_to_str( x) self._freq_Passa_Baixa_tool_bar.addWidget( Qt.QLabel('Freq (Chanel)' + ": ")) self._freq_Passa_Baixa_label = Qt.QLabel( str(self._freq_Passa_Baixa_formatter(self.freq_Passa_Baixa))) self._freq_Passa_Baixa_tool_bar.addWidget(self._freq_Passa_Baixa_label) self.top_grid_layout.addWidget(self._freq_Passa_Baixa_tool_bar, 3, 0, 1, 3) self.blocks_rms_xx_1 = blocks.rms_cf(0.0001) self.blocks_rms_xx_0 = blocks.rms_cf(0.0001) self.blocks_nlog10_ff_0_1 = blocks.nlog10_ff(20, 1, 1) self.blocks_nlog10_ff_0_0 = blocks.nlog10_ff(20, 1, 1) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_float * 1, OutputDir + FileNameCP, False) self.blocks_file_sink_1.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float * 1, OutputDir + FileNameCAS, False) self.blocks_file_sink_0.set_unbuffered(False) self.band_pass_filter = filter.fir_filter_ccf( 8, firdes.band_pass( 2, samp_rate, (vector[indice + 1] - vector[indice]) - bw + ajuste, (vector[indice + 1] - vector[indice]) + bw + ajuste, 10e3, firdes.WIN_HAMMING, 6.76)) self.POTENCIA_PASSA_FAIXA = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1) self.POTENCIA_PASSA_FAIXA.set_update_time(Update_Interval) self.POTENCIA_PASSA_FAIXA.set_title('POT_CAS (dB)') labels = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.POTENCIA_PASSA_FAIXA.set_min(i, -1) self.POTENCIA_PASSA_FAIXA.set_max(i, 1) self.POTENCIA_PASSA_FAIXA.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.POTENCIA_PASSA_FAIXA.set_label(i, "Data {0}".format(i)) else: self.POTENCIA_PASSA_FAIXA.set_label(i, labels[i]) self.POTENCIA_PASSA_FAIXA.set_unit(i, units[i]) self.POTENCIA_PASSA_FAIXA.set_factor(i, factor[i]) self.POTENCIA_PASSA_FAIXA.enable_autoscale(False) self._POTENCIA_PASSA_FAIXA_win = sip.wrapinstance( self.POTENCIA_PASSA_FAIXA.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._POTENCIA_PASSA_FAIXA_win, 4, 3, 1, 3) self.POTENCIA_PASSA_BAIXA = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1) self.POTENCIA_PASSA_BAIXA.set_update_time(Update_Interval) self.POTENCIA_PASSA_BAIXA.set_title('POT_CP (dB)') labels = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.POTENCIA_PASSA_BAIXA.set_min(i, -1) self.POTENCIA_PASSA_BAIXA.set_max(i, 1) self.POTENCIA_PASSA_BAIXA.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.POTENCIA_PASSA_BAIXA.set_label(i, "Data {0}".format(i)) else: self.POTENCIA_PASSA_BAIXA.set_label(i, labels[i]) self.POTENCIA_PASSA_BAIXA.set_unit(i, units[i]) self.POTENCIA_PASSA_BAIXA.set_factor(i, factor[i]) self.POTENCIA_PASSA_BAIXA.enable_autoscale(False) self._POTENCIA_PASSA_BAIXA_win = sip.wrapinstance( self.POTENCIA_PASSA_BAIXA.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._POTENCIA_PASSA_BAIXA_win, 4, 0, 1, 3) ################################################## # Connections ################################################## self.connect((self.band_pass_filter, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.band_pass_filter, 0), (self.qtgui_freq_sink_x_1_0, 0)) self.connect((self.blocks_nlog10_ff_0_0, 0), (self.POTENCIA_PASSA_BAIXA, 0)) self.connect((self.blocks_nlog10_ff_0_0, 0), (self.blocks_file_sink_1, 0)) self.connect((self.blocks_nlog10_ff_0_1, 0), (self.POTENCIA_PASSA_FAIXA, 0)) self.connect((self.blocks_nlog10_ff_0_1, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.blocks_nlog10_ff_0_1, 0)) self.connect((self.blocks_rms_xx_1, 0), (self.blocks_nlog10_ff_0_0, 0)) self.connect((self.low_pass_filter_0_1, 0), (self.blocks_rms_xx_1, 0)) self.connect((self.low_pass_filter_0_1, 0), (self.qtgui_freq_sink_x_1_1, 0)) self.connect((self.rtlsdr_source_0, 0), (self.band_pass_filter, 0)) self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0_1, 0)) self.connect((self.rtlsdr_source_0, 0), (self.qtgui_freq_sink_x_1, 0))
def __init__(self, gain=30, ppm=0, samp_rate=2000000.052982, shiftoff=400e3, fc=939.4e6*0+948e6): gr.top_block.__init__(self, "Airprobe Bladerf") Qt.QWidget.__init__(self) self.setWindowTitle("Airprobe Bladerf") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "airprobe_bladerf") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.gain = gain self.ppm = ppm self.samp_rate = samp_rate self.shiftoff = shiftoff self.fc = fc ################################################## # Variables ################################################## self.ppm_slider = ppm_slider = ppm self.g_slider = g_slider = gain self.fc_slider = fc_slider = fc ################################################## # Blocks ################################################## self._ppm_slider_range = Range(-150, 150, 1, ppm, 100) self._ppm_slider_win = RangeWidget(self._ppm_slider_range, self.set_ppm_slider, "PPM Offset", "counter") self.top_layout.addWidget(self._ppm_slider_win) self._g_slider_range = Range(0, 50, 0.5, gain, 100) self._g_slider_win = RangeWidget(self._g_slider_range, self.set_g_slider, "Gain", "counter") self.top_layout.addWidget(self._g_slider_win) self._fc_slider_range = Range(925e6, 1990e6, 2e5, fc, 100) self._fc_slider_win = RangeWidget(self._fc_slider_range, self.set_fc_slider, "Frequency", "counter_slider") self.top_layout.addWidget(self._fc_slider_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype fc_slider, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if complex == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "bladerf=0" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(fc_slider-shiftoff, 0) self.osmosdr_source_0.set_freq_corr(ppm_slider, 0) self.osmosdr_source_0.set_dc_offset_mode(2, 0) self.osmosdr_source_0.set_iq_balance_mode(2, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(g_slider, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(250e3+abs(shiftoff), 0) self.gsm_sdcch8_demapper_0 = grgsm.universal_ctrl_chans_demapper(1, ([0,4,8,12,16,20,24,28,32,36,40,44]), ([8,8,8,8,8,8,8,8,136,136,136,136])) self.gsm_receiver_0 = grgsm.receiver(4, ([0]), ([])) self.gsm_message_printer_1 = grgsm.message_printer(pmt.intern(""), False, False, False) self.gsm_input_0 = grgsm.gsm_input( ppm=0, osr=4, fc=fc, samp_rate_in=samp_rate, ) self.gsm_decryption_0 = grgsm.decryption(([]), 1) self.gsm_control_channels_decoder_0_0 = grgsm.control_channels_decoder() self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() self.gsm_clock_offset_control_0 = grgsm.clock_offset_control(fc-shiftoff) self.gsm_bcch_ccch_demapper_0 = grgsm.universal_ctrl_chans_demapper(0, ([2,6,12,16,22,26,32,36,42,46]), ([1,2,2,2,2,2,2,2,2,2])) self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "127.0.0.1", "4729", 10000, False) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000, False) self.blocks_rotator_cc_0 = blocks.rotator_cc(-2*pi*shiftoff/samp_rate) ################################################## # Connections ################################################## self.msg_connect((self.gsm_bcch_ccch_demapper_0, 'bursts'), (self.gsm_control_channels_decoder_0, 'bursts')) self.msg_connect((self.gsm_clock_offset_control_0, 'ppm'), (self.gsm_input_0, 'ppm_in')) self.msg_connect((self.gsm_control_channels_decoder_0, 'msgs'), (self.blocks_socket_pdu_0, 'pdus')) self.msg_connect((self.gsm_control_channels_decoder_0, 'msgs'), (self.gsm_message_printer_1, 'msgs')) self.msg_connect((self.gsm_control_channels_decoder_0_0, 'msgs'), (self.blocks_socket_pdu_0, 'pdus')) self.msg_connect((self.gsm_control_channels_decoder_0_0, 'msgs'), (self.gsm_message_printer_1, 'msgs')) self.msg_connect((self.gsm_decryption_0, 'bursts'), (self.gsm_control_channels_decoder_0_0, 'bursts')) self.msg_connect((self.gsm_receiver_0, 'C0'), (self.gsm_bcch_ccch_demapper_0, 'bursts')) self.msg_connect((self.gsm_receiver_0, 'measurements'), (self.gsm_clock_offset_control_0, 'measurements')) self.msg_connect((self.gsm_receiver_0, 'C0'), (self.gsm_sdcch8_demapper_0, 'bursts')) self.msg_connect((self.gsm_sdcch8_demapper_0, 'bursts'), (self.gsm_decryption_0, 'bursts')) self.connect((self.blocks_rotator_cc_0, 0), (self.gsm_input_0, 0)) self.connect((self.blocks_rotator_cc_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_rotator_cc_0, 0))
def __init__(self): gr.top_block.__init__(self, "Comms Signal Viewer") Qt.QWidget.__init__(self) self.setWindowTitle("Comms Signal Viewer") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "SignalViewer") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 20e6 self.recordBool = recordBool = True self.fskDemodBool = fskDemodBool = True self.freq = freq = 100e6 self.fmDemodBool = fmDemodBool = True ################################################## # Blocks ################################################## self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel("Sample Rate"+": ")) self._samp_rate_line_edit = Qt.QLineEdit(str(self.samp_rate)) self._samp_rate_tool_bar.addWidget(self._samp_rate_line_edit) self._samp_rate_line_edit.returnPressed.connect( lambda: self.set_samp_rate(eng_notation.str_to_num(self._samp_rate_line_edit.text().toAscii()))) self.top_grid_layout.addWidget(self._samp_rate_tool_bar, 4,1,1,2) _recordBool_check_box = Qt.QCheckBox("Don't Record IQ") self._recordBool_choices = {True: True, False: False} self._recordBool_choices_inv = dict((v,k) for k,v in self._recordBool_choices.iteritems()) self._recordBool_callback = lambda i: Qt.QMetaObject.invokeMethod(_recordBool_check_box, "setChecked", Qt.Q_ARG("bool", self._recordBool_choices_inv[i])) self._recordBool_callback(self.recordBool) _recordBool_check_box.stateChanged.connect(lambda i: self.set_recordBool(self._recordBool_choices[bool(i)])) self.top_grid_layout.addWidget(_recordBool_check_box, 6,4,1,1) self.main_tab = Qt.QTabWidget() self.main_tab_widget_0 = Qt.QWidget() self.main_tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.main_tab_widget_0) self.main_tab_grid_layout_0 = Qt.QGridLayout() self.main_tab_layout_0.addLayout(self.main_tab_grid_layout_0) self.main_tab.addTab(self.main_tab_widget_0, "PSD") self.main_tab_widget_1 = Qt.QWidget() self.main_tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.main_tab_widget_1) self.main_tab_grid_layout_1 = Qt.QGridLayout() self.main_tab_layout_1.addLayout(self.main_tab_grid_layout_1) self.main_tab.addTab(self.main_tab_widget_1, "Waterfall") self.top_grid_layout.addWidget(self.main_tab, 1,1,3,5) self._freq_layout = Qt.QHBoxLayout() self._freq_layout.addWidget(Qt.QLabel("Frequency"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._freq_counter = qwt_counter_pyslot() self._freq_counter.setRange(10e6, 6e9, 0.5e6) self._freq_counter.setNumButtons(2) self._freq_counter.setMinimumWidth(200) self._freq_counter.setValue(self.freq) self._freq_layout.addWidget(self._freq_counter) self._freq_counter.valueChanged.connect(self.set_freq) self.top_grid_layout.addLayout(self._freq_layout, 4,3,1,3) self.volumeBlock = blocks.multiply_const_vff((100, )) self.recordIQ = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(recordBool)) self.rational_resampler_xxx_0_0_0 = filter.rational_resampler_fff( interpolation=48, decimation=50, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=1, decimation=4, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024*4, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #fc 1e6/4, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) if complex == type(float()): self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [5, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.main_tab_layout_1.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2*1): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_char, 0, qtgui.NUM_GRAPH_HORIZ, 1 ) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ["", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 7,1,1,5) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024*4, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #fc 1e6/4, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) if complex == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.main_tab_layout_0.addWidget(self._qtgui_freq_sink_x_0_win) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "hackrf" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(2, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(0, 0) self.osmosdr_source_0.set_if_gain(0, 0) self.osmosdr_source_0.set_bb_gain(0, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.low_pass_filter_0_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, 100e3, 1e6, firdes.WIN_HAMMING, 6.76)) _fskDemodBool_check_box = Qt.QCheckBox("Don't FSK Demod") self._fskDemodBool_choices = {True: True, False: False} self._fskDemodBool_choices_inv = dict((v,k) for k,v in self._fskDemodBool_choices.iteritems()) self._fskDemodBool_callback = lambda i: Qt.QMetaObject.invokeMethod(_fskDemodBool_check_box, "setChecked", Qt.Q_ARG("bool", self._fskDemodBool_choices_inv[i])) self._fskDemodBool_callback(self.fskDemodBool) _fskDemodBool_check_box.stateChanged.connect(lambda i: self.set_fskDemodBool(self._fskDemodBool_choices[bool(i)])) self.top_grid_layout.addWidget(_fskDemodBool_check_box, 6,3, 1,1) self.fskDemod = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(fskDemodBool)) _fmDemodBool_check_box = Qt.QCheckBox("Don't FM Demod") self._fmDemodBool_choices = {True: True, False: False} self._fmDemodBool_choices_inv = dict((v,k) for k,v in self._fmDemodBool_choices.iteritems()) self._fmDemodBool_callback = lambda i: Qt.QMetaObject.invokeMethod(_fmDemodBool_check_box, "setChecked", Qt.Q_ARG("bool", self._fmDemodBool_choices_inv[i])) self._fmDemodBool_callback(self.fmDemodBool) _fmDemodBool_check_box.stateChanged.connect(lambda i: self.set_fmDemodBool(self._fmDemodBool_choices[bool(i)])) self.top_grid_layout.addWidget(_fmDemodBool_check_box, 6,2,1,1) self.fmDemod = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(fmDemodBool)) self.digital_gfsk_demod_0 = digital.gfsk_demod( samples_per_symbol=2, sensitivity=1.0, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=500e3, audio_decimation=10, ) self.IQData = blocks.file_sink(gr.sizeof_gr_complex*1, "/Users/ryanlagoy/Documents/Repositories/comms/HackRF/GNURadio/IQData.bin", False) self.IQData.set_unbuffered(False) ################################################## # Connections ################################################## self.connect((self.analog_wfm_rcv_0, 0), (self.rational_resampler_xxx_0_0_0, 0)) self.connect((self.digital_gfsk_demod_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.fmDemod, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.fskDemod, 0), (self.digital_gfsk_demod_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.fmDemod, 0)) self.connect((self.osmosdr_source_0, 0), (self.fskDemod, 0)) self.connect((self.osmosdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.recordIQ, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.volumeBlock, 0)) self.connect((self.recordIQ, 0), (self.IQData, 0)) self.connect((self.volumeBlock, 0), (self.audio_sink_0, 0))
def __init__(self): # Graphical initialisation gr.top_block.__init__(self, "Airprobe Rtlsdr") Qt.QWidget.__init__(self) self.setWindowTitle("Airprobe Rtlsdr") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass # Logging system (to specific file) logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', filename='graphical_sniffing_log', filemod='w', level=logging.INFO) # Windows setting self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "airprobe_rtlsdr") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.fc = 937755550 #937.7e6 self.gain = 30 self.ppm = 0 self.samp_rate = 2000000.052982 self.shiftoff = 400e3 ################################################## # Blocks ################################################## # Order : min value, max value, step, default value and ?) self._ppm_slider_range = Range(-150, 150, 1, self.ppm, 100) self._ppm_slider_win = RangeWidget(self._ppm_slider_range, self.set_ppm, "PPM Offset", "counter", float) self.top_layout.addWidget(self._ppm_slider_win) self._g_slider_range = Range(0, 50, 0.5, self.gain, 100) self._g_slider_win = RangeWidget(self._g_slider_range, self.set_gain, "Gain", "counter", float) self.top_layout.addWidget(self._g_slider_win) self._fc_slider_range = Range(925e6, 1990e6, 2e5, self.fc, 100) self._fc_slider_win = RangeWidget(self._fc_slider_range, self.set_fc, "Frequency", "counter_slider", float) self.top_layout.addWidget(self._fc_slider_win) # Initialisation of the rtlsdr module to communicate with the device self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(self.samp_rate) self.rtlsdr_source_0.set_center_freq(self.fc-self.shiftoff, 0) self.rtlsdr_source_0.set_freq_corr(self.ppm, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(self.gain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(250e3+abs(self.shiftoff), 0) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype self.fc, self.samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.gsm_sdcch8_demapper_0 = grgsm.universal_ctrl_chans_demapper(1, ([0,4,8,12,16,20,24,28,32,36,40,44]), ([8,8,8,8,8,8,8,8,136,136,136,136])) self.gsm_receiver_0 = grgsm.receiver(4, ([0]), ([])) self.gsm_message_printer_1 = grgsm.message_printer(pmt.intern(""), False) self.gsm_input_0 = grgsm.gsm_input( ppm=self.ppm, osr=4, fc=self.fc, samp_rate_in=self.samp_rate, ) self.gsm_decryption_0 = grgsm.decryption(([]), 1) self.gsm_control_channels_decoder_0_0 = grgsm.control_channels_decoder() self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() self.gsm_clock_offset_control_0 = grgsm.clock_offset_control(self.fc-self.shiftoff) self.gsm_bcch_ccch_demapper_0 = grgsm.universal_ctrl_chans_demapper(0, ([2,6,12,16,22,26,32,36,42,46]), ([1,2,2,2,2,2,2,2,2,2])) self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "127.0.0.1", "4729", 10000) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000) self.blocks_rotator_cc_0 = blocks.rotator_cc(-2*pi*self.shiftoff/self.samp_rate) ################################################## # Connections ################################################## self.msg_connect((self.gsm_bcch_ccch_demapper_0, 'bursts'), (self.gsm_control_channels_decoder_0, 'bursts')) self.msg_connect((self.gsm_clock_offset_control_0, 'ppm'), (self.gsm_input_0, 'ppm_in')) self.msg_connect((self.gsm_control_channels_decoder_0, 'msgs'), (self.blocks_socket_pdu_0, 'pdus')) self.msg_connect((self.gsm_control_channels_decoder_0, 'msgs'), (self.gsm_message_printer_1, 'msgs')) self.msg_connect((self.gsm_control_channels_decoder_0_0, 'msgs'), (self.blocks_socket_pdu_0, 'pdus')) self.msg_connect((self.gsm_control_channels_decoder_0_0, 'msgs'), (self.gsm_message_printer_1, 'msgs')) self.msg_connect((self.gsm_decryption_0, 'bursts'), (self.gsm_control_channels_decoder_0_0, 'bursts')) self.msg_connect((self.gsm_receiver_0, 'C0'), (self.gsm_bcch_ccch_demapper_0, 'bursts')) self.msg_connect((self.gsm_receiver_0, 'measurements'), (self.gsm_clock_offset_control_0, 'measurements')) self.msg_connect((self.gsm_receiver_0, 'C0'), (self.gsm_sdcch8_demapper_0, 'bursts')) self.msg_connect((self.gsm_sdcch8_demapper_0, 'bursts'), (self.gsm_decryption_0, 'bursts')) self.connect((self.blocks_rotator_cc_0, 0), (self.gsm_input_0, 0)) self.connect((self.blocks_rotator_cc_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_rotator_cc_0, 0))
def __init__(self): gr.top_block.__init__(self, "Test Float Conversion") Qt.QWidget.__init__(self) self.setWindowTitle("Test Float Conversion") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "test_float_conversion") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.window_size = window_size = 48 self.threshold = threshold = 1000 self.sync_length = sync_length = 320 self.samp_rate = samp_rate = 0.5e6 self.lo_offset = lo_offset = 0 self.gain_0 = gain_0 = 20 self.freq = freq = 943000000.0 self.decimation = decimation = 40 self.chan_est = chan_est = 1 ################################################## # Blocks ################################################## self._samp_rate_options = [0.5e6, 1e6, 5e6, 10e6, 20e6] self._samp_rate_labels = ["500 KHz", "1 MHz", "5 MHz", "10 MHz", "20 MHz"] self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel("Sample Rate"+": ")) self._samp_rate_combo_box = Qt.QComboBox() self._samp_rate_tool_bar.addWidget(self._samp_rate_combo_box) for label in self._samp_rate_labels: self._samp_rate_combo_box.addItem(label) self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(self._samp_rate_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._samp_rate_options.index(i))) self._samp_rate_callback(self.samp_rate) self._samp_rate_combo_box.currentIndexChanged.connect( lambda i: self.set_samp_rate(self._samp_rate_options[i])) self.top_layout.addWidget(self._samp_rate_tool_bar) self.qtgui_time_sink_x_0_0_0_0 = qtgui.time_sink_c( 2**17, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0_0.set_y_axis(-0.1, 1000) self.qtgui_time_sink_x_0_0_0_0.set_y_label("Amplitude COMPLEX", "") self.qtgui_time_sink_x_0_0_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, threshold, 5e-3, 0, "FISTOR") self.qtgui_time_sink_x_0_0_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0_0_0.disable_legend() labels = ["correlation I", "correlation Q", "correlation_big", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2*1): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0_0_0_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_0_0_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_0_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if complex == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.ofdm_80211_ftc_0 = ofdm_80211.ftc() self.nutaq_rtdex_source_0 = nutaq.rtdex_source("nutaq_carrier_perseus_0",gr.sizeof_float,1,3) self.nutaq_rtdex_source_0.set_type(0) self.nutaq_rtdex_source_0.set_packet_size(8192) self.nutaq_rtdex_source_0.set_channels("2") (self.nutaq_rtdex_source_0).set_min_output_buffer(8192) self.nutaq_radio420_tx_0_0_0 = nutaq.radio420_tx("nutaq_carrier_perseus_0", 2, 2) self.nutaq_radio420_tx_0_0_0.set_default_enable(0) self.nutaq_radio420_tx_0_0_0.set_default_tx_freq(743e6) self.nutaq_radio420_tx_0_0_0.set_default_reference(0) self.nutaq_radio420_tx_0_0_0.set_default_datarate(samp_rate*2*decimation) self.nutaq_radio420_tx_0_0_0.set_default_calibrate(1) self.nutaq_radio420_tx_0_0_0.set_default_band(0) self.nutaq_radio420_tx_0_0_0.set_default_update_rate(1) self.nutaq_radio420_tx_0_0_0.set_default_tx_vga1_gain(-10) self.nutaq_radio420_tx_0_0_0.set_default_tx_vga2_gain(15) self.nutaq_radio420_tx_0_0_0.set_default_tx_gain3(3) self.nutaq_radio420_tx_0_0_0.set_default_tx_lpf_bandwidth(6) self.nutaq_radio420_tx_0_0_0.set_default_ref_clk_ctrl(0) self.nutaq_radio420_tx_0_0_0.set_default_rf_ctrl(0) self.nutaq_radio420_tx_0_0_0.set_default_tx_gain_ctrl(0) self.nutaq_radio420_tx_0_0_0.set_default_pll_cpld_ctrl(0) self.nutaq_radio420_tx_0_0 = nutaq.radio420_tx("nutaq_carrier_perseus_0", 1, 0) self.nutaq_radio420_tx_0_0.set_default_enable(0) self.nutaq_radio420_tx_0_0.set_default_tx_freq(743e6) self.nutaq_radio420_tx_0_0.set_default_reference(0) self.nutaq_radio420_tx_0_0.set_default_datarate(samp_rate*2*decimation) self.nutaq_radio420_tx_0_0.set_default_calibrate(1) self.nutaq_radio420_tx_0_0.set_default_band(0) self.nutaq_radio420_tx_0_0.set_default_update_rate(1) self.nutaq_radio420_tx_0_0.set_default_tx_vga1_gain(-10) self.nutaq_radio420_tx_0_0.set_default_tx_vga2_gain(15) self.nutaq_radio420_tx_0_0.set_default_tx_gain3(3) self.nutaq_radio420_tx_0_0.set_default_tx_lpf_bandwidth(6) self.nutaq_radio420_tx_0_0.set_default_ref_clk_ctrl(0) self.nutaq_radio420_tx_0_0.set_default_rf_ctrl(0) self.nutaq_radio420_tx_0_0.set_default_tx_gain_ctrl(0) self.nutaq_radio420_tx_0_0.set_default_pll_cpld_ctrl(0) self.nutaq_radio420_rx_0_0 = nutaq.radio420_rx("nutaq_carrier_perseus_0", 2, 3) self.nutaq_radio420_rx_0_0.set_default_enable(1) self.nutaq_radio420_rx_0_0.set_default_rx_freq(943e6) self.nutaq_radio420_rx_0_0.set_default_reference(0) self.nutaq_radio420_rx_0_0.set_default_datarate(samp_rate*2*decimation) self.nutaq_radio420_rx_0_0.set_default_calibrate(1) self.nutaq_radio420_rx_0_0.set_default_band(0) self.nutaq_radio420_rx_0_0.set_default_update_rate(1) self.nutaq_radio420_rx_0_0.set_default_rx_lna_gain(3) self.nutaq_radio420_rx_0_0.set_default_rx_vga1_gain(3) self.nutaq_radio420_rx_0_0.set_default_rx_gain2(0) self.nutaq_radio420_rx_0_0.set_default_rx_gain3(8) self.nutaq_radio420_rx_0_0.set_default_rx_rf_filter(2) self.nutaq_radio420_rx_0_0.set_default_rx_lpf_bandwidth(2) self.nutaq_radio420_rx_0_0.set_default_ref_clk_ctrl(0) self.nutaq_radio420_rx_0_0.set_default_rf_ctrl(0) self.nutaq_radio420_rx_0_0.set_default_rx_gain_ctrl(0) self.nutaq_radio420_rx_0_0.set_default_pll_cpld_ctrl(0) self.nutaq_radio420_rx_0 = nutaq.radio420_rx("nutaq_carrier_perseus_0", 1, 1) self.nutaq_radio420_rx_0.set_default_enable(0) self.nutaq_radio420_rx_0.set_default_rx_freq(943e6) self.nutaq_radio420_rx_0.set_default_reference(0) self.nutaq_radio420_rx_0.set_default_datarate(samp_rate*2*decimation) self.nutaq_radio420_rx_0.set_default_calibrate(1) self.nutaq_radio420_rx_0.set_default_band(0) self.nutaq_radio420_rx_0.set_default_update_rate(1) self.nutaq_radio420_rx_0.set_default_rx_lna_gain(2) self.nutaq_radio420_rx_0.set_default_rx_vga1_gain(1) self.nutaq_radio420_rx_0.set_default_rx_gain2(0) self.nutaq_radio420_rx_0.set_default_rx_gain3(3) self.nutaq_radio420_rx_0.set_default_rx_rf_filter(2) self.nutaq_radio420_rx_0.set_default_rx_lpf_bandwidth(2) self.nutaq_radio420_rx_0.set_default_ref_clk_ctrl(0) self.nutaq_radio420_rx_0.set_default_rf_ctrl(0) self.nutaq_radio420_rx_0.set_default_rx_gain_ctrl(0) self.nutaq_radio420_rx_0.set_default_pll_cpld_ctrl(0) self.nutaq_custom_register_0_2 = nutaq.custom_register("nutaq_carrier_perseus_0",4) self.nutaq_custom_register_0_2.set_index(0) self.nutaq_custom_register_0_2.set_default_value(int((4e6)/samp_rate/40*(2**32))) self.nutaq_custom_register_0_2.set_update_rate(1) self.nutaq_custom_register_0_1 = nutaq.custom_register("nutaq_carrier_perseus_0",4) self.nutaq_custom_register_0_1.set_index(2) self.nutaq_custom_register_0_1.set_update_rate(1) self.nutaq_custom_register_0_0_1 = nutaq.custom_register("nutaq_carrier_perseus_0",5) self.nutaq_custom_register_0_0_1.set_index(3) self.nutaq_custom_register_0_0_1.set_default_value(7) self.nutaq_custom_register_0_0_1.set_update_rate(1) self.nutaq_custom_register_0_0_0 = nutaq.custom_register("nutaq_carrier_perseus_0",5) self.nutaq_custom_register_0_0_0.set_index(6) self.nutaq_custom_register_0_0_0.set_default_value(600) self.nutaq_custom_register_0_0_0.set_update_rate(1) self.nutaq_custom_register_0_0 = nutaq.custom_register("nutaq_carrier_perseus_0",5) self.nutaq_custom_register_0_0.set_index(4) self.nutaq_custom_register_0_0.set_update_rate(1) self.nutaq_custom_register_0 = nutaq.custom_register("nutaq_carrier_perseus_0",4) self.nutaq_custom_register_0.set_index(1) self.nutaq_custom_register_0.set_default_value(3) self.nutaq_custom_register_0.set_update_rate(1) self.nutaq_carrier_perseus_0 = nutaq.carrier(0,"nutaq_carrier_perseus_0", "192.168.0.101") self._gain_0_range = Range(0, 100, 1, 20, 200) self._gain_0_win = RangeWidget(self._gain_0_range, self.set_gain_0, "gain_0", "slider") self.top_layout.addWidget(self._gain_0_win) self._freq_options = [943000000.0, 2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0] self._freq_labels = [' 0 | 943.0 | ??', ' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'] self._freq_tool_bar = Qt.QToolBar(self) self._freq_tool_bar.addWidget(Qt.QLabel("Channel"+": ")) self._freq_combo_box = Qt.QComboBox() self._freq_tool_bar.addWidget(self._freq_combo_box) for label in self._freq_labels: self._freq_combo_box.addItem(label) self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(self._freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._freq_options.index(i))) self._freq_callback(self.freq) self._freq_combo_box.currentIndexChanged.connect( lambda i: self.set_freq(self._freq_options[i])) self.top_layout.addWidget(self._freq_tool_bar) self.blocks_null_sink_0_1_0_0_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) (self.blocks_float_to_complex_0).set_min_output_buffer(8192) (self.blocks_float_to_complex_0).set_max_output_buffer(8192) self.blocks_deinterleave_0 = blocks.deinterleave(gr.sizeof_float*1, 1) (self.blocks_deinterleave_0).set_min_output_buffer(8192) ################################################## # Connections ################################################## self.connect((self.blocks_deinterleave_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_deinterleave_0, 1), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.qtgui_time_sink_x_0_0_0_0, 0)) self.connect((self.nutaq_rtdex_source_0, 0), (self.blocks_deinterleave_0, 0)) self.connect((self.nutaq_rtdex_source_0, 0), (self.ofdm_80211_ftc_0, 0)) self.connect((self.ofdm_80211_ftc_0, 0), (self.blocks_null_sink_0_1_0_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "RKE Analyzer") Qt.QWidget.__init__(self) self.setWindowTitle("RKE Analyzer") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "garage") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps1 = sps1 = 1 self.sdr_rate = sdr_rate = 2e6 self.my_seq = my_seq = 0 self.my_encoder = my_encoder = 0 self.freqdetectada = freqdetectada = 292e6 self.decim = decim = 20 self.variable_qtgui_label_0_2 = variable_qtgui_label_0_2 = freqdetectada self.variable_qtgui_label_0_1_0 = variable_qtgui_label_0_1_0 = my_seq self.variable_qtgui_label_0_1 = variable_qtgui_label_0_1 = my_encoder self.variable_qtgui_label_0_0 = variable_qtgui_label_0_0 = sps1 self.sps = sps = 44 self.samp_rate = samp_rate = sdr_rate / decim self.gain = gain = 0.01 self.freq_list = freq_list = (292000000, 299000000, 315000000, 434000000) self.freq = freq = 0 self.fft_n = fft_n = 2048 self.encoder_length = encoder_length = ((12,"HT12E - M1E-N"),(28,"HT6P20B"),(9,"HT6026 - MC145026")) self.encoder_code = encoder_code = ((([((0,0,0,0,0,0,0,1), 'P'), ((0,1,1), 0), ((0,0,1), 1)])),(([((0,0,0,0,0,0,0,1), 'P'), ((0,1,1), 0), ((0,0,1), 1)])),(([((0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), 'P'),((0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1), 1),((0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0), 0),((0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0), "Z")]))) ################################################## # Blocks ################################################## self.sumx = sumx.summ(limiar_db=25, freq_list=freq_list, sample_rate=sdr_rate, len_fft=fft_n) self.crossing = crossing.crossing(sample_rate=samp_rate, threshold=10) def _sps_probe(): while True: val = self.crossing.retorna_sps() try: self.set_sps(val) except AttributeError: pass time.sleep(1.0 / (5)) _sps_thread = threading.Thread(target=_sps_probe) _sps_thread.daemon = True _sps_thread.start() def _freqdetectada_probe(): while True: val = self.sumx.freq_detectada() try: self.set_freqdetectada(val) except AttributeError: pass time.sleep(1.0 / (5)) _freqdetectada_thread = threading.Thread(target=_freqdetectada_probe) _freqdetectada_thread.daemon = True _freqdetectada_thread.start() def _freq_probe(): while True: val = self.sumx.freq_ativa() try: self.set_freq(val) except AttributeError: pass time.sleep(1.0 / (5)) _freq_thread = threading.Thread(target=_freq_probe) _freq_thread.daemon = True _freq_thread.start() self.detectorx = detectorx.blkfinal(decoders_list=encoder_code, decoders_length=encoder_length) self._variable_qtgui_label_0_2_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_2_formatter = None else: self._variable_qtgui_label_0_2_formatter = lambda x: eng_notation.num_to_str(x) self._variable_qtgui_label_0_2_tool_bar.addWidget(Qt.QLabel('Frequencia Detectada'+": ")) self._variable_qtgui_label_0_2_label = Qt.QLabel(str(self._variable_qtgui_label_0_2_formatter(self.variable_qtgui_label_0_2))) self._variable_qtgui_label_0_2_tool_bar.addWidget(self._variable_qtgui_label_0_2_label) self.top_grid_layout.addWidget(self._variable_qtgui_label_0_2_tool_bar) self._variable_qtgui_label_0_1_0_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_1_0_formatter = None else: self._variable_qtgui_label_0_1_0_formatter = lambda x: repr(x) self._variable_qtgui_label_0_1_0_tool_bar.addWidget(Qt.QLabel('Quadro'+": ")) self._variable_qtgui_label_0_1_0_label = Qt.QLabel(str(self._variable_qtgui_label_0_1_0_formatter(self.variable_qtgui_label_0_1_0))) self._variable_qtgui_label_0_1_0_tool_bar.addWidget(self._variable_qtgui_label_0_1_0_label) self.top_grid_layout.addWidget(self._variable_qtgui_label_0_1_0_tool_bar) self._variable_qtgui_label_0_1_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_1_formatter = None else: self._variable_qtgui_label_0_1_formatter = lambda x: repr(x) self._variable_qtgui_label_0_1_tool_bar.addWidget(Qt.QLabel('Codificador'+": ")) self._variable_qtgui_label_0_1_label = Qt.QLabel(str(self._variable_qtgui_label_0_1_formatter(self.variable_qtgui_label_0_1))) self._variable_qtgui_label_0_1_tool_bar.addWidget(self._variable_qtgui_label_0_1_label) self.top_grid_layout.addWidget(self._variable_qtgui_label_0_1_tool_bar) self._variable_qtgui_label_0_0_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_0_formatter = None else: self._variable_qtgui_label_0_0_formatter = lambda x: str(x) self._variable_qtgui_label_0_0_tool_bar.addWidget(Qt.QLabel('Frequencia do clock'+": ")) self._variable_qtgui_label_0_0_label = Qt.QLabel(str(self._variable_qtgui_label_0_0_formatter(self.variable_qtgui_label_0_0))) self._variable_qtgui_label_0_0_tool_bar.addWidget(self._variable_qtgui_label_0_0_label) self.top_grid_layout.addWidget(self._variable_qtgui_label_0_0_tool_bar) def _sps1_probe(): while True: val = self.crossing.retorna_freq() try: self.set_sps1(val) except AttributeError: pass time.sleep(1.0 / (1)) _sps1_thread = threading.Thread(target=_sps1_probe) _sps1_thread.daemon = True _sps1_thread.start() self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' ) self.rtlsdr_source_0.set_sample_rate(sdr_rate) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(20, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna('00', 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc sdr_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.probe = blocks.probe_signal_i() def _my_seq_probe(): while True: val = self.detectorx.retorna_sequencia_detectada() try: self.set_my_seq(val) except AttributeError: pass time.sleep(1.0 / (10)) _my_seq_thread = threading.Thread(target=_my_seq_probe) _my_seq_thread.daemon = True _my_seq_thread.start() def _my_encoder_probe(): while True: val = self.detectorx.retorna_codificador_detectado() try: self.set_my_encoder(val) except AttributeError: pass time.sleep(1.0 / (10)) _my_encoder_thread = threading.Thread(target=_my_encoder_probe) _my_encoder_thread.daemon = True _my_encoder_thread.start() self.insert_tag = insert_tag.clock_reset(sps=sps) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(decim, (1, ), freqdetectada - freq, sdr_rate) self.fir_filter_xxx_0 = filter.fir_filter_fff(1, (np.ones(sps) / (sps))) self.fir_filter_xxx_0.declare_sample_delay(0) self.fft = fft.fft_vcc(fft_n, True, (window.blackmanharris(fft_n)), True, 1) self.divide = divide.divide(threshold=0.1) self.digital_symbol_sync_xx_0 = digital.symbol_sync_ff(digital.TED_ZERO_CROSSING, 40, 0.1, 1.0, gain, 35, 1, digital.constellation_bpsk().base(), digital.IR_MMSE_8TAP, 128, ([])) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fft_n) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_float_to_int_0 = blocks.float_to_int(1, 1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(fft_n) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_mag_0, 0), (self.divide, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.sumx, 0)) self.connect((self.blocks_float_to_int_0, 0), (self.probe, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.detectorx, 0)) self.connect((self.digital_symbol_sync_xx_0, 3), (self.blocks_float_to_int_0, 0)) self.connect((self.digital_symbol_sync_xx_0, 2), (self.blocks_null_sink_0, 1)) self.connect((self.digital_symbol_sync_xx_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.digital_symbol_sync_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.divide, 0), (self.crossing, 0)) self.connect((self.divide, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.fft, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.insert_tag, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.insert_tag, 0), (self.digital_symbol_sync_xx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
def __init__(self, puncpat='11'): gr.top_block.__init__(self, "Rx") Qt.QWidget.__init__(self) self.setWindowTitle("Rx") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "rx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.puncpat = puncpat ################################################## # Variables ################################################## self.sps = sps = 4 self.samp_rate_array_MCR = samp_rate_array_MCR = [7500000,5000000,3750000,3000000,2500000,2000000,1500000,1000000,937500,882352,833333,714285,533333,500000,421052,400000,380952,200000] self.nfilts = nfilts = 32 self.eb = eb = 0.22 self.H_dec = H_dec = fec.ldpc_H_matrix('/usr/local/share/gnuradio/fec/ldpc/n_1100_k_0442_gap_24.alist', 24) self.variable_qtgui_range_0_1 = variable_qtgui_range_0_1 = 28 self.variable_qtgui_range_0_0 = variable_qtgui_range_0_0 = 51 self.samp_rate = samp_rate = samp_rate_array_MCR[17] self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine(nfilts, nfilts*sps, 1.0, eb, 11*sps*nfilts) self.pld_dec = pld_dec = map((lambda a: fec.ldpc_bit_flip_decoder.make(H_dec.get_base_sptr(), 50)), range(0,8)) self.pld_const = pld_const = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.pld_const.gen_soft_dec_lut(8) self.frequencia_usrp = frequencia_usrp = 484e6 self.MCR = MCR = "master_clock_rate=60e6" ################################################## # Blocks ################################################## self._variable_qtgui_range_0_1_range = Range(0, 73, 1, 28, 200) self._variable_qtgui_range_0_1_win = RangeWidget(self._variable_qtgui_range_0_1_range, self.set_variable_qtgui_range_0_1, 'Gain_RX', "counter_slider", float) self.top_grid_layout.addWidget(self._variable_qtgui_range_0_1_win, 0, 1, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._variable_qtgui_range_0_0_range = Range(0, 90, 1, 51, 200) self._variable_qtgui_range_0_0_win = RangeWidget(self._variable_qtgui_range_0_0_range, self.set_variable_qtgui_range_0_0, 'Gain_Jamming', "counter_slider", float) self.top_grid_layout.addWidget(self._variable_qtgui_range_0_0_win, 0, 2, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.uhd_usrp_source_0_0 = uhd.usrp_source( ",".join(("serial=F5EAC0", MCR)), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0_0.set_center_freq(frequencia_usrp, 0) self.uhd_usrp_source_0_0.set_gain(variable_qtgui_range_0_1, 0) self.uhd_usrp_source_0_0.set_antenna('TX/RX', 0) self.uhd_usrp_source_0_0.set_auto_dc_offset(True, 0) self.uhd_usrp_source_0_0.set_auto_iq_balance(True, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("serial=F5EAC0", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_subdev_spec('A:B', 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0.set_center_freq(frequencia_usrp, 0) self.uhd_usrp_sink_0.set_gain(variable_qtgui_range_0_0, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.qtgui_time_sink_x_1_0_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "TX JAMMING USRP", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0_0.enable_grid(False) self.qtgui_time_sink_x_1_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0_0.enable_control_panel(False) self.qtgui_time_sink_x_1_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_1_0_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_1_0_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_1_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_0_win, 1, 1, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_1_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "RX USRP", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0.enable_grid(False) self.qtgui_time_sink_x_1_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0.enable_control_panel(False) self.qtgui_time_sink_x_1_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_1_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_1_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_win, 1, 3, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f( 100*2, #size samp_rate, #samp_rate 'Rx Data', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_1.set_update_time(0.10) self.qtgui_time_sink_x_0_1.set_y_axis(-1, 256) self.qtgui_time_sink_x_0_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_1.enable_tags(-1, True) self.qtgui_time_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, 'packet_length_tag_key') self.qtgui_time_sink_x_0_1.enable_autoscale(True) self.qtgui_time_sink_x_0_1.enable_grid(True) self.qtgui_time_sink_x_0_1.enable_axis_labels(True) self.qtgui_time_sink_x_0_1.enable_control_panel(False) self.qtgui_time_sink_x_0_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_1_win = sip.wrapinstance(self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_win, 2, 3, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 1, 2, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0_0_1 = qtgui.const_sink_c( 1024, #size "RX Const", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0_1.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0_1.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0_1.enable_grid(False) self.qtgui_const_sink_x_0_0_0_1.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_0_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0_0_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_1_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_1_win, 2, 1, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c( 1024, #size "RX Treated", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_win, 2, 2, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.interp_fir_filter_xxx_1 = filter.interp_fir_filter_ccc(4, ([1,0,0,0])) self.interp_fir_filter_xxx_1.declare_sample_delay(0) self.fec_extended_decoder_0_0_1_0_1_0_0 = fec.extended_decoder(decoder_obj_list=pld_dec, threading='capillary', ann=None, puncpat=puncpat, integration_period=10000) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 6.28/100.0, (rx_rrc_taps), nfilts, nfilts/2, 1.5, 2) self.digital_map_bb_0_0_0_0_0_0 = digital.map_bb(([-1, 1])) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(pld_const.arity()) self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc(6.28/100.0, pld_const.arity(), False) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(pld_const) self.digital_cma_equalizer_cc_0_0 = digital.cma_equalizer_cc(15, 1, 0.01, 2) self.custom_corr = correlate_and_delay.corr_and_delay(200*sps, 0, 0.9995, sps) self.cac_cpp_cac_bb_0 = cac_cpp.cac_bb(digital.packet_utils.default_access_code, 1) self.blocks_repack_bits_bb_0_0_0_1_0 = blocks.repack_bits_bb(1, 8, '', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(pld_const.bits_per_symbol(), 1, '', False, gr.GR_MSB_FIRST) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vcc((0.5, )) self.blocks_keep_m_in_n_0_1_1_0 = blocks.keep_m_in_n(gr.sizeof_char, 440, 442, 0) self.blocks_keep_m_in_n_0_0_2_0_0 = blocks.keep_m_in_n(gr.sizeof_char, 1100, 1104, 0) self.blocks_file_sink_0_0_0_0_2 = blocks.file_sink(gr.sizeof_char*1, '/home/it/Desktop/Trasmited/simbolos_rx.txt', False) self.blocks_file_sink_0_0_0_0_2.set_unbuffered(False) self.blocks_char_to_float_1_0_1 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_2_0_0_0 = blocks.char_to_float(1, 1) self.analog_noise_source_x_0_0 = analog.noise_source_c(analog.GR_GAUSSIAN, 1, -5) self.adapt_lms_filter_xx_0 = adapt.lms_filter_cc(True, 32, 0.0001, 0, 1, True, False, False) ################################################## # Connections ################################################## self.connect((self.adapt_lms_filter_xx_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.adapt_lms_filter_xx_0, 1), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.analog_noise_source_x_0_0, 0), (self.interp_fir_filter_xxx_1, 0)) self.connect((self.blocks_char_to_float_0_2_0_0_0, 0), (self.fec_extended_decoder_0_0_1_0_1_0_0, 0)) self.connect((self.blocks_char_to_float_1_0_1, 0), (self.qtgui_time_sink_x_0_1, 0)) self.connect((self.blocks_keep_m_in_n_0_0_2_0_0, 0), (self.digital_map_bb_0_0_0_0_0_0, 0)) self.connect((self.blocks_keep_m_in_n_0_1_1_0, 0), (self.blocks_repack_bits_bb_0_0_0_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.custom_corr, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.qtgui_time_sink_x_1_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.cac_cpp_cac_bb_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0_0_1_0, 0), (self.blocks_char_to_float_1_0_1, 0)) self.connect((self.blocks_repack_bits_bb_0_0_0_1_0, 0), (self.blocks_file_sink_0_0_0_0_2, 0)) self.connect((self.cac_cpp_cac_bb_0, 0), (self.blocks_keep_m_in_n_0_0_2_0_0, 0)) self.connect((self.custom_corr, 0), (self.adapt_lms_filter_xx_0, 1)) self.connect((self.custom_corr, 1), (self.adapt_lms_filter_xx_0, 0)) self.connect((self.custom_corr, 2), (self.blocks_null_sink_1, 0)) self.connect((self.digital_cma_equalizer_cc_0_0, 0), (self.digital_costas_loop_cc_0_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.qtgui_const_sink_x_0_0_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_map_bb_0_0_0_0_0_0, 0), (self.blocks_char_to_float_0_2_0_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0_0, 0)) self.connect((self.fec_extended_decoder_0_0_1_0_1_0_0, 0), (self.blocks_keep_m_in_n_0_1_1_0, 0)) self.connect((self.interp_fir_filter_xxx_1, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.custom_corr, 1)) self.connect((self.uhd_usrp_source_0_0, 0), (self.qtgui_const_sink_x_0_0_0_1, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.qtgui_time_sink_x_1_0, 0))
def __init__(self): gr.top_block.__init__(self, "Uhd Snr Receiver") Qt.QWidget.__init__(self) self.setWindowTitle("Uhd Snr Receiver") self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "uhd_snr_receiver") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.samp_rate = samp_rate = 1e6 self.rrc_taps = rrc_taps = filter.firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts) self.gain = gain = 15 self.freq = freq = 520e6 self.fine_freq = fine_freq = -28400 ################################################## # Blocks ################################################## self._gain_layout = Qt.QVBoxLayout() self._gain_tool_bar = Qt.QToolBar(self) self._gain_layout.addWidget(self._gain_tool_bar) self._gain_tool_bar.addWidget(Qt.QLabel("RX Gain"+": ")) self._gain_counter = Qwt.QwtCounter() self._gain_counter.setRange(0, 31.5, 0.5) self._gain_counter.setNumButtons(2) self._gain_counter.setValue(self.gain) self._gain_tool_bar.addWidget(self._gain_counter) self._gain_counter.valueChanged.connect(self.set_gain) self._gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._gain_slider.setRange(0, 31.5, 0.5) self._gain_slider.setValue(self.gain) self._gain_slider.setMinimumWidth(200) self._gain_slider.valueChanged.connect(self.set_gain) self._gain_layout.addWidget(self._gain_slider) self.top_layout.addLayout(self._gain_layout) self._freq_layout = Qt.QVBoxLayout() self._freq_tool_bar = Qt.QToolBar(self) self._freq_layout.addWidget(self._freq_tool_bar) self._freq_tool_bar.addWidget(Qt.QLabel("Frequency"+": ")) self._freq_counter = Qwt.QwtCounter() self._freq_counter.setRange(514e6, 526e6, 1e6) self._freq_counter.setNumButtons(2) self._freq_counter.setValue(self.freq) self._freq_tool_bar.addWidget(self._freq_counter) self._freq_counter.valueChanged.connect(self.set_freq) self._freq_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._freq_slider.setRange(514e6, 526e6, 1e6) self._freq_slider.setValue(self.freq) self._freq_slider.setMinimumWidth(200) self._freq_slider.valueChanged.connect(self.set_freq) self._freq_layout.addWidget(self._freq_slider) self.top_grid_layout.addLayout(self._freq_layout, 2,0,1,1) self._fine_freq_layout = Qt.QVBoxLayout() self._fine_freq_tool_bar = Qt.QToolBar(self) self._fine_freq_layout.addWidget(self._fine_freq_tool_bar) self._fine_freq_tool_bar.addWidget(Qt.QLabel("Fine Frequency"+": ")) self._fine_freq_counter = Qwt.QwtCounter() self._fine_freq_counter.setRange(-50e3, 50e3, 100) self._fine_freq_counter.setNumButtons(2) self._fine_freq_counter.setValue(self.fine_freq) self._fine_freq_tool_bar.addWidget(self._fine_freq_counter) self._fine_freq_counter.valueChanged.connect(self.set_fine_freq) self._fine_freq_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._fine_freq_slider.setRange(-50e3, 50e3, 100) self._fine_freq_slider.setValue(self.fine_freq) self._fine_freq_slider.setMinimumWidth(200) self._fine_freq_slider.valueChanged.connect(self.set_fine_freq) self._fine_freq_layout.addWidget(self._fine_freq_slider) self.top_grid_layout.addLayout(self._fine_freq_layout, 2,1,1,1) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(freq + fine_freq, 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c( 500, #size samp_rate, #bw "QT GUI Plot", #name 3 #number of inputs ) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 0,0,1,1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name 1 #number of inputs ) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 1,0,1,2) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "QT GUI Plot", #name 2 #number of inputs ) self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 0,1,1,1) self.gr_multiply_xx_0 = gr.multiply_vcc(1) self.gr_agc2_xx_0 = gr.agc2_cc(1e-1, 1e-2, 1.0, 1.0, 0.0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 2*3.14/100.0, (rrc_taps), nfilts, nfilts/2, 1.5, 1) self.digital_mpsk_snr_est_cc_0_1 = digital.mpsk_snr_est_cc(3, 10000, 0.001) self.digital_mpsk_snr_est_cc_0_0 = digital.mpsk_snr_est_cc(2, 10000, 0.001) self.digital_mpsk_snr_est_cc_0 = digital.mpsk_snr_est_cc(0, 10000, 0.001) self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc(15, 0.010, 1, digital.constellation_qpsk().base()) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(2*3.14/100.0, 4) ################################################## # Connections ################################################## self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_mpsk_snr_est_cc_0, 0)) self.connect((self.gr_multiply_xx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_0, 0), (self.qtgui_const_sink_x_0, 1)) self.connect((self.gr_agc2_xx_0, 0), (self.gr_multiply_xx_0, 3)) self.connect((self.gr_agc2_xx_0, 0), (self.gr_multiply_xx_0, 2)) self.connect((self.gr_agc2_xx_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.gr_agc2_xx_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.gr_agc2_xx_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_lms_dd_equalizer_cc_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.gr_agc2_xx_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_mpsk_snr_est_cc_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_mpsk_snr_est_cc_0_1, 0)) self.connect((self.digital_mpsk_snr_est_cc_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.digital_mpsk_snr_est_cc_0_0, 0), (self.qtgui_time_sink_x_0_0, 1)) self.connect((self.digital_mpsk_snr_est_cc_0_1, 0), (self.qtgui_time_sink_x_0_0, 2))
def __init__(self): gr.top_block.__init__(self, "Mpsk Stage4 Lms") Qt.QWidget.__init__(self) self.setWindowTitle("Mpsk Stage4 Lms") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "mpsk_stage4_LMS") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.timing_loop_bw = timing_loop_bw = 6.28/100.0 self.time_offset = time_offset = 1.00 self.taps = taps = [1.0, 0.25-0.25j, 0.50 + 0.10j, -0.3 + 0.2j] self.samp_rate = samp_rate = 32000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts) self.qpsk = qpsk = digital.constellation_rect([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j], [0, 1, 2, 3], 4, 2, 2, 1, 1).base() self.noise_volt = noise_volt = 0.0001 self.freq_offset = freq_offset = 0 self.excess_bw = excess_bw = 0.35 self.eq_gain = eq_gain = 0.01 self.arity = arity = 4 ################################################## # Blocks ################################################## self.controls = Qt.QTabWidget() self.controls_widget_0 = Qt.QWidget() self.controls_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_0) self.controls_grid_layout_0 = Qt.QGridLayout() self.controls_layout_0.addLayout(self.controls_grid_layout_0) self.controls.addTab(self.controls_widget_0, 'Channel') self.controls_widget_1 = Qt.QWidget() self.controls_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_1) self.controls_grid_layout_1 = Qt.QGridLayout() self.controls_layout_1.addLayout(self.controls_grid_layout_1) self.controls.addTab(self.controls_widget_1, 'Receiver') self.top_grid_layout.addWidget(self.controls, 0, 0, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._timing_loop_bw_range = Range(0.0, 0.2, 0.01, 6.28/100.0, 200) self._timing_loop_bw_win = RangeWidget(self._timing_loop_bw_range, self.set_timing_loop_bw, 'Time: BW', "slider", float) self.controls_grid_layout_1.addWidget(self._timing_loop_bw_win, 0, 0, 1, 1) for r in range(0, 1): self.controls_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.controls_grid_layout_1.setColumnStretch(c, 1) self._time_offset_range = Range(0.999, 1.001, 0.0001, 1.00, 200) self._time_offset_win = RangeWidget(self._time_offset_range, self.set_time_offset, 'Timing Offset', "counter_slider", float) self.controls_grid_layout_0.addWidget(self._time_offset_win, 0, 2, 1, 1) for r in range(0, 1): self.controls_grid_layout_0.setRowStretch(r, 1) for c in range(2, 3): self.controls_grid_layout_0.setColumnStretch(c, 1) self._noise_volt_range = Range(0, 1, 0.01, 0.0001, 200) self._noise_volt_win = RangeWidget(self._noise_volt_range, self.set_noise_volt, 'Noise Voltage', "counter_slider", float) self.controls_grid_layout_0.addWidget(self._noise_volt_win, 0, 0, 1, 1) for r in range(0, 1): self.controls_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.controls_grid_layout_0.setColumnStretch(c, 1) self._freq_offset_range = Range(-0.1, 0.1, 0.001, 0, 200) self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, 'Frequency Offset', "counter_slider", float) self.controls_grid_layout_0.addWidget(self._freq_offset_win, 0, 1, 1, 1) for r in range(0, 1): self.controls_grid_layout_0.setRowStretch(r, 1) for c in range(1, 2): self.controls_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw '', #name 1 ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) labels = ['Equalized', '', '', '', '', '', '', '', '', ''] widths = [2, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 2, 1, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw '', #name 1 ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) labels = ['Timing Recov.', '', '', '', '', '', '', '', '', ''] widths = [2, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 2, 0, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( 1024, #size '', #name 1 #number of inputs ) self.qtgui_const_sink_x_1.set_update_time(0.10) self.qtgui_const_sink_x_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1.enable_autoscale(False) self.qtgui_const_sink_x_1.enable_grid(False) self.qtgui_const_sink_x_1.enable_axis_labels(True) labels = ['Timing Recov.', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [0.6, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_win = sip.wrapinstance(self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_1_win, 1, 0, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size '', #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) labels = ['Equalized', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [0.6, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 1, 1, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._eq_gain_range = Range(0.0, 0.1, 0.001, 0.01, 200) self._eq_gain_win = RangeWidget(self._eq_gain_range, self.set_eq_gain, 'Equalizer: rate', "slider", float) self.controls_grid_layout_1.addWidget(self._eq_gain_win, 0, 1, 1, 1) for r in range(0, 1): self.controls_grid_layout_1.setRowStretch(r, 1) for c in range(1, 2): self.controls_grid_layout_1.setColumnStretch(c, 1) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, rrc_taps, nfilts, nfilts/2, 1.5, 2) self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc(11, 0.01, 2, qpsk) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise_volt, frequency_offset=freq_offset, epsilon=time_offset, taps=taps, noise_seed=0, block_tags=False) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.analog_random_source_x_0 = blocks.vector_source_b(list(map(int, numpy.random.randint(0, 256, 10000))), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_lms_dd_equalizer_cc_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "WBFM 2 Channel") Qt.QWidget.__init__(self) self.setWindowTitle("WBFM 2 Channel") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "wbfm_2ch") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.radio_freq = radio_freq = 100 self.samp_rate = samp_rate = 240e4 self.rf_gain = rf_gain = 10 self.freq = freq = radio_freq * 1000000 self.ch2volume = ch2volume = 5 self.ch2squelch = ch2squelch = -30 self.ch2mute = ch2mute = 1 self.ch2freq = ch2freq = radio_freq self.ch1volume = ch1volume = 5 self.ch1squelch = ch1squelch = -30 self.ch1mute = ch1mute = 1 self.ch1freq = ch1freq = radio_freq ################################################## # Blocks ################################################## self.ch2 = Qt.QTabWidget() self.ch2_widget_0 = Qt.QWidget() self.ch2_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.ch2_widget_0) self.ch2_grid_layout_0 = Qt.QGridLayout() self.ch2_layout_0.addLayout(self.ch2_grid_layout_0) self.ch2.addTab(self.ch2_widget_0, "Ch 2") self.top_grid_layout.addWidget(self.ch2, 2,1,1,1) self.ch1 = Qt.QTabWidget() self.ch1_widget_0 = Qt.QWidget() self.ch1_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.ch1_widget_0) self.ch1_grid_layout_0 = Qt.QGridLayout() self.ch1_layout_0.addLayout(self.ch1_grid_layout_0) self.ch1.addTab(self.ch1_widget_0, "Ch 1") self.top_grid_layout.addWidget(self.ch1, 2,0,1,1) self._rf_gain_range = Range(0, 50, 1, 10, 200) self._rf_gain_win = RangeWidget(self._rf_gain_range, self.set_rf_gain, "RF Gain", "counter_slider", float) self.top_grid_layout.addWidget(self._rf_gain_win, 1,0,1,2) self._ch2volume_range = Range(0, 10, 1, 5, 200) self._ch2volume_win = RangeWidget(self._ch2volume_range, self.set_ch2volume, "Ch2 Volume", "counter_slider", float) self.ch2_grid_layout_0.addWidget(self._ch2volume_win, 1,0,1,2) self._ch2squelch_range = Range(-70, 0, 10, -30, 200) self._ch2squelch_win = RangeWidget(self._ch2squelch_range, self.set_ch2squelch, "Ch2 Squelch", "counter_slider", int) self.ch2_grid_layout_0.addWidget(self._ch2squelch_win, 2,0,1,2) _ch2mute_check_box = Qt.QCheckBox("Mute") self._ch2mute_choices = {True: 0, False: 1} self._ch2mute_choices_inv = dict((v,k) for k,v in self._ch2mute_choices.iteritems()) self._ch2mute_callback = lambda i: Qt.QMetaObject.invokeMethod(_ch2mute_check_box, "setChecked", Qt.Q_ARG("bool", self._ch2mute_choices_inv[i])) self._ch2mute_callback(self.ch2mute) _ch2mute_check_box.stateChanged.connect(lambda i: self.set_ch2mute(self._ch2mute_choices[bool(i)])) self.ch2_grid_layout_0.addWidget(_ch2mute_check_box, 0,1,1,1) self._ch2freq_tool_bar = Qt.QToolBar(self) self._ch2freq_tool_bar.addWidget(Qt.QLabel("Ch2 Freq"+": ")) self._ch2freq_line_edit = Qt.QLineEdit(str(self.ch2freq)) self._ch2freq_tool_bar.addWidget(self._ch2freq_line_edit) self._ch2freq_line_edit.returnPressed.connect( lambda: self.set_ch2freq(eng_notation.str_to_num(str(self._ch2freq_line_edit.text().toAscii())))) self.ch2_grid_layout_0.addWidget(self._ch2freq_tool_bar, 0,0,1,1) self._ch1volume_range = Range(0, 10, 1, 5, 200) self._ch1volume_win = RangeWidget(self._ch1volume_range, self.set_ch1volume, "Ch1 Volume", "counter_slider", float) self.ch1_grid_layout_0.addWidget(self._ch1volume_win, 1,0,1,2) self._ch1squelch_range = Range(-70, 0, 10, -30, 200) self._ch1squelch_win = RangeWidget(self._ch1squelch_range, self.set_ch1squelch, "Ch1 Squelch", "counter_slider", int) self.ch1_grid_layout_0.addWidget(self._ch1squelch_win, 2,0,1,2) _ch1mute_check_box = Qt.QCheckBox("Mute") self._ch1mute_choices = {True: 0, False: 1} self._ch1mute_choices_inv = dict((v,k) for k,v in self._ch1mute_choices.iteritems()) self._ch1mute_callback = lambda i: Qt.QMetaObject.invokeMethod(_ch1mute_check_box, "setChecked", Qt.Q_ARG("bool", self._ch1mute_choices_inv[i])) self._ch1mute_callback(self.ch1mute) _ch1mute_check_box.stateChanged.connect(lambda i: self.set_ch1mute(self._ch1mute_choices[bool(i)])) self.ch1_grid_layout_0.addWidget(_ch1mute_check_box, 0,1,1,1) self._ch1freq_tool_bar = Qt.QToolBar(self) self._ch1freq_tool_bar.addWidget(Qt.QLabel("Ch1 Freq"+": ")) self._ch1freq_line_edit = Qt.QLineEdit(str(self.ch1freq)) self._ch1freq_tool_bar.addWidget(self._ch1freq_line_edit) self._ch1freq_line_edit.returnPressed.connect( lambda: self.set_ch1freq(eng_notation.str_to_num(str(self._ch1freq_line_edit.text().toAscii())))) self.ch1_grid_layout_0.addWidget(self._ch1freq_tool_bar, 0,0,1,1) self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(rf_gain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.rational_resampler_xxx_2_0 = filter.rational_resampler_ccc( interpolation=400000, decimation=2400000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_2 = filter.rational_resampler_ccc( interpolation=400000, decimation=2400000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_1_0 = filter.rational_resampler_fff( interpolation=48, decimation=50, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_1 = filter.rational_resampler_fff( interpolation=48, decimation=50, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=500000, decimation=2400000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=500000, decimation=2400000, taps=None, fractional_bw=None, ) self._radio_freq_tool_bar = Qt.QToolBar(self) self._radio_freq_tool_bar.addWidget(Qt.QLabel("Frequency (MHz)"+": ")) self._radio_freq_line_edit = Qt.QLineEdit(str(self.radio_freq)) self._radio_freq_tool_bar.addWidget(self._radio_freq_line_edit) self._radio_freq_line_edit.returnPressed.connect( lambda: self.set_radio_freq(eng_notation.str_to_num(str(self._radio_freq_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._radio_freq_tool_bar, 0,0,1,2) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if complex == type(float()): self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-100, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 3,0,1,2) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype ch2freq, #fc 400000, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-100, 10) self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0_0.disable_legend() if complex == type(float()): self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.ch2_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_0_win, 3,0,1,2) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype ch1freq, #fc 400000, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-100, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if complex == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.ch1_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 3,0,1,2) self.low_pass_filter_0_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, 500000, 100e3, 8000, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, 500000, 100e3, 8000, firdes.WIN_HAMMING, 6.76)) self.freq_xlating_fft_filter_ccc_0_0 = filter.freq_xlating_fft_filter_ccc(1, (firdes.low_pass(1,samp_rate,200000,10000)), (ch2freq * 1000000) - freq, samp_rate) self.freq_xlating_fft_filter_ccc_0_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0_0.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc(1, (firdes.low_pass(1,samp_rate,200000,10000)), (ch1freq * 1000000) - freq, samp_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff((ch2mute, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((ch1mute, )) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((ch2volume, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((ch1volume, )) self.audio_sink_0_0 = audio.sink(48000, "", True) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_wfm_rcv_0_0 = analog.wfm_rcv( quad_rate=500000, audio_decimation=10, ) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=500000, audio_decimation=10, ) self.analog_pwr_squelch_xx_0_0 = analog.pwr_squelch_cc(ch2squelch, 1e-4, 0, True) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(ch1squelch, 1e-4, 0, True) ################################################## # Connections ################################################## self.connect((self.analog_pwr_squelch_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.analog_pwr_squelch_xx_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.analog_wfm_rcv_0_0, 0), (self.rational_resampler_xxx_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.audio_sink_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.rational_resampler_xxx_2, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.analog_pwr_squelch_xx_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.rational_resampler_xxx_2_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.analog_wfm_rcv_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.rational_resampler_xxx_1_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.rational_resampler_xxx_2, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_2_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self, args="", collector="localhost", collectorport='4729', fc=941.8e6, gain=30, osr=4, ppm=0, samp_rate=2000000.052982, serverport='4729', shiftoff=400e3): gr.top_block.__init__(self, "Gr-gsm Livemon") Qt.QWidget.__init__(self) self.setWindowTitle("Gr-gsm Livemon") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "grgsm_livemon") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Parameters ################################################## self.args = args self.collector = collector self.collectorport = collectorport self.fc = fc self.gain = gain self.osr = osr self.ppm = ppm self.samp_rate = samp_rate self.serverport = serverport self.shiftoff = shiftoff ################################################## # Variables ################################################## self.ppm_slider = ppm_slider = ppm self.gain_slider = gain_slider = gain self.fc_slider = fc_slider = fc ################################################## # Blocks ################################################## self._ppm_slider_range = Range(-150, 150, 0.1, ppm, 100) self._ppm_slider_win = RangeWidget(self._ppm_slider_range, self.set_ppm_slider, 'PPM Offset', "counter", float) self.top_grid_layout.addWidget(self._ppm_slider_win) self._gain_slider_range = Range(0, 100, 0.5, gain, 100) self._gain_slider_win = RangeWidget(self._gain_slider_range, self.set_gain_slider, 'Gain', "counter", float) self.top_grid_layout.addWidget(self._gain_slider_win) self._fc_slider_range = Range(800e6, 1990e6, 2e5, fc, 100) self._fc_slider_win = RangeWidget(self._fc_slider_range, self.set_fc_slider, 'Frequency', "counter_slider", float) self.top_grid_layout.addWidget(self._fc_slider_win) self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + 'str(grgsm.device.get_default_args(args))') self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(fc_slider - shiftoff, 0) self.rtlsdr_source_0.set_freq_corr(ppm_slider, 0) self.rtlsdr_source_0.set_gain(gain_slider, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(250e3 + abs(shiftoff), 0) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype fc_slider, #fc samp_rate, #bw "", #name 1) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.gsm_sdcch8_demapper_0 = grgsm.gsm_sdcch8_demapper(timeslot_nr=1, ) self.gsm_receiver_0 = grgsm.receiver(osr, [1022], [], False) self.gsm_message_printer_1 = grgsm.message_printer( pmt.intern(""), False, False, False) self.gsm_input_0 = grgsm.gsm_input( ppm=ppm - int(ppm), osr=osr, fc=fc_slider - shiftoff, samp_rate_in=samp_rate, ) self.gsm_decryption_0 = grgsm.decryption([], 1) self.gsm_control_channels_decoder_0_0 = grgsm.control_channels_decoder( ) self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() self.gsm_clock_offset_control_0 = grgsm.clock_offset_control( fc_slider - shiftoff, samp_rate, osr) self.gsm_bcch_ccch_demapper_0 = grgsm.gsm_bcch_ccch_demapper( timeslot_nr=0, ) self.blocks_socket_pdu_0_1 = blocks.socket_pdu('UDP_CLIENT', collector, collectorport, 1500, False) self.blocks_socket_pdu_0_0 = blocks.socket_pdu('UDP_SERVER', '127.0.0.1', serverport, 10000, False) self.blocks_rotator_cc_0 = blocks.rotator_cc(-2 * pi * shiftoff / samp_rate) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0_0, 'pdus'), (self.gsm_message_printer_1, 'msgs')) self.msg_connect((self.gsm_bcch_ccch_demapper_0, 'bursts'), (self.gsm_control_channels_decoder_0, 'bursts')) self.msg_connect((self.gsm_clock_offset_control_0, 'ctrl'), (self.gsm_input_0, 'ctrl_in')) self.msg_connect((self.gsm_control_channels_decoder_0, 'msgs'), (self.blocks_socket_pdu_0_1, 'pdus')) self.msg_connect((self.gsm_control_channels_decoder_0_0, 'msgs'), (self.blocks_socket_pdu_0_1, 'pdus')) self.msg_connect((self.gsm_decryption_0, 'bursts'), (self.gsm_control_channels_decoder_0_0, 'bursts')) self.msg_connect((self.gsm_receiver_0, 'C0'), (self.gsm_bcch_ccch_demapper_0, 'bursts')) self.msg_connect((self.gsm_receiver_0, 'measurements'), (self.gsm_clock_offset_control_0, 'measurements')) self.msg_connect((self.gsm_receiver_0, 'C0'), (self.gsm_sdcch8_demapper_0, 'bursts')) self.msg_connect((self.gsm_sdcch8_demapper_0, 'bursts'), (self.gsm_decryption_0, 'bursts')) self.connect((self.blocks_rotator_cc_0, 0), (self.gsm_input_0, 0)) self.connect((self.blocks_rotator_cc_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_rotator_cc_0, 0))
def __init__(self, addr='serial=30CF9D2', antenna_type='Vehicle MAgmount VHF Antenna', clock_rate=60e6, gpsd_log='gpsd_20191228_193400.log', morse_id='PSK | .--. ... -.-', output_format='Complex Float32', path="/captures/20191228", rx_alt=0, rx_lat=0, rx_lon=0, signal_type='VOR', tx_alt=340, tx_lat=37.087692, tx_lon=-80.712887, usrp_type='B210', wire_format='Automatic'): gr.top_block.__init__(self, "vor_record_sigmf") Qt.QWidget.__init__(self) self.setWindowTitle("vor_record_sigmf") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "vor_record_sigmf") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.addr = addr self.antenna_type = antenna_type self.clock_rate = clock_rate self.gpsd_log = gpsd_log self.morse_id = morse_id self.output_format = output_format self.path = path self.rx_alt = rx_alt self.rx_lat = rx_lat self.rx_lon = rx_lon self.signal_type = signal_type self.tx_alt = tx_alt self.tx_lat = tx_lat self.tx_lon = tx_lon self.usrp_type = usrp_type self.wire_format = wire_format ################################################## # Variables ################################################## self.ts_str = ts_str = dt.strftime(dt.utcnow(), "%Y-%m-%dT%H:%M:%SZ") self.fn = fn = "{:s}_{:s}".format(signal_type.upper(), ts_str) self.samp_rate = samp_rate = 250e3 self.rx_gain = rx_gain = 25 self.rx_freq = rx_freq = 116.8e6 self.fp = fp = "{:s}/{:s}".format(path, fn) self.fine = fine = -1.45e3 ################################################## # Blocks ################################################## self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel("samp_rate" + ": ")) self._samp_rate_line_edit = Qt.QLineEdit(str(self.samp_rate)) self._samp_rate_tool_bar.addWidget(self._samp_rate_line_edit) self._samp_rate_line_edit.returnPressed.connect( lambda: self.set_samp_rate( eng_notation.str_to_num( str(self._samp_rate_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._samp_rate_tool_bar, 0, 4, 1, 4) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self._rx_gain_tool_bar = Qt.QToolBar(self) self._rx_gain_tool_bar.addWidget(Qt.QLabel('Gain' + ": ")) self._rx_gain_line_edit = Qt.QLineEdit(str(self.rx_gain)) self._rx_gain_tool_bar.addWidget(self._rx_gain_line_edit) self._rx_gain_line_edit.returnPressed.connect(lambda: self.set_rx_gain( eng_notation.str_to_num( str(self._rx_gain_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._rx_gain_tool_bar, 2, 4, 1, 2) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self._rx_freq_tool_bar = Qt.QToolBar(self) self._rx_freq_tool_bar.addWidget(Qt.QLabel('Freq [Hz]' + ": ")) self._rx_freq_line_edit = Qt.QLineEdit(str(self.rx_freq)) self._rx_freq_tool_bar.addWidget(self._rx_freq_line_edit) self._rx_freq_line_edit.returnPressed.connect(lambda: self.set_rx_freq( eng_notation.str_to_num( str(self._rx_freq_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._rx_freq_tool_bar, 1, 4, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self._fine_tool_bar = Qt.QToolBar(self) self._fine_tool_bar.addWidget(Qt.QLabel('Fine [Hz]' + ": ")) self._fine_line_edit = Qt.QLineEdit(str(self.fine)) self._fine_tool_bar.addWidget(self._fine_line_edit) self._fine_line_edit.returnPressed.connect(lambda: self.set_fine( eng_notation.str_to_num(str(self._fine_line_edit.text().toAscii())) )) self.top_grid_layout.addWidget(self._fine_tool_bar, 1, 6, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 8): self.top_grid_layout.setColumnStretch(c, 1) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join((addr, "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_clock_rate(60e6, uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_clock_source('external', 0) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_center_freq( uhd.tune_request(rx_freq + fine, samp_rate / 2), 0) self.uhd_usrp_source_0.set_gain(rx_gain, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.uhd_usrp_source_0.set_auto_dc_offset(True, 0) self.uhd_usrp_source_0.set_auto_iq_balance(True, 0) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=5, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 5, 4, 2, 4) for r in range(5, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / 5, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.010) self.qtgui_freq_sink_x_0.set_y_axis(-140, -40) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 3, 4, 2, 4) for r in range(3, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.fosphor_qt_sink_c_0 = fosphor.qt_sink_c() self.fosphor_qt_sink_c_0.set_fft_window(window.WIN_BLACKMAN_hARRIS) self.fosphor_qt_sink_c_0.set_frequency_range(0, samp_rate) self._fosphor_qt_sink_c_0_win = sip.wrapinstance( self.fosphor_qt_sink_c_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._fosphor_qt_sink_c_0_win, 0, 0, 8, 4) for r in range(0, 8): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) ################################################## # Connections ################################################## self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.fosphor_qt_sink_c_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.rational_resampler_xxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 20e6 self.rx_freq = rx_freq = 100e6 ################################################## # Blocks ################################################## self._rx_freq_range = Range(1e6, 6e9, 20e6, 100e6, 200) self._rx_freq_win = RangeWidget(self._rx_freq_range, self.set_rx_freq, "rx_freq", "counter_slider", float) self.top_layout.addWidget(self._rx_freq_win) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_0_win) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(rx_freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(9, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(0, 0) ################################################## # Connections ################################################## self.connect((self.osmosdr_source_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "NOAA APT Satellite Receiver") Qt.QWidget.__init__(self) self.setWindowTitle("NOAA APT Satellite Receiver") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "apt_rx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) self._lock = threading.RLock() ################################################## # Variables ################################################## self.satellite_select = satellite_select = 137.62 self.valid_gains = valid_gains = [0.0, 0.9, 1.4, 2.7, 3.7, 7.7, 8.7, 12.5, 14.4, 15.7, 16.6, 19.7, 20.7, 22.9, 25.4, 28.0, 29.7, 32.8, 33.8, 36.4, 37.2, 38.6, 40.2, 42.1, 43.4, 43.9, 44.5, 48.0, 49.6] self.satellite_frequency = satellite_frequency = satellite_select * 1e6 self.rf_samp_rate = rf_samp_rate = 2.048e6 self.max_doppler = max_doppler = 3000 self.fsk_deviation_hz = fsk_deviation_hz = 17000 self.am_carrier = am_carrier = 2400 self.tuner_frequency = tuner_frequency = satellite_frequency - (rf_samp_rate / 4) self.rf_gain = rf_gain = valid_gains[-1] self.rail_level = rail_level = 0.5 self.processing_rate = processing_rate = 256000 self.fm_bandwidth = fm_bandwidth = (2 * (fsk_deviation_hz + am_carrier)) + max_doppler self.baud_rate = baud_rate = 4160 ################################################## # Blocks ################################################## self.tabs_top = Qt.QTabWidget() self.tabs_top_widget_0 = Qt.QWidget() self.tabs_top_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_top_widget_0) self.tabs_top_grid_layout_0 = Qt.QGridLayout() self.tabs_top_layout_0.addLayout(self.tabs_top_grid_layout_0) self.tabs_top.addTab(self.tabs_top_widget_0, "RF Recieve") self.tabs_top_widget_1 = Qt.QWidget() self.tabs_top_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_top_widget_1) self.tabs_top_grid_layout_1 = Qt.QGridLayout() self.tabs_top_layout_1.addLayout(self.tabs_top_grid_layout_1) self.tabs_top.addTab(self.tabs_top_widget_1, "APT Signal") self.tabs_top_widget_2 = Qt.QWidget() self.tabs_top_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_top_widget_2) self.tabs_top_grid_layout_2 = Qt.QGridLayout() self.tabs_top_layout_2.addLayout(self.tabs_top_grid_layout_2) self.tabs_top.addTab(self.tabs_top_widget_2, "APT Baseband") self.top_grid_layout.addWidget(self.tabs_top, 2, 0, 1, 4) self.tabs_rf = Qt.QTabWidget() self.tabs_rf_widget_0 = Qt.QWidget() self.tabs_rf_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_rf_widget_0) self.tabs_rf_grid_layout_0 = Qt.QGridLayout() self.tabs_rf_layout_0.addLayout(self.tabs_rf_grid_layout_0) self.tabs_rf.addTab(self.tabs_rf_widget_0, "Spectrum") self.tabs_rf_widget_1 = Qt.QWidget() self.tabs_rf_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_rf_widget_1) self.tabs_rf_grid_layout_1 = Qt.QGridLayout() self.tabs_rf_layout_1.addLayout(self.tabs_rf_grid_layout_1) self.tabs_rf.addTab(self.tabs_rf_widget_1, "Waterfall") self.tabs_rf_widget_2 = Qt.QWidget() self.tabs_rf_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_rf_widget_2) self.tabs_rf_grid_layout_2 = Qt.QGridLayout() self.tabs_rf_layout_2.addLayout(self.tabs_rf_grid_layout_2) self.tabs_rf.addTab(self.tabs_rf_widget_2, "Scope") self.tabs_top_layout_0.addWidget(self.tabs_rf) self.tabs_apt_data = Qt.QTabWidget() self.tabs_apt_data_widget_0 = Qt.QWidget() self.tabs_apt_data_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_apt_data_widget_0) self.tabs_apt_data_grid_layout_0 = Qt.QGridLayout() self.tabs_apt_data_layout_0.addLayout(self.tabs_apt_data_grid_layout_0) self.tabs_apt_data.addTab(self.tabs_apt_data_widget_0, "Scope") self.tabs_apt_data_widget_1 = Qt.QWidget() self.tabs_apt_data_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_apt_data_widget_1) self.tabs_apt_data_grid_layout_1 = Qt.QGridLayout() self.tabs_apt_data_layout_1.addLayout(self.tabs_apt_data_grid_layout_1) self.tabs_apt_data.addTab(self.tabs_apt_data_widget_1, "Raster") self.tabs_top_layout_1.addWidget(self.tabs_apt_data) self._satellite_select_options = [137.62, 137.9125, 137.1] self._satellite_select_labels = ['NOAA 15 (137.62 MHz)', 'NOAA 18 (137.9125 MHz)', 'NOAA 19 (137.1 MHz)'] self._satellite_select_tool_bar = Qt.QToolBar(self) self._satellite_select_tool_bar.addWidget(Qt.QLabel("Satellite Select"+": ")) self._satellite_select_combo_box = Qt.QComboBox() self._satellite_select_tool_bar.addWidget(self._satellite_select_combo_box) for label in self._satellite_select_labels: self._satellite_select_combo_box.addItem(label) self._satellite_select_callback = lambda i: Qt.QMetaObject.invokeMethod(self._satellite_select_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._satellite_select_options.index(i))) self._satellite_select_callback(self.satellite_select) self._satellite_select_combo_box.currentIndexChanged.connect( lambda i: self.set_satellite_select(self._satellite_select_options[i])) self.top_grid_layout.addWidget(self._satellite_select_tool_bar, 0, 0, 1, 1) self._rf_gain_options = valid_gains self._rf_gain_labels = map(str, self._rf_gain_options) self._rf_gain_tool_bar = Qt.QToolBar(self) self._rf_gain_tool_bar.addWidget(Qt.QLabel("RF Gain"+": ")) self._rf_gain_combo_box = Qt.QComboBox() self._rf_gain_tool_bar.addWidget(self._rf_gain_combo_box) for label in self._rf_gain_labels: self._rf_gain_combo_box.addItem(label) self._rf_gain_callback = lambda i: Qt.QMetaObject.invokeMethod(self._rf_gain_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._rf_gain_options.index(i))) self._rf_gain_callback(self.rf_gain) self._rf_gain_combo_box.currentIndexChanged.connect( lambda i: self.set_rf_gain(self._rf_gain_options[i])) self.top_grid_layout.addWidget(self._rf_gain_tool_bar, 0, 1 , 1, 1) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype satellite_frequency, #fc processing_rate // 2, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.50) self.qtgui_waterfall_sink_x_0.enable_grid(False) if not False: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-40, 0) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_rf_layout_1.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( baud_rate / 2, #size baud_rate, #samp_rate 'APT Full Line', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-0.5, 1.5) self.qtgui_time_sink_x_0_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0.01, 0, 'SyncA') self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_control_panel(False) if not False: self.qtgui_time_sink_x_0_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tabs_apt_data_layout_0.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size processing_rate // 2, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2*1): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_rf_layout_2.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_time_raster_sink_x_0 = qtgui.time_raster_sink_f( baud_rate, 120*3, baud_rate // 2, ([]), ([]), "", 1, ) self.qtgui_time_raster_sink_x_0.set_update_time(0.10) self.qtgui_time_raster_sink_x_0.set_intensity_range(-0.5, 1.5) self.qtgui_time_raster_sink_x_0.enable_grid(False) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_raster_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_raster_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_raster_sink_x_0.set_color_map(i, colors[i]) self.qtgui_time_raster_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_raster_sink_x_0_win = sip.wrapinstance(self.qtgui_time_raster_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_apt_data_layout_1.addWidget(self._qtgui_time_raster_sink_x_0_win) self.qtgui_freq_sink_x_1_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 16.64e3, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1_0.set_update_time(0.10) self.qtgui_freq_sink_x_1_0.set_y_axis(-40, 0) self.qtgui_freq_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1_0.enable_autoscale(False) self.qtgui_freq_sink_x_1_0.enable_grid(False) self.qtgui_freq_sink_x_1_0.set_fft_average(0.2) self.qtgui_freq_sink_x_1_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1_0.set_plot_pos_half(not True) labels = ["Raw", "AGC Output", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_1_0.pyqwidget(), Qt.QWidget) self.tabs_top_layout_2.addWidget(self._qtgui_freq_sink_x_1_0_win) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype satellite_frequency, #fc processing_rate // 2, #bw "", #name 2 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-100, 0) self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(0.2) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1.set_plot_pos_half(not True) labels = ["Raw", "AGC Output", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.tabs_rf_layout_0.addWidget(self._qtgui_freq_sink_x_1_win) self.low_pass_filter_0_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, processing_rate // 2, fm_bandwidth + 1e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(2, firdes.low_pass( 1, processing_rate, 60e3, 15e3, firdes.WIN_HAMMING, 6.76)) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, processing_rate,True) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/Users/bjmclaug/Downloads/noaa-12_256k.dat", False) self.blocks_file_meta_sink_0 = blocks.file_meta_sink(gr.sizeof_float*1, "/Users/bjmclaug/source/stem_station/noaa12_sample.dat", baud_rate, 1, blocks.GR_FILE_FLOAT, False, baud_rate * (60 * 20), "", True) self.blocks_file_meta_sink_0.set_unbuffered(False) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.apt_am_demod_0 = apt_am_demod( parameter_apt_gain=1, parameter_samp_rate=processing_rate / 2, ) self.analog_rail_ff_0_0 = analog.rail_ff(-rail_level, rail_level) self.analog_rail_ff_0 = analog.rail_ff(-rail_level, rail_level) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf((processing_rate // 2)/(2*math.pi*fsk_deviation_hz/8.0)) self.analog_agc3_xx_0 = analog.agc3_cc(0.25, 0.5, 0.9, 1.0, 1) self.analog_agc3_xx_0.set_max_gain(1) ################################################## # Connections ################################################## self.connect((self.analog_agc3_xx_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.apt_am_demod_0, 0)) self.connect((self.analog_rail_ff_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.analog_rail_ff_0_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.apt_am_demod_0, 0), (self.blocks_file_meta_sink_0, 0)) self.connect((self.apt_am_demod_0, 0), (self.qtgui_time_raster_sink_x_0, 0)) self.connect((self.apt_am_demod_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.analog_rail_ff_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.analog_rail_ff_0_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_agc3_xx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_freq_sink_x_1, 1)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self, puncpat='11'): gr.top_block.__init__(self, "Tutorial") Qt.QWidget.__init__(self) self.setWindowTitle("Tutorial") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "tutorial_10") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.puncpat = puncpat ################################################## # Variables ################################################## self.sps = sps = 4 self.samp_rate_array_MCR = samp_rate_array_MCR = [7500000,5000000,3750000,3000000,2500000,2000000,1500000,1000000,937500,882352,833333,714285,533333,500000,421052,400000,380952] self.rate = rate = 2 self.polys = polys = [109, 79] self.nfilts = nfilts = 32 self.k = k = 7 self.eb = eb = 0.22 self.vector = vector = [int(random.random()*7) for i in range(49600)] self.variable_qtgui_range_1_0 = variable_qtgui_range_1_0 = 0 self.variable_qtgui_range_1 = variable_qtgui_range_1 = 0 self.variable_qtgui_range_0_1 = variable_qtgui_range_0_1 = 38 self.variable_qtgui_range_0 = variable_qtgui_range_0 = 50 self.tx_rrc_taps = tx_rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0, eb, 5*sps*nfilts) self.samp_rate = samp_rate = samp_rate_array_MCR[7] self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine(sps, sps, 1.0, eb, 11*sps) self.rrc_taps = rrc_taps = firdes.root_raised_cosine(sps, sps, 1.0, eb, 11*sps) self.pld_enc = pld_enc = map( (lambda a: fec.cc_encoder_make(440, k, rate, (polys), 0, fec.CC_TERMINATED, False)), range(0,4) ); self.pld_dec = pld_dec = map( (lambda a: fec.cc_decoder.make(440, k, rate, (polys), 0, -1, fec.CC_TERMINATED, False)), range(0,8) ); self.pld_const = pld_const = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.pld_const.gen_soft_dec_lut(8) self.nfilts_rx = nfilts_rx = 4 self.frequencia_usrp = frequencia_usrp = 484e6 self.MCR = MCR = "master_clock_rate=60e6" ################################################## # Blocks ################################################## self._variable_qtgui_range_1_0_range = Range(0, 200, 1, 0, 200) self._variable_qtgui_range_1_0_win = RangeWidget(self._variable_qtgui_range_1_0_range, self.set_variable_qtgui_range_1_0, 'Delay SIGNAL', "counter_slider", int) self.top_grid_layout.addWidget(self._variable_qtgui_range_1_0_win, 3, 1, 1, 1) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._variable_qtgui_range_1_range = Range(0, 200, 1, 0, 200) self._variable_qtgui_range_1_win = RangeWidget(self._variable_qtgui_range_1_range, self.set_variable_qtgui_range_1, 'Delay JAMMING', "counter_slider", int) self.top_grid_layout.addWidget(self._variable_qtgui_range_1_win, 2, 1, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._variable_qtgui_range_0_1_range = Range(0, 73, 1, 38, 200) self._variable_qtgui_range_0_1_win = RangeWidget(self._variable_qtgui_range_0_1_range, self.set_variable_qtgui_range_0_1, 'Gain_RX', "counter_slider", float) self.top_grid_layout.addWidget(self._variable_qtgui_range_0_1_win, 0, 2, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self._variable_qtgui_range_0_range = Range(0, 90, 1, 50, 200) self._variable_qtgui_range_0_win = RangeWidget(self._variable_qtgui_range_0_range, self.set_variable_qtgui_range_0, 'Gain_TX', "counter_slider", float) self.top_grid_layout.addWidget(self._variable_qtgui_range_0_win, 0, 1, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_1 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "TX USRP", #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) self.qtgui_time_sink_x_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_1.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_1.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win, 1, 3, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f( 100*2, #size samp_rate, #samp_rate 'Rx Data', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_1.set_update_time(0.10) self.qtgui_time_sink_x_0_1.set_y_axis(-1, 256) self.qtgui_time_sink_x_0_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_1.enable_tags(-1, True) self.qtgui_time_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, 'packet_length_tag_key') self.qtgui_time_sink_x_0_1.enable_autoscale(True) self.qtgui_time_sink_x_0_1.enable_grid(True) self.qtgui_time_sink_x_0_1.enable_axis_labels(True) self.qtgui_time_sink_x_0_1.enable_control_panel(False) self.qtgui_time_sink_x_0_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_1_win = sip.wrapinstance(self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_win, 2, 3, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 100*2, #size samp_rate, #samp_rate 'Tx Data', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 256) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, 'packet_length_tag_key') self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 1, 1, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 2 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1.set_plot_pos_half(not True) labels = ['OUT', 'ERROR', 'Output', 'Error', 'MIX', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["black", "red", "green", "cyan", "magenta", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 6, 1, 1, 3) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0_1_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Difference Between ORIGINAL/RECOVERED", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0_0_1_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0_1_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0_1_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0_1_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0_1_0.enable_grid(False) self.qtgui_freq_sink_x_0_0_1_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0_1_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0_1_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0_1_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0_1_0.set_plot_pos_half(not True) labels = ['After chunks to symbols', 'ERROR LMS', 'Error LMS', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0_1_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0_1_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0_1_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0_1_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0_1_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_1_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_1_0_win, 5, 1, 1, 3) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0_0_1_0 = qtgui.const_sink_c( 1024, #size "RX Treated Constellation", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0_1_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0_1_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_1_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0_1_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0_1_0.enable_grid(False) self.qtgui_const_sink_x_0_0_0_1_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_0_1_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0_0_1_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0_1_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0_1_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0_1_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0_1_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0_1_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0_1_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_1_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0_0_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_1_0_win, 2, 2, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0_0_0 = qtgui.const_sink_c( 1024, #size "TX Constellation", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0_0_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_0_win, 1, 2, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.interp_fir_filter_xxx_1 = filter.interp_fir_filter_ccc(4, ([1])) self.interp_fir_filter_xxx_1.declare_sample_delay(0) self.interp_fir_filter_xxx_0_0 = filter.interp_fir_filter_ccc(sps, (rrc_taps)) self.interp_fir_filter_xxx_0_0.declare_sample_delay(0) self.insert_vec_cpp_new_vec_0 = insert_vec_cpp.new_vec((vector)) self.digital_pfb_clock_sync_xxx_0_0_0 = digital.pfb_clock_sync_ccf(sps, 6.28/100.0, (rx_rrc_taps), sps, sps/2, 1.5, 1) self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(pld_const.arity()) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(pld_const.arity()) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(6.28/100, 4, False) self.digital_correlate_access_code_xx_ts_0_0 = digital.correlate_access_code_bb_ts(digital.packet_utils.default_access_code, 1, 'packet_len') self.digital_constellation_decoder_cb_0_0 = digital.constellation_decoder_cb(pld_const) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc((pld_const.points()), 1) self.correlate_and_delay_corr_and_delay_0 = correlate_and_delay.corr_and_delay(100, 0, 0.999, 4) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True) self.blocks_stream_mux_0_1_0 = blocks.stream_mux(gr.sizeof_char*1, (96, 896)) self.blocks_repack_bits_bb_1_0_0_1 = blocks.repack_bits_bb(8, 1, '', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_0_1 = blocks.repack_bits_bb(1, pld_const.bits_per_symbol(), '', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(1, 8, '', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(pld_const.bits_per_symbol(), 1, '', False, gr.GR_MSB_FIRST) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((0.7, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.7, )) self.blocks_file_source_0_0_1_0 = blocks.file_source(gr.sizeof_char*1, '/home/andre/Desktop/Files_To_Transmit/trasmit_10_mb.txt', False) self.blocks_file_source_0_0_1_0.set_begin_tag(pmt.PMT_NIL) self.blocks_file_sink_0_0_0_2 = blocks.file_sink(gr.sizeof_char*1, '/home/andre/Desktop/Trasmited/depois.txt', False) self.blocks_file_sink_0_0_0_2.set_unbuffered(False) self.blocks_char_to_float_1_0_1 = blocks.char_to_float(1, 1) self.blocks_char_to_float_1_0_0 = blocks.char_to_float(1, 1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, 1.0, 0) self.adapt_lms_filter_xx_0 = adapt.lms_filter_cc(True, 64, 0.0001, 0, 1, True, False, False) self.acode_1104 = blocks.vector_source_b([0x1, 0x0, 0x1, 0x0, 0x1, 0x1, 0x0, 0x0, 0x1, 0x1, 0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0], True, 1, []) ################################################## # Connections ################################################## self.connect((self.acode_1104, 0), (self.blocks_stream_mux_0_1_0, 0)) self.connect((self.adapt_lms_filter_xx_0, 1), (self.digital_pfb_clock_sync_xxx_0_0_0, 0)) self.connect((self.adapt_lms_filter_xx_0, 1), (self.qtgui_freq_sink_x_1, 1)) self.connect((self.adapt_lms_filter_xx_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.analog_noise_source_x_0, 0), (self.interp_fir_filter_xxx_1, 0)) self.connect((self.blocks_add_xx_0, 0), (self.correlate_and_delay_corr_and_delay_0, 1)) self.connect((self.blocks_char_to_float_1_0_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_char_to_float_1_0_1, 0), (self.qtgui_time_sink_x_0_1, 0)) self.connect((self.blocks_file_source_0_0_1_0, 0), (self.blocks_char_to_float_1_0_0, 0)) self.connect((self.blocks_file_source_0_0_1_0, 0), (self.blocks_repack_bits_bb_1_0_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.correlate_and_delay_corr_and_delay_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_const_sink_x_0_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_correlate_access_code_xx_ts_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.blocks_char_to_float_1_0_1, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.blocks_file_sink_0_0_0_2, 0)) self.connect((self.blocks_repack_bits_bb_0_1, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_repack_bits_bb_1_0_0_1, 0), (self.blocks_stream_mux_0_1_0, 1)) self.connect((self.blocks_stream_mux_0_1_0, 0), (self.blocks_repack_bits_bb_0_1, 0)) self.connect((self.blocks_throttle_0, 0), (self.insert_vec_cpp_new_vec_0, 0)) self.connect((self.correlate_and_delay_corr_and_delay_0, 0), (self.adapt_lms_filter_xx_0, 1)) self.connect((self.correlate_and_delay_corr_and_delay_0, 1), (self.adapt_lms_filter_xx_0, 0)) self.connect((self.correlate_and_delay_corr_and_delay_0, 2), (self.blocks_null_sink_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.interp_fir_filter_xxx_0_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.qtgui_freq_sink_x_0_0_1_0, 0)) self.connect((self.digital_constellation_decoder_cb_0_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_correlate_access_code_xx_ts_0_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_constellation_decoder_cb_0_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0_0_0_1_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_freq_sink_x_0_0_1_0, 1)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_diff_encoder_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0_0_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.insert_vec_cpp_new_vec_0, 0), (self.digital_diff_encoder_bb_0, 0)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.interp_fir_filter_xxx_1, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Record_RX") Qt.QWidget.__init__(self) self.setWindowTitle("Record_RX") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "Record_RX") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2e6 ################################################## # Blocks ################################################## self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(462650000, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(10, 0) self.osmosdr_source_0.set_if_gain(25, 0) self.osmosdr_source_0.set_bb_gain(16, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, "/root/Desktop/TXRX", False) self.blocks_file_sink_0.set_unbuffered(False) ################################################## # Connections ################################################## self.connect((self.osmosdr_source_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
def __init__(self, gs_name='VTGS', ip='0.0.0.0', meta_rate=.1, port='52003', record_iq=0, record_rfo=0, record_snr=0, tx_freq=1265e6, tx_offset=250e3): gr.top_block.__init__(self, "VTGS Rocksat-X 2017 Transceiver v2.0") Qt.QWidget.__init__(self) self.setWindowTitle("VTGS Rocksat-X 2017 Transceiver v2.0") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "vtgs_trx_file") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.gs_name = gs_name self.ip = ip self.meta_rate = meta_rate self.port = port self.record_iq = record_iq self.record_rfo = record_rfo self.record_snr = record_snr self.tx_freq = tx_freq self.tx_offset = tx_offset ################################################## # Variables ################################################## self.ts_str = ts_str = dt.strftime(dt.utcnow(), "%Y%m%d_%H%M%S.%f") + '_UTC' self.samp_rate = samp_rate = 500e3 self.baud = baud = 125e3 self.snr_fn = snr_fn = "{:s}_{:s}.snr".format(gs_name, ts_str) self.samps_per_symb = samps_per_symb = int(samp_rate / baud) self.rx_freq = rx_freq = 2395e6 self.rfo_fn = rfo_fn = "{:s}_{:s}.rfo".format(gs_name, ts_str) self.iq_fn = iq_fn = "{:s}_{:s}_{:s}k.fc32".format( gs_name, ts_str, str(int(samp_rate) / 1000)) self.alpha = alpha = 0.5 self.uplink_label = uplink_label = '' self.tx_gain = tx_gain = 25 self.tx_correct = tx_correct = 2000 self.snr_fp = snr_fp = "/captures/rocksat/{:s}".format(snr_fn) self.rx_offset = rx_offset = 250e3 self.rx_gain = rx_gain = 1 self.rx_freq_lbl = rx_freq_lbl = "{:4.3f}".format(rx_freq / 1e6) self.rrc_filter_taps = rrc_filter_taps = firdes.root_raised_cosine( 32, 1.0, 1.0 / (samps_per_symb * 32), alpha, samps_per_symb * 32) self.rfo_fp = rfo_fp = "/captures/rocksat/{:s}".format(rfo_fn) self.mult = mult = (samp_rate) / 2 / 3.141593 self.lpf_taps = lpf_taps = firdes.low_pass(1.0, samp_rate, samp_rate / 2, 1000, firdes.WIN_HAMMING, 6.76) self.lo = lo = 1833e6 self.khz_offset = khz_offset = 0 self.iq_fp = iq_fp = "/captures/rocksat/{:s}".format(iq_fn) self.bb_gain = bb_gain = .75 ################################################## # Blocks ################################################## self._khz_offset_range = Range(-150, 150, 1, 0, 200) self._khz_offset_win = RangeWidget(self._khz_offset_range, self.set_khz_offset, 'Offset [kHz]', "counter_slider", float) self.top_grid_layout.addWidget(self._khz_offset_win, 4, 8, 1, 4) self._bb_gain_range = Range(0, 1, .01, .75, 200) self._bb_gain_win = RangeWidget(self._bb_gain_range, self.set_bb_gain, 'bb_gain', "counter_slider", float) self.top_grid_layout.addWidget(self._bb_gain_win, 11, 8, 1, 4) self.vtgs_mult_descrambler_0 = vtgs.mult_descrambler(17, 0x3FFFF) self.vtgs_ao40_decoder_0_0 = vtgs.ao40_decoder() self._uplink_label_tool_bar = Qt.QToolBar(self) if None: self._uplink_label_formatter = None else: self._uplink_label_formatter = lambda x: str(x) self._uplink_label_tool_bar.addWidget(Qt.QLabel('TX MSG' + ": ")) self._uplink_label_label = Qt.QLabel( str(self._uplink_label_formatter(self.uplink_label))) self._uplink_label_tool_bar.addWidget(self._uplink_label_label) self.top_grid_layout.addWidget(self._uplink_label_tool_bar, 9, 8, 1, 1) self._tx_gain_range = Range(0, 86, 1, 25, 200) self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, 'TX Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._tx_gain_win, 10, 8, 1, 4) self._tx_correct_range = Range(-10000, 10000, 1, 2000, 200) self._tx_correct_win = RangeWidget(self._tx_correct_range, self.set_tx_correct, "tx_correct", "counter_slider", float) self.top_grid_layout.addWidget(self._tx_correct_win, 12, 8, 1, 4) self._rx_gain_range = Range(0, 86, 1, 1, 200) self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, 'RX Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._rx_gain_win, 3, 8, 1, 4) self._rx_freq_lbl_tool_bar = Qt.QToolBar(self) if None: self._rx_freq_lbl_formatter = None else: self._rx_freq_lbl_formatter = lambda x: str(x) self._rx_freq_lbl_tool_bar.addWidget(Qt.QLabel('RX Freq [MHz]' + ": ")) self._rx_freq_lbl_label = Qt.QLabel( str(self._rx_freq_lbl_formatter(self.rx_freq_lbl))) self._rx_freq_lbl_tool_bar.addWidget(self._rx_freq_lbl_label) self.top_grid_layout.addWidget(self._rx_freq_lbl_tool_bar, 0, 10, 1, 2) self.rational_resampler_xxx_2 = filter.rational_resampler_ccc( interpolation=1, decimation=10, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=1, decimation=8, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=8, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw '', #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0.enable_grid(True) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not False: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['pre-d', 'post', '', '', '', '', '', '', '', ''] colors = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-130, -20) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 5, 0, 4, 8) self.qtgui_number_sink_2 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_2.set_update_time(0.10) self.qtgui_number_sink_2.set_title("") labels = ['EVM', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("blue", "red"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_2.set_min(i, -1) self.qtgui_number_sink_2.set_max(i, 1) self.qtgui_number_sink_2.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_2.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_2.set_label(i, labels[i]) self.qtgui_number_sink_2.set_unit(i, units[i]) self.qtgui_number_sink_2.set_factor(i, factor[i]) self.qtgui_number_sink_2.enable_autoscale(False) self._qtgui_number_sink_2_win = sip.wrapinstance( self.qtgui_number_sink_2.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_2_win, 2, 8, 1, 4) self.qtgui_number_sink_0_0_0_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0_0_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0_0_0.set_title("") labels = ['SNR', '', '', '', '', '', '', '', '', ''] units = ['dB', '', '', '', '', '', '', '', '', ''] colors = [("blue", "red"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_0_0_0.set_min(i, 0) self.qtgui_number_sink_0_0_0_0.set_max(i, 30) self.qtgui_number_sink_0_0_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_0_0.set_label( i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_0_win, 1, 8, 1, 4) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ['RX Freq Offset', 'SNR', '', '', '', '', '', '', '', ''] units = ['Hz', 'dB', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 0, 8, 1, 2) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / 10, #bw "TX Spectrum", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(True) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance( self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 9, 0, 4, 8) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024 * 4, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.0010) self.qtgui_freq_sink_x_0.set_y_axis(-140, -20) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['pre-d', 'post', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 5, 8) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-1, 1) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(True) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 5, 8, 4, 4) self.pyqt_text_input_0 = pyqt.text_input() self._pyqt_text_input_0_win = self.pyqt_text_input_0 self.top_grid_layout.addWidget(self._pyqt_text_input_0_win, 9, 9, 1, 3) self.mapper_demapper_soft_0 = mapper.demapper_soft( mapper.BPSK, ([0, 1])) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, (baud * (1 + alpha)) / 2, 1000, firdes.WIN_HAMMING, 6.76)) self.kiss_hdlc_framer_0 = kiss.hdlc_framer(preamble_bytes=64, postamble_bytes=16) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 1, (lpf_taps), khz_offset * 1000, samp_rate) self.digital_scrambler_bb_0 = digital.scrambler_bb(0x21, 0x0, 16) self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_ccf( samps_per_symb, math.pi * 2 / 100, (rrc_filter_taps), 32, 16, 1.5, 1) self.digital_gmsk_mod_0 = digital.gmsk_mod( samples_per_symbol=50, bt=alpha, verbose=False, log=False, ) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc( math.pi * 2 / 100, 2, False) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( math.pi * 2 / 100, 2, False) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_socket_pdu_0_2 = blocks.socket_pdu("UDP_SERVER", ip, '52002', 1024, False) self.blocks_socket_pdu_0_1 = blocks.socket_pdu("TCP_SERVER", ip, port, 1024, False) self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, 'packet_len') self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_null_sink_0_0_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_nlog10_ff_0_1 = blocks.nlog10_ff(10, 1, 0) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc( (bb_gain, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((mult, )) self.blocks_moving_average_xx_0_0_1 = blocks.moving_average_ff( 100000, 0.00001, 4000) self.blocks_moving_average_xx_0_0 = blocks.moving_average_ff( 1000, 0.001, 4000) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( 100000, 0.00001, 4000) self.blocks_keep_one_in_n_0_0 = blocks.keep_one_in_n( gr.sizeof_float * 1, int(samp_rate * meta_rate)) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_float * 1, int(samp_rate / 8 * meta_rate)) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, '/captures/rocksat/testing/trimmed_500k.fc32', True) self.blocks_file_sink_1_0 = blocks.file_sink(gr.sizeof_float * 1, rfo_fp, False) self.blocks_file_sink_1_0.set_unbuffered(False) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_float * 1, snr_fp, False) self.blocks_file_sink_1.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1, iq_fp, False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared( 1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, )) self.blks2_selector_0_0_0 = grc_blks2.selector( item_size=gr.sizeof_float * 1, num_inputs=1, num_outputs=2, input_index=0, output_index=int(record_snr), ) self.blks2_selector_0_0 = grc_blks2.selector( item_size=gr.sizeof_float * 1, num_inputs=1, num_outputs=2, input_index=0, output_index=int(record_rfo), ) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex * 1, num_inputs=1, num_outputs=2, input_index=0, output_index=int(record_iq), ) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 125e3, 1, 0) self.analog_agc2_xx_0_0 = analog.agc2_cc(1e-3, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0_1, 'pdus'), (self.kiss_hdlc_framer_0, 'in')) self.msg_connect((self.blocks_socket_pdu_0_2, 'pdus'), (self.kiss_hdlc_framer_0, 'in')) self.msg_connect((self.kiss_hdlc_framer_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus')) self.msg_connect((self.pyqt_text_input_0, 'pdus'), (self.kiss_hdlc_framer_0, 'in')) self.msg_connect((self.vtgs_ao40_decoder_0_0, 'valid_frames'), (self.blocks_socket_pdu_0_1, 'pdus')) self.connect((self.analog_agc2_xx_0_0, 0), (self.digital_costas_loop_cc_0_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blks2_selector_0, 1), (self.blocks_file_sink_0, 0)) self.connect((self.blks2_selector_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.blks2_selector_0_0, 1), (self.blocks_file_sink_1_0, 0)) self.connect((self.blks2_selector_0_0, 0), (self.blocks_null_sink_0_0, 0)) self.connect((self.blks2_selector_0_0_0, 1), (self.blocks_file_sink_1, 0)) self.connect((self.blks2_selector_0_0_0, 0), (self.blocks_null_sink_0_0_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.qtgui_number_sink_2, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_moving_average_xx_0_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_divide_xx_0, 0), (self.blocks_nlog10_ff_0_1, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.blks2_selector_0_0_0, 0)) self.connect((self.blocks_keep_one_in_n_0_0, 0), (self.blks2_selector_0_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_keep_one_in_n_0_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_moving_average_xx_0_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_moving_average_xx_0_0_1, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_moving_average_xx_0_0_1, 0), (self.qtgui_number_sink_0_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.rational_resampler_xxx_2, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.blocks_nlog10_ff_0_1, 0), (self.blocks_moving_average_xx_0_0_1, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.digital_gmsk_mod_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.digital_scrambler_bb_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blks2_selector_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.mapper_demapper_soft_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 1), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.vtgs_mult_descrambler_0, 0)) self.connect((self.digital_gmsk_mod_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_scrambler_bb_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_agc2_xx_0_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.digital_pfb_clock_sync_xxx_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.mapper_demapper_soft_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_complex_to_mag_squared_0_0, 0)) self.connect((self.rational_resampler_xxx_2, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.vtgs_mult_descrambler_0, 0), (self.vtgs_ao40_decoder_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.data_rate_V2 = data_rate_V2 = 510*2 self.version_chooser = version_chooser = data_rate_V2 self.freq_range = freq_range = 433.995 self.audio_rate = audio_rate = 48000 self.trans = trans = 1.2e3 self.samp_rate = samp_rate = 2400000 self.samp_per_sym = samp_per_sym = audio_rate/version_chooser self.gain = gain = 390 self.freq_offset = freq_offset = 100e3 self.freq = freq = (0*433.886e6+0*433.877e6+0*433.995e6)+freq_range*1e6+100e3 self.data_rate_V1 = data_rate_V1 = 680 self.data_rate = data_rate = version_chooser self.channel_trans = channel_trans = 2000 self.channel_spacing = channel_spacing = 25e3 ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, "Frequency") self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, "Signal") self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, "Datarate") self.top_layout.addWidget(self.tab) self._gain_layout = Qt.QVBoxLayout() self._gain_tool_bar = Qt.QToolBar(self) self._gain_layout.addWidget(self._gain_tool_bar) self._gain_tool_bar.addWidget(Qt.QLabel("Decoder_Gain"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._gain_counter = qwt_counter_pyslot() self._gain_counter.setRange(0, 1000, 1) self._gain_counter.setNumButtons(2) self._gain_counter.setValue(self.gain) self._gain_tool_bar.addWidget(self._gain_counter) self._gain_counter.valueChanged.connect(self.set_gain) self._gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._gain_slider.setRange(0, 1000, 1) self._gain_slider.setValue(self.gain) self._gain_slider.setMinimumWidth(1000) self._gain_slider.valueChanged.connect(self.set_gain) self._gain_layout.addWidget(self._gain_slider) self.tab_layout_1.addLayout(self._gain_layout) self._version_chooser_options = [data_rate_V1, data_rate_V2] self._version_chooser_labels = ["V1","V2"] self._version_chooser_tool_bar = Qt.QToolBar(self) self._version_chooser_tool_bar.addWidget(Qt.QLabel("Oregon Scientific Version"+": ")) self._version_chooser_combo_box = Qt.QComboBox() self._version_chooser_tool_bar.addWidget(self._version_chooser_combo_box) for label in self._version_chooser_labels: self._version_chooser_combo_box.addItem(label) self._version_chooser_callback = lambda i: Qt.QMetaObject.invokeMethod(self._version_chooser_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._version_chooser_options.index(i))) self._version_chooser_callback(self.version_chooser) self._version_chooser_combo_box.currentIndexChanged.connect( lambda i: self.set_version_chooser(self._version_chooser_options[i])) self.tab_grid_layout_2.addWidget(self._version_chooser_tool_bar, 0,0) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_win, 2,0) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype freq-freq_offset, #fc samp_rate/50, #bw "", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0/10) self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_layout_1.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(True) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1 ) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ["", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_1.addWidget(self._qtgui_number_sink_0_win, 0,0) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(1.0) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0,0) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(True, 0) self.osmosdr_source_0.set_gain(10, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna("TX/RX", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(50, (firdes.low_pass(1, samp_rate, channel_spacing,channel_trans, firdes.WIN_BLACKMAN, 6.76)), -freq_offset, samp_rate) self._freq_range_layout = Qt.QVBoxLayout() self._freq_range_tool_bar = Qt.QToolBar(self) self._freq_range_layout.addWidget(self._freq_range_tool_bar) self._freq_range_tool_bar.addWidget(Qt.QLabel("Frequency"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._freq_range_counter = qwt_counter_pyslot() self._freq_range_counter.setRange(433, 434, 0.005) self._freq_range_counter.setNumButtons(2) self._freq_range_counter.setValue(self.freq_range) self._freq_range_tool_bar.addWidget(self._freq_range_counter) self._freq_range_counter.valueChanged.connect(self.set_freq_range) self._freq_range_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._freq_range_slider.setRange(433, 434, 0.005) self._freq_range_slider.setValue(self.freq_range) self._freq_range_slider.setMinimumWidth(1) self._freq_range_slider.valueChanged.connect(self.set_freq_range) self._freq_range_layout.addWidget(self._freq_range_slider) self.tab_grid_layout_0.addLayout(self._freq_range_layout, 1,0) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(samp_per_sym*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_1 = digital.binary_slicer_fb() self._data_rate_tool_bar = Qt.QToolBar(self) self._data_rate_tool_bar.addWidget(Qt.QLabel("Datarate"+": ")) self._data_rate_line_edit = Qt.QLineEdit(str(self.data_rate)) self._data_rate_tool_bar.addWidget(self._data_rate_line_edit) self._data_rate_line_edit.returnPressed.connect( lambda: self.set_data_rate(int(self._data_rate_line_edit.text().toAscii()))) self.tab_grid_layout_2.addWidget(self._data_rate_tool_bar, 1,0) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/tmp/fifo", False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_add_const_vxx_0 = blocks.add_const_vff((gain*1e-3, )) self.band_pass_filter_0 = filter.fir_filter_ccc(1, firdes.complex_band_pass( 1, samp_rate/50, -2500, 2500, trans, firdes.WIN_HAMMING, 6.76)) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=samp_rate/50, audio_decim=1, audio_pass=0*500+1*2500, audio_stop=5000, ) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1, 0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.digital_binary_slicer_fb_1, 0), (self.blocks_file_sink_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_1, 0)) self.connect((self.osmosdr_source_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.tun_gain = tun_gain = 0 self.tun_freq = tun_freq = 2.45e9 self.samp_rate = samp_rate = 32000 self.rx_freq_off = rx_freq_off = 0 self.freq = freq = 2.45e9 ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("addr=192.168.10.3", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self._tun_gain_range = Range(0, 20, 1, 0, 200) self._tun_gain_win = RangeWidget(self._tun_gain_range, self.set_tun_gain, "UHD Tx Gain", "counter_slider", float) self.top_layout.addWidget(self._tun_gain_win) self._tun_freq_range = Range(2.4e9, 2.5e9, 1, 2.45e9, 200) self._tun_freq_win = RangeWidget(self._tun_freq_range, self.set_tun_freq, "UHD Freq (Hz)", "counter_slider", float) self.top_layout.addWidget(self._tun_freq_win) self._rx_freq_off_range = Range(-100e3, 100e3, 1, 0, 200) self._rx_freq_off_win = RangeWidget(self._rx_freq_off_range, self.set_rx_freq_off, "Rx Freq Offset (Hz)", "counter_slider", float) self.top_layout.addWidget(self._rx_freq_off_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #fc samp_rate, #bw "USRP RX", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.digital_dxpsk_demod_0 = digital.dqpsk_demod(samples_per_symbol=4, excess_bw=0.35, freq_bw=6.28 / 100.0, phase_bw=6.28 / 100.0, timing_bw=6.28 / 100.0, mod_code="gray", verbose=False, log=False) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_char * 1, "/home/test/Desktop/RX.png", False) self.blocks_file_sink_0.set_unbuffered(False) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b( grc_blks2.packet_decoder( access_code="", threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0. recv_pkt(ok, payload), ), ) ################################################## # Connections ################################################## self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.digital_dxpsk_demod_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.digital_dxpsk_demod_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Ham2Mon NBFM Receiver Flow Example") Qt.QWidget.__init__(self) self.setWindowTitle("Ham2Mon NBFM Receiver Flow Example") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "nbfm_flow_example") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1E6 self.initial_decim = initial_decim = 5 self.samp_ratio = samp_ratio = samp_rate/1E6 self.final_rate = final_rate = samp_rate/initial_decim**2/int(samp_rate/1E6) self.variable_low_pass_filter_taps_2 = variable_low_pass_filter_taps_2 = firdes.low_pass(1.0, final_rate, 3500, 500, firdes.WIN_HAMMING, 6.76) self.variable_low_pass_filter_taps_1 = variable_low_pass_filter_taps_1 = firdes.low_pass(1.0, samp_rate/25, 12.5E3, 1E3, firdes.WIN_HAMMING, 6.76) self.variable_low_pass_filter_taps_0 = variable_low_pass_filter_taps_0 = firdes.low_pass(1.0, 1, 0.090, 0.010, firdes.WIN_HAMMING, 6.76) self.squelch_dB = squelch_dB = -70 self.gain_db = gain_db = 30 self.final_decim = final_decim = int(samp_rate/1E6) self.file_name = file_name = "test.wav" self.fft_length = fft_length = 256 * int(pow(2, np.ceil(np.log(samp_ratio)/np.log(2)))) self.demod_bb_freq = demod_bb_freq = 390E3 self.center_freq = center_freq = 144E6 ################################################## # Blocks ################################################## self._squelch_dB_range = Range(-100, 0, 5, -70, 200) self._squelch_dB_win = RangeWidget(self._squelch_dB_range, self.set_squelch_dB, "Squelch (dB)", "counter_slider", float) self.top_grid_layout.addWidget(self._squelch_dB_win, 5,1,1,3) self._gain_db_range = Range(0, 70, 1, 30, 200) self._gain_db_win = RangeWidget(self._gain_db_range, self.set_gain_db, "HW Gain (dB)", "counter_slider", float) self.top_grid_layout.addWidget(self._gain_db_win, 4,1,1,3) self._demod_bb_freq_range = Range(-samp_rate/2, samp_rate/2, 5E3, 390E3, 200) self._demod_bb_freq_win = RangeWidget(self._demod_bb_freq_range, self.set_demod_bb_freq, "Demod BB Freq (Hz)", "counter_slider", float) self.top_grid_layout.addWidget(self._demod_bb_freq_win, 3,1,1,3) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( fft_length, #size samp_rate, #samp_rate "Averaged Spectrum", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-60, 40) self.qtgui_time_sink_x_0.set_y_label("Power", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 0,1,3,1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc final_rate, #bw "Decimated Channel", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-200, -60) self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0.disable_legend() if complex == type(float()): self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 3,0,3,1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( fft_length, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 144E6, #fc samp_rate, #bw "Spectrum", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-120, -20) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if complex == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0,0,3,1) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_fff( 16E3/float(final_rate/5), taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "uhd" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(center_freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(gain_db, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(samp_rate*0.8, 0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(initial_decim, (variable_low_pass_filter_taps_0), demod_bb_freq, samp_rate) self.fir_filter_xxx_0_1 = filter.fir_filter_fff(initial_decim, (variable_low_pass_filter_taps_0)) self.fir_filter_xxx_0_1.declare_sample_delay(0) self.fir_filter_xxx_0_0 = filter.fir_filter_ccc(int(samp_rate/1E6), (variable_low_pass_filter_taps_0)) self.fir_filter_xxx_0_0.declare_sample_delay(0) self.fir_filter_xxx_0 = filter.fir_filter_ccc(initial_decim, (variable_low_pass_filter_taps_0)) self.fir_filter_xxx_0.declare_sample_delay(0) self.fft_vxx_0 = fft.fft_vcc(fft_length, True, (window.blackmanharris(fft_length)), True, 1) self.blocks_wavfile_sink_0 = blocks.wavfile_sink(file_name, 1, 16000, 8) self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_float*1, fft_length) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fft_length) self.blocks_probe_signal_vx_0 = blocks.probe_signal_vf(fft_length) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, fft_length, 0) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_gr_complex*fft_length, int(round(samp_rate/fft_length/1000))) self.blocks_integrate_xx_0 = blocks.integrate_ff(100, fft_length) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(fft_length) self.audio_sink_0 = audio.sink(16000, "", True) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(0.050) self.analog_pwr_squelch_xx_0_0 = analog.pwr_squelch_ff(-200, 0.1, 0, True) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(squelch_dB, 0.1, 0, False) ################################################## # Connections ################################################## self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.analog_pwr_squelch_xx_0_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.fir_filter_xxx_0_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_integrate_xx_0, 0)) self.connect((self.blocks_integrate_xx_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_probe_signal_vx_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.fir_filter_xxx_0_0, 0)) self.connect((self.fir_filter_xxx_0_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.fir_filter_xxx_0_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.fir_filter_xxx_0_1, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.analog_pwr_squelch_xx_0_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.audio_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 20000000 self.center = center = 2865000000 self.bandwidth = bandwidth = 20000000 ################################################## # Blocks ################################################## self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel("samp_rate" + ": ")) self._samp_rate_line_edit = Qt.QLineEdit(str(self.samp_rate)) self._samp_rate_tool_bar.addWidget(self._samp_rate_line_edit) self._samp_rate_line_edit.returnPressed.connect( lambda: self.set_samp_rate( int(str(self._samp_rate_line_edit.text().toAscii())))) self.top_layout.addWidget(self._samp_rate_tool_bar) self._center_tool_bar = Qt.QToolBar(self) self._center_tool_bar.addWidget(Qt.QLabel("center" + ": ")) self._center_line_edit = Qt.QLineEdit(str(self.center)) self._center_tool_bar.addWidget(self._center_line_edit) self._center_line_edit.returnPressed.connect(lambda: self.set_center( int(str(self._center_line_edit.text().toAscii())))) self.top_layout.addWidget(self._center_tool_bar) self._bandwidth_tool_bar = Qt.QToolBar(self) self._bandwidth_tool_bar.addWidget(Qt.QLabel("bandwidth" + ": ")) self._bandwidth_line_edit = Qt.QLineEdit(str(self.bandwidth)) self._bandwidth_tool_bar.addWidget(self._bandwidth_line_edit) self._bandwidth_line_edit.returnPressed.connect( lambda: self.set_bandwidth( eval(str(self._bandwidth_line_edit.text().toAscii())))) self.top_layout.addWidget(self._bandwidth_tool_bar) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype center, #fc bandwidth, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + '') self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(center, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(10, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(0, 0) ################################################## # Connections ################################################## self.connect((self.osmosdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 400000 self.preamble = preamble = [ -0.70711 + 0.70711j, 0.70711 - 0.70711j, -0.70711 + 0.70711j, 0.70711 + 0.70711j, 0.70711 - 0.70711j, 0.70711 - 0.70711j, -0.70711 + 0.70711j, -0.70711 + 0.70711j, -0.70711 - 0.70711j, -0.70711 - 0.70711j, 0.70711 - 0.70711j, 0.70711 + 0.70711j, -0.70711 + 0.70711j, 0.70711 - 0.70711j, 0.70711 - 0.70711j, -0.70711 + 0.70711j, -0.70711 + 0.70711j, 0.70711 + 0.70711j, 0.70711 + 0.70711j, 0.70711 + 0.70711j, -0.70711 - 0.70711j, -0.70711 + 0.70711j, -0.70711 + 0.70711j, -0.70711 - 0.70711j, -0.70711 - 0.70711j, 0.70711 - 0.70711j, 0.70711 + 0.70711j, -0.70711 - 0.70711j, -0.70711 - 0.70711j, 0.70711 - 0.70711j, 0.70711 + 0.70711j, -0.70711 - 0.70711j, 0.70711 + 0.70711j, 0.70711 + 0.70711j, 0.70711 - 0.70711j, -0.70711 + 0.70711j, 0.70711 + 0.70711j, -0.70711 - 0.70711j, 0.70711 - 0.70711j, 0.70711 + 0.70711j] self.audio_rate = audio_rate = 8000 self.audio_interp = audio_interp = 2 self.voice_gain = voice_gain = 0 self.tau = tau = 75e-6 self.rx_channel = rx_channel = 110 self.quadrature_rate = quadrature_rate = audio_rate*audio_interp self.qpsk_constellation = qpsk_constellation = digital.constellation_calcdist(([(sqrt(2)/2)+(sqrt(2)/2)*1j,-(sqrt(2)/2)+(sqrt(2)/2)*1j,(sqrt(2)/2)-(sqrt(2)/2)*1j,-(sqrt(2)/2)-(sqrt(2)/2)*1j]), (digital.psk_4()[1]), 4, 1).base() self.qpsk_constellation.gen_soft_dec_lut(8) self.preamble_size = preamble_size = len(preamble) self.poly_taps = poly_taps = firdes.low_pass(2.0, samp_rate, 20000, 1000, firdes.WIN_HAMMING, 6.76) self.payload_size = payload_size = 100 self.num_channels = num_channels = 4 self.max_deviation = max_deviation = 3500 self.guard_size = guard_size = 10 self.codec_rate = codec_rate = 64000 self.bpsk_rate = bpsk_rate = 400000 ################################################## # Blocks ################################################## self._voice_gain_range = Range(0, 2, 0.01, 0, 200) self._voice_gain_win = RangeWidget(self._voice_gain_range, self.set_voice_gain, "voice_gain", "counter_slider", float) self.top_layout.addWidget(self._voice_gain_win) self.tab2 = Qt.QTabWidget() self.tab2_widget_0 = Qt.QWidget() self.tab2_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab2_widget_0) self.tab2_grid_layout_0 = Qt.QGridLayout() self.tab2_layout_0.addLayout(self.tab2_grid_layout_0) self.tab2.addTab(self.tab2_widget_0, "Preamble Correlation") self.tab2_widget_1 = Qt.QWidget() self.tab2_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab2_widget_1) self.tab2_grid_layout_1 = Qt.QGridLayout() self.tab2_layout_1.addLayout(self.tab2_grid_layout_1) self.tab2.addTab(self.tab2_widget_1, "Received Analog Voice") self.top_grid_layout.addWidget(self.tab2, 1,1,1,1) self._rx_channel_options = (110, 110*2, 110*3, 0, ) self._rx_channel_labels = ("0", "1", "2", "3", ) self._rx_channel_group_box = Qt.QGroupBox("rx_channel") self._rx_channel_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._rx_channel_button_group = variable_chooser_button_group() self._rx_channel_group_box.setLayout(self._rx_channel_box) for i, label in enumerate(self._rx_channel_labels): radio_button = Qt.QRadioButton(label) self._rx_channel_box.addWidget(radio_button) self._rx_channel_button_group.addButton(radio_button, i) self._rx_channel_callback = lambda i: Qt.QMetaObject.invokeMethod(self._rx_channel_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._rx_channel_options.index(i))) self._rx_channel_callback(self.rx_channel) self._rx_channel_button_group.buttonClicked[int].connect( lambda i: self.set_rx_channel(self._rx_channel_options[i])) self.top_layout.addWidget(self._rx_channel_group_box) self.vocoder_ulaw_decode_bs_0 = vocoder.ulaw_decode_bs() self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("serial=309AF9C", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(433e6, 0) self.uhd_usrp_source_0.set_gain(5, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.root_raised_cosine_filter_1 = filter.fir_filter_ccf(2, firdes.root_raised_cosine( 1, bpsk_rate, bpsk_rate/2, 0.35, 101)) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size bpsk_rate/2, #samp_rate "Preamble Correlation", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, False) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not False: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2*1): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.tab2_layout_0.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_time_raster_sink_x_0_0 = qtgui.time_raster_sink_b( codec_rate, 100, (guard_size+payload_size)*num_channels, ([]), ([]), "Received TDM Frame", 1, ) self.qtgui_time_raster_sink_x_0_0.set_update_time(0.10) self.qtgui_time_raster_sink_x_0_0.set_intensity_range(-1, 1) self.qtgui_time_raster_sink_x_0_0.enable_grid(False) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [2, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_raster_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_raster_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_raster_sink_x_0_0.set_color_map(i, colors[i]) self.qtgui_time_raster_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_raster_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_raster_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_raster_sink_x_0_0_win, 1,2,1,1) self.qtgui_freq_sink_x_3 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc audio_rate, #bw "Received Analog Voice", #name 1 #number of inputs ) self.qtgui_freq_sink_x_3.set_update_time(0.10) self.qtgui_freq_sink_x_3.set_y_axis(-140, 10) self.qtgui_freq_sink_x_3.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_3.enable_autoscale(False) self.qtgui_freq_sink_x_3.enable_grid(False) self.qtgui_freq_sink_x_3.set_fft_average(1.0) self.qtgui_freq_sink_x_3.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_3.disable_legend() if float == type(float()): self.qtgui_freq_sink_x_3.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_3.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_3.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_3.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_3.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_3.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_3_win = sip.wrapinstance(self.qtgui_freq_sink_x_3.pyqwidget(), Qt.QWidget) self.tab2_layout_1.addWidget(self._qtgui_freq_sink_x_3_win) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Received Spectrum", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_1.disable_legend() if complex == type(float()): self.qtgui_freq_sink_x_1.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 0,0,1,1) self.digital_map_bb_0_0 = digital.map_bb((digital.psk_4()[1])) self.digital_corr_est_cc_0 = digital.corr_est_cc((preamble), 1, 0, 0.15) self.digital_constellation_decoder_cb_0_0 = digital.constellation_decoder_cb(qpsk_constellation) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2) self.blocks_tagged_stream_align_0 = blocks.tagged_stream_align(gr.sizeof_gr_complex*1, "corr_start") self.blocks_short_to_float_0 = blocks.short_to_float(1, 2000) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((voice_gain, )) self.blocks_keep_m_in_n_1 = blocks.keep_m_in_n(gr.sizeof_char, payload_size, num_channels*(payload_size+guard_size), rx_channel) self.blocks_keep_m_in_n_0 = blocks.keep_m_in_n(gr.sizeof_gr_complex, num_channels*(payload_size+guard_size)/2, num_channels*(payload_size+guard_size)/2 + preamble_size, preamble_size) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, 2*(num_channels*(payload_size+guard_size)/2+preamble_size)-1) self.audio_sink_0 = audio.sink(8000, "", True) ################################################## # Connections ################################################## self.connect((self.blocks_delay_0, 0), (self.blocks_keep_m_in_n_0, 0)) self.connect((self.blocks_keep_m_in_n_0, 0), (self.digital_constellation_decoder_cb_0_0, 0)) self.connect((self.blocks_keep_m_in_n_1, 0), (self.vocoder_ulaw_decode_bs_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blocks_keep_m_in_n_1, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.qtgui_time_raster_sink_x_0_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.qtgui_freq_sink_x_3, 0)) self.connect((self.blocks_tagged_stream_align_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.digital_constellation_decoder_cb_0_0, 0), (self.digital_map_bb_0_0, 0)) self.connect((self.digital_corr_est_cc_0, 0), (self.blocks_tagged_stream_align_0, 0)) self.connect((self.digital_corr_est_cc_0, 1), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_map_bb_0_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.root_raised_cosine_filter_1, 0), (self.digital_corr_est_cc_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.root_raised_cosine_filter_1, 0)) self.connect((self.vocoder_ulaw_decode_bs_0, 0), (self.blocks_short_to_float_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.tx_gain_ch2 = tx_gain_ch2 = 0 self.tx_gain_ch1 = tx_gain_ch1 = 50 self.tx_freq_ch2 = tx_freq_ch2 = 2.4e9 self.tx_freq_ch1 = tx_freq_ch1 = 2.4e9 self.samp_rate = samp_rate = 32000 self.rx_gain_ch2 = rx_gain_ch2 = 0 self.rx_gain_ch1 = rx_gain_ch1 = 50 self.rx_freq_ch2 = rx_freq_ch2 = 2.4e9 self.rx_freq_ch1 = rx_freq_ch1 = 2.4e9 ################################################## # Blocks ################################################## self._tx_gain_ch1_range = Range(0, 50, 1, 50, 200) self._tx_gain_ch1_win = RangeWidget(self._tx_gain_ch1_range, self.set_tx_gain_ch1, 'TX Gain CH1', "counter_slider", float) self.top_layout.addWidget(self._tx_gain_ch1_win) self._tx_freq_ch1_range = Range(10e6, 6e9, 100e3, 2.4e9, 200) self._tx_freq_ch1_win = RangeWidget(self._tx_freq_ch1_range, self.set_tx_freq_ch1, 'TX Freq CH1', "counter_slider", float) self.top_layout.addWidget(self._tx_freq_ch1_win) self._rx_gain_ch1_range = Range(0, 50, 1, 50, 200) self._rx_gain_ch1_win = RangeWidget(self._rx_gain_ch1_range, self.set_rx_gain_ch1, 'RX Gain CH1', "counter_slider", float) self.top_layout.addWidget(self._rx_gain_ch1_win) self._rx_freq_ch1_range = Range(10e6, 6e9, 100e3, 2.4e9, 200) self._rx_freq_ch1_win = RangeWidget(self._rx_freq_ch1_range, self.set_rx_freq_ch1, 'RX Freq CH1', "counter_slider", float) self.top_layout.addWidget(self._rx_freq_ch1_win) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("addr=192.168.30.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_clock_rate(200e6, uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_clock_source('internal', 0) self.uhd_usrp_source_0.set_subdev_spec('A:0 ', 0) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_center_freq(rx_freq_ch1, 0) self.uhd_usrp_source_0.set_gain(rx_gain_ch1, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_subdev_spec('A:0 ', 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(tx_freq_ch1, 0) self.uhd_usrp_sink_0.set_gain(tx_gain_ch1, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self._tx_gain_ch2_range = Range(0, 30, 1, 0, 200) self._tx_gain_ch2_win = RangeWidget(self._tx_gain_ch2_range, self.set_tx_gain_ch2, 'TX Gain CH2', "counter_slider", float) self.top_layout.addWidget(self._tx_gain_ch2_win) self._tx_freq_ch2_range = Range(10e6, 6e9, 100e3, 2.4e9, 200) self._tx_freq_ch2_win = RangeWidget(self._tx_freq_ch2_range, self.set_tx_freq_ch2, 'TX Freq CH2', "counter_slider", float) self.top_layout.addWidget(self._tx_freq_ch2_win) self._rx_gain_ch2_range = Range(0, 30, 1, 0, 200) self._rx_gain_ch2_win = RangeWidget(self._rx_gain_ch2_range, self.set_rx_gain_ch2, 'RX Gain CH2', "counter_slider", float) self.top_layout.addWidget(self._rx_gain_ch2_win) self._rx_freq_ch2_range = Range(10e6, 6e9, 100e3, 2.4e9, 200) self._rx_freq_ch2_win = RangeWidget(self._rx_freq_ch2_range, self.set_rx_freq_ch2, 'RX Freq CH2', "counter_slider", float) self.top_layout.addWidget(self._rx_freq_ch2_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_number_sink_0_0 = qtgui.number_sink(gr.sizeof_char, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0.set_title("") labels = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_0.set_min(i, -255) self.qtgui_number_sink_0_0.set_max(i, 256) self.qtgui_number_sink_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_0_win) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_char, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -5) self.qtgui_number_sink_0.set_max(i, 10) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_win) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.digital_dxpsk_mod_0 = digital.dbpsk_mod(samples_per_symbol=2, excess_bw=0.35, mod_code="gray", verbose=False, log=False) self.digital_dxpsk_demod_0 = digital.dbpsk_demod(samples_per_symbol=2, excess_bw=0.35, freq_bw=6.28 / 100.0, phase_bw=6.28 / 100.0, timing_bw=6.28 / 100.0, mod_code="gray", verbose=False, log=False) self.blocks_vector_source_x_0 = blocks.vector_source_b( (1, 0, 0, 0, 0, 1), True, 1, []) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb( 1, gr.GR_MSB_FIRST) self.blocks_file_sink_0_0_0 = blocks.file_sink( gr.sizeof_gr_complex * 1, '/home/hanqing/Wireless Research/Y_test', False) self.blocks_file_sink_0_0_0.set_unbuffered(False) self.blocks_file_sink_0_0 = blocks.file_sink( gr.sizeof_gr_complex * 1, '/home/hanqing/Wireless Research/X_test', False) self.blocks_file_sink_0_0.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_char * 1, '/home/hanqing/Wireless Research/dbpsk_out', False) self.blocks_file_sink_0.set_unbuffered(False) ################################################## # Connections ################################################## self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.digital_dxpsk_mod_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.qtgui_number_sink_0_0, 0)) self.connect((self.digital_dxpsk_demod_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.digital_dxpsk_demod_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_file_sink_0_0_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.digital_dxpsk_demod_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_time_sink_x_0_0, 0))
def __init__(self, freq=0, gain=40, loopbw=100, loopbw_0=100, fllbw=0.002): gr.top_block.__init__(self, "Rx Gui") Qt.QWidget.__init__(self) self.setWindowTitle("Rx Gui") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "rx_gui") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.freq = freq self.gain = gain self.loopbw = loopbw self.loopbw_0 = loopbw_0 self.fllbw = fllbw ################################################## # Variables ################################################## self.sps = sps = 8 self.excess_bw = excess_bw = 0.25 self.target_samp_rate = target_samp_rate = sps*(200e3/(1 + excess_bw)) self.qpsk_const = qpsk_const = digital.constellation_qpsk().base() self.dsp_rate = dsp_rate = 100e6 self.const_choice = const_choice = "qpsk" self.bpsk_const = bpsk_const = digital.constellation_bpsk().base() self.barker_code_two_dim = barker_code_two_dim = [-1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j] self.barker_code_one_dim = barker_code_one_dim = sqrt(2)*numpy.real([-1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j]) self.rrc_delay = rrc_delay = int(round(-44*excess_bw + 33)) self.nfilts = nfilts = 32 self.n_barker_rep = n_barker_rep = 10 self.dec_factor = dec_factor = ceil(dsp_rate/target_samp_rate) self.constellation = constellation = qpsk_const if (const_choice=="qpsk") else bpsk_const self.barker_code = barker_code = barker_code_two_dim if (const_choice == "qpsk") else barker_code_one_dim self.preamble_syms = preamble_syms = numpy.matlib.repmat(barker_code, 1, n_barker_rep)[0] self.n_rrc_taps = n_rrc_taps = rrc_delay * int(sps*nfilts) self.n_codewords = n_codewords = 1 self.even_dec_factor = even_dec_factor = dec_factor if (dec_factor % 1 == 1) else (dec_factor+1) self.const_order = const_order = pow(2,constellation.bits_per_symbol()) self.codeword_len = codeword_len = 18444 self.usrp_rx_addr = usrp_rx_addr = "192.168.10.2" self.samp_rate = samp_rate = dsp_rate/even_dec_factor self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts*sps, 1.0, excess_bw, n_rrc_taps) self.rf_center_freq = rf_center_freq = 1428.4309e6 self.preamble_size = preamble_size = len(preamble_syms) self.pmf_peak_threshold = pmf_peak_threshold = 0.6 self.payload_size = payload_size = codeword_len*n_codewords/int(numpy.log2(const_order)) self.dataword_len = dataword_len = 6144 self.barker_len = barker_len = 13 ################################################## # Blocks ################################################## self.tabs = Qt.QTabWidget() self.tabs_widget_0 = Qt.QWidget() self.tabs_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_0) self.tabs_grid_layout_0 = Qt.QGridLayout() self.tabs_layout_0.addLayout(self.tabs_grid_layout_0) self.tabs.addTab(self.tabs_widget_0, 'PMF Out') self.tabs_widget_1 = Qt.QWidget() self.tabs_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_1) self.tabs_grid_layout_1 = Qt.QGridLayout() self.tabs_layout_1.addLayout(self.tabs_grid_layout_1) self.tabs.addTab(self.tabs_widget_1, 'Abs PMF Out') self.tabs_widget_2 = Qt.QWidget() self.tabs_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_2) self.tabs_grid_layout_2 = Qt.QGridLayout() self.tabs_layout_2.addLayout(self.tabs_grid_layout_2) self.tabs.addTab(self.tabs_widget_2, 'FLL In') self.tabs_widget_3 = Qt.QWidget() self.tabs_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_3) self.tabs_grid_layout_3 = Qt.QGridLayout() self.tabs_layout_3.addLayout(self.tabs_grid_layout_3) self.tabs.addTab(self.tabs_widget_3, 'FLL Out') self.tabs_widget_4 = Qt.QWidget() self.tabs_layout_4 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_4) self.tabs_grid_layout_4 = Qt.QGridLayout() self.tabs_layout_4.addLayout(self.tabs_grid_layout_4) self.tabs.addTab(self.tabs_widget_4, 'FLL State') self.tabs_widget_5 = Qt.QWidget() self.tabs_layout_5 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_5) self.tabs_grid_layout_5 = Qt.QGridLayout() self.tabs_layout_5.addLayout(self.tabs_grid_layout_5) self.tabs.addTab(self.tabs_widget_5, 'PFB Sync Out') self.tabs_widget_6 = Qt.QWidget() self.tabs_layout_6 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_6) self.tabs_grid_layout_6 = Qt.QGridLayout() self.tabs_layout_6.addLayout(self.tabs_grid_layout_6) self.tabs.addTab(self.tabs_widget_6, 'Costas State') self.tabs_widget_7 = Qt.QWidget() self.tabs_layout_7 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_7) self.tabs_grid_layout_7 = Qt.QGridLayout() self.tabs_layout_7.addLayout(self.tabs_grid_layout_7) self.tabs.addTab(self.tabs_widget_7, 'Demod Bits') self.tabs_widget_8 = Qt.QWidget() self.tabs_layout_8 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_8) self.tabs_grid_layout_8 = Qt.QGridLayout() self.tabs_layout_8.addLayout(self.tabs_grid_layout_8) self.tabs.addTab(self.tabs_widget_8, 'Costas Sym Out') self.tabs_widget_9 = Qt.QWidget() self.tabs_layout_9 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_9) self.tabs_grid_layout_9 = Qt.QGridLayout() self.tabs_layout_9.addLayout(self.tabs_grid_layout_9) self.tabs.addTab(self.tabs_widget_9, 'Payload Symbols') self.top_layout.addWidget(self.tabs) self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(gain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.qtgui_time_sink_x_2 = qtgui.time_sink_c( preamble_size + payload_size, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_2.set_update_time(0.10) self.qtgui_time_sink_x_2.set_y_axis(-1, 1) self.qtgui_time_sink_x_2.set_y_label('Amplitude', "") self.qtgui_time_sink_x_2.enable_tags(-1, True) self.qtgui_time_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_2.enable_autoscale(True) self.qtgui_time_sink_x_2.enable_grid(False) self.qtgui_time_sink_x_2.enable_axis_labels(True) self.qtgui_time_sink_x_2.enable_control_panel(False) if not True: self.qtgui_time_sink_x_2.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2*1): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_2.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_2.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_2.set_line_label(i, labels[i]) self.qtgui_time_sink_x_2.set_line_width(i, widths[i]) self.qtgui_time_sink_x_2.set_line_color(i, colors[i]) self.qtgui_time_sink_x_2.set_line_style(i, styles[i]) self.qtgui_time_sink_x_2.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_2.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_2_win = sip.wrapinstance(self.qtgui_time_sink_x_2.pyqwidget(), Qt.QWidget) self.tabs_layout_0.addWidget(self._qtgui_time_sink_x_2_win) self.qtgui_time_sink_x_1_0_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0_0.set_y_axis(-128, 128) self.qtgui_time_sink_x_1_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0_0.enable_tags(-1, False) self.qtgui_time_sink_x_1_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0_0.enable_grid(False) self.qtgui_time_sink_x_1_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0_0.pyqwidget(), Qt.QWidget) self.tabs_layout_7.addWidget(self._qtgui_time_sink_x_1_0_0_win) self.qtgui_time_sink_x_1_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0.enable_grid(False) self.qtgui_time_sink_x_1_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget) self.tabs_layout_7.addWidget(self._qtgui_time_sink_x_1_0_win) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 8192, #size samp_rate, #samp_rate "", #name 3 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ['FLL Freq (PI Output)', 'FLL Phase Accum', 'FLL Error', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(3): if len(labels[i]) == 0: self.qtgui_time_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.tabs_layout_4.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0_3 = qtgui.time_sink_f( 1024*4, #size samp_rate, #samp_rate "Error", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_3.set_update_time(0.10) self.qtgui_time_sink_x_0_3.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_3.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_3.enable_tags(-1, True) self.qtgui_time_sink_x_0_3.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_3.enable_autoscale(False) self.qtgui_time_sink_x_0_3.enable_grid(False) self.qtgui_time_sink_x_0_3.enable_axis_labels(True) self.qtgui_time_sink_x_0_3.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_3.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_3.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_3.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_3.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_3.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_3.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_3.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_3.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_3_win = sip.wrapinstance(self.qtgui_time_sink_x_0_3.pyqwidget(), Qt.QWidget) self.tabs_layout_6.addWidget(self._qtgui_time_sink_x_0_3_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( preamble_size + payload_size, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['Mag Sq', 'Mag', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tabs_layout_1.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_sink_x_5 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name True, #plotfreq False, #plotwaterfall False, #plottime True, #plotconst ) self.qtgui_sink_x_5.set_update_time(1.0/10) self._qtgui_sink_x_5_win = sip.wrapinstance(self.qtgui_sink_x_5.pyqwidget(), Qt.QWidget) self.tabs_layout_3.addWidget(self._qtgui_sink_x_5_win) self.qtgui_sink_x_5.enable_rf_freq(False) self.qtgui_sink_x_1 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name True, #plotfreq False, #plotwaterfall False, #plottime True, #plotconst ) self.qtgui_sink_x_1.set_update_time(1.0/10) self._qtgui_sink_x_1_win = sip.wrapinstance(self.qtgui_sink_x_1.pyqwidget(), Qt.QWidget) self.tabs_layout_2.addWidget(self._qtgui_sink_x_1_win) self.qtgui_sink_x_1.enable_rf_freq(False) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name False, #plotfreq False, #plotwaterfall False, #plottime True, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0/10) self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_layout_5.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(False) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_layout_2.addWidget(self._qtgui_freq_sink_x_0_win) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_1.set_update_time(0.10) self.qtgui_const_sink_x_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1.enable_autoscale(False) self.qtgui_const_sink_x_1.enable_grid(False) self.qtgui_const_sink_x_1.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_win = sip.wrapinstance(self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget) self.tabs_layout_9.addWidget(self._qtgui_const_sink_x_1_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_layout_8.addWidget(self._qtgui_const_sink_x_0_win) self.mods_turbo_decoder_0 = mods.turbo_decoder(codeword_len, dataword_len) self.mods_frame_sync_fast_0 = mods.frame_sync_fast(pmf_peak_threshold, preamble_size, payload_size, 0, 1, 1, int(const_order)) self.mods_fifo_async_sink_0 = mods.fifo_async_sink('/tmp/async_rx') self.interp_fir_filter_xxx_0_0 = filter.interp_fir_filter_fff(1, ( numpy.ones(n_barker_rep*barker_len))) self.interp_fir_filter_xxx_0_0.declare_sample_delay(0) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(1, ( numpy.flipud(numpy.conj(preamble_syms)))) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.framers_gr_hdlc_deframer_b_0 = framers.gr_hdlc_deframer_b(0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 2*pi/50, (rrc_taps), nfilts, nfilts/2, pi/8, 1) self.digital_map_bb_0_0_0 = digital.map_bb(([1,- 1])) self.digital_fll_band_edge_cc_1 = digital.fll_band_edge_cc(sps, excess_bw, rrc_delay * int(sps) + 1, fllbw) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0x7F, 16) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(2*pi/loopbw, 2**constellation.bits_per_symbol(), False) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(constellation.base()) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(constellation.bits_per_symbol()) self.blocks_rms_xx_1 = blocks.rms_cf(0.0001) self.blocks_pack_k_bits_bb_1 = blocks.pack_k_bits_bb(8) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_1_1 = blocks.multiply_const_vcc((1.0/sqrt(2), )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((1.0/(preamble_size*sqrt(2)), )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_divide_xx_1 = blocks.divide_ff(1) self.blocks_divide_xx_0 = blocks.divide_cc(1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_1 = blocks.complex_to_mag(1) self.blocks_char_to_float_0_1 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) ################################################## # Connections ################################################## self.msg_connect((self.framers_gr_hdlc_deframer_b_0, 'pdu'), (self.mods_fifo_async_sink_0, 'async_pdu')) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_1_0, 0)) self.connect((self.blocks_char_to_float_0_1, 0), (self.qtgui_time_sink_x_1_0_0, 0)) self.connect((self.blocks_complex_to_mag_1, 0), (self.blocks_divide_xx_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.interp_fir_filter_xxx_0_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.digital_fll_band_edge_cc_1, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.qtgui_sink_x_1, 0)) self.connect((self.blocks_divide_xx_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_divide_xx_1, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.mods_frame_sync_fast_0, 2)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_time_sink_x_2, 0)) self.connect((self.blocks_multiply_const_vxx_1_1, 0), (self.blocks_complex_to_mag_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.mods_frame_sync_fast_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_pack_k_bits_bb_1, 0), (self.blocks_char_to_float_0_1, 0)) self.connect((self.blocks_rms_xx_1, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.digital_map_bb_0_0_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.mods_frame_sync_fast_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_costas_loop_cc_0, 1), (self.qtgui_time_sink_x_0_3, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.blocks_pack_k_bits_bb_1, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.framers_gr_hdlc_deframer_b_0, 0)) self.connect((self.digital_fll_band_edge_cc_1, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_fll_band_edge_cc_1, 0), (self.qtgui_sink_x_5, 0)) self.connect((self.digital_fll_band_edge_cc_1, 3), (self.qtgui_time_sink_x_1, 2)) self.connect((self.digital_fll_band_edge_cc_1, 1), (self.qtgui_time_sink_x_1, 0)) self.connect((self.digital_fll_band_edge_cc_1, 2), (self.qtgui_time_sink_x_1, 1)) self.connect((self.digital_map_bb_0_0_0, 0), (self.mods_turbo_decoder_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_multiply_const_vxx_1_1, 0)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.blocks_divide_xx_1, 1)) self.connect((self.mods_frame_sync_fast_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.mods_frame_sync_fast_0, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.mods_turbo_decoder_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_rms_xx_1, 0)) self.connect((self.rtlsdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.timing_loop_bw = timing_loop_bw = 15.0 / 100.0 self.taps = taps = [1.0, 0.25 - 0.25j, 0.50 + 0.10j, -0.3 + 0.2j] self.samp_rate = samp_rate = 250e3 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), 0.35, 11 * sps * nfilts) self.phase_bw = phase_bw = 6.0 / 100.0 self.frequency = frequency = 2.45e9 self.excess_bw = excess_bw = 0.35 self.eq_gain = eq_gain = 10.0e-3 self.code1 = code1 = '010110011011101100010101011111101001001110001011010001101010001' self.arity = arity = 4 ################################################## # Blocks ################################################## self._timing_loop_bw_range = Range(0.0, 0.2, 0.01, 15.0 / 100.0, 200) self._timing_loop_bw_win = RangeWidget(self._timing_loop_bw_range, self.set_timing_loop_bw, "Time: BW", "slider", float) self.top_layout.addWidget(self._timing_loop_bw_win) self.qtgui_tab_widget_1 = Qt.QTabWidget() self.qtgui_tab_widget_1_widget_0 = Qt.QWidget() self.qtgui_tab_widget_1_layout_0 = Qt.QBoxLayout( Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_1_widget_0) self.qtgui_tab_widget_1_grid_layout_0 = Qt.QGridLayout() self.qtgui_tab_widget_1_layout_0.addLayout( self.qtgui_tab_widget_1_grid_layout_0) self.qtgui_tab_widget_1.addTab(self.qtgui_tab_widget_1_widget_0, "channel") self.qtgui_tab_widget_1_widget_1 = Qt.QWidget() self.qtgui_tab_widget_1_layout_1 = Qt.QBoxLayout( Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_1_widget_1) self.qtgui_tab_widget_1_grid_layout_1 = Qt.QGridLayout() self.qtgui_tab_widget_1_layout_1.addLayout( self.qtgui_tab_widget_1_grid_layout_1) self.qtgui_tab_widget_1.addTab(self.qtgui_tab_widget_1_widget_1, "clock") self.qtgui_tab_widget_1_widget_2 = Qt.QWidget() self.qtgui_tab_widget_1_layout_2 = Qt.QBoxLayout( Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_1_widget_2) self.qtgui_tab_widget_1_grid_layout_2 = Qt.QGridLayout() self.qtgui_tab_widget_1_layout_2.addLayout( self.qtgui_tab_widget_1_grid_layout_2) self.qtgui_tab_widget_1.addTab(self.qtgui_tab_widget_1_widget_2, "equilizer") self.qtgui_tab_widget_1_widget_3 = Qt.QWidget() self.qtgui_tab_widget_1_layout_3 = Qt.QBoxLayout( Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_1_widget_3) self.qtgui_tab_widget_1_grid_layout_3 = Qt.QGridLayout() self.qtgui_tab_widget_1_layout_3.addLayout( self.qtgui_tab_widget_1_grid_layout_3) self.qtgui_tab_widget_1.addTab(self.qtgui_tab_widget_1_widget_3, "frequency correction") self.qtgui_tab_widget_1_widget_4 = Qt.QWidget() self.qtgui_tab_widget_1_layout_4 = Qt.QBoxLayout( Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_1_widget_4) self.qtgui_tab_widget_1_grid_layout_4 = Qt.QGridLayout() self.qtgui_tab_widget_1_layout_4.addLayout( self.qtgui_tab_widget_1_grid_layout_4) self.qtgui_tab_widget_1.addTab(self.qtgui_tab_widget_1_widget_4, "difference") self.qtgui_tab_widget_1_widget_5 = Qt.QWidget() self.qtgui_tab_widget_1_layout_5 = Qt.QBoxLayout( Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_1_widget_5) self.qtgui_tab_widget_1_grid_layout_5 = Qt.QGridLayout() self.qtgui_tab_widget_1_layout_5.addLayout( self.qtgui_tab_widget_1_grid_layout_5) self.qtgui_tab_widget_1.addTab(self.qtgui_tab_widget_1_widget_5, "in/out") self.top_layout.addWidget(self.qtgui_tab_widget_1) self._phase_bw_range = Range(0.0, 1.0, 0.01, 6.0 / 100.0, 200) self._phase_bw_win = RangeWidget(self._phase_bw_range, self.set_phase_bw, "Phase: Bandwidth", "slider", float) self.top_layout.addWidget(self._phase_bw_win) self._eq_gain_range = Range(0.0, 0.1, 0.0001, 10.0e-3, 200) self._eq_gain_win = RangeWidget(self._eq_gain_range, self.set_eq_gain, "Equalizer: rate", "slider", float) self.top_layout.addWidget(self._eq_gain_win) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(250e3) self.uhd_usrp_source_0.set_center_freq(frequency, 0) self.uhd_usrp_source_0.set_gain(30, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.uhd_usrp_source_0.set_bandwidth(250e3, 0) self.tutorial_my_qpsk_demod_cb_1 = tutorial.my_qpsk_demod_cb(False) self.qtgui_freq_sink_x_2 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_2.set_update_time(0.10) self.qtgui_freq_sink_x_2.set_y_axis(-140, 10) self.qtgui_freq_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_2.enable_autoscale(False) self.qtgui_freq_sink_x_2.enable_grid(False) self.qtgui_freq_sink_x_2.set_fft_average(1.0) self.qtgui_freq_sink_x_2.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_2.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_2.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_2.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_2.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_2.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_2.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_2.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_2_win = sip.wrapinstance( self.qtgui_freq_sink_x_2.pyqwidget(), Qt.QWidget) self.qtgui_tab_widget_1_grid_layout_1.addWidget( self._qtgui_freq_sink_x_2_win, 0, 1) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance( self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.qtgui_tab_widget_1_grid_layout_0.addWidget( self._qtgui_freq_sink_x_1_win, 0, 1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.qtgui_tab_widget_1_grid_layout_3.addWidget( self._qtgui_freq_sink_x_0_0_win, 0, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.qtgui_tab_widget_1_grid_layout_2.addWidget( self._qtgui_freq_sink_x_0_win, 0, 1) self.output_0_1_0 = qtgui.time_sink_f( 500, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.output_0_1_0.set_update_time(0.10) self.output_0_1_0.set_y_axis(-1, 1) self.output_0_1_0.set_y_label("Amplitude", "") self.output_0_1_0.enable_tags(-1, True) self.output_0_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.output_0_1_0.enable_autoscale(False) self.output_0_1_0.enable_grid(False) self.output_0_1_0.enable_control_panel(True) if not True: self.output_0_1_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.output_0_1_0.set_line_label(i, "Data {0}".format(i)) else: self.output_0_1_0.set_line_label(i, labels[i]) self.output_0_1_0.set_line_width(i, widths[i]) self.output_0_1_0.set_line_color(i, colors[i]) self.output_0_1_0.set_line_style(i, styles[i]) self.output_0_1_0.set_line_marker(i, markers[i]) self.output_0_1_0.set_line_alpha(i, alphas[i]) self._output_0_1_0_win = sip.wrapinstance( self.output_0_1_0.pyqwidget(), Qt.QWidget) self.qtgui_tab_widget_1_grid_layout_5.addWidget( self._output_0_1_0_win, 0, 1) self.equilizer_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.equilizer_0.set_update_time(0.10) self.equilizer_0.set_y_axis(-2, 2) self.equilizer_0.set_x_axis(-2, 2) self.equilizer_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.equilizer_0.enable_autoscale(False) self.equilizer_0.enable_grid(False) if not True: self.equilizer_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.equilizer_0.set_line_label(i, "Data {0}".format(i)) else: self.equilizer_0.set_line_label(i, labels[i]) self.equilizer_0.set_line_width(i, widths[i]) self.equilizer_0.set_line_color(i, colors[i]) self.equilizer_0.set_line_style(i, styles[i]) self.equilizer_0.set_line_marker(i, markers[i]) self.equilizer_0.set_line_alpha(i, alphas[i]) self._equilizer_0_win = sip.wrapinstance(self.equilizer_0.pyqwidget(), Qt.QWidget) self.qtgui_tab_widget_1_grid_layout_3.addWidget( self._equilizer_0_win, 0, 0) self.equilizer = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.equilizer.set_update_time(0.10) self.equilizer.set_y_axis(-2, 2) self.equilizer.set_x_axis(-2, 2) self.equilizer.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.equilizer.enable_autoscale(False) self.equilizer.enable_grid(False) if not True: self.equilizer.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.equilizer.set_line_label(i, "Data {0}".format(i)) else: self.equilizer.set_line_label(i, labels[i]) self.equilizer.set_line_width(i, widths[i]) self.equilizer.set_line_color(i, colors[i]) self.equilizer.set_line_style(i, styles[i]) self.equilizer.set_line_marker(i, markers[i]) self.equilizer.set_line_alpha(i, alphas[i]) self._equilizer_win = sip.wrapinstance(self.equilizer.pyqwidget(), Qt.QWidget) self.qtgui_tab_widget_1_grid_layout_2.addWidget( self._equilizer_win, 0, 0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, timing_loop_bw, (rrc_taps), nfilts, nfilts / 2, 1.5, 2) self.digital_map_bb_0 = digital.map_bb(([0, 1, 2, 3])) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( phase_bw, arity, False) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc( 15, 1, eq_gain, 2) self.clock = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.clock.set_update_time(0.10) self.clock.set_y_axis(-2, 2) self.clock.set_x_axis(-2, 2) self.clock.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.clock.enable_autoscale(False) self.clock.enable_grid(False) if not True: self.clock.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.clock.set_line_label(i, "Data {0}".format(i)) else: self.clock.set_line_label(i, labels[i]) self.clock.set_line_width(i, widths[i]) self.clock.set_line_color(i, colors[i]) self.clock.set_line_style(i, styles[i]) self.clock.set_line_marker(i, markers[i]) self.clock.set_line_alpha(i, alphas[i]) self._clock_win = sip.wrapinstance(self.clock.pyqwidget(), Qt.QWidget) self.qtgui_tab_widget_1_grid_layout_1.addWidget(self._clock_win, 0, 0) self.channel = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.channel.set_update_time(0.10) self.channel.set_y_axis(-2, 2) self.channel.set_x_axis(-2, 2) self.channel.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.channel.enable_autoscale(False) self.channel.enable_grid(False) if not True: self.channel.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.channel.set_line_label(i, "Data {0}".format(i)) else: self.channel.set_line_label(i, labels[i]) self.channel.set_line_width(i, widths[i]) self.channel.set_line_color(i, colors[i]) self.channel.set_line_style(i, styles[i]) self.channel.set_line_marker(i, markers[i]) self.channel.set_line_alpha(i, alphas[i]) self._channel_win = sip.wrapinstance(self.channel.pyqwidget(), Qt.QWidget) self.qtgui_tab_widget_1_grid_layout_0.addWidget( self._channel_win, 0, 0) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( 2, 8, "", False, gr.GR_MSB_FIRST) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( 1, gr.GR_MSB_FIRST) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_char * 1, "/home/sudhir/Desktop/EE340_Project/Output/output.png", False) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_char_to_float_0_0_1_0 = blocks.char_to_float(1, 1) self.blks2_packet_decoder_0_0 = grc_blks2.packet_demod_b( grc_blks2.packet_decoder( access_code=code1, threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0_0. recv_pkt(ok, payload), ), ) ################################################## # Connections ################################################## self.connect((self.blks2_packet_decoder_0_0, 0), (self.blocks_char_to_float_0_0_1_0, 0)) self.connect((self.blks2_packet_decoder_0_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_char_to_float_0_0_1_0, 0), (self.output_0_1_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.blks2_packet_decoder_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.equilizer, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.equilizer_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.tutorial_my_qpsk_demod_cb_1, 0)) self.connect((self.digital_map_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.clock, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_freq_sink_x_2, 0)) self.connect((self.tutorial_my_qpsk_demod_cb_1, 0), (self.digital_map_bb_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.channel, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_freq_sink_x_1, 0))
def __init__(self, ppm_param=0): gr.top_block.__init__(self, "Airprobe Rtlsdr") Qt.QWidget.__init__(self) self.setWindowTitle("Airprobe Rtlsdr") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "airprobe_rtlsdr") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.ppm_param = args.ppm_param ################################################## # Variables ################################################## self.samp_rate = samp_rate = args.sample_rate self.ppm = ppm = ppm_param self.g = g = args.gain self.fc = fc = args.frequency self.SDCCH = SDCCH = 6 self.RACH = RACH = 3 self.PCH = PCH = 5 self.CHANNEL_UNKNOWN = CHANNEL_UNKNOWN = 0 self.CCCH = CCCH = 2 self.BCCH = BCCH = 1 self.AGCH = AGCH = 4 ################################################## # Blocks ################################################## self._ppm_layout = Qt.QHBoxLayout() self._ppm_layout.addWidget(Qt.QLabel("clock_correction [ppm]"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._ppm_counter = qwt_counter_pyslot() self._ppm_counter.setRange(-150, 150, 1) self._ppm_counter.setNumButtons(2) self._ppm_counter.setMinimumWidth(100) self._ppm_counter.setValue(self.ppm) self._ppm_layout.addWidget(self._ppm_counter) self._ppm_counter.valueChanged.connect(self.set_ppm) self.top_layout.addLayout(self._ppm_layout) self._g_layout = Qt.QHBoxLayout() self._g_layout.addWidget(Qt.QLabel("gain"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._g_counter = qwt_counter_pyslot() self._g_counter.setRange(0, 50, 0.5) self._g_counter.setNumButtons(2) self._g_counter.setMinimumWidth(100) self._g_counter.setValue(self.g) self._g_layout.addWidget(self._g_counter) self._g_counter.valueChanged.connect(self.set_g) self.top_layout.addLayout(self._g_layout) self._fc_layout = Qt.QVBoxLayout() self._fc_tool_bar = Qt.QToolBar(self) self._fc_layout.addWidget(self._fc_tool_bar) self._fc_tool_bar.addWidget(Qt.QLabel("center_frequency"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._fc_counter = qwt_counter_pyslot() self._fc_counter.setRange(925e6, 960e6, 2e5) self._fc_counter.setNumButtons(2) self._fc_counter.setValue(self.fc) self._fc_tool_bar.addWidget(self._fc_counter) self._fc_counter.valueChanged.connect(self.set_fc) self._fc_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._fc_slider.setRange(925e6, 960e6, 2e5) self._fc_slider.setValue(self.fc) self._fc_slider.setMinimumWidth(100) self._fc_slider.valueChanged.connect(self.set_fc) self._fc_layout.addWidget(self._fc_slider) self.top_layout.addLayout(self._fc_layout) self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(fc, 0) self.rtlsdr_source_0.set_freq_corr(ppm, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(True, 0) self.rtlsdr_source_0.set_gain(g, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(250e3, 0) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype fc, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.gsm_universal_ctrl_chans_demapper_0 = grgsm.universal_ctrl_chans_demapper(([2,6,12,16,22,26,32,36,42,46]), ([BCCH,CCCH,CCCH,CCCH,CCCH,CCCH,CCCH,CCCH,CCCH,CCCH])) self.gsm_receiver_0 = grgsm.receiver(4, ([0]), ([])) self.gsm_message_printer_1 = grgsm.message_printer() self.gsm_input_0 = grgsm.gsm_input( ppm=0, osr=4, fc=fc, samp_rate_in=samp_rate, ) self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() self.gsm_clock_offset_control_0 = grgsm.clock_offset_control(fc) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000, False) ################################################## # Connections ################################################## self.connect((self.rtlsdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.gsm_input_0, 0)) self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.gsm_clock_offset_control_0, "ppm", self.gsm_input_0, "ppm_in") self.msg_connect(self.gsm_receiver_0, "C0", self.gsm_universal_ctrl_chans_demapper_0, "bursts") self.msg_connect(self.gsm_control_channels_decoder_0, "msgs", self.gsm_message_printer_1, "msgs") self.msg_connect(self.gsm_control_channels_decoder_0, "msgs", self.blocks_socket_pdu_0, "pdus") self.msg_connect(self.gsm_universal_ctrl_chans_demapper_0, "bursts", self.gsm_control_channels_decoder_0, "bursts") self.msg_connect(self.gsm_receiver_0, "measurements", self.gsm_clock_offset_control_0, "measurements")
def __init__(self, puncpat='11'): gr.top_block.__init__(self, "Tx No Gui") Qt.QWidget.__init__(self) self.setWindowTitle("Tx No Gui") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "tx_no_gui") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.puncpat = puncpat ################################################## # Variables ################################################## self.sps = sps = 4 self.samp_rate_array_MCR = samp_rate_array_MCR = [ 7500000, 5000000, 3750000, 3000000, 2500000, 2000000, 1500000, 1000000, 937500, 882352, 833333, 714285, 533333, 500000, 421052, 400000, 380952, 200000, 100000, 50000 ] self.nfilts = nfilts = 32 self.eb = eb = 0.22 self.H = H = fec.ldpc_H_matrix( '/usr/local/share/gnuradio/fec/ldpc/n_1100_k_0442_gap_24.alist', 24) self.vector = vector = [ int(random.random() * 4) for i in range(198400) ] self.variable_qtgui_range_0_0 = variable_qtgui_range_0_0 = 43 self.tx_rrc_taps = tx_rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0, eb, 11 * sps * nfilts) self.samp_rate = samp_rate = samp_rate_array_MCR[15] self.pld_enc = pld_enc = map( (lambda a: fec.ldpc_par_mtrx_encoder_make_H(H)), range(0, 4)) self.pld_const = pld_const = digital.constellation_rect(([ 0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j ]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.pld_const.gen_soft_dec_lut(8) self.frequencia_usrp = frequencia_usrp = 484e6 self.MCR = MCR = "master_clock_rate=60e6" ################################################## # Blocks ################################################## self._variable_qtgui_range_0_0_range = Range(0, 90, 1, 43, 200) self._variable_qtgui_range_0_0_win = RangeWidget( self._variable_qtgui_range_0_0_range, self.set_variable_qtgui_range_0_0, 'Gain_TX', "counter_slider", float) self.top_grid_layout.addWidget(self._variable_qtgui_range_0_0_win, 0, 2, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.uhd_usrp_sink_0_0 = uhd.usrp_sink( ",".join(("serial=F5EAE1", MCR)), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0_0.set_center_freq(frequencia_usrp, 0) self.uhd_usrp_sink_0_0.set_gain(variable_qtgui_range_0_0, 0) self.uhd_usrp_sink_0_0.set_antenna('TX/RX', 0) self.scrambler_cpp_additive_scrambler_0 = scrambler_cpp.additive_scrambler( 0x8A, 0x7F, 7, 440 - 32) self.qtgui_time_sink_x_1 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "TX USRP", #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) self.qtgui_time_sink_x_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_1.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance( self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win, 1, 3, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 3, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0_0_0 = qtgui.const_sink_c( 1024, #size "TX Const", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_0.set_trigger_mode( qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0_0_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_0_win, 1, 2, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( sps, taps=(tx_rrc_taps), flt_size=nfilts) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.insert_vec_cpp_new_vec_0 = insert_vec_cpp.new_vec((vector)) self.fec_extended_encoder_0 = fec.extended_encoder( encoder_obj_list=pld_enc, threading='capillary', puncpat=puncpat) self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb( pld_const.arity()) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc( (pld_const.points()), 1) self.blocks_vector_source_x_0_0_0 = blocks.vector_source_b([0], True, 1, []) self.blocks_vector_source_x_0_0 = blocks.vector_source_b([0], True, 1, []) self.blocks_vector_source_x_0 = blocks.vector_source_b([ 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x1, 0x1, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1, 0x0, 0x1, 0x0, 0x1, 0x1, 0x0, 0x0, 0x1, 0x1, 0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ], True, 1, []) self.blocks_stream_mux_0_1_0_0 = blocks.stream_mux( gr.sizeof_char * 1, (155, 1104)) self.blocks_stream_mux_0_0_0 = blocks.stream_mux( gr.sizeof_char * 1, (1100, 4)) self.blocks_stream_mux_0_0 = blocks.stream_mux(gr.sizeof_char * 1, (440, 2)) self.blocks_repack_bits_bb_1_0_0_1 = blocks.repack_bits_bb( 8, 1, '', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_1_0_0_0 = blocks.repack_bits_bb( 1, pld_const.bits_per_symbol(), '', False, gr.GR_MSB_FIRST) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((0.7, )) self.blocks_file_source_0_0_1_0 = blocks.file_source( gr.sizeof_char * 1, '/home/andre/Desktop/Files_To_Transmit/trasmit_10_mb.txt', False) self.blocks_file_source_0_0_1_0.set_begin_tag(pmt.PMT_NIL) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 500000) ################################################## # Connections ################################################## self.connect((self.blocks_delay_0, 0), (self.qtgui_const_sink_x_0_0_0_0, 0)) self.connect((self.blocks_delay_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_delay_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_delay_0, 0), (self.uhd_usrp_sink_0_0, 0)) self.connect((self.blocks_file_source_0_0_1_0, 0), (self.blocks_repack_bits_bb_1_0_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_repack_bits_bb_1_0_0_0, 0), (self.insert_vec_cpp_new_vec_0, 0)) self.connect((self.blocks_repack_bits_bb_1_0_0_1, 0), (self.scrambler_cpp_additive_scrambler_0, 0)) self.connect((self.blocks_stream_mux_0_0, 0), (self.fec_extended_encoder_0, 0)) self.connect((self.blocks_stream_mux_0_0_0, 0), (self.blocks_stream_mux_0_1_0_0, 1)) self.connect((self.blocks_stream_mux_0_1_0_0, 0), (self.blocks_repack_bits_bb_1_0_0_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_mux_0_1_0_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_stream_mux_0_0, 1)) self.connect((self.blocks_vector_source_x_0_0_0, 0), (self.blocks_stream_mux_0_0_0, 1)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.digital_diff_encoder_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.fec_extended_encoder_0, 0), (self.blocks_stream_mux_0_0_0, 0)) self.connect((self.insert_vec_cpp_new_vec_0, 0), (self.digital_diff_encoder_bb_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.scrambler_cpp_additive_scrambler_0, 0), (self.blocks_stream_mux_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Ofdm00") Qt.QWidget.__init__(self) self.setWindowTitle("Ofdm00") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "ofdm00") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 100000 self.packet_len = packet_len = 50 self.len_tag_key = len_tag_key = "packet_len" self.fft_len = fft_len = 128 ################################################## # Blocks ################################################## self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-80, 10) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len/4, packet_length_tag_key=len_tag_key, bps_header=1, bps_payload=2, rolloff=0, debug_log=False, scramble_bits=False ) self.digital_ofdm_rx_0 = digital.ofdm_rx( fft_len=fft_len, cp_len=fft_len/4, frame_length_tag_key='frame_'+"rx_len", packet_length_tag_key="rx_len", bps_header=1, bps_payload=2, debug_log=False, scramble_bits=False ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_char*1, "", ""); self.blocks_tag_debug_0.set_display(True) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, packet_len, len_tag_key) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 1000)), True) ################################################## # Connections ################################################## self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.digital_ofdm_rx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_tag_debug_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.fft_vxx_0 = fft.fft_vcc(1024, True, (window.blackmanharris(1024)), True, 1) self.blocks_wavfile_source_0 = blocks.wavfile_source("/home/iocoder/school/networks/project/radio_waves/src/radio_waves.wav", True) self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, 1024) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 1024) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) ################################################## # Connections ################################################## self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_0, 0))
def __init__(self): gr.top_block.__init__(self, "VOR Decoder") Qt.QWidget.__init__(self) self.setWindowTitle("VOR Decoder") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "vor_playback_sigmf_3") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 250e3 self.throttle_rate = throttle_rate = 1 self.nfft = nfft = 512 self.fine = fine = 1e3 self.delay = delay = 440 self.avg = avg = 100.0 self.audio_rate = audio_rate = samp_rate / 5 / 25 * 24 self.audio_gain = audio_gain = 1 ################################################## # Blocks ################################################## self._throttle_rate_tool_bar = Qt.QToolBar(self) self._throttle_rate_tool_bar.addWidget( Qt.QLabel("throttle_rate" + ": ")) self._throttle_rate_line_edit = Qt.QLineEdit(str(self.throttle_rate)) self._throttle_rate_tool_bar.addWidget(self._throttle_rate_line_edit) self._throttle_rate_line_edit.returnPressed.connect( lambda: self.set_throttle_rate( eng_notation.str_to_num( str(self._throttle_rate_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._throttle_rate_tool_bar, 0, 6, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 8): self.top_grid_layout.setColumnStretch(c, 1) self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel("samp_rate" + ": ")) self._samp_rate_line_edit = Qt.QLineEdit(str(self.samp_rate)) self._samp_rate_tool_bar.addWidget(self._samp_rate_line_edit) self._samp_rate_line_edit.returnPressed.connect( lambda: self.set_samp_rate( eng_notation.str_to_num( str(self._samp_rate_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._samp_rate_tool_bar, 0, 4, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self._delay_tool_bar = Qt.QToolBar(self) self._delay_tool_bar.addWidget(Qt.QLabel('delay' + ": ")) self._delay_line_edit = Qt.QLineEdit(str(self.delay)) self._delay_tool_bar.addWidget(self._delay_line_edit) self._delay_line_edit.returnPressed.connect(lambda: self.set_delay( int(str(self._delay_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._delay_tool_bar, 2, 4, 1, 2) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self._avg_tool_bar = Qt.QToolBar(self) self._avg_tool_bar.addWidget(Qt.QLabel('avg' + ": ")) self._avg_line_edit = Qt.QLineEdit(str(self.avg)) self._avg_tool_bar.addWidget(self._avg_line_edit) self._avg_line_edit.returnPressed.connect(lambda: self.set_avg( eng_notation.str_to_num(str(self._avg_line_edit.text().toAscii()))) ) self.top_grid_layout.addWidget(self._avg_tool_bar, 1, 6, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 7): self.top_grid_layout.setColumnStretch(c, 1) self.sigmf_source_0 = gr_sigmf.source( '/captures/20191228/VOR_2019-12-28T19:07:15Z.sigmf-data', "cf32" + ("_le" if sys.byteorder == "little" else "_be"), True) self.rational_resampler_xxx_0_0_0 = filter.rational_resampler_ccc( interpolation=24, decimation=25 * 5, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc audio_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 4, 0, 4, 4) for r in range(4, 8): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 512, #size audio_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.0010) self.qtgui_time_sink_x_0_0.set_y_axis(-180, 180) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, 0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['Reference', 'Variable', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 5, 4, 2, 4) for r in range(5, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 8192, #size audio_rate, #samp_rate "30 Hz Signals", #name 2 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.0010) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, 0, 0, 1, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['var', 'ref', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 3, 4, 2, 4) for r in range(3, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_1_0 = qtgui.freq_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc audio_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1_0.set_update_time(0.10) self.qtgui_freq_sink_x_1_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1_0.enable_autoscale(False) self.qtgui_freq_sink_x_1_0.enable_grid(False) self.qtgui_freq_sink_x_1_0.set_fft_average(1.0) self.qtgui_freq_sink_x_1_0.enable_axis_labels(True) self.qtgui_freq_sink_x_1_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1_0.set_plot_pos_half(not False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_0_win, 0, 0, 4, 4) for r in range(0, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.low_pass_filter_1_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, audio_rate, 750, 250, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_1 = filter.fir_filter_ccf( 1, firdes.low_pass(1, audio_rate, 500, 250, firdes.WIN_HAMMING, 6.76)) self._fine_tool_bar = Qt.QToolBar(self) self._fine_tool_bar.addWidget(Qt.QLabel('Fine [Hz]' + ": ")) self._fine_line_edit = Qt.QLineEdit(str(self.fine)) self._fine_tool_bar.addWidget(self._fine_line_edit) self._fine_line_edit.returnPressed.connect(lambda: self.set_fine( eng_notation.str_to_num(str(self._fine_line_edit.text().toAscii())) )) self.top_grid_layout.addWidget(self._fine_tool_bar, 1, 4, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self.fft_vxx_0_0 = fft.fft_vfc(nfft, True, (window.blackmanharris(nfft)), 1) self.fft_vxx_0 = fft.fft_vfc(nfft, True, (window.blackmanharris(nfft)), 1) self.dc_blocker_xx_0_0 = filter.dc_blocker_ff(1024, True) self.dc_blocker_xx_0 = filter.dc_blocker_ff(256, True) self.blocks_vector_to_stream_1 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, nfft) self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, nfft) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate * throttle_rate, True) self.blocks_stream_to_vector_1 = blocks.stream_to_vector( gr.sizeof_float * 1, nfft) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_float * 1, nfft) self.blocks_skiphead_0_0 = blocks.skiphead(gr.sizeof_gr_complex * 1, 30) self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_gr_complex * 1, 30) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff( (180 / math.pi, )) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_moving_average_xx_0_0 = blocks.moving_average_ff( int(avg), 1 / avg, 4000, 1) self.blocks_keep_one_in_n_0_0 = blocks.keep_one_in_n( gr.sizeof_gr_complex * 1, nfft) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_gr_complex * 1, nfft) self.blocks_delay_2 = blocks.delay(gr.sizeof_gr_complex * 1, delay) self.blocks_complex_to_arg_0_0_0 = blocks.complex_to_arg(1) self.band_pass_filter_0_0 = filter.fir_filter_fff( 1, firdes.band_pass(1, audio_rate, 25, 35, 5, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0 = filter.fir_filter_fff( 1, firdes.band_pass(1, audio_rate, 25, 35, 5, firdes.WIN_HAMMING, 6.76)) self._audio_gain_tool_bar = Qt.QToolBar(self) self._audio_gain_tool_bar.addWidget(Qt.QLabel('vol30' + ": ")) self._audio_gain_line_edit = Qt.QLineEdit(str(self.audio_gain)) self._audio_gain_tool_bar.addWidget(self._audio_gain_line_edit) self._audio_gain_line_edit.returnPressed.connect( lambda: self.set_audio_gain( eng_notation.str_to_num( str(self._audio_gain_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._audio_gain_tool_bar, 1, 7, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(7, 8): self.top_grid_layout.setColumnStretch(c, 1) self.analog_sig_source_x_1 = analog.sig_source_c( audio_rate, analog.GR_COS_WAVE, 9960, 1, 0) self.analog_pll_carriertracking_cc_0 = analog.pll_carriertracking_cc( math.pi / 200, math.pi / 10, -math.pi / 10) self.analog_fm_demod_cf_0 = analog.fm_demod_cf( channel_rate=audio_rate, audio_decim=1, deviation=480, audio_pass=30, audio_stop=100, gain=1.0, tau=75e-6, ) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=48e3, audio_decim=1, audio_pass=35, audio_stop=100, ) self.analog_agc2_xx_0_0_0 = analog.agc2_ff(1e-3, 1e-3, .65, 1) self.analog_agc2_xx_0_0_0.set_max_gain(65536) self.analog_agc2_xx_0_0 = analog.agc2_ff(1e-1, 1e-2, .65, 1) self.analog_agc2_xx_0_0.set_max_gain(65536) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.analog_pll_carriertracking_cc_0, 0)) self.connect((self.analog_agc2_xx_0_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.analog_agc2_xx_0_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.analog_agc2_xx_0_0_0, 0), (self.blocks_stream_to_vector_1, 0)) self.connect((self.analog_agc2_xx_0_0_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.analog_fm_demod_cf_0, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.analog_pll_carriertracking_cc_0, 0), (self.rational_resampler_xxx_0_0_0, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.band_pass_filter_0, 0), (self.dc_blocker_xx_0, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.dc_blocker_xx_0_0, 0)) self.connect((self.blocks_complex_to_arg_0_0_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_delay_2, 0), (self.low_pass_filter_1, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.blocks_keep_one_in_n_0_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.blocks_moving_average_xx_0_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_arg_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_moving_average_xx_0_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.low_pass_filter_1_0, 0)) self.connect((self.blocks_skiphead_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_skiphead_0_0, 0), (self.blocks_keep_one_in_n_0_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_stream_to_vector_1, 0), (self.fft_vxx_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_skiphead_0, 0)) self.connect((self.blocks_vector_to_stream_1, 0), (self.blocks_skiphead_0_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.analog_agc2_xx_0_0, 0)) self.connect((self.dc_blocker_xx_0_0, 0), (self.analog_agc2_xx_0_0_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.fft_vxx_0_0, 0), (self.blocks_vector_to_stream_1, 0)) self.connect((self.low_pass_filter_1, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.low_pass_filter_1_0, 0), (self.analog_fm_demod_cf_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.blocks_delay_2, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.qtgui_freq_sink_x_1_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.sigmf_source_0, 0), (self.blocks_throttle_0, 0))
def __init__(self): gr.top_block.__init__(self, "I/Q imbalance") Qt.QWidget.__init__(self) self.setWindowTitle("I/Q imbalance") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "iqi") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1000000 self.signal_amp = signal_amp = 0 self.sigfreq = sigfreq = samp_rate/10.0 self.noise_amp = noise_amp = -150 self.iq_phase = iq_phase = 0 self.iq_mag = iq_mag = 0 ################################################## # Blocks ################################################## self._signal_amp_range = Range(-150, 10, 5, 0, 200) self._signal_amp_win = RangeWidget(self._signal_amp_range, self.set_signal_amp, 'Singal Power', "counter_slider", float) self.top_grid_layout.addWidget(self._signal_amp_win, 2,0,1,1) self._sigfreq_range = Range(0, samp_rate/2, 1000, samp_rate/10.0, 200) self._sigfreq_win = RangeWidget(self._sigfreq_range, self.set_sigfreq, 'Signal Freq', "counter_slider", float) self.top_grid_layout.addWidget(self._sigfreq_win, 3,0,1,1) self._iq_phase_range = Range(-3.14, 3.14, 0.001, 0, 200) self._iq_phase_win = RangeWidget(self._iq_phase_range, self.set_iq_phase, 'IQ Phase', "counter_slider", float) self.top_grid_layout.addWidget(self._iq_phase_win, 3,1,1,1) self._iq_mag_range = Range(0, 1, 0.001, 0, 200) self._iq_mag_win = RangeWidget(self._iq_mag_range, self.set_iq_mag, 'IQ Mag', "counter_slider", float) self.top_grid_layout.addWidget(self._iq_mag_win, 4,1,1,1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_FLATTOP, #wintype 0, #fc samp_rate, #bw 'QT GUI Plot', #name 2 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-200, 0) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ['Input', 'IQ Imbal', '', '', '', '', '', '', '', ''] widths = [2, 2, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [0.5, 0.5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 0,0,1,2) self._noise_amp_range = Range(-150, 0, 5, -150, 200) self._noise_amp_win = RangeWidget(self._noise_amp_range, self.set_noise_amp, 'Noise Power', "counter_slider", float) self.top_grid_layout.addWidget(self._noise_amp_win, 2,1,1,1) self.channels_iqbal_gen_0 = channels.iqbal_gen(iq_mag, iq_phase) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, sigfreq, pow(10.0,signal_amp/20.0), 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.channels_iqbal_gen_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.channels_iqbal_gen_0, 0), (self.qtgui_freq_sink_x_0_0, 1))
def __init__(self): gr.top_block.__init__(self, "Flaress Modulation Test") Qt.QWidget.__init__(self) self.setWindowTitle("Flaress Modulation Test") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "flaress_modulation_test") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.tw = tw = 10 self.sps = sps = 32 self.samp_rate = samp_rate = 320000 self.n_bit = n_bit = 38 self.cof = cof = 10.0 self.bit_rate = bit_rate = 16000 ################################################## # Blocks ################################################## self._tw_range = Range(10.0, 10000.0, 100.0, 10, 50) self._tw_win = RangeWidget(self._tw_range, self.set_tw, 'LPF Transition Width', "counter_slider", float) self.top_grid_layout.addWidget(self._tw_win, 1, 2, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self._n_bit_range = Range(4, 52, 1, 38, 50) self._n_bit_win = RangeWidget(self._n_bit_range, self.set_n_bit, 'PLL N bits', "counter_slider", int) self.top_grid_layout.addWidget(self._n_bit_win, 1, 0, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._cof_range = Range(10.0, 10000.0, 100.0, 10.0, 50) self._cof_win = RangeWidget(self._cof_range, self.set_cof, 'LPF cut-off frequency', "counter_slider", float) self.top_grid_layout.addWidget(self._cof_win, 1, 1, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate 'Modulated Signal Output', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 5, 0, 2, 3) for r in range(5, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate 'Input', #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 2, 0, 1, 3) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw 'Output Signal Spectrum', #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(True) self.qtgui_freq_sink_x_0_0.enable_grid(True) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(True) if not True: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 7, 0, 2, 3) for r in range(7, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 3): self.top_grid_layout.setColumnStretch(c, 1) self.low_pass_filter_0 = filter.fir_filter_fff( 1, firdes.low_pass(1, samp_rate, cof, tw, firdes.WIN_HAMMING, 6.76)) self.flaress_selector_0 = flaress.selector(gr.sizeof_char * 1, 0, 2, 1) self.ecss_phase_converter_0 = ecss.phase_converter(n_bit) self.ecss_modulator_0 = ecss.modulator(7, 2, ([79, -109]), 0, False, samp_rate, bit_rate, 1, 0, 1, 0.35, samp_rate / 11, True, 16000) self.ecss_coherent_phase_modulator_0 = ecss.coherent_phase_modulator( n_bit, 1) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True) self.blocks_file_source_0_0 = blocks.file_source( gr.sizeof_char * 1, '/mnt/c/Users/amir/WSL/grc/FlowGraps/FlaReSS/files/Convolutionally_encoded_CADU.bin', True) self.blocks_file_source_0_0.set_begin_tag(pmt.PMT_NIL) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, '/mnt/c/Users/amir/WSL/grc/FlowGraps/FlaReSS/files/CADU.bin', True) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_gr_complex * 1, '/mnt/c/Users/amir/WSL/grc/FlowGraps/FlaReSS/files/modulated_signal_output', False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) ################################################## # Connections ################################################## self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.flaress_selector_0, 0)) self.connect((self.blocks_file_source_0_0, 0), (self.flaress_selector_0, 1)) self.connect((self.blocks_throttle_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.ecss_modulator_0, 0)) self.connect((self.ecss_coherent_phase_modulator_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.ecss_coherent_phase_modulator_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.ecss_modulator_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.ecss_phase_converter_0, 0), (self.ecss_coherent_phase_modulator_0, 0)) self.connect((self.flaress_selector_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.ecss_phase_converter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_time_sink_x_0_0, 0))
def __init__(self, gain=30, ppm=0, samp_rate=2000000.052982, shiftoff=400e3, fc=943.6e6): gr.top_block.__init__(self, "Decode Raw") Qt.QWidget.__init__(self) self.setWindowTitle("Decode Raw") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "decode_raw") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.gain = gain self.ppm = ppm self.samp_rate = samp_rate self.shiftoff = shiftoff self.fc = fc ################################################## # Variables ################################################## self.ppm_slider = ppm_slider = ppm self.g_slider = g_slider = gain self.fc_slider = fc_slider = fc ################################################## # Blocks ################################################## self._fc_slider_layout = Qt.QVBoxLayout() self._fc_slider_tool_bar = Qt.QToolBar(self) self._fc_slider_layout.addWidget(self._fc_slider_tool_bar) self._fc_slider_tool_bar.addWidget(Qt.QLabel("Frequency"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._fc_slider_counter = qwt_counter_pyslot() self._fc_slider_counter.setRange(925e6, 1990e6, 2e5) self._fc_slider_counter.setNumButtons(2) self._fc_slider_counter.setValue(self.fc_slider) self._fc_slider_tool_bar.addWidget(self._fc_slider_counter) self._fc_slider_counter.valueChanged.connect(self.set_fc_slider) self._fc_slider_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._fc_slider_slider.setRange(925e6, 1990e6, 2e5) self._fc_slider_slider.setValue(self.fc_slider) self._fc_slider_slider.setMinimumWidth(100) self._fc_slider_slider.valueChanged.connect(self.set_fc_slider) self._fc_slider_layout.addWidget(self._fc_slider_slider) self.top_layout.addLayout(self._fc_slider_layout) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype fc_slider, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self._ppm_slider_layout = Qt.QHBoxLayout() self._ppm_slider_layout.addWidget(Qt.QLabel("PPM Offset"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._ppm_slider_counter = qwt_counter_pyslot() self._ppm_slider_counter.setRange(-150, 150, 1) self._ppm_slider_counter.setNumButtons(2) self._ppm_slider_counter.setMinimumWidth(100) self._ppm_slider_counter.setValue(self.ppm_slider) self._ppm_slider_layout.addWidget(self._ppm_slider_counter) self._ppm_slider_counter.valueChanged.connect(self.set_ppm_slider) self.top_layout.addLayout(self._ppm_slider_layout) self.gsm_sdcch8_demapper_0 = grgsm.universal_ctrl_chans_demapper(1, ([0,4,8,12,16,20,24,28,32,36,40,44]), ([8,8,8,8,8,8,8,8,136,136,136,136])) self.gsm_receiver_0 = grgsm.receiver(4, ([0]), ([])) self.gsm_message_printer_1 = grgsm.message_printer(pmt.intern(""), False, False, False) self.gsm_input_0 = grgsm.gsm_input( ppm=0, osr=4, fc=fc, samp_rate_in=samp_rate, ) self.gsm_decryption_0 = grgsm.decryption(([]), 1) self.gsm_control_channels_decoder_0_0 = grgsm.control_channels_decoder() self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() self.gsm_clock_offset_control_0 = grgsm.clock_offset_control(fc-shiftoff) self.gsm_bcch_ccch_demapper_0 = grgsm.universal_ctrl_chans_demapper(0, ([2,6,12,16,22,26,32,36,42,46]), ([1,2,2,2,2,2,2,2,2,2])) self._g_slider_layout = Qt.QHBoxLayout() self._g_slider_layout.addWidget(Qt.QLabel("Gain"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._g_slider_counter = qwt_counter_pyslot() self._g_slider_counter.setRange(0, 50, 0.5) self._g_slider_counter.setNumButtons(2) self._g_slider_counter.setMinimumWidth(100) self._g_slider_counter.setValue(self.g_slider) self._g_slider_layout.addWidget(self._g_slider_counter) self._g_slider_counter.valueChanged.connect(self.set_g_slider) self.top_layout.addLayout(self._g_slider_layout) self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "127.0.0.1", "4729", 10000, False) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000, False) self.blocks_rotator_cc_0 = blocks.rotator_cc(-2*pi*shiftoff/samp_rate) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/tmp/gsm_raw", False) ################################################## # Connections ################################################## self.connect((self.blocks_rotator_cc_0, 0), (self.gsm_input_0, 0)) self.connect((self.blocks_rotator_cc_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_rotator_cc_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.gsm_bcch_ccch_demapper_0, "bursts", self.gsm_control_channels_decoder_0, "bursts") self.msg_connect(self.gsm_clock_offset_control_0, "ppm", self.gsm_input_0, "ppm_in") self.msg_connect(self.gsm_control_channels_decoder_0, "msgs", self.blocks_socket_pdu_0, "pdus") self.msg_connect(self.gsm_control_channels_decoder_0, "msgs", self.gsm_message_printer_1, "msgs") self.msg_connect(self.gsm_control_channels_decoder_0_0, "msgs", self.blocks_socket_pdu_0, "pdus") self.msg_connect(self.gsm_control_channels_decoder_0_0, "msgs", self.gsm_message_printer_1, "msgs") self.msg_connect(self.gsm_decryption_0, "bursts", self.gsm_control_channels_decoder_0_0, "bursts") self.msg_connect(self.gsm_receiver_0, "C0", self.gsm_bcch_ccch_demapper_0, "bursts") self.msg_connect(self.gsm_receiver_0, "C0", self.gsm_sdcch8_demapper_0, "bursts") self.msg_connect(self.gsm_receiver_0, "measurements", self.gsm_clock_offset_control_0, "measurements") self.msg_connect(self.gsm_sdcch8_demapper_0, "bursts", self.gsm_decryption_0, "bursts")
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.sdrplay_hro_sdrplay_vc_0 = sdrplay.hro_sdrplay_vc(25, 2, 14.1, 600, 450) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 16000, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ["real", "", "", "", "", "", "", "", "", ""] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-128, 128) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_time_sink_x_2 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_2.set_update_time(0.10) self.qtgui_time_sink_x_2.set_y_axis(-10000, 10000) self.qtgui_time_sink_x_2.set_y_label("Amplitude", "") self.qtgui_time_sink_x_2.enable_tags(-1, True) self.qtgui_time_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_2.enable_autoscale(True) self.qtgui_time_sink_x_2.enable_grid(False) self.qtgui_time_sink_x_2.enable_control_panel(False) if not True: self.qtgui_time_sink_x_2.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2*1): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_2.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_2.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_2.set_line_label(i, labels[i]) self.qtgui_time_sink_x_2.set_line_width(i, widths[i]) self.qtgui_time_sink_x_2.set_line_color(i, colors[i]) self.qtgui_time_sink_x_2.set_line_style(i, styles[i]) self.qtgui_time_sink_x_2.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_2.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_2_win = sip.wrapinstance(self.qtgui_time_sink_x_2.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_2_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-1000, 1000) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) ################################################## # Connections ################################################## self.connect((self.sdrplay_hro_sdrplay_vc_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.sdrplay_hro_sdrplay_vc_0, 0), (self.qtgui_time_sink_x_2, 0)) self.connect((self.sdrplay_hro_sdrplay_vc_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.offset_tune_freq = offset_tune_freq = -10E3 self.band_freq = band_freq = 7.055E6 self.usrp_clk_rate = usrp_clk_rate = 200E6 self.usrp_ask_freq = usrp_ask_freq = band_freq+offset_tune_freq self.usrp_DDC_freq = usrp_DDC_freq = np.round(usrp_ask_freq/usrp_clk_rate* 2**32)/2**32 * usrp_clk_rate self.fine_tuner_freq = fine_tuner_freq = 0 self.coarse_tuner_freq = coarse_tuner_freq = 0 self.samp_rate = samp_rate = 250000 self.lo_freq = lo_freq = usrp_DDC_freq + coarse_tuner_freq + fine_tuner_freq - offset_tune_freq self.record_check_box = record_check_box = False self.file_name_string = file_name_string = str(int(time.mktime(time.gmtime())))+"UTC_"+'{:.6f}'.format(lo_freq)+"Hz"+"_"+str(int(samp_rate/100))+"sps"+".raw" self.variable_function_probe_0 = variable_function_probe_0 = 0 self.file_name = file_name = file_name_string if record_check_box==True else "/dev/null" self.volume = volume = 5.0 self.rx_power_label = rx_power_label = '{:.1f}'.format(variable_function_probe_0) self.lo_freq_label = lo_freq_label = '{:.6f}'.format(lo_freq) self.gain_offset_dB = gain_offset_dB = 18.86 self.filter_taps = filter_taps = firdes.low_pass(1.0,2.5,0.1,0.02,firdes.WIN_HAMMING) self.filename_label = filename_label = file_name self.cw_filter_bw = cw_filter_bw = 1000 self.RX_power_offset_dB = RX_power_offset_dB = -35.2 ################################################## # Blocks ################################################## self._volume_layout = Qt.QVBoxLayout() self._volume_knob = Qwt.QwtKnob() self._volume_knob.setRange(0, 10.0, 1.0) self._volume_knob.setValue(self.volume) self._volume_knob.valueChanged.connect(self.set_volume) self._volume_layout.addWidget(self._volume_knob) self._volume_label = Qt.QLabel("Volume") self._volume_label.setAlignment(Qt.Qt.AlignTop | Qt.Qt.AlignHCenter) self._volume_layout.addWidget(self._volume_label) self.top_grid_layout.addLayout(self._volume_layout, 5,6,1,1) self._cw_filter_bw_options = (100, 500, 1000, ) self._cw_filter_bw_labels = ("100 Hz", "500 Hz", "1 kHz", ) self._cw_filter_bw_tool_bar = Qt.QToolBar(self) self._cw_filter_bw_tool_bar.addWidget(Qt.QLabel("CW Filter BW"+": ")) self._cw_filter_bw_combo_box = Qt.QComboBox() self._cw_filter_bw_tool_bar.addWidget(self._cw_filter_bw_combo_box) for label in self._cw_filter_bw_labels: self._cw_filter_bw_combo_box.addItem(label) self._cw_filter_bw_callback = lambda i: Qt.QMetaObject.invokeMethod(self._cw_filter_bw_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._cw_filter_bw_options.index(i))) self._cw_filter_bw_callback(self.cw_filter_bw) self._cw_filter_bw_combo_box.currentIndexChanged.connect( lambda i: self.set_cw_filter_bw(self._cw_filter_bw_options[i])) self.top_grid_layout.addWidget(self._cw_filter_bw_tool_bar, 5,5,1,1) self.blocks_probe_signal_x_0 = blocks.probe_signal_f() def _variable_function_probe_0_probe(): while True: val = self.blocks_probe_signal_x_0.level() try: self.set_variable_function_probe_0(val) except AttributeError: pass time.sleep(1.0 / (5)) _variable_function_probe_0_thread = threading.Thread(target=_variable_function_probe_0_probe) _variable_function_probe_0_thread.daemon = True _variable_function_probe_0_thread.start() self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "addr=192.168.40.2")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_subdev_spec("B:A", 0) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(usrp_ask_freq, 0) self.uhd_usrp_source_0.set_gain(6, 0) self._rx_power_label_tool_bar = Qt.QToolBar(self) if None: self._rx_power_label_formatter = None else: self._rx_power_label_formatter = lambda x: x self._rx_power_label_tool_bar.addWidget(Qt.QLabel("RX Power (dBm)"+": ")) self._rx_power_label_label = Qt.QLabel(str(self._rx_power_label_formatter(self.rx_power_label))) self._rx_power_label_tool_bar.addWidget(self._rx_power_label_label) self.top_grid_layout.addWidget(self._rx_power_label_tool_bar, 4,7,1,1) _record_check_box_check_box = Qt.QCheckBox("Record") self._record_check_box_choices = {True: True, False: False} self._record_check_box_choices_inv = dict((v,k) for k,v in self._record_check_box_choices.iteritems()) self._record_check_box_callback = lambda i: Qt.QMetaObject.invokeMethod(_record_check_box_check_box, "setChecked", Qt.Q_ARG("bool", self._record_check_box_choices_inv[i])) self._record_check_box_callback(self.record_check_box) _record_check_box_check_box.stateChanged.connect(lambda i: self.set_record_check_box(self._record_check_box_choices[bool(i)])) self.top_grid_layout.addWidget(_record_check_box_check_box, 6,5,1,1) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=48000, decimation=2500, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype usrp_DDC_freq, #fc samp_rate, #bw "Band Waterfall", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) if complex == type(float()): self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [5, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-100, -70) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 4,0,3,5) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype lo_freq, #fc samp_rate/100, #bw str(samp_rate/100) + " Hz Channel Spectrum", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-120, -70) self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(True) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) if complex == type(float()): self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 0,5,3,5) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype usrp_DDC_freq, #fc samp_rate, #bw "Band Spectrum", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-110, -60) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.2) if complex == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0,0,3,5) self.low_pass_filter_0_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate/100, 0.9*cw_filter_bw, 0.1*cw_filter_bw, firdes.WIN_BLACKMAN, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 10**(gain_offset_dB/20), samp_rate, 100E3, 20E3, firdes.WIN_HAMMING, 6.76)) self._lo_freq_label_tool_bar = Qt.QToolBar(self) if None: self._lo_freq_label_formatter = None else: self._lo_freq_label_formatter = lambda x: x self._lo_freq_label_tool_bar.addWidget(Qt.QLabel("LO Freq (Hz)"+": ")) self._lo_freq_label_label = Qt.QLabel(str(self._lo_freq_label_formatter(self.lo_freq_label))) self._lo_freq_label_tool_bar.addWidget(self._lo_freq_label_label) self.top_grid_layout.addWidget(self._lo_freq_label_tool_bar, 4,6,1,1) self.hilbert_fc_0_0 = filter.hilbert_fc(65, firdes.WIN_HAMMING, 6.76) self.hilbert_fc_0 = filter.hilbert_fc(65, firdes.WIN_HAMMING, 6.76) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(10, (filter_taps), lo_freq - usrp_DDC_freq, samp_rate) self.fir_filter_xxx_0_0_0 = filter.fir_filter_ccc(10, (filter_taps)) self.fir_filter_xxx_0_0_0.declare_sample_delay(0) self._fine_tuner_freq_layout = Qt.QVBoxLayout() self._fine_tuner_freq_tool_bar = Qt.QToolBar(self) self._fine_tuner_freq_layout.addWidget(self._fine_tuner_freq_tool_bar) self._fine_tuner_freq_tool_bar.addWidget(Qt.QLabel("Fine Tuner (Hz)"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._fine_tuner_freq_counter = qwt_counter_pyslot() self._fine_tuner_freq_counter.setRange(-500, 500, 1) self._fine_tuner_freq_counter.setNumButtons(2) self._fine_tuner_freq_counter.setValue(self.fine_tuner_freq) self._fine_tuner_freq_tool_bar.addWidget(self._fine_tuner_freq_counter) self._fine_tuner_freq_counter.valueChanged.connect(self.set_fine_tuner_freq) self._fine_tuner_freq_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._fine_tuner_freq_slider.setRange(-500, 500, 1) self._fine_tuner_freq_slider.setValue(self.fine_tuner_freq) self._fine_tuner_freq_slider.setMinimumWidth(200) self._fine_tuner_freq_slider.valueChanged.connect(self.set_fine_tuner_freq) self._fine_tuner_freq_layout.addWidget(self._fine_tuner_freq_slider) self.top_grid_layout.addLayout(self._fine_tuner_freq_layout, 3,5,1,5) self._filename_label_tool_bar = Qt.QToolBar(self) if None: self._filename_label_formatter = None else: self._filename_label_formatter = lambda x: x self._filename_label_tool_bar.addWidget(Qt.QLabel("File Name"+": ")) self._filename_label_label = Qt.QLabel(str(self._filename_label_formatter(self.filename_label))) self._filename_label_tool_bar.addWidget(self._filename_label_label) self.top_grid_layout.addWidget(self._filename_label_tool_bar, 6,6,1,3) self._coarse_tuner_freq_layout = Qt.QVBoxLayout() self._coarse_tuner_freq_tool_bar = Qt.QToolBar(self) self._coarse_tuner_freq_layout.addWidget(self._coarse_tuner_freq_tool_bar) self._coarse_tuner_freq_tool_bar.addWidget(Qt.QLabel("Coarse Tuner (Hz)"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._coarse_tuner_freq_counter = qwt_counter_pyslot() self._coarse_tuner_freq_counter.setRange(-samp_rate/2, samp_rate/2, 100) self._coarse_tuner_freq_counter.setNumButtons(2) self._coarse_tuner_freq_counter.setValue(self.coarse_tuner_freq) self._coarse_tuner_freq_tool_bar.addWidget(self._coarse_tuner_freq_counter) self._coarse_tuner_freq_counter.valueChanged.connect(self.set_coarse_tuner_freq) self._coarse_tuner_freq_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._coarse_tuner_freq_slider.setRange(-samp_rate/2, samp_rate/2, 100) self._coarse_tuner_freq_slider.setValue(self.coarse_tuner_freq) self._coarse_tuner_freq_slider.setMinimumWidth(50) self._coarse_tuner_freq_slider.valueChanged.connect(self.set_coarse_tuner_freq) self._coarse_tuner_freq_layout.addWidget(self._coarse_tuner_freq_slider) self.top_grid_layout.addLayout(self._coarse_tuner_freq_layout, 3,0,1,5) self.blocks_null_sink_1_0_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_null_sink_1_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, RX_power_offset_dB) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_integrate_xx_0 = blocks.integrate_ff(500) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, file_name, False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_float_1_0 = blocks.complex_to_float(1) self.blocks_complex_to_float_0_0 = blocks.complex_to_float(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_0 = blocks.add_vff(1) self._band_freq_options = [1.84E6, 3.598E6, 7.055E6, 2.5E6, 5.0E6, 10.0E6] self._band_freq_labels = ["160m", "80m", "40m", "2.5 MHz", "5 MHz", "10 MHz"] self._band_freq_tool_bar = Qt.QToolBar(self) self._band_freq_tool_bar.addWidget(Qt.QLabel("Band"+": ")) self._band_freq_combo_box = Qt.QComboBox() self._band_freq_tool_bar.addWidget(self._band_freq_combo_box) for label in self._band_freq_labels: self._band_freq_combo_box.addItem(label) self._band_freq_callback = lambda i: Qt.QMetaObject.invokeMethod(self._band_freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._band_freq_options.index(i))) self._band_freq_callback(self.band_freq) self._band_freq_combo_box.currentIndexChanged.connect( lambda i: self.set_band_freq(self._band_freq_options[i])) self.top_grid_layout.addWidget(self._band_freq_tool_bar, 4,5,1,1) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate/100, analog.GR_COS_WAVE, 600, 1, 0) self.analog_agc3_xx_0 = analog.agc3_cc(1e-1, 1e-4, volume/100, 1, 1) self.analog_agc3_xx_0.set_max_gain(2**16) ################################################## # Connections ################################################## self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.fir_filter_xxx_0_0_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.fir_filter_xxx_0_0_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.fir_filter_xxx_0_0_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_integrate_xx_0, 0)) self.connect((self.blocks_integrate_xx_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_probe_signal_x_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.analog_agc3_xx_0, 0)) self.connect((self.analog_agc3_xx_0, 0), (self.blocks_complex_to_float_1_0, 0)) self.connect((self.fir_filter_xxx_0_0_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_complex_to_float_0_0, 1), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_complex_to_float_0_0, 0), (self.blocks_null_sink_1_0_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_null_sink_1_0, 0)) self.connect((self.blocks_complex_to_float_1_0, 1), (self.hilbert_fc_0, 0)) self.connect((self.hilbert_fc_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.blocks_complex_to_float_1_0, 0), (self.hilbert_fc_0_0, 0)) self.connect((self.hilbert_fc_0_0, 0), (self.blocks_complex_to_float_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_freq_sink_x_0_0, 1))
def __init__(self): gr.top_block.__init__(self, "Ex Freq Sel Fading Model") Qt.QWidget.__init__(self) self.setWindowTitle("Ex Freq Sel Fading Model") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "ex_freq_sel_fading_model") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.trig_umts_ped_b = trig_umts_ped_b = 1.5 self.trig_umts_ped_a = trig_umts_ped_a = 0.5 self.trig_del_umts_ped_b = trig_del_umts_ped_b = 0.000001 self.trig_del_umts_ped_a = trig_del_umts_ped_a = 0.000001 self.trig_del_ca0 = trig_del_ca0 = 2e-9 self.trig_ca0 = trig_ca0 = 2.8 self.samp_rate_umts_ped_b = samp_rate_umts_ped_b = 7.68e6 self.samp_rate_umts_ped_a = samp_rate_umts_ped_a = 7.68e6 self.samp_rate_ca0 = samp_rate_ca0 = 4e9 self.pdp_times_umts_ped_b = pdp_times_umts_ped_b = [0, 1.536, 6.144, 9.216, 17.664, 28.416] self.pdp_times_umts_ped_a = pdp_times_umts_ped_a = [0, 0.8448, 1.4592, 3.1488] self.pdp_times_ca0 = pdp_times_ca0 = [-0.25, -0.125, 0.0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1.0, 1.125, 1.25, 1.5, 1.625, 1.75, 1.875, 2.0, 2.125, 2.25, 2.375, 2.5, 2.75, 2.875, 3.0, 3.125, 3.25, 3.375, 3.5, 3.625, 3.75, 3.875, 4.0, 4.125, 4.25, 4.375, 4.5, 4.625, 4.75, 5.125, 5.25, 5.5, 5.625, 5.75, 6.0, 6.375, 6.5, 6.625, 6.75, 6.875, 7.25, 8.0, 8.125, 8.5, 8.625, 8.75, 8.875, 9.125, 9.25, 9.375, 9.5, 9.875, 10.0, 10.75, 10.875, 11.0, 11.125, 13.125, 13.25] self.pdp_mags_umts_ped_b = pdp_mags_umts_ped_b = [1, 0.9139311853, 0.6126263942, 0.4493289641, 0.4584060113, 0.0916296839] self.pdp_mags_umts_ped_a = pdp_mags_umts_ped_a = [1, 0.3790830381, 0.1466069621, 0.1022842067] self.pdp_mags_ca0 = pdp_mags_ca0 = [0.16529889, 0.46954084, 0.58274825, 0.24561255, 0.50459457, 0.69767633, 1.0, 0.77724474, 0.48675226, 0.46954084, 0.21267289, 0.19090106, 0.31600413, 0.45293801, 0.8057353, 0.64920938, 0.50459457, 0.1978987, 0.35204369, 0.54226525, 0.31600413, 0.15945397, 0.2204686, 0.35204369, 0.37832563, 0.37832563, 0.36494815, 0.2204686, 0.17763933, 0.45293801, 0.52309091, 0.52309091, 0.46954084, 0.35204369, 0.40656966, 0.25461568, 0.23692776, 0.32758753, 0.1978987, 0.21267289, 0.2204686, 0.19090106, 0.24561255, 0.17135806, 0.21267289, 0.16529889, 0.2204686, 0.30483032, 0.33959553, 0.18415085, 0.18415085, 0.22855006, 0.2940516, 0.19090106, 0.17135806, 0.18415085, 0.1978987, 0.17763933, 0.15945397, 0.26394884, 0.24561255, 0.21267289, 0.19090106, 0.17763933, 0.2204686, 0.21267289, 0.17135806, 0.17135806, 0.16529889] self.model = model = 2 self.trig_del = trig_del = [trig_del_ca0, trig_del_umts_ped_a, trig_del_umts_ped_b][model] self.trig = trig = [trig_ca0, trig_umts_ped_a, trig_umts_ped_b][model] self.timing = timing = 1.000 self.samp_rate = samp_rate = [samp_rate_ca0, samp_rate_umts_ped_a, samp_rate_umts_ped_b][model] self.pdp_times = pdp_times = [pdp_times_ca0, pdp_times_umts_ped_a, pdp_times_umts_ped_b][model] self.pdp_mags = pdp_mags = [pdp_mags_ca0, pdp_mags_umts_ped_a, pdp_mags_umts_ped_b][model] self.noise = noise = 0.01 self.freq = freq = 0.0 ################################################## # Blocks ################################################## self._timing_layout = Qt.QVBoxLayout() self._timing_tool_bar = Qt.QToolBar(self) self._timing_layout.addWidget(self._timing_tool_bar) self._timing_tool_bar.addWidget(Qt.QLabel("Timing Offset"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._timing_counter = qwt_counter_pyslot() self._timing_counter.setRange(0.999, 1.001, 0.0001) self._timing_counter.setNumButtons(2) self._timing_counter.setValue(self.timing) self._timing_tool_bar.addWidget(self._timing_counter) self._timing_counter.valueChanged.connect(self.set_timing) self._timing_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._timing_slider.setRange(0.999, 1.001, 0.0001) self._timing_slider.setValue(self.timing) self._timing_slider.setMinimumWidth(200) self._timing_slider.valueChanged.connect(self.set_timing) self._timing_layout.addWidget(self._timing_slider) self.top_grid_layout.addLayout(self._timing_layout, 3,0,1,1) self._noise_layout = Qt.QVBoxLayout() self._noise_tool_bar = Qt.QToolBar(self) self._noise_layout.addWidget(self._noise_tool_bar) self._noise_tool_bar.addWidget(Qt.QLabel("Noise Voltage"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._noise_counter = qwt_counter_pyslot() self._noise_counter.setRange(0, 1, 0.01) self._noise_counter.setNumButtons(2) self._noise_counter.setValue(self.noise) self._noise_tool_bar.addWidget(self._noise_counter) self._noise_counter.valueChanged.connect(self.set_noise) self._noise_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._noise_slider.setRange(0, 1, 0.01) self._noise_slider.setValue(self.noise) self._noise_slider.setMinimumWidth(200) self._noise_slider.valueChanged.connect(self.set_noise) self._noise_layout.addWidget(self._noise_slider) self.top_grid_layout.addLayout(self._noise_layout, 2,0,1,1) self._freq_layout = Qt.QVBoxLayout() self._freq_tool_bar = Qt.QToolBar(self) self._freq_layout.addWidget(self._freq_tool_bar) self._freq_tool_bar.addWidget(Qt.QLabel("Frequency Offset"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._freq_counter = qwt_counter_pyslot() self._freq_counter.setRange(-1, 1, 0.01) self._freq_counter.setNumButtons(2) self._freq_counter.setValue(self.freq) self._freq_tool_bar.addWidget(self._freq_counter) self._freq_counter.valueChanged.connect(self.set_freq) self._freq_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._freq_slider.setRange(-1, 1, 0.01) self._freq_slider.setValue(self.freq) self._freq_slider.setMinimumWidth(200) self._freq_slider.valueChanged.connect(self.set_freq) self._freq_layout.addWidget(self._freq_slider) self.top_grid_layout.addLayout(self._freq_layout, 2,1,1,1) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 0,1,1,1) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 30, #size samp_rate, #samp_rate "QT GUI Plot", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, trig, trig_del, 0, "") self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 1,1,1,1) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "QT GUI Plot", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-3, 3) self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 1,0,1,1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-80, 10) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0,0,1,1) self.channels_selective_fading_model_0 = channels.selective_fading_model( 8, 10.0/samp_rate, False, 4.0, 0, (pdp_times), (pdp_mags), 8 ) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise, frequency_offset=freq, epsilon=timing, taps=(1.0, ), noise_seed=0, block_tags=False ) self.blocks_vector_source_x_0 = blocks.vector_source_c(511*[0,] + [1,] + 512*[0,], True, 1, []) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) ################################################## # Connections ################################################## self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.channels_selective_fading_model_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.channels_selective_fading_model_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_freq_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Lab 2") Qt.QWidget.__init__(self) self.setWindowTitle("Lab 2") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "lab2") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.sps = sps = 8 self.roll_off = roll_off = 0.5 self.freqc = freqc = 900 self.std_dev = std_dev = 0.05 self.samp_rate = samp_rate = 1000 self.rrc_filter = rrc_filter = firdes.root_raised_cosine( 4, sps, 1, roll_off, 32 * sps + 1) self.phase = phase = 0 self.lw = lw = 2 self.gain_ = gain_ = 0.5 self.freqc_ = freqc_ = freqc self.fps = fps = 30 self.const = const = digital.constellation_calcdist( digital.psk_2()[0], digital.psk_2()[1], 2, 1).base() self.bw = bw = 1 self.buff_size = buff_size = 32768 self.bNoise = bNoise = 0 self.bFilter = bFilter = 0 self.axis = axis = 2 self.N = N = 0 ################################################## # Blocks ################################################## self.tab0 = Qt.QTabWidget() self.tab0_widget_0 = Qt.QWidget() self.tab0_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_0) self.tab0_grid_layout_0 = Qt.QGridLayout() self.tab0_layout_0.addLayout(self.tab0_grid_layout_0) self.tab0.addTab(self.tab0_widget_0, 'Spectrum/Constellation') self.tab0_widget_1 = Qt.QWidget() self.tab0_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_1) self.tab0_grid_layout_1 = Qt.QGridLayout() self.tab0_layout_1.addLayout(self.tab0_grid_layout_1) self.tab0.addTab(self.tab0_widget_1, 'Eye Diagram') self.top_grid_layout.addWidget(self.tab0, 0, 0, 10, 2) for r in range(0, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._std_dev_range = Range(0, 1, 0.01, 0.05, 200) self._std_dev_win = RangeWidget(self._std_dev_range, self.set_std_dev, 'Noise Std. Dev', "counter_slider", float) self.top_grid_layout.addWidget(self._std_dev_win, 11, 0, 1, 1) for r in range(11, 12): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._phase_range = Range(-180 * 2, 180 * 2, 0.1, 0, 200) self._phase_win = RangeWidget(self._phase_range, self.set_phase, 'Phase Offset (Degrees)', "counter_slider", float) self.top_grid_layout.addWidget(self._phase_win, 11, 1, 1, 1) for r in range(11, 12): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._gain__range = Range(0.1, 1, 0.01, 0.5, 200) self._gain__win = RangeWidget(self._gain__range, self.set_gain_, 'Gain (Amp)', "counter_slider", float) self.top_grid_layout.addWidget(self._gain__win, 10, 1, 1, 1) for r in range(10, 11): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) # Create the options list self._bNoise_options = ( 0, 1, ) # Create the labels list self._bNoise_labels = ( 'Noise Only', 'Signal + Noise', ) # Create the combo box # Create the radio buttons self._bNoise_group_box = Qt.QGroupBox('Waveform Select' + ": ") self._bNoise_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._bNoise_button_group = variable_chooser_button_group() self._bNoise_group_box.setLayout(self._bNoise_box) for i, _label in enumerate(self._bNoise_labels): radio_button = Qt.QRadioButton(_label) self._bNoise_box.addWidget(radio_button) self._bNoise_button_group.addButton(radio_button, i) self._bNoise_callback = lambda i: Qt.QMetaObject.invokeMethod( self._bNoise_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._bNoise_options.index(i))) self._bNoise_callback(self.bNoise) self._bNoise_button_group.buttonClicked[int].connect( lambda i: self.set_bNoise(self._bNoise_options[i])) self.top_grid_layout.addWidget(self._bNoise_group_box, 12, 1, 1, 1) for r in range(12, 13): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) # Create the options list self._bFilter_options = ( 0, 1, ) # Create the labels list self._bFilter_labels = ( 'Rectangular', 'Raised Cosine', ) # Create the combo box # Create the radio buttons self._bFilter_group_box = Qt.QGroupBox('Pulse Shaping Select' + ": ") self._bFilter_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._bFilter_button_group = variable_chooser_button_group() self._bFilter_group_box.setLayout(self._bFilter_box) for i, _label in enumerate(self._bFilter_labels): radio_button = Qt.QRadioButton(_label) self._bFilter_box.addWidget(radio_button) self._bFilter_button_group.addButton(radio_button, i) self._bFilter_callback = lambda i: Qt.QMetaObject.invokeMethod( self._bFilter_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._bFilter_options.index(i))) self._bFilter_callback(self.bFilter) self._bFilter_button_group.buttonClicked[int].connect( lambda i: self.set_bFilter(self._bFilter_options[i])) self.top_grid_layout.addWidget(self._bFilter_group_box, 12, 0, 1, 1) for r in range(12, 13): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._N_range = Range(0, 7, 1, 0, 200) self._N_win = RangeWidget(self._N_range, self.set_N, 'Nth Sample', "counter_slider", float) self.top_grid_layout.addWidget(self._N_win, 13, 1, 1, 1) for r in range(13, 14): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._roll_off_range = Range(0.01, 0.99, 0.01, 0.5, 200) self._roll_off_win = RangeWidget(self._roll_off_range, self.set_roll_off, 'Beta (Roll-Off-Factor)', "counter_slider", float) self.top_grid_layout.addWidget(self._roll_off_win, 13, 0, 1, 1) for r in range(13, 14): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 2 * sps, #size 1, #samp_rate "", #name 10 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(1 / fps) self.qtgui_time_sink_x_0.set_y_axis(-2, 2) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "buffer_start") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(True) self.qtgui_time_sink_x_0.enable_stem_plot(False) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] widths = [lw, lw, lw, lw, lw, lw, lw, lw, lw, lw] colors = [ 'blue', 'red', 'yellow', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(10): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.tab0_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_win, 0, 0, 5, 1) for r in range(0, 5): self.tab0_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.tab0_grid_layout_1.setColumnStretch(c, 1) self.qtgui_histogram_sink_x_0 = qtgui.histogram_sink_f( int(1e5), 400, -axis, axis, "", 1) self.qtgui_histogram_sink_x_0.set_update_time(1 / fps) self.qtgui_histogram_sink_x_0.enable_autoscale(True) self.qtgui_histogram_sink_x_0.enable_accumulate(False) self.qtgui_histogram_sink_x_0.enable_grid(True) self.qtgui_histogram_sink_x_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_histogram_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_histogram_sink_x_0.set_line_label(i, labels[i]) self.qtgui_histogram_sink_x_0.set_line_width(i, widths[i]) self.qtgui_histogram_sink_x_0.set_line_color(i, colors[i]) self.qtgui_histogram_sink_x_0.set_line_style(i, styles[i]) self.qtgui_histogram_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_histogram_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_histogram_sink_x_0_win = sip.wrapinstance( self.qtgui_histogram_sink_x_0.pyqwidget(), Qt.QWidget) self.tab0_grid_layout_0.addWidget(self._qtgui_histogram_sink_x_0_win, 5, 1, 5, 1) for r in range(5, 10): self.tab0_grid_layout_0.setRowStretch(r, 1) for c in range(1, 2): self.tab0_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_RECTANGULAR, #wintype 0, #fc samp_rate * 1e3, #bw "", #name 1) self.qtgui_freq_sink_x_0_0.set_update_time(1 / fps) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(True) self.qtgui_freq_sink_x_0_0.set_fft_average(0.05) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) labels = ['Magnitude', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tab0_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_0_win, 0, 0, 5, 1) for r in range(0, 5): self.tab0_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.tab0_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0.set_processor_affinity([0]) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_RECTANGULAR, #wintype 0, #fc samp_rate * 1e3, #bw "", #name 2) self.qtgui_freq_sink_x_0.set_update_time(1 / fps) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.05) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['In-Phase', 'Quadrature', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.tab0_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 5, 0, 5, 1) for r in range(5, 10): self.tab0_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.tab0_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0.set_processor_affinity([0]) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 2 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(1 / fps) self.qtgui_const_sink_x_0.set_y_axis(-axis, axis) self.qtgui_const_sink_x_0.set_x_axis(-axis, axis) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(True) self.qtgui_const_sink_x_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, -1, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 0.5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(2): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.tab0_grid_layout_0.addWidget(self._qtgui_const_sink_x_0_win, 0, 1, 5, 1) for r in range(0, 5): self.tab0_grid_layout_0.setRowStretch(r, 1) for c in range(1, 2): self.tab0_grid_layout_0.setColumnStretch(c, 1) self.qtgui_const_sink_x_0.set_processor_affinity([0]) self.interp_fir_filter_xxx_1_0 = filter.interp_fir_filter_ccc( sps, (1, 1, 1, 1, 1, 1, 1, 1)) self.interp_fir_filter_xxx_1_0.declare_sample_delay(0) self.interp_fir_filter_xxx_1 = filter.interp_fir_filter_ccc( sps, rrc_filter) self.interp_fir_filter_xxx_1.declare_sample_delay(0) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc( 1, rrc_filter) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self._freqc__range = Range(70, 6000, .01, freqc, 200) self._freqc__win = RangeWidget(self._freqc__range, self.set_freqc_, 'Carrier (MHz)', "counter_slider", float) self.top_grid_layout.addWidget(self._freqc__win, 10, 0, 1, 1) for r in range(10, 11): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.digital_chunks_to_symbols_xx_1 = digital.chunks_to_symbols_bc( const.points(), 1) self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_tag_gate_0.set_single_key("") self.blocks_selector_0_0 = blocks.selector(gr.sizeof_gr_complex * 1, bFilter, 0) self.blocks_selector_0_0.set_enabled(True) self.blocks_selector_0 = blocks.selector(gr.sizeof_gr_complex * 1, N, 0) self.blocks_selector_0.set_enabled(True) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_cc( np.exp(1j * 2 * pi * phase / 360)) self.blocks_multiply_const_vxx_0_0_0 = blocks.multiply_const_cc(2) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_cc(bNoise) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(gain_) self.blocks_delay_0_2 = blocks.delay(gr.sizeof_float * 1, -N + 1024) self.blocks_delay_0_1 = blocks.delay(gr.sizeof_float * 1, sps) self.blocks_delay_0_0_1 = blocks.delay(gr.sizeof_float * 1, sps) self.blocks_delay_0_0_0_1_0 = blocks.delay(gr.sizeof_float * 1, sps) self.blocks_delay_0_0_0_1 = blocks.delay(gr.sizeof_float * 1, sps) self.blocks_delay_0_0_0_0_0 = blocks.delay(gr.sizeof_float * 1, sps) self.blocks_delay_0_0_0_0 = blocks.delay(gr.sizeof_float * 1, sps) self.blocks_delay_0_0_0 = blocks.delay(gr.sizeof_float * 1, sps) self.blocks_delay_0_0 = blocks.delay(gr.sizeof_float * 1, sps) self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, sps) self.blocks_deinterleave_0 = blocks.deinterleave( gr.sizeof_gr_complex * 1, 1) self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_random_source_x_0 = blocks.vector_source_b( list(map(int, numpy.random.randint(0, 2, 8192))), True) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, std_dev * (1.414), 0) self.analog_agc_xx_0 = analog.agc_cc(1e-4, 1.0, 1.0) self.analog_agc_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.blocks_deinterleave_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_random_source_x_0, 0), (self.digital_chunks_to_symbols_xx_1, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_complex_to_imag_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_delay_0_2, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_complex_to_real_0_0, 0), (self.qtgui_histogram_sink_x_0, 0)) self.connect((self.blocks_deinterleave_0, 4), (self.blocks_selector_0, 4)) self.connect((self.blocks_deinterleave_0, 0), (self.blocks_selector_0, 0)) self.connect((self.blocks_deinterleave_0, 2), (self.blocks_selector_0, 2)) self.connect((self.blocks_deinterleave_0, 1), (self.blocks_selector_0, 1)) self.connect((self.blocks_deinterleave_0, 5), (self.blocks_selector_0, 5)) self.connect((self.blocks_deinterleave_0, 3), (self.blocks_selector_0, 3)) self.connect((self.blocks_deinterleave_0, 7), (self.blocks_selector_0, 7)) self.connect((self.blocks_deinterleave_0, 6), (self.blocks_selector_0, 6)) self.connect((self.blocks_delay_0, 0), (self.blocks_delay_0_0, 0)) self.connect((self.blocks_delay_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blocks_delay_0_0, 0), (self.blocks_delay_0_0_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.qtgui_time_sink_x_0, 2)) self.connect((self.blocks_delay_0_0_0, 0), (self.blocks_delay_0_0_0_0, 0)) self.connect((self.blocks_delay_0_0_0, 0), (self.qtgui_time_sink_x_0, 3)) self.connect((self.blocks_delay_0_0_0_0, 0), (self.blocks_delay_0_1, 0)) self.connect((self.blocks_delay_0_0_0_0, 0), (self.qtgui_time_sink_x_0, 4)) self.connect((self.blocks_delay_0_0_0_0_0, 0), (self.blocks_delay_0_0_0_1_0, 0)) self.connect((self.blocks_delay_0_0_0_0_0, 0), (self.qtgui_time_sink_x_0, 8)) self.connect((self.blocks_delay_0_0_0_1, 0), (self.blocks_delay_0_0_0_0_0, 0)) self.connect((self.blocks_delay_0_0_0_1, 0), (self.qtgui_time_sink_x_0, 7)) self.connect((self.blocks_delay_0_0_0_1_0, 0), (self.qtgui_time_sink_x_0, 9)) self.connect((self.blocks_delay_0_0_1, 0), (self.blocks_delay_0_0_0_1, 0)) self.connect((self.blocks_delay_0_0_1, 0), (self.qtgui_time_sink_x_0, 6)) self.connect((self.blocks_delay_0_1, 0), (self.blocks_delay_0_0_1, 0)) self.connect((self.blocks_delay_0_1, 0), (self.qtgui_time_sink_x_0, 5)) self.connect((self.blocks_delay_0_2, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_delay_0_2, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0_0, 0), (self.blocks_selector_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.analog_agc_xx_0, 0)) self.connect((self.blocks_selector_0, 0), (self.blocks_complex_to_real_0_0, 0)) self.connect((self.blocks_selector_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_selector_0, 0), (self.qtgui_const_sink_x_0, 1)) self.connect((self.blocks_selector_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.blocks_complex_to_imag_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_1, 0), (self.interp_fir_filter_xxx_1, 0)) self.connect((self.digital_chunks_to_symbols_xx_1, 0), (self.interp_fir_filter_xxx_1_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_selector_0_0, 1)) self.connect((self.interp_fir_filter_xxx_1, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.interp_fir_filter_xxx_1_0, 0), (self.blocks_multiply_const_vxx_0_0_0, 0))
def __init__(self, address="addr=192.168.10.3", port=65500, noise=0, seed1=108): gr.top_block.__init__(self, "Ue") Qt.QWidget.__init__(self) self.setWindowTitle("Ue") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "UE") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.address = address self.port = port self.noise = noise self.seed1 = seed1 ################################################## # Variables ################################################## self.seed2 = seed2 = seed1 + 384 self.pilot_symbols = pilot_symbols = (( 1, 1, 1, -1, ), ) self.pilot_carriers = pilot_carriers = (( -21, -7, 7, 21, ), ) self.payload_mod = payload_mod = digital.constellation_qpsk() self.occupied_carriers = occupied_carriers = ( range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27), ) self.header_mod = header_mod = digital.constellation_bpsk() self.fft_len = fft_len = 64 self.sync_word2 = sync_word2 = [ 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 0, 0, 0, 0, 0 ] self.sync_word1 = sync_word1 = [ 0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0. ] self.seed6 = seed6 = seed1 + 4590 self.seed5 = seed5 = seed2 + 851 self.seed4 = seed4 = seed1 + 9027 self.seed3 = seed3 = seed1 + 2791 self.samp_rate = samp_rate = 500000 self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe( fft_len, payload_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 0, 1) self.packet_length_tag_key = packet_length_tag_key = "packet_len" self.packet_len = packet_len = 12 self.noise_power = noise_power = 0 self.length_tag_key = length_tag_key = "frame_len" self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe( fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 0, 1) self.h_2 = h_2 = 0 self.h_1 = h_1 = 0 self.h_0 = h_0 = 1 ################################################## # Blocks ################################################## self.s_2 = blocks.probe_signal_c() self.s_1 = blocks.probe_signal_c() self.s_0 = blocks.probe_signal_c() self.noise_variance = blocks.probe_signal_f() def _noise_power_probe(): while True: val = self.noise_variance.level() try: self.set_noise_power(val) except AttributeError: pass time.sleep(1.0 / (10)) _noise_power_thread = threading.Thread(target=_noise_power_probe) _noise_power_thread.daemon = True _noise_power_thread.start() def _h_2_probe(): while True: val = self.s_2.level() try: self.set_h_2(val) except AttributeError: pass time.sleep(1.0 / (10)) _h_2_thread = threading.Thread(target=_h_2_probe) _h_2_thread.daemon = True _h_2_thread.start() def _h_1_probe(): while True: val = self.s_1.level() try: self.set_h_1(val) except AttributeError: pass time.sleep(1.0 / (10)) _h_1_thread = threading.Thread(target=_h_1_probe) _h_1_thread.daemon = True _h_1_thread.start() def _h_0_probe(): while True: val = self.s_0.level() try: self.set_h_0(val) except AttributeError: pass time.sleep(1.0 / (10)) _h_0_thread = threading.Thread(target=_h_0_probe) _h_0_thread.daemon = True _h_0_thread.start() self.uhd_usrp_source_0 = uhd.usrp_source( ",".join((address, "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(450e6, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.uhd_usrp_source_0.set_antenna("RX2", 0) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0.enable_grid(False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) if complex == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.projectGT_variance_cc_0 = projectGT.variance_cc(5000) self.projectGT_IA_vectors_vcvc_0 = projectGT.IA_vectors_vcvc( fft_len, noise_power, 1, 2, (15, 25, 40, 45), length_tag_key) self.ofdm_rx_phase_1_0 = ofdm_rx_phase_1( pilot_symbols=pilot_symbols, header_mod=header_mod, payload_mod=payload_mod, sync_word2=sync_word2, sync_word1=sync_word1, fft_len=fft_len, packet_len=packet_len, occupied_carriers=occupied_carriers, pilot_carriers=pilot_carriers, samp_rate=samp_rate, ) self.channels_channel_model_4_0 = channels.channel_model( noise_voltage=0.1, frequency_offset=0.0, epsilon=1.0, taps=(1.0, ), noise_seed=seed6, block_tags=False) self.channels_channel_model_4 = channels.channel_model( noise_voltage=0.1, frequency_offset=0.0, epsilon=1.0, taps=(1.0, ), noise_seed=seed4, block_tags=False) self.channels_channel_model_3_0 = channels.channel_model( noise_voltage=0.05, frequency_offset=0.0, epsilon=1.0, taps=(1.0, ), noise_seed=seed5, block_tags=False) self.channels_channel_model_3 = channels.channel_model( noise_voltage=0.1, frequency_offset=0.0, epsilon=1.0, taps=(1.0, ), noise_seed=seed3, block_tags=False) self.channels_channel_model_2 = channels.channel_model( noise_voltage=0.11, frequency_offset=0.0, epsilon=1.0, taps=(1.0, ), noise_seed=seed2, block_tags=False) self.channels_channel_model_1 = channels.channel_model( noise_voltage=0.12, frequency_offset=0.0, epsilon=1.0, taps=(1.0, ), noise_seed=seed1, block_tags=False) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise, frequency_offset=0.0, epsilon=1.0, taps=((h_0, h_1, h_2)), noise_seed=0, block_tags=False) self.blocks_vector_to_stream_1 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, fft_len) self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, fft_len) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_gr_complex * 1, "134.214.146.135", port, 1472, True) self.blocks_tag_debug_3 = blocks.tag_debug(gr.sizeof_gr_complex * 1, "IA", "") self.blocks_tag_debug_3.set_display(True) self.blocks_tag_debug_1 = blocks.tag_debug( gr.sizeof_gr_complex * fft_len, "chnl_intrf", "") self.blocks_tag_debug_1.set_display(False) self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_char * 1, "Payload_intrf", "") self.blocks_tag_debug_0.set_display(False) self.blocks_null_source_3_0 = blocks.null_source(gr.sizeof_gr_complex * 1) self.blocks_null_source_3 = blocks.null_source(gr.sizeof_gr_complex * 1) self.blocks_null_source_2_0 = blocks.null_source(gr.sizeof_gr_complex * 1) self.blocks_null_source_2 = blocks.null_source(gr.sizeof_gr_complex * 1) self.blocks_null_source_1 = blocks.null_source(gr.sizeof_gr_complex * 1) self.blocks_null_source_0 = blocks.null_source(gr.sizeof_gr_complex * 1) self.blocks_float_to_complex_1_0 = blocks.float_to_complex(1) self.blocks_float_to_complex_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared( 1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_3_0 = blocks.complex_to_mag(1) self.blocks_complex_to_mag_3 = blocks.complex_to_mag(1) self.blocks_complex_to_mag_2_0 = blocks.complex_to_mag(1) self.blocks_complex_to_mag_2 = blocks.complex_to_mag(1) self.blocks_complex_to_mag_1 = blocks.complex_to_mag(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_add_const_vxx_1_0 = blocks.add_const_vcc((0.0, )) self.blocks_add_const_vxx_1 = blocks.add_const_vcc((0.1, )) self.blocks_add_const_vxx_0 = blocks.add_const_vcc((0.8, )) ################################################## # Connections ################################################## self.connect((self.blocks_add_const_vxx_0, 0), (self.s_0, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.s_1, 0)) self.connect((self.blocks_add_const_vxx_1_0, 0), (self.s_2, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_complex_to_mag_1, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_complex_to_mag_2, 0), (self.blocks_float_to_complex_1, 0)) self.connect((self.blocks_complex_to_mag_2_0, 0), (self.blocks_float_to_complex_1_0, 0)) self.connect((self.blocks_complex_to_mag_3, 0), (self.blocks_float_to_complex_1, 1)) self.connect((self.blocks_complex_to_mag_3_0, 0), (self.blocks_float_to_complex_1_0, 1)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_float_to_complex_1, 0), (self.blocks_add_const_vxx_1, 0)) self.connect((self.blocks_float_to_complex_1_0, 0), (self.blocks_add_const_vxx_1_0, 0)) self.connect((self.blocks_null_source_0, 0), (self.channels_channel_model_1, 0)) self.connect((self.blocks_null_source_1, 0), (self.channels_channel_model_2, 0)) self.connect((self.blocks_null_source_2, 0), (self.channels_channel_model_3, 0)) self.connect((self.blocks_null_source_2_0, 0), (self.channels_channel_model_3_0, 0)) self.connect((self.blocks_null_source_3, 0), (self.channels_channel_model_4, 0)) self.connect((self.blocks_null_source_3_0, 0), (self.channels_channel_model_4_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.blocks_vector_to_stream_1, 0), (self.blocks_complex_to_mag_squared_0_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.ofdm_rx_phase_1_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.projectGT_variance_cc_0, 0)) self.connect((self.channels_channel_model_1, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.channels_channel_model_2, 0), (self.blocks_complex_to_mag_1, 0)) self.connect((self.channels_channel_model_3, 0), (self.blocks_complex_to_mag_2, 0)) self.connect((self.channels_channel_model_3_0, 0), (self.blocks_complex_to_mag_2_0, 0)) self.connect((self.channels_channel_model_4, 0), (self.blocks_complex_to_mag_3, 0)) self.connect((self.channels_channel_model_4_0, 0), (self.blocks_complex_to_mag_3_0, 0)) self.connect((self.ofdm_rx_phase_1_0, 2), (self.blocks_tag_debug_0, 0)) self.connect((self.ofdm_rx_phase_1_0, 0), (self.blocks_tag_debug_1, 0)) self.connect((self.ofdm_rx_phase_1_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.ofdm_rx_phase_1_0, 1), (self.blocks_vector_to_stream_1, 0)) self.connect((self.projectGT_IA_vectors_vcvc_0, 0), (self.blocks_tag_debug_3, 0)) self.connect((self.projectGT_IA_vectors_vcvc_0, 0), (self.blocks_udp_sink_0, 0)) self.connect((self.projectGT_variance_cc_0, 0), (self.noise_variance, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.ofdm_rx_phase_1_0, 1), (self.projectGT_IA_vectors_vcvc_0, 0)) self.connect((self.ofdm_rx_phase_1_0, 0), (self.projectGT_IA_vectors_vcvc_0, 1))
def __init__(self, Filename="/Users/yuwang/gnuradio/Workspace/MyGraph/FFT/freq_sign"): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.Filename = Filename ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if complex == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 1000, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.qtgui_freq_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.down_sampling = down_sampling = 16 self.sample_rate = sample_rate = 250e3 * down_sampling self.freq_slider = freq_slider = 500e3 self.f1_bp_taps = f1_bp_taps = [ -0.0034913108684122562, 0.016121335327625275, -0.030533839017152786, 0.01881207898259163, 0.043789319694042206, -0.12244637310504913, 0.13050289452075958, -0.020888589322566986, -0.1393565535545349, 0.21573688089847565, -0.1393565535545349, -0.020888589322566986, 0.13050289452075958, -0.12244637310504913, 0.043789319694042206, 0.01881207898259163, -0.030533839017152786, 0.016121335327625275, -0.0034913108684122562 ] self.f0_bp_taps = f0_bp_taps = [ 0.009907027706503868, 0.01748894527554512, 0.0200509000569582, -0.00631917268037796, -0.06848347187042236, -0.12408018857240677, -0.10601181536912918, 0.006915525533258915, 0.14913780987262726, 0.21388313174247742, 0.14913780987262726, 0.006915525533258915, -0.10601181536912918, -0.12408018857240677, -0.06848347187042236, -0.00631917268037796, 0.0200509000569582, 0.01748894527554512, 0.009907027706503868 ] ################################################## # Blocks ################################################## self._freq_slider_range = Range(100e3, 2e6, 100, 500e3, 200) self._freq_slider_win = RangeWidget(self._freq_slider_range, self.set_freq_slider, "freq_slider", "counter_slider", float) self.top_layout.addWidget(self._freq_slider_win) self.rad1o_id_compare_select_fb_0 = rad1o_id.compare_select_fb() self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_char, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ["", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_win) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc sample_rate / down_sampling, #bw "", #name 2 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1.disable_legend() if complex == type(float()): self.qtgui_freq_sink_x_1.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance( self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_1_win) self.fir_filter_xxx_0_0 = filter.fir_filter_ccc( down_sampling, (f1_bp_taps)) self.fir_filter_xxx_0_0.declare_sample_delay(0) self.fir_filter_xxx_0 = filter.fir_filter_ccc(down_sampling, (f0_bp_taps)) self.fir_filter_xxx_0.declare_sample_delay(0) self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared( 1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.analog_sig_source_x_0 = analog.sig_source_c( sample_rate, analog.GR_COS_WAVE, freq_slider, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.fir_filter_xxx_0_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.rad1o_id_compare_select_fb_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0_0, 0), (self.rad1o_id_compare_select_fb_0, 1)) self.connect((self.fir_filter_xxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.fir_filter_xxx_0_0, 0), (self.blocks_complex_to_mag_squared_0_0, 0)) self.connect((self.fir_filter_xxx_0_0, 0), (self.qtgui_freq_sink_x_1, 1)) self.connect((self.rad1o_id_compare_select_fb_0, 0), (self.qtgui_number_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 14250000 self.packet_len = packet_len = 2**21 self.freq_res = freq_res = samp_rate/float(packet_len) self.freq = freq = (-6000000,6000000) self.center_freq = center_freq = 2.45e9 self.v_res = v_res = freq_res*3e8/2/center_freq self.time_res = time_res = packet_len/float(samp_rate) self.threshold = threshold = -50 self.samp_protect = samp_protect = 1 self.range_time = range_time = 30 self.range_res = range_res = 3e8/2/float((freq[1]-freq[0])) self.range_add = range_add = -1 self.min_output_buffer = min_output_buffer = int(packet_len*2) self.max_output_buffer = max_output_buffer = 0 self.gain_tx = gain_tx = 40 self.gain_rx = gain_rx = 20 self.delay_samp = delay_samp = 28 self.decim_fac = decim_fac = 2**10 self.amplitude = amplitude = 0.5 ################################################## # Blocks ################################################## self._threshold_layout = Qt.QVBoxLayout() self._threshold_tool_bar = Qt.QToolBar(self) self._threshold_layout.addWidget(self._threshold_tool_bar) self._threshold_tool_bar.addWidget(Qt.QLabel("Find peak threshold"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._threshold_counter = qwt_counter_pyslot() self._threshold_counter.setRange(-200, 100, 1) self._threshold_counter.setNumButtons(2) self._threshold_counter.setValue(self.threshold) self._threshold_tool_bar.addWidget(self._threshold_counter) self._threshold_counter.valueChanged.connect(self.set_threshold) self._threshold_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._threshold_slider.setRange(-200, 100, 1) self._threshold_slider.setValue(self.threshold) self._threshold_slider.setMinimumWidth(200) self._threshold_slider.valueChanged.connect(self.set_threshold) self._threshold_layout.addWidget(self._threshold_slider) self.top_grid_layout.addLayout(self._threshold_layout, 1,0) self._samp_protect_layout = Qt.QVBoxLayout() self._samp_protect_tool_bar = Qt.QToolBar(self) self._samp_protect_layout.addWidget(self._samp_protect_tool_bar) self._samp_protect_tool_bar.addWidget(Qt.QLabel("Find peak protected samples"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._samp_protect_counter = qwt_counter_pyslot() self._samp_protect_counter.setRange(0, 10, 1) self._samp_protect_counter.setNumButtons(2) self._samp_protect_counter.setValue(self.samp_protect) self._samp_protect_tool_bar.addWidget(self._samp_protect_counter) self._samp_protect_counter.valueChanged.connect(self.set_samp_protect) self._samp_protect_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._samp_protect_slider.setRange(0, 10, 1) self._samp_protect_slider.setValue(self.samp_protect) self._samp_protect_slider.setMinimumWidth(200) self._samp_protect_slider.valueChanged.connect(self.set_samp_protect) self._samp_protect_layout.addWidget(self._samp_protect_slider) self.top_grid_layout.addLayout(self._samp_protect_layout, 1,1) self._range_add_layout = Qt.QVBoxLayout() self._range_add_tool_bar = Qt.QToolBar(self) self._range_add_layout.addWidget(self._range_add_tool_bar) self._range_add_tool_bar.addWidget(Qt.QLabel("Add range"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._range_add_counter = qwt_counter_pyslot() self._range_add_counter.setRange(-range_res, range_res, 0.1) self._range_add_counter.setNumButtons(2) self._range_add_counter.setValue(self.range_add) self._range_add_tool_bar.addWidget(self._range_add_counter) self._range_add_counter.valueChanged.connect(self.set_range_add) self._range_add_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._range_add_slider.setRange(-range_res, range_res, 0.1) self._range_add_slider.setValue(self.range_add) self._range_add_slider.setMinimumWidth(200) self._range_add_slider.valueChanged.connect(self.set_range_add) self._range_add_layout.addWidget(self._range_add_slider) self.top_grid_layout.addLayout(self._range_add_layout, 2,1) self._gain_tx_layout = Qt.QVBoxLayout() self._gain_tx_tool_bar = Qt.QToolBar(self) self._gain_tx_layout.addWidget(self._gain_tx_tool_bar) self._gain_tx_tool_bar.addWidget(Qt.QLabel("TX gain"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._gain_tx_counter = qwt_counter_pyslot() self._gain_tx_counter.setRange(0, 100, 1) self._gain_tx_counter.setNumButtons(2) self._gain_tx_counter.setValue(self.gain_tx) self._gain_tx_tool_bar.addWidget(self._gain_tx_counter) self._gain_tx_counter.valueChanged.connect(self.set_gain_tx) self._gain_tx_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._gain_tx_slider.setRange(0, 100, 1) self._gain_tx_slider.setValue(self.gain_tx) self._gain_tx_slider.setMinimumWidth(200) self._gain_tx_slider.valueChanged.connect(self.set_gain_tx) self._gain_tx_layout.addWidget(self._gain_tx_slider) self.top_grid_layout.addLayout(self._gain_tx_layout, 0,0) self._gain_rx_layout = Qt.QVBoxLayout() self._gain_rx_tool_bar = Qt.QToolBar(self) self._gain_rx_layout.addWidget(self._gain_rx_tool_bar) self._gain_rx_tool_bar.addWidget(Qt.QLabel("RX gain"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._gain_rx_counter = qwt_counter_pyslot() self._gain_rx_counter.setRange(0, 100, 1) self._gain_rx_counter.setNumButtons(2) self._gain_rx_counter.setValue(self.gain_rx) self._gain_rx_tool_bar.addWidget(self._gain_rx_counter) self._gain_rx_counter.valueChanged.connect(self.set_gain_rx) self._gain_rx_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._gain_rx_slider.setRange(0, 100, 1) self._gain_rx_slider.setValue(self.gain_rx) self._gain_rx_slider.setMinimumWidth(200) self._gain_rx_slider.valueChanged.connect(self.set_gain_rx) self._gain_rx_layout.addWidget(self._gain_rx_slider) self.top_grid_layout.addLayout(self._gain_rx_layout, 0,1) self._delay_samp_layout = Qt.QVBoxLayout() self._delay_samp_tool_bar = Qt.QToolBar(self) self._delay_samp_layout.addWidget(self._delay_samp_tool_bar) self._delay_samp_tool_bar.addWidget(Qt.QLabel("Number delay samples"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._delay_samp_counter = qwt_counter_pyslot() self._delay_samp_counter.setRange(0, 100, 1) self._delay_samp_counter.setNumButtons(2) self._delay_samp_counter.setValue(self.delay_samp) self._delay_samp_tool_bar.addWidget(self._delay_samp_counter) self._delay_samp_counter.valueChanged.connect(self.set_delay_samp) self._delay_samp_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._delay_samp_slider.setRange(0, 100, 1) self._delay_samp_slider.setValue(self.delay_samp) self._delay_samp_slider.setMinimumWidth(200) self._delay_samp_slider.valueChanged.connect(self.set_delay_samp) self._delay_samp_layout.addWidget(self._delay_samp_slider) self.top_grid_layout.addLayout(self._delay_samp_layout, 2,0) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim_fac, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim_fac, taps=None, fractional_bw=None, ) self.radar_usrp_echotimer_cc_0 = radar.usrp_echotimer_cc(samp_rate, center_freq, int(delay_samp), 'addr=192.168.10.4', '', 'internal', 'none', 'J1', gain_tx, 0.1, 0.05, 0, 'addr=192.168.10.6', '', 'mimo', 'mimo', 'J1', gain_rx, 0.1, 0.05, 0, "packet_len") (self.radar_usrp_echotimer_cc_0).set_min_output_buffer(4194304) self.radar_ts_fft_cc_0_0 = radar.ts_fft_cc(packet_len/decim_fac, "packet_len") (self.radar_ts_fft_cc_0_0).set_min_output_buffer(4194304) self.radar_ts_fft_cc_0 = radar.ts_fft_cc(packet_len/decim_fac, "packet_len") (self.radar_ts_fft_cc_0).set_min_output_buffer(4194304) self.radar_tracking_singletarget_0 = radar.tracking_singletarget(300, 0.5, 0.3, 0.1, 0.001, 1, 'particle') self.radar_signal_generator_cw_c_0_0 = radar.signal_generator_cw_c(packet_len, samp_rate, (freq[1], ), amplitude, "packet_len") (self.radar_signal_generator_cw_c_0_0).set_min_output_buffer(4194304) self.radar_signal_generator_cw_c_0 = radar.signal_generator_cw_c(packet_len, samp_rate, (freq[0], ), amplitude, "packet_len") (self.radar_signal_generator_cw_c_0).set_min_output_buffer(4194304) self.radar_qtgui_time_plot_1_0 = radar.qtgui_time_plot(100, 'velocity', (-3,3), range_time, 'TRACKING') self.radar_qtgui_time_plot_1 = radar.qtgui_time_plot(100, 'velocity', (-3,3), range_time, "") self.radar_qtgui_time_plot_0_0 = radar.qtgui_time_plot(100, 'range', (0,range_res), range_time, 'TRACKING') self.radar_qtgui_time_plot_0 = radar.qtgui_time_plot(100, 'range', (0,range_res), range_time, "") self.radar_print_results_0 = radar.print_results(False, "") self.radar_msg_manipulator_0 = radar.msg_manipulator(('range',), (range_add, ), (1, )) self.radar_find_max_peak_c_0 = radar.find_max_peak_c(samp_rate/decim_fac, threshold, int(samp_protect), ((-300,300)), True, "packet_len") self.radar_estimator_fsk_0 = radar.estimator_fsk(center_freq, (freq[1]-freq[0]), False) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( packet_len/decim_fac, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate/decim_fac, #bw "QT GUI Plot", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.blocks_tagged_stream_multiply_length_0_0 = blocks.tagged_stream_multiply_length(gr.sizeof_gr_complex*1, "packet_len", 1.0/float(decim_fac)) (self.blocks_tagged_stream_multiply_length_0_0).set_min_output_buffer(4194304) self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(gr.sizeof_gr_complex*1, "packet_len", 1.0/float(decim_fac)) (self.blocks_tagged_stream_multiply_length_0).set_min_output_buffer(4194304) self.blocks_multiply_conjugate_cc_1 = blocks.multiply_conjugate_cc(1) (self.blocks_multiply_conjugate_cc_1).set_min_output_buffer(4194304) self.blocks_multiply_conjugate_cc_0_0 = blocks.multiply_conjugate_cc(1) (self.blocks_multiply_conjugate_cc_0_0).set_min_output_buffer(4194304) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) (self.blocks_multiply_conjugate_cc_0).set_min_output_buffer(4194304) self.blocks_add_xx_1 = blocks.add_vcc(1) (self.blocks_add_xx_1).set_min_output_buffer(4194304) ################################################## # Connections ################################################## self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.radar_ts_fft_cc_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0_0, 0), (self.radar_ts_fft_cc_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_tagged_stream_multiply_length_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.blocks_multiply_conjugate_cc_1, 0), (self.radar_find_max_peak_c_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.radar_usrp_echotimer_cc_0, 0)) self.connect((self.radar_usrp_echotimer_cc_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.radar_usrp_echotimer_cc_0, 0), (self.blocks_multiply_conjugate_cc_0_0, 0)) self.connect((self.radar_signal_generator_cw_c_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.radar_signal_generator_cw_c_0_0, 0), (self.blocks_multiply_conjugate_cc_0_0, 1)) self.connect((self.radar_signal_generator_cw_c_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.radar_signal_generator_cw_c_0_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.radar_ts_fft_cc_0, 0), (self.blocks_multiply_conjugate_cc_1, 0)) self.connect((self.radar_ts_fft_cc_0_0, 0), (self.blocks_multiply_conjugate_cc_1, 1)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.radar_find_max_peak_c_0, "Msg out", self.radar_estimator_fsk_0, "Msg in") self.msg_connect(self.radar_estimator_fsk_0, "Msg out", self.radar_msg_manipulator_0, "Msg in") self.msg_connect(self.radar_msg_manipulator_0, "Msg out", self.radar_print_results_0, "Msg in") self.msg_connect(self.radar_msg_manipulator_0, "Msg out", self.radar_qtgui_time_plot_0, "Msg in") self.msg_connect(self.radar_msg_manipulator_0, "Msg out", self.radar_qtgui_time_plot_1, "Msg in") self.msg_connect(self.radar_tracking_singletarget_0, "Msg out", self.radar_qtgui_time_plot_0_0, "Msg in") self.msg_connect(self.radar_tracking_singletarget_0, "Msg out", self.radar_qtgui_time_plot_1_0, "Msg in") self.msg_connect(self.radar_msg_manipulator_0, "Msg out", self.radar_tracking_singletarget_0, "Msg in")
def __init__(self): gr.top_block.__init__(self, "selector") Qt.QWidget.__init__(self) self.setWindowTitle("selector") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.uiselector = uiselector = 0 self.samp_rate = samp_rate = 100000 ################################################## # Blocks ################################################## self._uiselector_options = ( 0, 1, ) self._uiselector_labels = ( 'Sound card', 'Signal source', ) self._uiselector_tool_bar = Qt.QToolBar(self) self._uiselector_tool_bar.addWidget(Qt.QLabel('Source selector' + ": ")) self._uiselector_combo_box = Qt.QComboBox() self._uiselector_tool_bar.addWidget(self._uiselector_combo_box) for label in self._uiselector_labels: self._uiselector_combo_box.addItem(label) self._uiselector_callback = lambda i: Qt.QMetaObject.invokeMethod( self._uiselector_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._uiselector_options.index(i))) self._uiselector_callback(self.uiselector) self._uiselector_combo_box.currentIndexChanged.connect( lambda i: self.set_uiselector(self._uiselector_options[i])) self.top_layout.addWidget(self._uiselector_tool_bar) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex * 1, num_inputs=2, num_outputs=1, input_index=uiselector, output_index=0, ) self.audio_source_0 = audio.source(samp_rate, '', True) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 1000, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.audio_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blks2_selector_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blks2_selector_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blks2_selector_0, 1))