def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.wxgui_scopesink2_0_0 = scopesink2.scope_sink_f( self.GetWin(), title='Scope Plot', sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label='Counts', ) self.Add(self.wxgui_scopesink2_0_0.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title='Scope Plot', sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label='Counts', ) self.Add(self.wxgui_scopesink2_0.win) self.channels_quantizer_0 = channels.quantizer(2) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True) self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1000, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.channels_quantizer_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.wxgui_scopesink2_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.channels_quantizer_0, 0), (self.blocks_throttle_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 = 64000 self.n = n = 1 ################################################## # Blocks ################################################## self._n_range = Range(1, 16, 1, 1, 200) self._n_win = RangeWidget(self._n_range, self.set_n, "n", "counter_slider", float) self.top_grid_layout.addWidget(self._n_win) self.aba = Qt.QTabWidget() self.aba_widget_0 = Qt.QWidget() self.aba_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.aba_widget_0) self.aba_grid_layout_0 = Qt.QGridLayout() self.aba_layout_0.addLayout(self.aba_grid_layout_0) self.aba.addTab(self.aba_widget_0, 'Time') self.aba_widget_1 = Qt.QWidget() self.aba_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.aba_widget_1) self.aba_grid_layout_1 = Qt.QGridLayout() self.aba_layout_1.addLayout(self.aba_grid_layout_1) self.aba.addTab(self.aba_widget_1, 'Freq') self.aba_widget_2 = Qt.QWidget() self.aba_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.aba_widget_2) self.aba_grid_layout_2 = Qt.QGridLayout() self.aba_layout_2.addLayout(self.aba_grid_layout_2) self.aba.addTab(self.aba_widget_2, 'RSR') self.top_grid_layout.addWidget(self.aba) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Sinais no Tempo", #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(True) self.qtgui_time_sink_x_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ['x(t)', 'x^(kTs)', 'x^(t)', '', '', '', '', '', '', ''] 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.aba_grid_layout_0.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Erro de Quant.", #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) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['q(kTs)', '', '', '', '', '', '', '', '', ''] 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.aba_grid_layout_2.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 2 ) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("RSR da Quant.") labels = ['RSR_q', 'Pot_x', '', '', '', '', '', '', '', ''] 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(2): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 100) 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.aba_grid_layout_2.addWidget(self._qtgui_number_sink_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 3 #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(True) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "float" == "float" or "float" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['x(t)', 'x^(kTs)', 'x^(t)', '', '', '', '', '', '', ''] 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(3): 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.aba_grid_layout_1.addWidget(self._qtgui_freq_sink_x_0_win) self.low_pass_filter_0 = filter.fir_filter_fff(1, firdes.low_pass( 1, samp_rate, 4000, 500, firdes.WIN_HAMMING, 6.76)) self.channels_quantizer_0 = channels.quantizer(n) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_rms_xx_0_0 = blocks.rms_ff(0.0001) self.blocks_rms_xx_0 = blocks.rms_ff(0.0001) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(20, 1, 0) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.analog_sig_source_x_0_1_1 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 3000, 0.2, 0) self.analog_sig_source_x_0_1_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 2400, 0.2, 0) self.analog_sig_source_x_0_1 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1800, 0.2, 0) self.analog_sig_source_x_0_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1200, 0.2, 0) self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 600, 0.2, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_sig_source_x_0_1, 0), (self.blocks_add_xx_0, 2)) self.connect((self.analog_sig_source_x_0_1_0, 0), (self.blocks_add_xx_0, 3)) self.connect((self.analog_sig_source_x_0_1_1, 0), (self.blocks_add_xx_0, 4)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.qtgui_number_sink_0, 1)) self.connect((self.blocks_rms_xx_0_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_sub_xx_0, 0), (self.blocks_rms_xx_0_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.channels_quantizer_0, 0)) self.connect((self.channels_quantizer_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.channels_quantizer_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.channels_quantizer_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.channels_quantizer_0, 0), (self.qtgui_time_sink_x_1, 1)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_0, 2)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_time_sink_x_1, 2))
def __init__(self): gr.top_block.__init__(self, "Quantization") Qt.QWidget.__init__(self) self.setWindowTitle("Quantization") 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", "quantization") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 100000 self.signal_amp = signal_amp = -150 self.sigfreq = sigfreq = samp_rate * 1.0247385 / 11.0 self.noise_amp = noise_amp = -150 self.center = center = samp_rate / 11.0 self.bw = bw = samp_rate / 2 self.bits = bits = 2 ################################################## # Blocks ################################################## self._signal_amp_range = Range(-150, 20, 5, -150, 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 * 1.0247385 / 11.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._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._center_range = Range(0, samp_rate / 2, 100, samp_rate / 11.0, 200) self._center_win = RangeWidget(self._center_range, self.set_center, 'Center Freq', "counter_slider", float) self.top_grid_layout.addWidget(self._center_win, 3, 1, 1, 1) self._bw_range = Range(samp_rate / 100.0, samp_rate / 2, 100, samp_rate / 2, 200) self._bw_win = RangeWidget(self._bw_range, self.set_bw, 'BW', "counter_slider", float) self.top_grid_layout.addWidget(self._bw_win, 4, 1, 1, 1) self._bits_options = [2, 4, 6, 8, 10, 12, 14, 16] self._bits_labels = map(str, self._bits_options) self._bits_tool_bar = Qt.QToolBar(self) self._bits_tool_bar.addWidget(Qt.QLabel('Bits' + ": ")) self._bits_combo_box = Qt.QComboBox() self._bits_tool_bar.addWidget(self._bits_combo_box) for label in self._bits_labels: self._bits_combo_box.addItem(label) self._bits_callback = lambda i: Qt.QMetaObject.invokeMethod( self._bits_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._bits_options.index(i))) self._bits_callback(self.bits) self._bits_combo_box.currentIndexChanged.connect( lambda i: self.set_bits(self._bits_options[i])) self.top_grid_layout.addWidget(self._bits_tool_bar, 4, 0, 1, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 128, #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(-bits, bits) 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, 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 = [2, 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 = [0, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [0.5, 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, 1, 0, 1, 2) self.qtgui_histogram_sink_x_0 = qtgui.histogram_sink_f( 10000, 100, -1 - pow(2, bits - 1), 1 + pow(2, bits - 1), '', 1) self.qtgui_histogram_sink_x_0.set_update_time(0.10) 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(False) self.qtgui_histogram_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_histogram_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" ] 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_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.top_grid_layout.addWidget(self._qtgui_histogram_sink_x_0_win, 0, 1, 1, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( 2048, #size firdes.WIN_FLATTOP, #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(-180, 0) 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 "float" == "float" or "float" == "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, 0, 1, 1) self.channels_quantizer_0 = channels.quantizer(bits) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((1, )) self.blocks_add_xx_0 = blocks.add_vff(1) self.band_pass_filter_0 = filter.fir_filter_fff( 1, firdes.band_pass( 1, samp_rate, max(bw / 15.0, center - bw / 2.0), min(samp_rate / 2.0 - bw / 15.0, center + bw / 2.0), bw / 5.0, firdes.WIN_HANN, 6.76)) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, sigfreq, pow(10.0, signal_amp / 20.0), 0) self.analog_noise_source_x_0 = analog.noise_source_f( analog.GR_GAUSSIAN, pow(10.0, noise_amp / 20.0), 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.band_pass_filter_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_histogram_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.channels_quantizer_0, 0)) self.connect((self.channels_quantizer_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.channels_quantizer_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") 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 = 10000 self.atraso = atraso = 190 self.K = K = 1000 ################################################## # Blocks ################################################## self._atraso_range = Range(0, 200, 1, 190, 200) self._atraso_win = RangeWidget(self._atraso_range, self.set_atraso, "atraso", "counter_slider", float) self.top_grid_layout.addWidget(self._atraso_win, 3, 0, 1, 1) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._K_range = Range(0, 2000, 1, 1000, 200) self._K_win = RangeWidget(self._K_range, self.set_K, "K", "counter_slider", float) self.top_grid_layout.addWidget(self._K_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_time_sink_x_1_0 = qtgui.time_sink_f( 512, #size samp_rate, #samp_rate "DPCM", #name 3 #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 = ['RX', 'TX', 'erro', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "black", "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_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.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_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_f( 512, #size samp_rate, #samp_rate "PCM", #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) self.qtgui_time_sink_x_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ['RX', 'TX', 'erro', '', '', '', '', '', '', ''] 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.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_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.qtgui_time_sink_x_0 = qtgui.time_sink_f( 512, #size samp_rate, #samp_rate "Residuos", #name 2 #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) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['Delta[k]', 'Delta_quant[k]', '', '', '', '', '', '', '', ''] 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, 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_number_sink_0_0 = qtgui.number_sink( gr.sizeof_float, 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("SNR PCM") 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, -1) self.qtgui_number_sink_0_0.set_max(i, 1) 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_grid_layout.addWidget(self._qtgui_number_sink_0_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.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("SNR DPCM") 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, 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 = qtgui.const_sink_c( 1024, #size "Quantizador", #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.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.iir_filter_xxx_0 = filter.iir_filter_ffd(([1.0/K]), ([1.0, -1.99, 0.990025]), False) self.fir_filter_xxx_0 = filter.fir_filter_fff(1, (0,2,-1)) self.fir_filter_xxx_0.declare_sample_delay(0) self.channels_quantizer_0_0 = channels.quantizer(3) self.channels_quantizer_0 = channels.quantizer(7) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True) self.blocks_sub_xx_2 = blocks.sub_ff(1) self.blocks_sub_xx_1 = blocks.sub_ff(1) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_rms_xx_0_1 = blocks.rms_ff(0.0001) self.blocks_rms_xx_0_0_0 = blocks.rms_ff(0.0001) self.blocks_rms_xx_0_0 = blocks.rms_ff(0.0001) self.blocks_rms_xx_0 = blocks.rms_ff(0.0001) self.blocks_nlog10_ff_0_0 = blocks.nlog10_ff(20, 1, 0) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(20, 1, 0) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((K, )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_divide_xx_0_0 = blocks.divide_ff(1) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, atraso) self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 50, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_sub_xx_2, 1)) self.connect((self.blocks_delay_0, 0), (self.qtgui_time_sink_x_1_0, 1)) self.connect((self.blocks_divide_xx_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_divide_xx_0_0, 0), (self.blocks_nlog10_ff_0_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.channels_quantizer_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_nlog10_ff_0_0, 0), (self.qtgui_number_sink_0_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.blocks_rms_xx_0_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_rms_xx_0_0_0, 0), (self.blocks_divide_xx_0_0, 1)) self.connect((self.blocks_rms_xx_0_1, 0), (self.blocks_divide_xx_0_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_sub_xx_1, 0), (self.blocks_rms_xx_0_0_0, 0)) self.connect((self.blocks_sub_xx_1, 0), (self.qtgui_time_sink_x_1, 2)) self.connect((self.blocks_sub_xx_2, 0), (self.blocks_rms_xx_0_0, 0)) self.connect((self.blocks_sub_xx_2, 0), (self.qtgui_time_sink_x_1_0, 2)) self.connect((self.blocks_throttle_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_rms_xx_0_1, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_sub_xx_1, 0)) self.connect((self.blocks_throttle_0, 0), (self.channels_quantizer_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_time_sink_x_1, 1)) self.connect((self.channels_quantizer_0, 0), (self.blocks_sub_xx_1, 1)) self.connect((self.channels_quantizer_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.channels_quantizer_0_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.channels_quantizer_0_0, 0), (self.iir_filter_xxx_0, 0)) self.connect((self.channels_quantizer_0_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.fir_filter_xxx_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.iir_filter_xxx_0, 0), (self.blocks_sub_xx_2, 0)) self.connect((self.iir_filter_xxx_0, 0), (self.qtgui_time_sink_x_1_0, 0))
def __init__(self): gr.top_block.__init__(self, "quantizer") Qt.QWidget.__init__(self) self.setWindowTitle("quantizer") 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", "Quantizer") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 256e3 self.res = res = 8 self.freq = freq = 1e3 ################################################## # Blocks ################################################## self._res_options = [2, 3, 4, 5, 6, 7, 8, 12, 16] self._res_labels = [ "2 bits", "3 bits", "4 bits", "5 bits", "6 bits", "7bits", "8 bits", "12 bits", "16 bits" ] self._res_group_box = Qt.QGroupBox('Resolution') self._res_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._res_button_group = variable_chooser_button_group() self._res_group_box.setLayout(self._res_box) for i, label in enumerate(self._res_labels): radio_button = Qt.QRadioButton(label) self._res_box.addWidget(radio_button) self._res_button_group.addButton(radio_button, i) self._res_callback = lambda i: Qt.QMetaObject.invokeMethod( self._res_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._res_options.index(i))) self._res_callback(self.res) self._res_button_group.buttonClicked[int].connect( lambda i: self.set_res(self._res_options[i])) self.top_grid_layout.addWidget(self._res_group_box, 0, 0, 1, 1) self._freq_range = Range(100, samp_rate / 2.0, 10, 1e3, 200) self._freq_win = RangeWidget(self._freq_range, self.set_freq, 'Frequency', "counter_slider", float) self.top_grid_layout.addWidget(self._freq_win, 1, 0, 1, 1) 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(-0.1, 0.1) self.qtgui_time_sink_x_0_0.set_y_label('Quantization error', "") 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 = ['Quantized ', 'Analog', '', '', '', '', '', '', '', ''] widths = [2, 2, 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, 4, 0, 1, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 2 #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 = ['Quantized ', 'Analog', '', '', '', '', '', '', '', ''] widths = [2, 2, 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, 2, 0, 1, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( 2048, #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 "float" == "float" or "float" == "msg_float": self.qtgui_freq_sink_x_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_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, 1) self.channels_quantizer_0 = channels.quantizer(res) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, freq, 0.9, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.channels_quantizer_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blocks_sub_xx_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.channels_quantizer_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.channels_quantizer_0, 0), (self.blocks_throttle_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.C_1 = C_1 = np.array([ 0.0000, 0.0001, 0.0002, 0.0001, -0.0000, -0.0001, -0.0002, -0.0002, 0.0000, 0.0002, 0.0003, 0.0002, -0.0000, -0.0003, -0.0005, -0.0004, 0.0000, 0.0005, 0.0008, 0.0007, -0.0000, -0.0009, -0.0015, -0.0013, 0.0000, 0.0019, 0.0033, 0.0030, -0.0000, -0.0051, -0.0099, -0.0101, 0.0000, 0.0255, 0.0693, 0.1307, 0.2041, 0.2800, 0.3465, 0.3921, 0.4082, 0.3921, 0.3465, 0.2800, 0.2041, 0.1307, 0.0693, 0.0255, 0.0000, -0.0101, -0.0099, -0.0051, -0.0000, 0.0030, 0.0033, 0.0019, 0.0000, -0.0013, -0.0015, -0.0009, -0.0000, 0.0007, 0.0008, 0.0005, 0.0000, -0.0004, -0.0005, -0.0003, -0.0000, 0.0002, 0.0003, 0.0002, 0.0000, -0.0002, -0.0002, -0.0001, -0.0000, 0.0001, 0.0002, 0.0001, 0.0000 ]) / 0.4082 self.samp_rate = samp_rate = 10000 self.Sigma = Sigma = 0 self.R_RZ = R_RZ = 4 * [1] + 4 * [0] self.R_NRZ = R_NRZ = 8 * [1] self.NPTS = NPTS = 8 self.Iterp_rate = Iterp_rate = len(C_1) self.C_3 = C_3 = np.array([ 0.0000, 0.0071, 0.0137, 0.0186, 0.0209, 0.0201, 0.0160, 0.0090, -0.0000, -0.0098, -0.0188, -0.0257, -0.0290, -0.0281, -0.0225, -0.0128, 0.0000, 0.0141, 0.0273, 0.0377, 0.0431, 0.0421, 0.0342, 0.0197, -0.0000, -0.0226, -0.0448, -0.0633, -0.0746, -0.0754, -0.0637, -0.0384, 0.0000, 0.0496, 0.1071, 0.1682, 0.2279, 0.2810, 0.3229, 0.3496, 0.3588, 0.3496, 0.3229, 0.2810, 0.2279, 0.1682, 0.1071, 0.0496, 0.0000, -0.0384, -0.0637, -0.0754, -0.0746, -0.0633, -0.0448, -0.0226, -0.0000, 0.0197, 0.0342, 0.0421, 0.0431, 0.0377, 0.0273, 0.0141, 0.0000, -0.0128, -0.0225, -0.0281, -0.0290, -0.0257, -0.0188, -0.0098, -0.0000, 0.0090, 0.0160, 0.0201, 0.0209, 0.0186, 0.0137, 0.0071, 0.0000 ]) / 0.3588 self.C_2 = C_2 = np.array([ 0.0000, -0.0001, -0.0003, -0.0007, -0.0010, -0.0012, -0.0011, -0.0007, 0.0000, 0.0008, 0.0016, 0.0021, 0.0022, 0.0018, 0.0010, 0.0003, 0.0000, 0.0004, 0.0018, 0.0040, 0.0065, 0.0084, 0.0086, 0.0060, -0.0000, -0.0096, -0.0218, -0.0347, -0.0454, -0.0504, -0.0463, -0.0301, 0.0000, 0.0438, 0.0992, 0.1621, 0.2269, 0.2868, 0.3353, 0.3670, 0.3780, 0.3670, 0.3353, 0.2868, 0.2269, 0.1621, 0.0992, 0.0438, 0.0000, -0.0301, -0.0463, -0.0504, -0.0454, -0.0347, -0.0218, -0.0096, -0.0000, 0.0060, 0.0086, 0.0084, 0.0065, 0.0040, 0.0018, 0.0004, 0.0000, 0.0003, 0.0010, 0.0018, 0.0022, 0.0021, 0.0016, 0.0008, 0.0000, -0.0007, -0.0011, -0.0012, -0.0010, -0.0007, -0.0003, -0.0001, 0.0000 ]) / 0.3780 ################################################## # Blocks ################################################## self._Sigma_range = Range(0, 2, 0.02, 0, 200) self._Sigma_win = RangeWidget(self._Sigma_range, self.set_Sigma, "Sigma", "counter_slider", float) self.top_grid_layout.addWidget(self._Sigma_win, 3, 0, 1, 3) for r in range(3, 4): 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_2 = qtgui.time_sink_f( 81, #size samp_rate * NPTS * 8, #samp_rate "Diagrama de olho", #name 10 #number of inputs ) self.qtgui_time_sink_x_0_2.set_update_time(0.10) self.qtgui_time_sink_x_0_2.set_y_axis(-1.25, 1.25) self.qtgui_time_sink_x_0_2.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_2.enable_tags(-1, 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) if not True: self.qtgui_time_sink_x_0_2.disable_legend() labels = ['Cod Polar', 'Pulsos TX', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "black", "black", "black", "black", "black", "black", "black", "black", "black", "black" ] 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(10): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_2.set_line_label( i, "Data {0}".format(i)) 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.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_2_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_1_1 = qtgui.time_sink_f( 512, #size samp_rate, #samp_rate "Mensagens", #name 3 #number of inputs ) self.qtgui_time_sink_x_0_1_1.set_update_time(0.10) self.qtgui_time_sink_x_0_1_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_1_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_1_1.enable_tags(-1, True) self.qtgui_time_sink_x_0_1_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_1_1.enable_autoscale(False) self.qtgui_time_sink_x_0_1_1.enable_grid(False) self.qtgui_time_sink_x_0_1_1.enable_axis_labels(True) self.qtgui_time_sink_x_0_1_1.enable_control_panel(False) self.qtgui_time_sink_x_0_1_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_1_1.disable_legend() labels = ['Recuperada', 'Original', 'Erro', '', '', '', '', '', '', ''] 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_1_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_1_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_1_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_1_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_1_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_1_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_1_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_1_1_win = sip.wrapinstance( self.qtgui_time_sink_x_0_1_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_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_time_sink_x_0_1 = qtgui.time_sink_f( 32, #size samp_rate * NPTS, #samp_rate "Bits Decodificados", #name 2 #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(-0.25, 1.25) 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, "") 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) if not True: self.qtgui_time_sink_x_0_1.disable_legend() labels = ['RX', 'TX', '', '', '', '', '', '', '', ''] 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 = [0, 0, 1, 1, 1, 1, 1, 1, 1, 1] markers = [0, 0, -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_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, 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_time_sink_x_0_0 = qtgui.time_sink_f( 128, #size samp_rate * NPTS * 8, #samp_rate "Pulso Amostragem e Pulso RX", #name 3 #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.25, 1.25) 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) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = [ 'Pulso RX', 'Amostrador', 'Amostrado', '', '', '', '', '', '', '' ] 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, 0, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, 0, -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_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, 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.qtgui_time_sink_x_0 = qtgui.time_sink_f( 128, #size samp_rate * NPTS * Iterp_rate, #samp_rate "Cod. Polar e Pulso TX", #name 2 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1.25, 1.25) 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) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['Cod Polar', 'Pulsos TX', '', '', '', '', '', '', '', ''] 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, 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.qtgui_histogram_sink_x_0 = qtgui.histogram_sink_f( 2048, 300, -2, 2, "Amostras RX", 1) self.qtgui_histogram_sink_x_0.set_update_time(0.10) self.qtgui_histogram_sink_x_0.enable_autoscale(True) self.qtgui_histogram_sink_x_0.enable_accumulate(True) self.qtgui_histogram_sink_x_0.enable_grid(False) self.qtgui_histogram_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_histogram_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" ] 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_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.top_grid_layout.addWidget(self._qtgui_histogram_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 = qtgui.freq_sink_f( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate * NPTS * 8, #bw "Espectros", #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.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 "float" == "float" or "float" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['TX', 'RX', '', '', '', '', '', '', '', ''] 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, 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.interp_fir_filter_xxx_0_0 = filter.interp_fir_filter_fff( Iterp_rate, (C_1)) self.interp_fir_filter_xxx_0_0.declare_sample_delay(0) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_fff( Iterp_rate, (1 * [1] + (Iterp_rate - 1) * [0])) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.fir_filter_xxx_0 = filter.fir_filter_fff(Iterp_rate, (Iterp_rate * [1])) self.fir_filter_xxx_0.declare_sample_delay(0) self.epy_block_0 = epy_block_0.blk(passo=1) self.channels_quantizer_0 = channels.quantizer(NPTS) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(NPTS) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_sub_xx_1 = blocks.sub_ff(1) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(NPTS) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((0.5, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((2, )) self.blocks_float_to_char_0_0 = blocks.float_to_char(1, 1) self.blocks_float_to_char_0 = blocks.float_to_char(1, 128) self.blocks_delay_2_4 = blocks.delay(gr.sizeof_float * 1, 2 * 81) self.blocks_delay_2_3 = blocks.delay(gr.sizeof_float * 1, 3 * 81) self.blocks_delay_2_2_0 = blocks.delay(gr.sizeof_float * 1, 7 * 81) self.blocks_delay_2_2 = blocks.delay(gr.sizeof_float * 1, 4 * 81) self.blocks_delay_2_1_0 = blocks.delay(gr.sizeof_float * 1, 8 * 81) self.blocks_delay_2_1 = blocks.delay(gr.sizeof_float * 1, 5 * 81) self.blocks_delay_2_0_0 = blocks.delay(gr.sizeof_float * 1, 9 * 81) self.blocks_delay_2_0 = blocks.delay(gr.sizeof_float * 1, 6 * 81) self.blocks_delay_2 = blocks.delay(gr.sizeof_float * 1, 81) self.blocks_delay_1_0_0 = blocks.delay(gr.sizeof_float * 1, 1) self.blocks_delay_1_0 = blocks.delay(gr.sizeof_float * 1, 7) self.blocks_delay_1 = blocks.delay(gr.sizeof_float * 1, 1) self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, Iterp_rate / 2) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 128) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_add_xx_0_0 = blocks.add_vff(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.blocks_add_const_vxx_1 = blocks.add_const_vff((1, )) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-0.5, )) self.blocks_abs_xx_0 = blocks.abs_ff(1) self.analog_sig_source_x_0_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 53, 0.5, 0) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 100, 0.5, 0) self.analog_noise_source_x_0 = analog.noise_source_f( analog.GR_GAUSSIAN, Sigma, 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0_0, 1)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_abs_xx_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_abs_xx_0, 0), (self.qtgui_time_sink_x_0_0, 1)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.channels_quantizer_0, 0)) self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_add_xx_0_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.blocks_add_xx_0_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_delay_1, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.blocks_sub_xx_1, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_0_1_1, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_abs_xx_0, 0)) self.connect((self.blocks_delay_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_delay_1, 0), (self.qtgui_time_sink_x_0_1, 1)) self.connect((self.blocks_delay_1_0, 0), (self.blocks_float_to_char_0_0, 0)) self.connect((self.blocks_delay_1_0_0, 0), (self.blocks_sub_xx_1, 1)) self.connect((self.blocks_delay_1_0_0, 0), (self.qtgui_time_sink_x_0_1_1, 1)) self.connect((self.blocks_delay_2, 0), (self.qtgui_time_sink_x_0_2, 1)) self.connect((self.blocks_delay_2_0, 0), (self.qtgui_time_sink_x_0_2, 6)) self.connect((self.blocks_delay_2_0_0, 0), (self.qtgui_time_sink_x_0_2, 9)) self.connect((self.blocks_delay_2_1, 0), (self.qtgui_time_sink_x_0_2, 5)) self.connect((self.blocks_delay_2_1_0, 0), (self.qtgui_time_sink_x_0_2, 8)) self.connect((self.blocks_delay_2_2, 0), (self.qtgui_time_sink_x_0_2, 4)) self.connect((self.blocks_delay_2_2_0, 0), (self.qtgui_time_sink_x_0_2, 7)) self.connect((self.blocks_delay_2_3, 0), (self.qtgui_time_sink_x_0_2, 3)) self.connect((self.blocks_delay_2_4, 0), (self.qtgui_time_sink_x_0_2, 2)) self.connect((self.blocks_float_to_char_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.blocks_float_to_char_0_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.interp_fir_filter_xxx_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_delay_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.qtgui_time_sink_x_0_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_time_sink_x_0_0, 2)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.blocks_sub_xx_1, 0), (self.qtgui_time_sink_x_0_1_1, 2)) self.connect((self.blocks_throttle_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.channels_quantizer_0, 0), (self.blocks_delay_1_0_0, 0)) self.connect((self.channels_quantizer_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.epy_block_0, 0), (self.blocks_add_const_vxx_1, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.epy_block_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.qtgui_histogram_sink_x_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_delay_0, 0)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.blocks_add_xx_0_0, 0)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.blocks_delay_2, 0)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.blocks_delay_2_0, 0)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.blocks_delay_2_0_0, 0)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.blocks_delay_2_1, 0)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.blocks_delay_2_1_0, 0)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.blocks_delay_2_2, 0)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.blocks_delay_2_2_0, 0)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.blocks_delay_2_3, 0)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.blocks_delay_2_4, 0)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.qtgui_time_sink_x_0_2, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 200e3 self.frec_portadora = frec_portadora = 1e3 self.frec_moduladora = frec_moduladora = 500 ################################################## # Blocks ################################################## self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "mod BPSK") self.nb.AddPage(grc_wxgui.Panel(self.nb), "demod floatPSK") self.Add(self.nb) _frec_portadora_sizer = wx.BoxSizer(wx.VERTICAL) self._frec_portadora_text_box = forms.text_box( parent=self.GetWin(), sizer=_frec_portadora_sizer, value=self.frec_portadora, callback=self.set_frec_portadora, label='frec_portadora', converter=forms.float_converter(), proportion=0, ) self._frec_portadora_slider = forms.slider( parent=self.GetWin(), sizer=_frec_portadora_sizer, value=self.frec_portadora, callback=self.set_frec_portadora, minimum=0, maximum=15e3, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_frec_portadora_sizer) _frec_moduladora_sizer = wx.BoxSizer(wx.VERTICAL) self._frec_moduladora_text_box = forms.text_box( parent=self.GetWin(), sizer=_frec_moduladora_sizer, value=self.frec_moduladora, callback=self.set_frec_moduladora, label='frec_moduladora', converter=forms.float_converter(), proportion=0, ) self._frec_moduladora_slider = forms.slider( parent=self.GetWin(), sizer=_frec_moduladora_sizer, value=self.frec_moduladora, callback=self.set_frec_moduladora, minimum=0, maximum=3e3, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_frec_moduladora_sizer) self.wxgui_scopesink2_0_0_0 = scopesink2.scope_sink_f( self.nb.GetPage(1).GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=2, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(1).Add(self.wxgui_scopesink2_0_0_0.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.nb.GetPage(0).GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=2, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(0).Add(self.wxgui_scopesink2_0.win) self.low_pass_filter_0_0 = filter.fir_filter_fff( 1, firdes.low_pass(10, samp_rate, 600, 280, firdes.WIN_HAMMING, 6.76)) self.channels_quantizer_0 = channels.quantizer(16) self.blocks_throttle_1 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_multiply_xx_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_abs_xx_0 = blocks.abs_ff(1) self.analog_sig_source_x_1 = analog.sig_source_f( samp_rate, analog.GR_SQR_WAVE, frec_moduladora, 2, -1) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_SIN_WAVE, frec_portadora, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_throttle_1, 0)) self.connect((self.blocks_abs_xx_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_abs_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_throttle_1, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_throttle_1, 0), (self.wxgui_scopesink2_0, 1)) self.connect((self.blocks_throttle_1, 0), (self.wxgui_scopesink2_0_0_0, 1)) self.connect((self.channels_quantizer_0, 0), (self.wxgui_scopesink2_0_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.channels_quantizer_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 = 32000 ################################################## # Blocks ################################################## 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(-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) 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(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_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) 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.top_grid_layout.addWidget(self._qtgui_number_sink_0_win) self.qtgui_freq_sink_x_2 = 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_2.set_update_time(0.10) self.qtgui_freq_sink_x_2.set_y_axis(-140, 10) self.qtgui_freq_sink_x_2.set_y_label('Relative Gain', 'dB') 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_axis_labels(True) 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.top_grid_layout.addWidget(self._qtgui_freq_sink_x_2_win) self.qtgui_freq_sink_x_1 = 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_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) 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_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) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( 1024, #size 'QT GUI Plot', #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.top_grid_layout.addWidget(self._qtgui_const_sink_x_1_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size 'QT GUI Plot', #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.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win) self.fec_ber_bf_0 = fec.ber_bf(False, 100, -7.0) self.digital_psk_mod_1 = digital.psk.psk_mod( constellation_points=2, mod_code="none", differential=False, samples_per_symbol=2, excess_bw=0.35, verbose=True, log=True, ) self.digital_psk_mod_0 = digital.psk.psk_mod( constellation_points=4, mod_code="gray", differential=True, samples_per_symbol=2, excess_bw=0.35, verbose=False, log=False, ) self.digital_psk_demod_0 = digital.psk.psk_demod( constellation_points=2, differential=True, samples_per_symbol=2, excess_bw=0.35, phase_bw=6.28 / 100.0, timing_bw=6.28 / 100.0, mod_code="gray", verbose=False, log=False, ) self.channels_quantizer_0 = channels.quantizer(2) self.blocks_wavfile_source_1 = blocks.wavfile_source( '/home/iiitd/Desktop/handel9.wav', True) self.blocks_wavfile_source_0 = blocks.wavfile_source( '/home/iiitd/Desktop/awgn.wav', True) self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_float_to_uchar_1 = blocks.float_to_uchar() self.blocks_float_to_uchar_0 = blocks.float_to_uchar() self.blocks_float_to_complex_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) ################################################## # Connections ################################################## 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)) self.connect((self.blocks_float_to_complex_1, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.blocks_float_to_complex_1, 0), (self.qtgui_freq_sink_x_2, 0)) self.connect((self.blocks_float_to_uchar_0, 0), (self.digital_psk_mod_0, 0)) self.connect((self.blocks_float_to_uchar_0, 0), (self.digital_psk_mod_1, 0)) self.connect((self.blocks_float_to_uchar_1, 0), (self.fec_ber_bf_0, 1)) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_float_to_complex_1, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.channels_quantizer_0, 0)) self.connect((self.blocks_wavfile_source_1, 0), (self.blocks_float_to_uchar_1, 0)) self.connect((self.channels_quantizer_0, 0), (self.blocks_float_to_uchar_0, 0)) self.connect((self.digital_psk_demod_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.digital_psk_demod_0, 0), (self.fec_ber_bf_0, 0)) self.connect((self.digital_psk_mod_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_psk_mod_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.digital_psk_mod_1, 0), (self.digital_psk_demod_0, 0)) self.connect((self.fec_ber_bf_0, 0), (self.qtgui_number_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "Demo Quantization") Qt.QWidget.__init__(self) self.setWindowTitle("Demo Quantization") 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_quantization") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 100000 self.signal_amp = signal_amp = -150 self.sigfreq = sigfreq = samp_rate*1.0247385/11.0 self.noise_amp = noise_amp = -150 self.center = center = samp_rate/11.0 self.bw = bw = samp_rate/2 self.bits = bits = 2 ################################################## # 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, 0, 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, 0, 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._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._center_layout = Qt.QVBoxLayout() self._center_tool_bar = Qt.QToolBar(self) self._center_layout.addWidget(self._center_tool_bar) self._center_tool_bar.addWidget(Qt.QLabel("Center 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._center_counter = qwt_counter_pyslot() self._center_counter.setRange(0, samp_rate/2, 100) self._center_counter.setNumButtons(2) self._center_counter.setValue(self.center) self._center_tool_bar.addWidget(self._center_counter) self._center_counter.valueChanged.connect(self.set_center) self._center_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._center_slider.setRange(0, samp_rate/2, 100) self._center_slider.setValue(self.center) self._center_slider.setMinimumWidth(200) self._center_slider.valueChanged.connect(self.set_center) self._center_layout.addWidget(self._center_slider) self.top_grid_layout.addLayout(self._center_layout, 3,1,1,1) self._bw_layout = Qt.QVBoxLayout() self._bw_tool_bar = Qt.QToolBar(self) self._bw_layout.addWidget(self._bw_tool_bar) self._bw_tool_bar.addWidget(Qt.QLabel("BW"+": ")) 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._bw_counter = qwt_counter_pyslot() self._bw_counter.setRange(samp_rate/100.0, samp_rate/2, 100) self._bw_counter.setNumButtons(2) self._bw_counter.setValue(self.bw) self._bw_tool_bar.addWidget(self._bw_counter) self._bw_counter.valueChanged.connect(self.set_bw) self._bw_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._bw_slider.setRange(samp_rate/100.0, samp_rate/2, 100) self._bw_slider.setValue(self.bw) self._bw_slider.setMinimumWidth(200) self._bw_slider.valueChanged.connect(self.set_bw) self._bw_layout.addWidget(self._bw_slider) self.top_grid_layout.addLayout(self._bw_layout, 4,1,1,1) self._bits_options = [2,4,6,8,10,12,14,16] self._bits_labels = map(str, self._bits_options) self._bits_tool_bar = Qt.QToolBar(self) self._bits_tool_bar.addWidget(Qt.QLabel("Bits"+": ")) self._bits_combo_box = Qt.QComboBox() self._bits_tool_bar.addWidget(self._bits_combo_box) for label in self._bits_labels: self._bits_combo_box.addItem(label) self._bits_callback = lambda i: Qt.QMetaObject.invokeMethod(self._bits_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._bits_options.index(i))) self._bits_callback(self.bits) self._bits_combo_box.currentIndexChanged.connect( lambda i: self.set_bits(self._bits_options[i])) self.top_grid_layout.addWidget(self._bits_tool_bar, 4,0,1,1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 128, #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(-1 - pow(2,bits-1), 1 + pow(2,bits-1)) 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, 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,2) self.qtgui_histogram_sink_x_0 = qtgui.histogram_sink_f( 10000, 100, -1 - pow(2,bits-1), 1 + pow(2,bits-1), "QT GUI Plot", 1 ) self.qtgui_histogram_sink_x_0.set_update_time(0.10) self._qtgui_histogram_sink_x_0_win = sip.wrapinstance(self.qtgui_histogram_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_histogram_sink_x_0_win, 0,1,1,1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( 2048, #size firdes.WIN_FLATTOP, #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(-180, 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,1) self.channels_quantizer_0 = channels.quantizer(bits) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((pow(2,bits-1), )) self.blocks_add_xx_0 = blocks.add_vff(1) self.band_pass_filter_0 = filter.fir_filter_fff(1, firdes.band_pass( 1, samp_rate, max(bw/15.0,center-bw/2.0), min(samp_rate/2.0-bw/15.0,center+bw/2.0), bw/5.0, firdes.WIN_HANN, 6.76)) self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, sigfreq, pow(10.0,signal_amp/20.0), 0) self.analog_noise_source_x_0 = analog.noise_source_f(analog.GR_GAUSSIAN, pow(10.0,noise_amp/20.0), 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.channels_quantizer_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_histogram_sink_x_0, 0)) self.connect((self.channels_quantizer_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.channels_quantizer_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_time_sink_x_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2.88e6 self.freq_corr = freq_corr = 0 self.freq = freq = 433e6 self.cte = cte = -380e-3 ################################################## # Blocks ################################################## _freq_corr_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_corr_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_corr_sizer, value=self.freq_corr, callback=self.set_freq_corr, label='freq_corr', converter=forms.float_converter(), proportion=0, ) self._freq_corr_slider = forms.slider( parent=self.GetWin(), sizer=_freq_corr_sizer, value=self.freq_corr, callback=self.set_freq_corr, minimum=-100, maximum=100, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freq_corr_sizer) _freq_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, label='freq', converter=forms.float_converter(), proportion=0, ) self._freq_slider = forms.slider( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, minimum=420e6, maximum=434e6, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freq_sizer) _cte_sizer = wx.BoxSizer(wx.VERTICAL) self._cte_text_box = forms.text_box( parent=self.GetWin(), sizer=_cte_sizer, value=self.cte, callback=self.set_cte, label='cte', converter=forms.float_converter(), proportion=0, ) self._cte_slider = forms.slider( parent=self.GetWin(), sizer=_cte_sizer, value=self.cte, callback=self.set_cte, minimum=-1, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_cte_sizer) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title='Scope Plot', sample_rate=samp_rate, v_scale=500e-3, v_offset=1, t_scale=100e-6, ac_couple=False, xy_mode=False, num_inputs=2, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label='Counts', ) self.Add(self.wxgui_scopesink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title='FFT Plot', peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.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(freq_corr, 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(10, 0) self.rtlsdr_source_0.set_if_gain(30, 0) self.rtlsdr_source_0.set_bb_gain(30, 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 480e3, 48e3, firdes.WIN_HAMMING, 6.76)) self.channels_quantizer_0 = channels.quantizer(2) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((2, )) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_float * 1, 120) self.blocks_float_to_char_0 = blocks.float_to_char(1, 1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_add_const_vxx_1 = blocks.add_const_vff((ord('0'), )) self.blocks_add_const_vxx_0 = blocks.add_const_vff((cte, )) self.blks2_tcp_sink_0 = grc_blks2.tcp_sink( itemsize=gr.sizeof_char * 1, addr='127.0.0.1', port=3333, server=False, ) self.analog_agc_xx_0 = analog.agc_ff(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_add_const_vxx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.channels_quantizer_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.wxgui_scopesink2_0, 1)) self.connect((self.blocks_add_const_vxx_1, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blks2_tcp_sink_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_const_vxx_1, 0)) self.connect((self.channels_quantizer_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.channels_quantizer_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.wxgui_fftsink2_0, 0))