def __init__(self): gr.top_block.__init__(self) Rs = 8000 f1 = 100 f2 = 200 npts = 2048 self.qapp = QtGui.QApplication(sys.argv) src1 = analog.sig_source_c(Rs, analog.GR_SIN_WAVE, f1, 0.5, 0) src2 = analog.sig_source_c(Rs, analog.GR_SIN_WAVE, f2, 0.5, 0) src = blocks.add_cc() channel = channels.channel_model(0.001) thr = blocks.throttle(gr.sizeof_gr_complex, 100 * npts) self.snk1 = qtgui.const_sink_c(npts, "Constellation Example", 1) self.connect(src1, (src, 0)) self.connect(src2, (src, 1)) self.connect(src, channel, thr, (self.snk1, 0)) self.ctrl_win = control_box() self.ctrl_win.attach_signal1(src1) self.ctrl_win.attach_signal2(src2) # Get the reference pointer to the SpectrumDisplayForm QWidget pyQt = self.snk1.pyqwidget() # Wrap the pointer as a PyQt SIP object # This can now be manipulated as a PyQt4.QtGui.QWidget pyWin = sip.wrapinstance(pyQt, QtGui.QWidget) self.main_box = dialog_box(pyWin, self.ctrl_win) self.main_box.show()
def __init__(self): gr.top_block.__init__(self, "Top Block2") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block2") 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_block2") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.occupied_carriers = occupied_carriers = 200 self.fft_len = fft_len = 512 self.rcvd_pktq = rcvd_pktq = gr.msg_queue() self.modulation = modulation = 'bpsk' self.mods = mods = {"bpsk": 2, "qpsk": 4, "8psk": 8, "qam8": 8, "qam16": 16, "qam64": 64, "qam256": 256} self.bw = bw = (float(occupied_carriers) / float(fft_len)) / 2.0 self.zeros_on_left = zeros_on_left = int(math.ceil((fft_len - occupied_carriers)/2.0)) self.win = win = [1 for i in range(fft_len )] self.watcher = watcher = pp._queue_watcher_thread(rcvd_pktq) self.tb = tb = bw*0.08 self.samp_rate = samp_rate = 100000000/16 self.rotated_const = rotated_const = gp.gen_framer_info(modulation) self.phgain = phgain = 0.25 self.max_fft_shift = max_fft_shift = 4 self.ks0 = ks0 = gp.gen_preamble_data(fft_len , occupied_carriers) self.cp_len = cp_len = 128 self.arity = arity = mods[modulation] ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2*1): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_char, 0, qtgui.NUM_GRAPH_HORIZ, 1 ) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ["", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(True) self.qtgui_const_sink_x_0.enable_grid(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_layout.addWidget(self._qtgui_const_sink_x_0_win) self.ofdm_packet_sync_0 = ofdm_packet_sync( fft_len=fft_len, cp_len=cp_len, ) self.ofdm_ofdm_mrx_frame_sink_0 = ofdm.ofdm_mrx_frame_sink(rotated_const, range(arity), rcvd_pktq, occupied_carriers, phgain, phgain*phgain /4.0, 1) self.fft_vxx_0 = fft.fft_vcc(fft_len, True, (win), True, 1) self.fft_filter_xxx_0 = filter.fft_filter_ccc(1, (filter.firdes.low_pass (1.0, 1.0, bw+tb, tb, filter.firdes.WIN_HAMMING)), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.digital_ofdm_sampler_0 = digital.ofdm_sampler(fft_len, cp_len+fft_len, 1000000) self.digital_ofdm_frame_acquisition_0 = digital.ofdm_frame_acquisition(occupied_carriers, fft_len, cp_len, (ks0), max_fft_shift) self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, occupied_carriers) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_message_debug_0_0 = blocks.message_debug() self.blocks_message_debug_0 = blocks.message_debug() self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/tmp/data.txt", False) ################################################## # Connections ################################################## self.msg_connect((self.ofdm_ofdm_mrx_frame_sink_0, 'packet'), (self.blocks_message_debug_0, 'store')) self.msg_connect((self.ofdm_ofdm_mrx_frame_sink_0, 'header_dfe'), (self.blocks_message_debug_0_0, 'store')) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.digital_ofdm_sampler_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.blocks_vector_to_stream_0_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_ofdm_frame_acquisition_0, 1), (self.ofdm_ofdm_mrx_frame_sink_0, 0)) self.connect((self.digital_ofdm_frame_acquisition_0, 0), (self.ofdm_ofdm_mrx_frame_sink_0, 1)) self.connect((self.digital_ofdm_sampler_0, 1), (self.digital_ofdm_frame_acquisition_0, 1)) self.connect((self.digital_ofdm_sampler_0, 0), (self.fft_vxx_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.ofdm_packet_sync_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_frame_acquisition_0, 0)) self.connect((self.ofdm_ofdm_mrx_frame_sink_0, 0), (self.blocks_vector_to_stream_0_0, 0)) self.connect((self.ofdm_packet_sync_0, 1), (self.blocks_multiply_xx_0, 0)) self.connect((self.ofdm_packet_sync_0, 2), (self.blocks_multiply_xx_0, 1)) self.connect((self.ofdm_packet_sync_0, 0), (self.digital_ofdm_sampler_0, 1)) self.connect((self.ofdm_packet_sync_0, 2), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.ofdm_packet_sync_0, 0), (self.qtgui_number_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "Time offset mitigation") Qt.QWidget.__init__(self) self.setWindowTitle("Time offset mitigation") 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", "time_recovery") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.timing_loop_bw = timing_loop_bw = 6.28/100.0 self.time_offset = time_offset = 1.00 self.taps = taps = [1.0 + 0.0j, ] self.samp_rate = samp_rate = 32000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts) self.noise_volt = noise_volt = 0.0 self.freq_offset = freq_offset = 0 self.arity = arity = 4 ################################################## # Blocks ################################################## self._timing_loop_bw_range = Range(0.0, 0.2, 0.005, 6.28/100.0, 200) self._timing_loop_bw_win = RangeWidget(self._timing_loop_bw_range, self.set_timing_loop_bw, 'Time: BW', "slider", float) self.top_grid_layout.addWidget(self._timing_loop_bw_win, 3,1,1,1) self._time_offset_range = Range(0.999, 1.001, 0.0001, 1.00, 200) self._time_offset_win = RangeWidget(self._time_offset_range, self.set_time_offset, 'Channel: Timing Offset', "slider", float) self.top_grid_layout.addWidget(self._time_offset_win, 3,0,1,1) self._noise_volt_range = Range(0, 1, 0.01, 0.0, 200) self._noise_volt_win = RangeWidget(self._noise_volt_range, self.set_noise_volt, 'Channel: Noise Voltage', "slider", float) self.top_grid_layout.addWidget(self._noise_volt_win, 2,0,1,1) self._freq_offset_range = Range(-0.1, 0.1, 0.001, 0, 200) self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, 'Channel: Frequency Offset', "slider", float) self.top_grid_layout.addWidget(self._freq_offset_win, 2,1,1,1) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 1024, #size 'QT GUI Plot', #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win, 0,1,1,1) 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, 0,0,1,1) self.digital_psk_mod_0 = digital.psk.psk_mod( constellation_points=arity, mod_code="gray", differential=True, samples_per_symbol=sps, excess_bw=0.35, verbose=False, log=False, ) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps*1.001, timing_loop_bw, (rrc_taps), nfilts, nfilts/2, 1.5, 1) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise_volt, frequency_offset=freq_offset, epsilon=time_offset, taps=(taps), noise_seed=0, block_tags=False ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((.5+.5j, )) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_psk_mod_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.digital_psk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0))
def test09(self): self.qtsnk = qtgui.const_sink_c(1024, "Test", 1, None)
def __init__(self): gr.top_block.__init__(self, "Tempate Qt") Qt.QWidget.__init__(self) self.setWindowTitle("Tempate Qt") 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", "tempate_qt") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) 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_layout.addWidget(self._qtgui_const_sink_x_0_win) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 1000, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_const_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 45 self.nfilts = nfilts = 25 self.samp_rate = samp_rate = 44.1E3 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), 0.35, 45 * nfilts) self.fc_slider = fc_slider = 2200 self.BPSK = BPSK = digital.constellation_calcdist(([-1, 1]), ([0, 1]), 4, 1).base() ################################################## # Blocks ################################################## self._fc_slider_range = Range(0, 18200, 200, 2200, 150) self._fc_slider_win = RangeWidget(self._fc_slider_range, self.set_fc_slider, "fc", "counter_slider", float) self.top_layout.addWidget(self._fc_slider_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Sinal capturado pelo mic", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.5) 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(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_layout.addWidget(self._qtgui_const_sink_x_0_win) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 1.1E3, .6E3, firdes.WIN_HAMMING, 6.76)) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, .063, (rrc_taps), nfilts, nfilts / 2, 1.5, 1) self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc( 8, .01, 1, BPSK) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(.05, 2, False) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blks2_tcp_sink_0 = grc_blks2.tcp_sink( itemsize=gr.sizeof_char * 1, addr="127.0.0.1", port=1234, server=False, ) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b( grc_blks2.packet_decoder( access_code="", threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0. recv_pkt(ok, payload), ), ) self.audio_source_0 = audio.source(44100, "", True) self.analog_sig_source_x_0_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, fc_slider, 1, 0) self.analog_feedforward_agc_cc_0 = analog.feedforward_agc_cc(1024, 1) ################################################## # Connections ################################################## self.connect((self.analog_feedforward_agc_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.audio_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.audio_source_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blks2_packet_decoder_0, 0), (self.blks2_tcp_sink_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_lms_dd_equalizer_cc_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_feedforward_agc_cc_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") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 150000 self.filter_width = filter_width = 5000 self.carrier = carrier = 40000 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=10, taps=None, fractional_bw=None, ) self.qtgui_time_sink_x_0_0_1 = qtgui.time_sink_c( 2048, #size samp_rate / 10, #samp_rate "Decimated PSK Mod", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_1.set_update_time(0.10) self.qtgui_time_sink_x_0_0_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0_1.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_1.enable_autoscale(False) self.qtgui_time_sink_x_0_0_1.enable_grid(False) self.qtgui_time_sink_x_0_0_1.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_1.enable_control_panel(False) self.qtgui_time_sink_x_0_0_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0_0_1.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0_1.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_1_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_1_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c( 4096, #size samp_rate, #samp_rate "PSK Mod", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 4096, #size samp_rate, #samp_rate "carrier x psk mod", #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_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 8192, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.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(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_0_win) self.digital_psk_mod_0 = digital.psk.psk_mod( constellation_points=2, mod_code="gray", differential=True, samples_per_symbol=2, excess_bw=0.1, 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.1, phase_bw=6.28 / 100.0, timing_bw=6.28 / 100.0, mod_code="gray", verbose=False, log=False, ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_char * 1, addr='127.0.0.1', port=1234, server=True, ) self.blks2_tcp_sink_0 = grc_blks2.tcp_sink( itemsize=gr.sizeof_char * 1, addr='127.0.0.1', port=9989, server=False, ) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b( grc_blks2.packet_encoder( samples_per_symbol=2, bits_per_symbol=1, preamble='', access_code='', pad_for_usrp=False, ), payload_length=1, ) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b( grc_blks2.packet_decoder( access_code='', threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0. recv_pkt(ok, payload), ), ) self.band_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.band_pass(1, samp_rate, carrier - (filter_width / 2), carrier + (filter_width / 2), 100, firdes.WIN_HAMMING, 6.76)) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, carrier, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.blks2_packet_decoder_0, 0), (self.blks2_tcp_sink_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.digital_psk_mod_0, 0)) self.connect((self.blks2_tcp_source_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.digital_psk_demod_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.digital_psk_demod_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.digital_psk_mod_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.digital_psk_mod_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_psk_mod_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_time_sink_x_0_0_1, 0))
def __init__(self, ip='127.0.0.1', iq_file='./rocksat_125kbd_500ksps_date_comment.dat', meta_rate=.1, port='52001', record_iq=0, record_rfo=0, record_snr=0, rfo_file='./rocksat_rfo_date_comment.meta', snr_file='./rocksat_snr_date_comment.meta'): gr.top_block.__init__(self, "VTGS Rocksat Receiver") Qt.QWidget.__init__(self) self.setWindowTitle("VTGS Rocksat Receiver") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "vtgs_rx_1") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.ip = ip self.iq_file = iq_file self.meta_rate = meta_rate self.port = port self.record_iq = record_iq self.record_rfo = record_rfo self.record_snr = record_snr self.rfo_file = rfo_file self.snr_file = snr_file ################################################## # Variables ################################################## self.samp_rate = samp_rate = 250e3 self.baud = baud = 125e3 / 2 self.samps_per_symb = samps_per_symb = int(samp_rate / baud) self.rx_freq = rx_freq = 2395e6 self.alpha = alpha = 0.5 self.tuned_center = tuned_center = 'baud_0' self.rx_offset = rx_offset = 250e3 self.rx_gain = rx_gain = 10 self.rrc_filter_taps = rrc_filter_taps = firdes.root_raised_cosine( 32, 1.0, 1.0 / (samps_per_symb * 32), alpha, samps_per_symb * 32) self.noise = noise = 0 self.mult = mult = (samp_rate) / 2 / 3.141593 self.lpf_taps = lpf_taps = firdes.low_pass(1.0, samp_rate, samp_rate / 2, 1000, firdes.WIN_HAMMING, 6.76) self.lo = lo = 1833e6 self.khz_offset = khz_offset = 0 self.center_freq_lbl = center_freq_lbl = rx_freq / 1e6 ################################################## # Blocks ################################################## self._noise_range = Range(0, 1, 0.00001, 0, 200) self._noise_win = RangeWidget(self._noise_range, self.set_noise, "noise", "counter_slider", float) self.top_layout.addWidget(self._noise_win) self._khz_offset_range = Range(-150, 150, 1, 0, 200) self._khz_offset_win = RangeWidget(self._khz_offset_range, self.set_khz_offset, 'Offset [kHz]', "counter_slider", float) self.top_grid_layout.addWidget(self._khz_offset_win, 7, 8, 1, 4) self.vtgs_mult_descrambler_0 = vtgs.mult_descrambler(17, 0x3FFFF) self.vtgs_ao40_decoder_0_0 = vtgs.ao40_decoder() self._tuned_center_tool_bar = Qt.QToolBar(self) if None: self._tuned_center_formatter = None else: self._tuned_center_formatter = lambda x: x self._tuned_center_tool_bar.addWidget( Qt.QLabel(' Tuned Center [MHz]' + ": ")) self._tuned_center_label = Qt.QLabel( str(self._tuned_center_formatter(self.tuned_center))) self._tuned_center_tool_bar.addWidget(self._tuned_center_label) self.top_grid_layout.addWidget(self._tuned_center_tool_bar, 1, 8, 1, 2) self._rx_gain_range = Range(0, 86, 1, 10, 200) self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, 'RX Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._rx_gain_win, 6, 8, 1, 4) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw '', #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0.enable_grid(True) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not False: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['pre-d', 'post', '', '', '', '', '', '', '', ''] colors = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-130, -20) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 8, 0, 8, 8) self.qtgui_number_sink_1 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_1.set_update_time(0.10) self.qtgui_number_sink_1.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_1.set_min(i, -1) self.qtgui_number_sink_1.set_max(i, 1) self.qtgui_number_sink_1.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_1.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_1.set_label(i, labels[i]) self.qtgui_number_sink_1.set_unit(i, units[i]) self.qtgui_number_sink_1.set_factor(i, factor[i]) self.qtgui_number_sink_1.enable_autoscale(False) self._qtgui_number_sink_1_win = sip.wrapinstance( self.qtgui_number_sink_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_1_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024 * 4, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.0010) self.qtgui_freq_sink_x_0.set_y_axis(-120, -20) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['pre-d', 'post', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 8, 8) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-1, 1) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(True) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 8, 8, 8, 4) self.mapper_demapper_soft_0 = mapper.demapper_soft( mapper.BPSK, ([0, 1])) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, (baud * (1 + alpha)) / 2, 1000, firdes.WIN_HAMMING, 6.76)) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 1, (lpf_taps), khz_offset * 1000, samp_rate) self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_ccf( samps_per_symb, math.pi * 2 / 100, (rrc_filter_taps), 32, 16, 1.5, 1) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc( math.pi * 2 / 100, 2, False) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( math.pi * 2 / 100, 2, False) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self._center_freq_lbl_tool_bar = Qt.QToolBar(self) if None: self._center_freq_lbl_formatter = None else: self._center_freq_lbl_formatter = lambda x: x self._center_freq_lbl_tool_bar.addWidget( Qt.QLabel('Center Frequency [MHz]' + ": ")) self._center_freq_lbl_label = Qt.QLabel( str(self._center_freq_lbl_formatter(self.center_freq_lbl))) self._center_freq_lbl_tool_bar.addWidget(self._center_freq_lbl_label) self.top_grid_layout.addWidget(self._center_freq_lbl_tool_bar, 0, 8, 1, 2) self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", ip, port, 1024, False) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((mult, )) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_gr_complex * 1, addr='127.0.0.1', port=5000, server=True, ) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, noise, 0) self.analog_agc2_xx_0_0 = analog.agc2_cc(1e-3, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect((self.vtgs_ao40_decoder_0_0, 'valid_frames'), (self.blocks_socket_pdu_0, 'pdus')) self.connect((self.analog_agc2_xx_0_0, 0), (self.digital_costas_loop_cc_0_0, 0)) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blks2_tcp_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.analog_agc2_xx_0_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_waterfall_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_number_sink_1, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.mapper_demapper_soft_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 1), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.vtgs_mult_descrambler_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.digital_pfb_clock_sync_xxx_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.mapper_demapper_soft_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.vtgs_mult_descrambler_0, 0), (self.vtgs_ao40_decoder_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sub_carrier_freq = sub_carrier_freq = 1000 self.send_gain = send_gain = 40 self.samp_rate = samp_rate = 10000 self.recieve_gain = recieve_gain = 1 self._carrier_freq_config = ConfigParser.ConfigParser() self._carrier_freq_config.read("default") try: carrier_freq = self._carrier_freq_config.getfloat("main", "key") except: carrier_freq = 915000000 self.carrier_freq = carrier_freq self._USRP_IP_config = ConfigParser.ConfigParser() self._USRP_IP_config.read("default") try: USRP_IP = self._USRP_IP_config.get("main", "key") except: USRP_IP = "addr=192.168.10.14" self.USRP_IP = USRP_IP ################################################## # Blocks ################################################## self.tabs = Qt.QTabWidget() self.tabs_widget_0 = Qt.QWidget() self.tabs_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_0) self.tabs_grid_layout_0 = Qt.QGridLayout() self.tabs_layout_0.addLayout(self.tabs_grid_layout_0) self.tabs.addTab(self.tabs_widget_0, "Plots") self.tabs_widget_1 = Qt.QWidget() self.tabs_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_1) self.tabs_grid_layout_1 = Qt.QGridLayout() self.tabs_layout_1.addLayout(self.tabs_grid_layout_1) self.tabs.addTab(self.tabs_widget_1, "Settings") self.top_layout.addWidget(self.tabs) self._sub_carrier_freq_layout = Qt.QVBoxLayout() self._sub_carrier_freq_tool_bar = Qt.QToolBar(self) self._sub_carrier_freq_layout.addWidget(self._sub_carrier_freq_tool_bar) self._sub_carrier_freq_tool_bar.addWidget(Qt.QLabel("Sub-Carrier Freq (Hz)"+": ")) self._sub_carrier_freq_counter = Qwt.QwtCounter() self._sub_carrier_freq_counter.setRange(0, 50000, 1000) self._sub_carrier_freq_counter.setNumButtons(2) self._sub_carrier_freq_counter.setValue(self.sub_carrier_freq) self._sub_carrier_freq_tool_bar.addWidget(self._sub_carrier_freq_counter) self._sub_carrier_freq_counter.valueChanged.connect(self.set_sub_carrier_freq) self._sub_carrier_freq_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._sub_carrier_freq_slider.setRange(0, 50000, 1000) self._sub_carrier_freq_slider.setValue(self.sub_carrier_freq) self._sub_carrier_freq_slider.setMinimumWidth(200) self._sub_carrier_freq_slider.valueChanged.connect(self.set_sub_carrier_freq) self._sub_carrier_freq_layout.addWidget(self._sub_carrier_freq_slider) self.tabs_layout_1.addLayout(self._sub_carrier_freq_layout) self._send_gain_layout = Qt.QVBoxLayout() self._send_gain_tool_bar = Qt.QToolBar(self) self._send_gain_layout.addWidget(self._send_gain_tool_bar) self._send_gain_tool_bar.addWidget(Qt.QLabel("Send Gain (dB)"+": ")) self._send_gain_counter = Qwt.QwtCounter() self._send_gain_counter.setRange(0, 100, 1) self._send_gain_counter.setNumButtons(2) self._send_gain_counter.setValue(self.send_gain) self._send_gain_tool_bar.addWidget(self._send_gain_counter) self._send_gain_counter.valueChanged.connect(self.set_send_gain) self._send_gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._send_gain_slider.setRange(0, 100, 1) self._send_gain_slider.setValue(self.send_gain) self._send_gain_slider.setMinimumWidth(200) self._send_gain_slider.valueChanged.connect(self.set_send_gain) self._send_gain_layout.addWidget(self._send_gain_slider) self.tabs_layout_1.addLayout(self._send_gain_layout) self._recieve_gain_layout = Qt.QVBoxLayout() self._recieve_gain_tool_bar = Qt.QToolBar(self) self._recieve_gain_layout.addWidget(self._recieve_gain_tool_bar) self._recieve_gain_tool_bar.addWidget(Qt.QLabel("Recieve Gain (dB)"+": ")) self._recieve_gain_counter = Qwt.QwtCounter() self._recieve_gain_counter.setRange(0, 100, 1) self._recieve_gain_counter.setNumButtons(2) self._recieve_gain_counter.setValue(self.recieve_gain) self._recieve_gain_tool_bar.addWidget(self._recieve_gain_counter) self._recieve_gain_counter.valueChanged.connect(self.set_recieve_gain) self._recieve_gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._recieve_gain_slider.setRange(0, 100, 1) self._recieve_gain_slider.setValue(self.recieve_gain) self._recieve_gain_slider.setMinimumWidth(200) self._recieve_gain_slider.valueChanged.connect(self.set_recieve_gain) self._recieve_gain_layout.addWidget(self._recieve_gain_slider) self.tabs_layout_1.addLayout(self._recieve_gain_layout) self.uhd_usrp_source_0_0 = uhd.usrp_source( device_addr=USRP_IP, stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0_0.set_center_freq(carrier_freq, 0) self.uhd_usrp_source_0_0.set_gain(recieve_gain, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr=USRP_IP, stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(carrier_freq, 0) self.uhd_usrp_sink_0.set_gain(send_gain, 0) self.uhd_usrp_sink_0.set_bandwidth(samp_rate, 0) 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_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_0_win) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, sub_carrier_freq, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.qtgui_const_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Evm Simulation") Qt.QWidget.__init__(self) self.setWindowTitle("Evm Simulation") 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", "evm_simulation") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.vlen = vlen = 64 self.samp_rate = samp_rate = 1e6 self.noise_amp = noise_amp = 0 ################################################## # Blocks ################################################## 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 Amplitude"+": ")) 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(0, 1, 0.01) 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(0, 1, 0.01) 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_layout.addLayout(self._noise_amp_layout) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 2 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(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(True) labels = ["Reference Points", "Received Points", "", "", "", "", "", "", "", ""] widths = [2, 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 = [2.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_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_layout.addWidget(self._qtgui_const_sink_x_0_win) self.cs436_constellation_source_0 = cs436.constellation_source(64, 2) self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, vlen) self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, vlen) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*vlen, samp_rate,True) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, vlen) self.blocks_add_xx_0 = blocks.add_vcc(vlen) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(analog.GR_GAUSSIAN, noise_amp, 0, 8192) ################################################## # Connections ################################################## self.connect((self.cs436_constellation_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_vector_to_stream_0_0, 0)) self.connect((self.blocks_vector_to_stream_0_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.qtgui_const_sink_x_0, 1))
def __init__(self): gr.top_block.__init__(self, "Cr Application") Qt.QWidget.__init__(self) self.setWindowTitle("Cr Application") 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", "cr_application") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.preamble = preamble = [1,-1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,1,1,1,1,1,1,-1,-1] self.usrp_rf_freq = usrp_rf_freq = 2435000000 self.tx_pkt_rate = tx_pkt_rate = 157 self.samp_rate = samp_rate = 200000 self.preamble_qpsk = preamble_qpsk = map(lambda x: x*(1+1j)/pow(2,0.5), preamble) self.payload_size = payload_size = 50 self.nfilts = nfilts = 32 self.eb = eb = 0.35 self.digital_gain = digital_gain = 1.0/8 ################################################## # Blocks ################################################## self.crew_db_channel_selector_0 = crew.db_channel_selector('test_crew', 'zigbee', 'max', 0.05) def _usrp_rf_freq_probe(): while True: val = self.crew_db_channel_selector_0.get_freq() try: self.set_usrp_rf_freq(val) except AttributeError: pass time.sleep(1.0 / (10)) _usrp_rf_freq_thread = threading.Thread(target=_usrp_rf_freq_probe) _usrp_rf_freq_thread.daemon = True _usrp_rf_freq_thread.start() self.uhd_usrp_source_0_0 = uhd.usrp_source( ",".join(("addr=192.168.30.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0_0.set_center_freq(usrp_rf_freq, 0) self.uhd_usrp_source_0_0.set_gain(28, 0) self.uhd_usrp_source_0_0.set_antenna("J1", 0) self.uhd_usrp_sink_0_0 = uhd.usrp_sink( ",".join(("addr=192.168.50.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0_0.set_center_freq(usrp_rf_freq, 0) self.uhd_usrp_sink_0_0.set_gain(26, 0) self.uhd_usrp_sink_0_0.set_antenna("J1", 0) self.sync_blocks_0 = sync_blocks( digital_gain=19, ) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_VERT, 1 ) self.qtgui_number_sink_0.set_update_time(0.2) self.qtgui_number_sink_0.set_title("Packet Reception Rate") labels = [" ", "", "", "", "", "", "", "", "", ""] units = ["%", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [100, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, 0) 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.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 0,1,1,1) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 20000, #size "Rx Constellation", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(True) if not False: self.qtgui_const_sink_x_0_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win, 0,0,1,1) self.packet_gen_0 = packet_gen( payload_size=payload_size, ) self.crew_packet_decoder_cb_0 = crew.packet_decoder_cb((preamble_qpsk)) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char*1) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff((1.0/(tx_pkt_rate), )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((-1.0/(tx_pkt_rate), )) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/root/BasicTxRx/wilabt/file_sent.txt", True) self.blocks_add_const_vxx_0 = blocks.add_const_vff((1.0, )) ################################################## # Connections ################################################## self.connect((self.blocks_add_const_vxx_0, 0), (self.crew_db_channel_selector_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.packet_gen_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.crew_packet_decoder_cb_0, 1), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.crew_packet_decoder_cb_0, 1), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.crew_packet_decoder_cb_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.packet_gen_0, 0), (self.uhd_usrp_sink_0_0, 0)) self.connect((self.sync_blocks_0, 0), (self.crew_packet_decoder_cb_0, 0)) self.connect((self.sync_blocks_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.sync_blocks_0, 0))
def __init__(self): gr.top_block.__init__(self, "MPSK Demod Demo") Qt.QWidget.__init__(self) self.setWindowTitle("MPSK Demod Demo") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "mpsk_demod") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samps_per_sym = samps_per_sym = 4 self.samp_rate = samp_rate = 50000000 ################################################## # Blocks ################################################## self.notebook = Qt.QTabWidget() self.notebook_widget_0 = Qt.QWidget() self.notebook_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_widget_0) self.notebook_grid_layout_0 = Qt.QGridLayout() self.notebook_layout_0.addLayout(self.notebook_grid_layout_0) self.notebook.addTab(self.notebook_widget_0, "Constellation") self.notebook_widget_1 = Qt.QWidget() self.notebook_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_widget_1) self.notebook_grid_layout_1 = Qt.QGridLayout() self.notebook_layout_1.addLayout(self.notebook_grid_layout_1) self.notebook.addTab(self.notebook_widget_1, "Spectrum") self.top_layout.addWidget(self.notebook) 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_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.notebook_layout_1.addWidget(self._qtgui_freq_sink_x_0_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_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.notebook_layout_0.addWidget(self._qtgui_const_sink_x_0_win) self.digital_dxpsk_mod_0 = digital.dqpsk_mod( samples_per_symbol=samps_per_sym, excess_bw=0.35, mod_code="gray", verbose=False, log=False) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate) self.blks2_tcp_sink_0 = grc_blks2.tcp_sink( itemsize=gr.sizeof_gr_complex*1, addr="127.0.0.1", port=3305, server=True, ) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 2**8, 1000000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_dxpsk_mod_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blks2_tcp_sink_0, 0))
def test09(self): self.qtsnk = qtgui.const_sink_c(1024, "Test", 1)
def __init__(self, puncpat='11'): gr.top_block.__init__(self, "Eve") Qt.QWidget.__init__(self) self.setWindowTitle("Eve") 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", "eve") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.puncpat = puncpat ################################################## # Variables ################################################## self.sps = sps = 4 self.samp_rate_array_MCR = samp_rate_array_MCR = [ 7500000, 5000000, 3750000, 3000000, 2500000, 2000000, 1500000, 1000000, 937500, 882352, 833333, 714285, 533333, 500000, 421052, 400000, 380952, 200000 ] self.nfilts = nfilts = 32 self.eb = eb = 0.22 self.H_dec = H_dec = fec.ldpc_H_matrix( '/usr/local/share/gnuradio/fec/ldpc/n_1100_k_0442_gap_24.alist', 24) self.variable_qtgui_range_0_1 = variable_qtgui_range_0_1 = 56 self.samp_rate = samp_rate = samp_rate_array_MCR[15] self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine( nfilts, nfilts * sps, 1.0, eb, 11 * sps * nfilts) self.pld_dec = pld_dec = map( (lambda a: fec.ldpc_bit_flip_decoder.make(H_dec.get_base_sptr(), 7) ), range(0, 8)) self.pld_const = pld_const = digital.constellation_rect(([ 0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j ]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.pld_const.gen_soft_dec_lut(8) self.frequencia_usrp = frequencia_usrp = 24e8 self.MCR = MCR = "master_clock_rate=60e6" ################################################## # Blocks ################################################## self._variable_qtgui_range_0_1_range = Range(0, 73, 1, 56, 200) self._variable_qtgui_range_0_1_win = RangeWidget( self._variable_qtgui_range_0_1_range, self.set_variable_qtgui_range_0_1, 'Gain_RX', "counter_slider", float) self.top_grid_layout.addWidget(self._variable_qtgui_range_0_1_win, 0, 2, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.uhd_usrp_source_0_0 = uhd.usrp_source( ",".join(("serial=F5EB09", MCR)), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0_0.set_center_freq(frequencia_usrp, 0) self.uhd_usrp_source_0_0.set_gain(variable_qtgui_range_0_1, 0) self.uhd_usrp_source_0_0.set_antenna('TX/RX', 0) self.uhd_usrp_source_0_0.set_auto_dc_offset(True, 0) self.uhd_usrp_source_0_0.set_auto_iq_balance(True, 0) self.qtgui_time_sink_x_2_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "After CAC", #name 1 #number of inputs ) self.qtgui_time_sink_x_2_0.set_update_time(0.10) self.qtgui_time_sink_x_2_0.set_y_axis(0, 1.5) self.qtgui_time_sink_x_2_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_2_0.enable_tags(-1, True) self.qtgui_time_sink_x_2_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_2_0.enable_autoscale(False) self.qtgui_time_sink_x_2_0.enable_grid(True) self.qtgui_time_sink_x_2_0.enable_axis_labels(True) self.qtgui_time_sink_x_2_0.enable_control_panel(False) self.qtgui_time_sink_x_2_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_2_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_2_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_2_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_2_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_2_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_2_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_2_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_2_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_2_0_win = sip.wrapinstance( self.qtgui_time_sink_x_2_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_2_0_win, 2, 2, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_1_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "RX USRP", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0.enable_grid(False) self.qtgui_time_sink_x_1_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0.enable_control_panel(False) self.qtgui_time_sink_x_1_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_1_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_win = sip.wrapinstance( self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_win, 1, 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( 100 * 2, #size samp_rate, #samp_rate 'Rx Data', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_1.set_update_time(0.10) self.qtgui_time_sink_x_0_1.set_y_axis(-1, 256) self.qtgui_time_sink_x_0_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_1.enable_tags(-1, True) self.qtgui_time_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, 'packet_length_tag_key') self.qtgui_time_sink_x_0_1.enable_autoscale(True) self.qtgui_time_sink_x_0_1.enable_grid(True) self.qtgui_time_sink_x_0_1.enable_axis_labels(True) self.qtgui_time_sink_x_0_1.enable_control_panel(False) self.qtgui_time_sink_x_0_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_1_win = sip.wrapinstance( self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_win, 2, 3, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0_0_1 = qtgui.const_sink_c( 1024, #size "RX Const", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0_1.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_1.set_trigger_mode( qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0_1.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0_1.enable_grid(False) self.qtgui_const_sink_x_0_0_0_1.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_0_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_1_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_1_win, 1, 3, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c( 1024, #size "RX Treated", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_win, 2, 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.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, 6.28 / 100.0, (rx_rrc_taps), nfilts, nfilts / 2, 1.5, 2) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb( pld_const.arity()) self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc( 6.28 / 100.0, pld_const.arity(), False) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( pld_const) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc( 15, 1, 0.01, 2) self.cac_cpp_cac_bb_0 = cac_cpp.cac_bb( digital.packet_utils.default_access_code, 1) self.blocks_repack_bits_bb_0_0_0_1_0 = blocks.repack_bits_bb( 1, 8, '', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( pld_const.bits_per_symbol(), 1, '', False, gr.GR_MSB_FIRST) self.blocks_file_sink_0_0_0_0_0 = blocks.file_sink( gr.sizeof_char * 1, '/home/andre/ELI/1/EVE_55_8000_BRUTO.txt', False) self.blocks_file_sink_0_0_0_0_0.set_unbuffered(True) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_gr_complex * 1, '/home/andre/ELI/1/EVE_EVM.txt', False) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_char_to_float_1_0_1 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) ################################################## # Connections ################################################## self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_2_0, 0)) self.connect((self.blocks_char_to_float_1_0_1, 0), (self.qtgui_time_sink_x_0_1, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.cac_cpp_cac_bb_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0_0_1_0, 0), (self.blocks_char_to_float_1_0_1, 0)) self.connect((self.blocks_repack_bits_bb_0_0_0_1_0, 0), (self.blocks_file_sink_0_0_0_0_0, 0)) self.connect((self.cac_cpp_cac_bb_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.cac_cpp_cac_bb_0, 0), (self.blocks_repack_bits_bb_0_0_0_1_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.qtgui_const_sink_x_0_0_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.qtgui_const_sink_x_0_0_0_1, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.qtgui_time_sink_x_1_0, 0))
def __init__(self): gr.top_block.__init__(self, "DAB channel decoder") Qt.QWidget.__init__(self) self.setWindowTitle("DAB channel decoder") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "dab_channel_decoder") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2048000 self.freq_offset = freq_offset = 0 ################################################## # Blocks ################################################## self.rtlsdr_source_0_0 = osmosdr.source(args="numchan=" + str(1) + " " + '') self.rtlsdr_source_0_0.set_time_unknown_pps(osmosdr.time_spec_t()) self.rtlsdr_source_0_0.set_sample_rate(samp_rate) self.rtlsdr_source_0_0.set_center_freq(218640000, 0) self.rtlsdr_source_0_0.set_freq_corr(0, 0) self.rtlsdr_source_0_0.set_gain(30, 0) self.rtlsdr_source_0_0.set_if_gain(20, 0) self.rtlsdr_source_0_0.set_bb_gain(20, 0) self.rtlsdr_source_0_0.set_antenna('', 0) self.rtlsdr_source_0_0.set_bandwidth(0, 0) self.qtgui_time_sink_x_1_0 = qtgui.time_sink_f( 2048 * 96 * 2, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0.set_y_axis(-1 * 3.1415 / 2048, 1 * 3.1415 / 2048) self.qtgui_time_sink_x_1_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0.enable_tags(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) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_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) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 2048 * 5, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(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(True) 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) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_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) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_1.set_update_time(0.10) self.qtgui_const_sink_x_1.set_y_axis(-200, 200) self.qtgui_const_sink_x_1.set_x_axis(-200, 200) self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1.enable_autoscale(False) self.qtgui_const_sink_x_1.enable_grid(False) self.qtgui_const_sink_x_1.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(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._freq_offset_range = Range(-1000, +1000, 10, 0, 200) self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, 'freq_offset', "counter_slider", float) self.top_grid_layout.addWidget(self._freq_offset_win) self.fft_vxx_0 = fft.fft_vcc(2048, True, [], True, 1) self.blocks_vector_to_stream_0_0_0_1 = blocks.vector_to_stream( gr.sizeof_char * 1, 2304) self.blocks_vector_to_stream_0_0_0 = blocks.vector_to_stream( gr.sizeof_char * 1, 768) self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, 2048) self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, 1536) self.blocks_unpacked_to_packed_xx_0_0_0 = blocks.unpacked_to_packed_bb( 1, gr.GR_MSB_FIRST) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb( 1, gr.GR_MSB_FIRST) self.blocks_file_sink_0_0_0 = blocks.file_sink(gr.sizeof_char * 1, 'msc.fifo', False) self.blocks_file_sink_0_0_0.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1, 'fic.dat', False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.bad_time_deinterleaver_0 = bad.time_deinterleaver(4608) self.bad_qpsk_symbol_demapper_0 = bad.qpsk_symbol_demapper() self.bad_ofdm_symbols_selector_0_0 = bad.ofdm_symbols_selector(4, 72) self.bad_ofdm_symbols_selector_0 = bad.ofdm_symbols_selector(1, 3) self.bad_ofdm_sampler_0 = bad.ofdm_sampler() self.bad_ofdm_fine_frequency_correction_0 = bad.ofdm_fine_frequency_correction( 0.1) self.bad_ofdm_differential_demodulator_0 = bad.ofdm_differential_demodulator( ) self.bad_ofdm_coarse_frequency_correction_0 = bad.ofdm_coarse_frequency_correction( ) self.bad_ns_detector_1 = bad.ns_detector() self.bad_msc_eep_convolutional_decoder_0 = bad.convolutional_decoder( bad.PROTECTION_TYPE_EEP_A, 3, 12) self.bad_frequency_deinterleaver_0 = bad.frequency_deinterleaver() self.bad_fic_convolutional_decoder_0 = bad.convolutional_decoder( bad.PROTECTION_TYPE_FIC, 0, 0) self.bad_energy_dispersal_descrambler_0_0 = bad.energy_dispersal_descrambler( 2304) self.bad_energy_dispersal_descrambler_0 = bad.energy_dispersal_descrambler( 768) self.bad_cus_selector_0 = bad.cus_selector(618, 72) self.bad_adapter_0_1 = bad.adapter_ff(64, 72, 64 * 72, 1, "") self.bad_adapter_0_0 = bad.adapter_ff(3072, 3, 2304, 4, "") self.bad_adapter_0 = bad.adapter_ff(3072, 18, 64, 864, "cu") ################################################## # Connections ################################################## self.connect((self.bad_adapter_0, 0), (self.bad_cus_selector_0, 0)) self.connect((self.bad_adapter_0_0, 0), (self.bad_fic_convolutional_decoder_0, 0)) self.connect((self.bad_adapter_0_1, 0), (self.bad_time_deinterleaver_0, 0)) self.connect((self.bad_cus_selector_0, 0), (self.bad_adapter_0_1, 0)) self.connect((self.bad_energy_dispersal_descrambler_0, 0), (self.blocks_vector_to_stream_0_0_0, 0)) self.connect((self.bad_energy_dispersal_descrambler_0_0, 0), (self.blocks_vector_to_stream_0_0_0_1, 0)) self.connect((self.bad_fic_convolutional_decoder_0, 0), (self.bad_energy_dispersal_descrambler_0, 0)) self.connect((self.bad_frequency_deinterleaver_0, 0), (self.bad_qpsk_symbol_demapper_0, 0)) self.connect((self.bad_msc_eep_convolutional_decoder_0, 0), (self.bad_energy_dispersal_descrambler_0_0, 0)) self.connect((self.bad_ns_detector_1, 0), (self.bad_ofdm_fine_frequency_correction_0, 0)) self.connect((self.bad_ofdm_coarse_frequency_correction_0, 0), (self.bad_ofdm_differential_demodulator_0, 0)) self.connect((self.bad_ofdm_differential_demodulator_0, 0), (self.bad_frequency_deinterleaver_0, 0)) self.connect((self.bad_ofdm_differential_demodulator_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.bad_ofdm_fine_frequency_correction_0, 0), (self.bad_ofdm_sampler_0, 0)) self.connect((self.bad_ofdm_fine_frequency_correction_0, 1), (self.qtgui_time_sink_x_1_0, 0)) self.connect((self.bad_ofdm_sampler_0, 0), (self.fft_vxx_0, 0)) self.connect((self.bad_ofdm_symbols_selector_0, 0), (self.bad_adapter_0_0, 0)) self.connect((self.bad_ofdm_symbols_selector_0_0, 0), (self.bad_adapter_0, 0)) self.connect((self.bad_qpsk_symbol_demapper_0, 0), (self.bad_ofdm_symbols_selector_0, 0)) self.connect((self.bad_qpsk_symbol_demapper_0, 0), (self.bad_ofdm_symbols_selector_0_0, 0)) self.connect((self.bad_time_deinterleaver_0, 0), (self.bad_msc_eep_convolutional_decoder_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0_0_0, 0), (self.blocks_file_sink_0_0_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.blocks_vector_to_stream_0_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.blocks_vector_to_stream_0_0_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.blocks_vector_to_stream_0_0_0_1, 0), (self.blocks_unpacked_to_packed_xx_0_0_0, 0)) self.connect((self.fft_vxx_0, 0), (self.bad_ofdm_coarse_frequency_correction_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_0_0, 0)) self.connect((self.rtlsdr_source_0_0, 0), (self.bad_ns_detector_1, 0)) self.connect((self.rtlsdr_source_0_0, 0), (self.qtgui_freq_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Psk Rx") Qt.QWidget.__init__(self) self.setWindowTitle("Psk Rx") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "psk_rx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 2 self.samp_rate = samp_rate = 1e6 self.my_constellation = my_constellation = digital.constellation_calcdist(([-1,1]), ([0, 1]), 2, 1).base() self.freq = freq = 2.4e9 ################################################## # Blocks ################################################## self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #fc samp_rate, #bw "", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0/10) self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(False) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) 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_layout.addWidget(self._qtgui_const_sink_x_0_win) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(10, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 6.28/100.0, (filter.firdes.root_raised_cosine(32,32*sps,1.0,0.35,11*32*sps)), 32, 16, 1.5, 1) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(sps, 0.35, 55, 6.28/100.0) self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2) self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb(my_constellation, 6.28/100.0, -0.25, 0.25) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(1) self.blocks_null_sink_0_1 = blocks.null_sink(gr.sizeof_float*1) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, "/home/ubuntu/recv.b", False) self.blocks_file_sink_0.set_unbuffered(False) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_c(grc_blks2.packet_decoder( access_code="", threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload), ), ) self.analog_agc2_xx_0 = analog.agc2_cc(0.06, 0.001, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 2), (self.blocks_null_sink_0_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 3), (self.blocks_null_sink_0_1, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.digital_diff_encoder_bb_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 4), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_diff_encoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_constellation_receiver_cb_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.qtgui_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Bob") Qt.QWidget.__init__(self) self.setWindowTitle("Bob") 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", "bob") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.samp_rate_array_MCR = samp_rate_array_MCR = [ 7500000, 5000000, 3750000, 3000000, 2500000, 2000000, 1500000, 1000000, 937500, 882352, 833333, 714285, 533333, 500000, 421052, 400000, 380952, 200000 ] self.nfilts = nfilts = 32 self.eb = eb = 0.22 self.variable_qtgui_range_0_1 = variable_qtgui_range_0_1 = rpower self.variable_qtgui_range_0_0 = variable_qtgui_range_0_0 = jpower self.samp_rate = samp_rate = samp_rate_array_MCR[15] self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine( nfilts, nfilts * sps, 1.0, eb, 11 * sps * nfilts) self.pld_const = pld_const = digital.constellation_rect(([ 0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j ]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.pld_const.gen_soft_dec_lut(8) self.frequencia_usrp = frequencia_usrp = 24e8 self.MCR = MCR = "master_clock_rate=60e6" ################################################## # Blocks ################################################## self._variable_qtgui_range_0_1_range = Range(0, 73, 1, rpower, 200) self._variable_qtgui_range_0_1_win = RangeWidget( self._variable_qtgui_range_0_1_range, self.set_variable_qtgui_range_0_1, 'Gain_RX', "counter_slider", float) self.top_grid_layout.addWidget(self._variable_qtgui_range_0_1_win, 0, 1, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._variable_qtgui_range_0_0_range = Range(0, 90, 1, jpower, 200) self._variable_qtgui_range_0_0_win = RangeWidget( self._variable_qtgui_range_0_0_range, self.set_variable_qtgui_range_0_0, 'Gain_Jamming', "counter_slider", float) self.top_grid_layout.addWidget(self._variable_qtgui_range_0_0_win, 0, 2, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.uhd_usrp_source_0_0 = uhd.usrp_source( ",".join(("serial=F5EAC0", MCR)), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0_0.set_center_freq(frequencia_usrp, 0) self.uhd_usrp_source_0_0.set_gain(variable_qtgui_range_0_1, 0) self.uhd_usrp_source_0_0.set_antenna('TX/RX', 0) self.uhd_usrp_source_0_0.set_auto_dc_offset(True, 0) self.uhd_usrp_source_0_0.set_auto_iq_balance(True, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("serial=F5EAC0", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_subdev_spec('A:B', 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0.set_center_freq(frequencia_usrp, 0) self.uhd_usrp_sink_0.set_gain(variable_qtgui_range_0_0, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.qtgui_time_sink_x_1_0_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "TX JAMMING USRP", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0_0.enable_grid(False) self.qtgui_time_sink_x_1_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0_0.enable_control_panel(False) self.qtgui_time_sink_x_1_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_1_0_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_1_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_0_win, 1, 1, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_1_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "RX USRP", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0.enable_grid(False) self.qtgui_time_sink_x_1_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0.enable_control_panel(False) self.qtgui_time_sink_x_1_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_1_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_win = sip.wrapinstance( self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_win, 1, 3, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_1_0 = qtgui.time_sink_f( 100 * 2, #size samp_rate, #samp_rate 'Rx Data', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_1_0.set_update_time(0.10) self.qtgui_time_sink_x_0_1_0.set_y_axis(-1, 256) self.qtgui_time_sink_x_0_1_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_1_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, 'packet_length_tag_key') self.qtgui_time_sink_x_0_1_0.enable_autoscale(True) self.qtgui_time_sink_x_0_1_0.enable_grid(True) self.qtgui_time_sink_x_0_1_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_1_0.enable_control_panel(False) self.qtgui_time_sink_x_0_1_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_1_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_1_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_1_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_0_win, 2, 3, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance( self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 1, 2, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0_0_1 = qtgui.const_sink_c( 1024, #size "RX Const", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0_1.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_1.set_trigger_mode( qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0_1.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0_1.enable_grid(False) self.qtgui_const_sink_x_0_0_0_1.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_0_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_1_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_1_win, 2, 1, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c( 1024, #size "RX Treated", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_win, 2, 2, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.interp_fir_filter_xxx_1 = filter.interp_fir_filter_ccc( 4, ([1, 0, 0, 0])) self.interp_fir_filter_xxx_1.declare_sample_delay(0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, 6.28 / 100.0, (rx_rrc_taps), nfilts, nfilts / 2, 1.5, 2) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb( pld_const.arity()) self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc( 6.28 / 100.0, pld_const.arity(), False) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( pld_const) self.digital_cma_equalizer_cc_0_0 = digital.cma_equalizer_cc( 15, 1, 0.01, 2) self.custom_corr = correlate_and_delay.corr_and_delay( 200 * sps, 0, 0.9995, sps) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( pld_const.bits_per_symbol(), 8, '', False, gr.GR_MSB_FIRST) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vcc((0.5, )) self.blocks_file_sink_0_0_0_0_2 = blocks.file_sink( gr.sizeof_char * 1, '/home/it/ELI/' + num + '/BOB_55_8000_BRUTO.txt', False) self.blocks_file_sink_0_0_0_0_2.set_unbuffered(True) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_gr_complex * 1, '/home/it/ELI/' + num + '/BOB_EVM.txt', False) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_char_to_float_1_0_1_0 = blocks.char_to_float(1, 1) self.analog_noise_source_x_0_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 1, -5) self.adapt_lms_filter_xx_0 = adapt.lms_filter_cc( True, 64, 0.0001, 0, 1, True, False, False) ################################################## # Connections ################################################## self.connect((self.adapt_lms_filter_xx_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.adapt_lms_filter_xx_0, 1), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.analog_noise_source_x_0_0, 0), (self.interp_fir_filter_xxx_1, 0)) self.connect((self.blocks_char_to_float_1_0_1_0, 0), (self.qtgui_time_sink_x_0_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.custom_corr, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.qtgui_time_sink_x_1_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_char_to_float_1_0_1_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_file_sink_0_0_0_0_2, 0)) self.connect((self.custom_corr, 0), (self.adapt_lms_filter_xx_0, 1)) self.connect((self.custom_corr, 1), (self.adapt_lms_filter_xx_0, 0)) self.connect((self.custom_corr, 2), (self.blocks_null_sink_1, 0)) self.connect((self.digital_cma_equalizer_cc_0_0, 0), (self.digital_costas_loop_cc_0_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.qtgui_const_sink_x_0_0_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0_0, 0)) self.connect((self.interp_fir_filter_xxx_1, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.custom_corr, 1)) self.connect((self.uhd_usrp_source_0_0, 0), (self.qtgui_const_sink_x_0_0_0_1, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.qtgui_time_sink_x_1_0, 0))
def __init__(self): gr.top_block.__init__(self, "FM Radio") Qt.QWidget.__init__(self) self.setWindowTitle("FM Radio") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "fm_radio") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.valid_gains = valid_gains = [0.0, 0.9, 1.4, 2.7, 3.7, 7.7, 8.7, 12.5, 14.4, 15.7, 16.6, 19.7, 20.7, 22.9, 25.4, 28.0, 29.7, 32.8, 33.8, 36.4, 37.2, 38.6, 40.2, 42.1, 43.4, 43.9, 44.5, 48.0, 49.6] self.samp_rate = samp_rate = 2.048e6 self.baseband_decimation = baseband_decimation = 10 self.rf_gain = rf_gain = len(valid_gains)-1 self.rds_dec = rds_dec = 10 self.pilot_tone = pilot_tone = 19e3 self.baseband_rate = baseband_rate = samp_rate // baseband_decimation self.stereo_subcarrier = stereo_subcarrier = pilot_tone * 2 self.stereo_button = stereo_button = 0 self.slider_volume = slider_volume = 0 self.sdr_gain = sdr_gain = valid_gains[rf_gain] self.rds_symbols_per_bit = rds_symbols_per_bit = 2 self.rds_subcarrier = rds_subcarrier = pilot_tone * 3 self.rds_samp_rate = rds_samp_rate = baseband_rate / rds_dec self.rds_bitrate = rds_bitrate = 1.1875e3 self.rds_bandwidth = rds_bandwidth = 2.83e3 self.fm_station = fm_station = 102.7 self.fm_broadcast_seperation = fm_broadcast_seperation = 0.2 self.fm_broadcast_low = fm_broadcast_low = 87.1 self.fm_broadcast_high = fm_broadcast_high = 107.9 self.audio_rate = audio_rate = 48e3 ################################################## # Blocks ################################################## self.notebook_top = Qt.QTabWidget() self.notebook_top_widget_0 = Qt.QWidget() self.notebook_top_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_top_widget_0) self.notebook_top_grid_layout_0 = Qt.QGridLayout() self.notebook_top_layout_0.addLayout(self.notebook_top_grid_layout_0) self.notebook_top.addTab(self.notebook_top_widget_0, "RF Receive") self.notebook_top_widget_1 = Qt.QWidget() self.notebook_top_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_top_widget_1) self.notebook_top_grid_layout_1 = Qt.QGridLayout() self.notebook_top_layout_1.addLayout(self.notebook_top_grid_layout_1) self.notebook_top.addTab(self.notebook_top_widget_1, "Baseband") self.notebook_top_widget_2 = Qt.QWidget() self.notebook_top_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_top_widget_2) self.notebook_top_grid_layout_2 = Qt.QGridLayout() self.notebook_top_layout_2.addLayout(self.notebook_top_grid_layout_2) self.notebook_top.addTab(self.notebook_top_widget_2, "Mono Audio") self.notebook_top_widget_3 = Qt.QWidget() self.notebook_top_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_top_widget_3) self.notebook_top_grid_layout_3 = Qt.QGridLayout() self.notebook_top_layout_3.addLayout(self.notebook_top_grid_layout_3) self.notebook_top.addTab(self.notebook_top_widget_3, "Sub-Carrier Generation") self.notebook_top_widget_4 = Qt.QWidget() self.notebook_top_layout_4 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_top_widget_4) self.notebook_top_grid_layout_4 = Qt.QGridLayout() self.notebook_top_layout_4.addLayout(self.notebook_top_grid_layout_4) self.notebook_top.addTab(self.notebook_top_widget_4, "Stereo") self.notebook_top_widget_5 = Qt.QWidget() self.notebook_top_layout_5 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_top_widget_5) self.notebook_top_grid_layout_5 = Qt.QGridLayout() self.notebook_top_layout_5.addLayout(self.notebook_top_grid_layout_5) self.notebook_top.addTab(self.notebook_top_widget_5, "RDS") self.top_grid_layout.addWidget(self.notebook_top, 3, 0, 1, 8) self._slider_volume_range = Range(0, 11.1, 0.1, 0, 100) self._slider_volume_win = RangeWidget(self._slider_volume_range, self.set_slider_volume, 'Volume', "counter_slider", float) self.top_grid_layout.addWidget(self._slider_volume_win, 1, 1, 1, 1) self.notebook_subcarriers = Qt.QTabWidget() self.notebook_subcarriers_widget_0 = Qt.QWidget() self.notebook_subcarriers_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_subcarriers_widget_0) self.notebook_subcarriers_grid_layout_0 = Qt.QGridLayout() self.notebook_subcarriers_layout_0.addLayout(self.notebook_subcarriers_grid_layout_0) self.notebook_subcarriers.addTab(self.notebook_subcarriers_widget_0, "Pilot Signal") self.notebook_subcarriers_widget_1 = Qt.QWidget() self.notebook_subcarriers_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_subcarriers_widget_1) self.notebook_subcarriers_grid_layout_1 = Qt.QGridLayout() self.notebook_subcarriers_layout_1.addLayout(self.notebook_subcarriers_grid_layout_1) self.notebook_subcarriers.addTab(self.notebook_subcarriers_widget_1, "Spectrum") self.notebook_top_grid_layout_3.addWidget(self.notebook_subcarriers, 0, 0, 1, 1) self.notebook_rds = Qt.QTabWidget() self.notebook_rds_widget_0 = Qt.QWidget() self.notebook_rds_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_rds_widget_0) self.notebook_rds_grid_layout_0 = Qt.QGridLayout() self.notebook_rds_layout_0.addLayout(self.notebook_rds_grid_layout_0) self.notebook_rds.addTab(self.notebook_rds_widget_0, "RDS Signal") self.notebook_rds_widget_1 = Qt.QWidget() self.notebook_rds_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_rds_widget_1) self.notebook_rds_grid_layout_1 = Qt.QGridLayout() self.notebook_rds_layout_1.addLayout(self.notebook_rds_grid_layout_1) self.notebook_rds.addTab(self.notebook_rds_widget_1, "RDS Bitstream") self.notebook_top_grid_layout_5.addWidget(self.notebook_rds, 0, 0, 1, 1) self._fm_station_range = Range(fm_broadcast_low, fm_broadcast_high, fm_broadcast_seperation, 102.7, 200) self._fm_station_win = RangeWidget(self._fm_station_range, self.set_fm_station, "FM Station", "counter_slider", float) self.top_grid_layout.addWidget(self._fm_station_win, 0, 0, 1, 8) self._stereo_button_options = (0, 1, ) self._stereo_button_labels = ("Mono", "Stereo", ) self._stereo_button_tool_bar = Qt.QToolBar(self) self._stereo_button_tool_bar.addWidget(Qt.QLabel("Audio Output"+": ")) self._stereo_button_combo_box = Qt.QComboBox() self._stereo_button_tool_bar.addWidget(self._stereo_button_combo_box) for label in self._stereo_button_labels: self._stereo_button_combo_box.addItem(label) self._stereo_button_callback = lambda i: Qt.QMetaObject.invokeMethod(self._stereo_button_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._stereo_button_options.index(i))) self._stereo_button_callback(self.stereo_button) self._stereo_button_combo_box.currentIndexChanged.connect( lambda i: self.set_stereo_button(self._stereo_button_options[i])) self.top_grid_layout.addWidget(self._stereo_button_tool_bar, 1, 2, 1, 1) self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(fm_station * 1e6, 0) self.rtlsdr_source_0.set_freq_corr(14, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(sdr_gain, 0) self.rtlsdr_source_0.set_if_gain(0, 0) self.rtlsdr_source_0.set_bb_gain(0, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(1, firdes.root_raised_cosine( 2, rds_samp_rate, rds_bitrate * rds_symbols_per_bit, 0.275, 16)) self._rf_gain_range = Range(0, len(valid_gains)-1, 1, len(valid_gains)-1, 200) self._rf_gain_win = RangeWidget(self._rf_gain_range, self.set_rf_gain, "RF Gain", "counter_slider", int) self.top_grid_layout.addWidget(self._rf_gain_win, 1, 0, 1, 1) self.rds_qt_panel_0 = self.rds_qt_panel_0 = rds.qt_panel() self.notebook_top_layout_5.addWidget(self.rds_qt_panel_0) self.rational_resampler_xxx_0_0_0_1 = filter.rational_resampler_fff( interpolation=int(audio_rate), decimation=int(baseband_rate), taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0_0_0_0 = filter.rational_resampler_fff( interpolation=int(audio_rate), decimation=int(baseband_rate), taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0_0_0 = filter.rational_resampler_fff( interpolation=int(audio_rate), decimation=int(baseband_rate), taps=None, fractional_bw=None, ) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "RBDS Bit Stream", #name 2 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1.7, 1.7) self.qtgui_time_sink_x_1.set_y_label("Amplitude", "") self.qtgui_time_sink_x_1.enable_tags(-1, False) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(True) self.qtgui_time_sink_x_1.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ["Raw Bit Stream", "Differential Decoded", "", "", "", "", "", "", "", ""] 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_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.notebook_rds_layout_1.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size baseband_rate, #samp_rate "19 KHz Pilot Signal", #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.5, 1.5) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "counts") self.qtgui_time_sink_x_0.enable_tags(-1, False) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not False: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(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.notebook_subcarriers_grid_layout_0.addWidget(self._qtgui_time_sink_x_0_win, 0, 1, 1, 1) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc rds_samp_rate, #bw "RDS Subcarrier Signal (DSB-SSC)", #name 2 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-100, 0) self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_1.disable_legend() if complex == type(float()): self.qtgui_freq_sink_x_1.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.notebook_rds_grid_layout_0 .addWidget(self._qtgui_freq_sink_x_1_win, 0, 0, 1, 1) self.qtgui_freq_sink_x_0_1_0_1_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc audio_rate, #bw "Stereo Audio Left", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0_1_0_1_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_1_0_1_0.set_y_axis(-100, -30) self.qtgui_freq_sink_x_0_1_0_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_1_0_1_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_1_0_1_0.enable_grid(False) self.qtgui_freq_sink_x_0_1_0_1_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0_1_0_1_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0_1_0_1_0.disable_legend() if float == type(float()): self.qtgui_freq_sink_x_0_1_0_1_0.set_plot_pos_half(not False) labels = ["Stereo Left", "Stereo Right", "", "", "", "", "", "", "", ""] 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_1_0_1_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_1_0_1_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_1_0_1_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_1_0_1_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_1_0_1_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_1_0_1_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_1_0_1_0.pyqwidget(), Qt.QWidget) self.notebook_top_grid_layout_4.addWidget(self._qtgui_freq_sink_x_0_1_0_1_0_win, 0, 0, 1, 1) self.qtgui_freq_sink_x_0_1_0_1 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc audio_rate, #bw "Stereo Audio Right", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0_1_0_1.set_update_time(0.10) self.qtgui_freq_sink_x_0_1_0_1.set_y_axis(-100, -30) self.qtgui_freq_sink_x_0_1_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_1_0_1.enable_autoscale(False) self.qtgui_freq_sink_x_0_1_0_1.enable_grid(False) self.qtgui_freq_sink_x_0_1_0_1.set_fft_average(0.1) self.qtgui_freq_sink_x_0_1_0_1.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0_1_0_1.disable_legend() if float == type(float()): self.qtgui_freq_sink_x_0_1_0_1.set_plot_pos_half(not False) labels = ["Stereo Right", "Stereo Right", "", "", "", "", "", "", "", ""] 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_1_0_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_1_0_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_1_0_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_1_0_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_1_0_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_1_0_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_1_0_1.pyqwidget(), Qt.QWidget) self.notebook_top_grid_layout_4.addWidget(self._qtgui_freq_sink_x_0_1_0_1_win, 0, 1, 1, 1) self.qtgui_freq_sink_x_0_1_0_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc baseband_rate, #bw "Pilot & Stereo Carrier", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0_1_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_1_0_0.set_y_axis(-80, 0) self.qtgui_freq_sink_x_0_1_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_1_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_1_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_1_0_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0_1_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_1_0_0.disable_legend() if float == type(float()): self.qtgui_freq_sink_x_0_1_0_0.set_plot_pos_half(not False) labels = ["Pilot Tone", "Stereo Carrier", "RDS Carrier", "", "", "", "", "", "", ""] 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_1_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_1_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_1_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_1_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_1_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_1_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_1_0_0.pyqwidget(), Qt.QWidget) self.notebook_subcarriers_grid_layout_1.addWidget(self._qtgui_freq_sink_x_0_1_0_0_win, 0, 0, 1, 1) self.qtgui_freq_sink_x_0_0_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc audio_rate, #bw "Mono Audio (L+R)", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0_0.set_y_axis(-100, -30) self.qtgui_freq_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0_0_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0_0_0.disable_legend() if float == type(float()): self.qtgui_freq_sink_x_0_0_0.set_plot_pos_half(not False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.notebook_top_grid_layout_2.addWidget(self._qtgui_freq_sink_x_0_0_0_win, 1, 0, 1, 5) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc baseband_rate, #bw "FM Baseband", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-100, -30) self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0_0.disable_legend() if float == type(float()): self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.notebook_top_grid_layout_1.addWidget(self._qtgui_freq_sink_x_0_0_win, 0, 1, 1, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype fm_station * 1e6, #fc samp_rate, #bw "RF Frequency", #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(-90, 0) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if complex == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.notebook_top_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0, 1, 1, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "RDS BPSK Constellation", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-1.6, 1.6) self.qtgui_const_sink_x_0.set_x_axis(-1.6, 1.6) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(True) if not False: self.qtgui_const_sink_x_0.disable_legend() labels = ["RBDS BPSK", "", "", "", "", "", "", "", "", ""] 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.notebook_rds_grid_layout_0.addWidget(self._qtgui_const_sink_x_0_win, 0, 1, 1, 1) self.low_pass_filter_4 = filter.fir_filter_fff(1, firdes.low_pass( 1, baseband_rate, 60e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_2 = filter.fir_filter_fff(1, firdes.low_pass( 1, baseband_rate, 16e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_1 = filter.fir_filter_fff(1, firdes.low_pass( 10, baseband_rate, 15e3, 3e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(baseband_decimation, firdes.low_pass( 1, samp_rate, 75e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.gr_rds_parser_0 = rds.parser(False, False, 1) self.gr_rds_decoder_0 = rds.decoder(False, False) self.freq_xlating_fir_filter_xxx_1 = filter.freq_xlating_fir_filter_fcc(rds_dec, (firdes.low_pass(2500,baseband_rate,rds_bandwidth,1e3,firdes.WIN_HAMMING)), rds_subcarrier, baseband_rate) self.digital_mpsk_receiver_cc_0 = digital.mpsk_receiver_cc(2, 0, (2 * cmath.pi) / 100, -0.00006, 0.00006, 0.5, 0.05, rds_samp_rate / (rds_bitrate * 2), ((rds_samp_rate / (rds_bitrate * 2)) ** 2)/ 4, 0.005) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_uchar_to_float_0_0 = blocks.uchar_to_float() self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_multiply_xx_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_1_0_1_0_1 = blocks.multiply_const_vff((11, )) self.blocks_multiply_const_vxx_1_0_1_0_0 = blocks.multiply_const_vff((11, )) self.blocks_multiply_const_vxx_1_0_1_0 = blocks.multiply_const_vff((11, )) self.blocks_multiply_const_vxx_1_0_1 = blocks.multiply_const_vff((slider_volume, )) self.blocks_multiply_const_vxx_1_0_0 = blocks.multiply_const_vff((slider_volume, )) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff((slider_volume, )) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_char*1, 2) self.blocks_complex_to_real_1 = blocks.complex_to_real(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.blocks_add_const_vxx_0_0 = blocks.add_const_vff((0.5, )) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1.5, )) self.blks2_selector_0_0 = grc_blks2.selector( item_size=gr.sizeof_float*1, num_inputs=2, num_outputs=1, input_index=0, output_index=0, ) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_float*1, num_inputs=2, num_outputs=1, input_index=0, output_index=0, ) self.band_pass_filter_1 = filter.fir_filter_fff(1, firdes.band_pass( 1, baseband_rate, stereo_subcarrier - 0.5e3, stereo_subcarrier + 0.5e3, 0.5e3, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0_0 = filter.fir_filter_fff(1, firdes.band_pass( 1, baseband_rate, 23e3, 53e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0 = filter.fir_filter_fcc(1, firdes.complex_band_pass( 1, baseband_rate, pilot_tone - 0.5e3, pilot_tone+0.5e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=baseband_rate, audio_decimation=1, ) self.analog_pll_refout_cc_0 = analog.pll_refout_cc(1e-3, 2 * cmath.pi * (19000+200) / baseband_rate, 2 * cmath.pi * (19000-200) / baseband_rate) self.analog_fm_deemph_0_0_0_1 = analog.fm_deemph(fs=baseband_rate, tau=75e-6) self.analog_fm_deemph_0_0_0_0 = analog.fm_deemph(fs=baseband_rate, tau=75e-6) self.analog_fm_deemph_0_0_0 = analog.fm_deemph(fs=baseband_rate, tau=75e-6) ################################################## # Connections ################################################## self.msg_connect((self.gr_rds_decoder_0, 'out'), (self.gr_rds_parser_0, 'in')) self.msg_connect((self.gr_rds_parser_0, 'out'), (self.rds_qt_panel_0, 'in')) self.connect((self.analog_fm_deemph_0_0_0, 0), (self.rational_resampler_xxx_0_0_0, 0)) self.connect((self.analog_fm_deemph_0_0_0_0, 0), (self.rational_resampler_xxx_0_0_0_0, 0)) self.connect((self.analog_fm_deemph_0_0_0_1, 0), (self.rational_resampler_xxx_0_0_0_1, 0)) self.connect((self.analog_pll_refout_cc_0, 0), (self.blocks_complex_to_real_1, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.low_pass_filter_4, 0)) self.connect((self.band_pass_filter_0, 0), (self.analog_pll_refout_cc_0, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.band_pass_filter_1, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.band_pass_filter_1, 0), (self.qtgui_freq_sink_x_0_1_0_0, 1)) self.connect((self.blks2_selector_0, 0), (self.audio_sink_0, 0)) self.connect((self.blks2_selector_0_0, 0), (self.audio_sink_0, 1)) self.connect((self.blocks_add_const_vxx_0, 0), (self.qtgui_time_sink_x_1, 1)) self.connect((self.blocks_add_const_vxx_0_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_add_xx_0, 0), (self.analog_fm_deemph_0_0_0_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.blocks_complex_to_real_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_complex_to_real_1, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_real_1, 0), (self.qtgui_freq_sink_x_0_1_0_0, 0)) self.connect((self.blocks_complex_to_real_1, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.blks2_selector_0, 1)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.qtgui_freq_sink_x_0_1_0_1, 1)) self.connect((self.blocks_multiply_const_vxx_1_0_0, 0), (self.blks2_selector_0_0, 1)) self.connect((self.blocks_multiply_const_vxx_1_0_0, 0), (self.qtgui_freq_sink_x_0_1_0_1_0, 1)) self.connect((self.blocks_multiply_const_vxx_1_0_1, 0), (self.blks2_selector_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0_1, 0), (self.blks2_selector_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0_1, 0), (self.qtgui_freq_sink_x_0_0_0, 1)) self.connect((self.blocks_multiply_const_vxx_1_0_1_0, 0), (self.qtgui_freq_sink_x_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0_1_0_0, 0), (self.qtgui_freq_sink_x_0_1_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_1_0_1_0_1, 0), (self.qtgui_freq_sink_x_0_1_0_1_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.band_pass_filter_1, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.low_pass_filter_2, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.analog_fm_deemph_0_0_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_add_const_vxx_0_0, 0)) self.connect((self.blocks_uchar_to_float_0_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_uchar_to_float_0_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.gr_rds_decoder_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.analog_fm_deemph_0_0_0_1, 0)) self.connect((self.low_pass_filter_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.low_pass_filter_2, 0), (self.blocks_add_xx_0, 1)) self.connect((self.low_pass_filter_2, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.low_pass_filter_4, 0), (self.band_pass_filter_0, 0)) self.connect((self.low_pass_filter_4, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.low_pass_filter_4, 0), (self.freq_xlating_fir_filter_xxx_1, 0)) self.connect((self.low_pass_filter_4, 0), (self.low_pass_filter_1, 0)) self.connect((self.low_pass_filter_4, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.blocks_multiply_const_vxx_1_0_1_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0_0, 0), (self.blocks_multiply_const_vxx_1_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0_0, 0), (self.blocks_multiply_const_vxx_1_0_1_0_1, 0)) self.connect((self.rational_resampler_xxx_0_0_0_1, 0), (self.blocks_multiply_const_vxx_1_0_1, 0)) self.connect((self.rational_resampler_xxx_0_0_0_1, 0), (self.blocks_multiply_const_vxx_1_0_1_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_mpsk_receiver_cc_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.qtgui_freq_sink_x_1, 1)) self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Byte Construction") Qt.QWidget.__init__(self) self.setWindowTitle("Byte Construction") 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", "byte_construction") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.timing_loop_bw = timing_loop_bw = 6.28 / 100.0 self.time_offset = time_offset = 1.00 self.taps = taps = [1.0, 0.25 - 0.25j, 0.50 + 0.10j, -0.3 + 0.2j] self.samp_rate = samp_rate = 32000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), 0.35, 11 * sps * nfilts) self.qpsk = qpsk = digital.constellation_rect(([ 0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j ]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.phase_bw = phase_bw = 6.28 / 100.0 self.noise_volt = noise_volt = 0.0001 self.freq_offset = freq_offset = 0 self.excess_bw = excess_bw = 0.35 self.eq_gain = eq_gain = 0.01 self.delay = delay = 58 self.arity = arity = 4 ################################################## # Blocks ################################################## self.controls = Qt.QTabWidget() self.controls_widget_0 = Qt.QWidget() self.controls_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_0) self.controls_grid_layout_0 = Qt.QGridLayout() self.controls_layout_0.addLayout(self.controls_grid_layout_0) self.controls.addTab(self.controls_widget_0, 'Channel') self.controls_widget_1 = Qt.QWidget() self.controls_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_1) self.controls_grid_layout_1 = Qt.QGridLayout() self.controls_layout_1.addLayout(self.controls_grid_layout_1) self.controls.addTab(self.controls_widget_1, 'Receiver') self.top_grid_layout.addWidget(self.controls, 0, 0, 1, 2) [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 1)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 2)] self._timing_loop_bw_range = Range(0.0, 0.2, 0.01, 6.28 / 100.0, 200) self._timing_loop_bw_win = RangeWidget(self._timing_loop_bw_range, self.set_timing_loop_bw, 'Time: BW', "slider", float) self.controls_grid_layout_1.addWidget(self._timing_loop_bw_win, 0, 0, 1, 1) [self.controls_grid_layout_1.setRowStretch(r, 1) for r in range(0, 1)] [ self.controls_grid_layout_1.setColumnStretch(c, 1) for c in range(0, 1) ] self._time_offset_range = Range(0.999, 1.001, 0.0001, 1.00, 200) self._time_offset_win = RangeWidget(self._time_offset_range, self.set_time_offset, 'Timing Offset', "counter_slider", float) self.controls_grid_layout_0.addWidget(self._time_offset_win, 0, 2, 1, 1) [self.controls_grid_layout_0.setRowStretch(r, 1) for r in range(0, 1)] [ self.controls_grid_layout_0.setColumnStretch(c, 1) for c in range(2, 3) ] self.received = Qt.QTabWidget() self.received_widget_0 = Qt.QWidget() self.received_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.received_widget_0) self.received_grid_layout_0 = Qt.QGridLayout() self.received_layout_0.addLayout(self.received_grid_layout_0) self.received.addTab(self.received_widget_0, 'Constellation') self.received_widget_1 = Qt.QWidget() self.received_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.received_widget_1) self.received_grid_layout_1 = Qt.QGridLayout() self.received_layout_1.addLayout(self.received_grid_layout_1) self.received.addTab(self.received_widget_1, 'Symbols') self.top_grid_layout.addWidget(self.received, 2, 0, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(2, 3)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 1)] self._phase_bw_range = Range(0.0, 1.0, 0.01, 6.28 / 100.0, 200) self._phase_bw_win = RangeWidget(self._phase_bw_range, self.set_phase_bw, 'Phase: Bandwidth', "slider", float) self.controls_grid_layout_1.addWidget(self._phase_bw_win, 0, 2, 1, 1) [self.controls_grid_layout_1.setRowStretch(r, 1) for r in range(0, 1)] [ self.controls_grid_layout_1.setColumnStretch(c, 1) for c in range(2, 3) ] self._noise_volt_range = Range(0, 1, 0.01, 0.0001, 200) self._noise_volt_win = RangeWidget(self._noise_volt_range, self.set_noise_volt, 'Noise Voltage', "counter_slider", float) self.controls_grid_layout_0.addWidget(self._noise_volt_win, 0, 0, 1, 1) [self.controls_grid_layout_0.setRowStretch(r, 1) for r in range(0, 1)] [ self.controls_grid_layout_0.setColumnStretch(c, 1) for c in range(0, 1) ] self._freq_offset_range = Range(-0.1, 0.1, 0.001, 0, 200) self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, 'Frequency Offset', "counter_slider", float) self.controls_grid_layout_0.addWidget(self._freq_offset_win, 0, 1, 1, 1) [self.controls_grid_layout_0.setRowStretch(r, 1) for r in range(0, 1)] [ self.controls_grid_layout_0.setColumnStretch(c, 1) for c in range(1, 2) ] self._eq_gain_range = Range(0.0, 0.1, 0.001, 0.01, 200) self._eq_gain_win = RangeWidget(self._eq_gain_range, self.set_eq_gain, 'Equalizer: rate', "slider", float) self.controls_grid_layout_1.addWidget(self._eq_gain_win, 0, 1, 1, 1) [self.controls_grid_layout_1.setRowStretch(r, 1) for r in range(0, 1)] [ self.controls_grid_layout_1.setColumnStretch(c, 1) for c in range(1, 2) ] self._delay_range = Range(0, 200, 1, 58, 200) self._delay_win = RangeWidget(self._delay_range, self.set_delay, 'Delay', "counter_slider", float) self.top_grid_layout.addWidget(self._delay_win, 1, 0, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(1, 2)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 1)] self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Input mins Output stream", #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) self.qtgui_time_sink_x_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance( self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 500, #size samp_rate, #samp_rate '', #name 2 #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, 2) 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 = ['Rx Bits', 'Tx Bits', '', '', '', '', '', '', '', ''] 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_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, 2, 1, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(2, 3)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(1, 2)] self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 500, #size samp_rate, #samp_rate '', #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 4) 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 = ['Symbols', '', '', '', '', '', '', '', '', ''] 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.received_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_win, 0, 0, 1, 1) [self.received_grid_layout_1.setRowStretch(r, 1) for r in range(0, 1)] [ self.received_grid_layout_1.setColumnStretch(c, 1) for c in range(0, 1) ] self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) 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.received_grid_layout_0.addWidget(self._qtgui_const_sink_x_0_win, 0, 0, 1, 1) [self.received_grid_layout_0.setRowStretch(r, 1) for r in range(0, 1)] [ self.received_grid_layout_0.setColumnStretch(c, 1) for c in range(0, 1) ] self.myblocks_qpsk_demod_v2_0 = myblocks.qpsk_demod_v2(0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, timing_loop_bw, (rrc_taps), nfilts, nfilts / 2, 1.5, 2) self.digital_map_bb_0 = digital.map_bb(([0, 3, 2, 1])) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( phase_bw, arity, False) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False, ) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc( 15, 1, eq_gain, 2) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise_volt, frequency_offset=freq_offset, epsilon=time_offset, taps=(taps), noise_seed=0, block_tags=False) self.blocks_unpack_k_bits_bb_0_0 = blocks.unpack_k_bits_bb(8) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( 2, 8, "", False, gr.GR_LSB_FIRST) self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, int(delay)) self.blocks_char_to_float_0_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 256, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.blocks_unpack_k_bits_bb_0_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_char_to_float_0_0_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_delay_0, 0), (self.qtgui_time_sink_x_0_0, 1)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0_0, 0), (self.blocks_char_to_float_0_0_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.myblocks_qpsk_demod_v2_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0)) self.connect((self.myblocks_qpsk_demod_v2_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.myblocks_qpsk_demod_v2_0, 0), (self.digital_map_bb_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self.noise_level = noise_level = 0 ################################################## # Blocks ################################################## self._noise_level_layout = Qt.QVBoxLayout() self._noise_level_tool_bar = Qt.QToolBar(self) self._noise_level_layout.addWidget(self._noise_level_tool_bar) self._noise_level_tool_bar.addWidget(Qt.QLabel("noise_level"+": ")) self._noise_level_counter = Qwt.QwtCounter() self._noise_level_counter.setRange(0, 2, 0.01) self._noise_level_counter.setNumButtons(2) self._noise_level_counter.setValue(self.noise_level) self._noise_level_tool_bar.addWidget(self._noise_level_counter) self._noise_level_counter.valueChanged.connect(self.set_noise_level) self._noise_level_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._noise_level_slider.setRange(0, 2, 0.01) self._noise_level_slider.setValue(self.noise_level) self._noise_level_slider.setMinimumWidth(200) self._noise_level_slider.valueChanged.connect(self.set_noise_level) self._noise_level_layout.addWidget(self._noise_level_slider) self.top_layout.addLayout(self._noise_level_layout) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_0_win) self.digital_psk_mod_0 = digital.psk.psk_mod( constellation_points=4, mod_code="gray", differential=False, samples_per_symbol=4, excess_bw=0.35, verbose=False, log=False, ) self.digital_psk_demod_0 = digital.psk.psk_demod( constellation_points=4, differential=False, samples_per_symbol=4, excess_bw=0.35, phase_bw=6.28/100.0, timing_bw=6.28/100.0, mod_code="gray", verbose=False, log=False, ) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_f(grc_blks2.packet_encoder( samples_per_symbol=4, bits_per_symbol=2, preamble="", access_code="", pad_for_usrp=True, ), payload_length=0, ) self.blks2_packet_decoder_1 = grc_blks2.packet_demod_f(grc_blks2.packet_decoder( access_code="", threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_1.recv_pkt(ok, payload), ), ) self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1000, 1, 0) self.Gausssion = analog.noise_source_c(analog.GR_GAUSSIAN, noise_level, 0) ################################################## # Connections ################################################## self.connect((self.Gausssion, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_sig_source_x_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.blks2_packet_decoder_1, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.digital_psk_mod_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.digital_psk_demod_0, 0)) self.connect((self.digital_psk_demod_0, 0), (self.blks2_packet_decoder_1, 0)) self.connect((self.digital_psk_mod_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.digital_psk_mod_0, 0), (self.qtgui_const_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") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.MiconstellationObject = MiconstellationObject = digital.constellation_calcdist( digital.constellation_qpsk().points(), (0, 1, 2, 3), 4, 1).base() self.Constelacion = Constelacion = MiconstellationObject.points() self.M = M = len(Constelacion) self.samp_rate_usrp_rx = samp_rate_usrp_rx = 100e6 self.Rb = Rb = 100 self.Bps = Bps = int(math.log(M, 2)) self.samp_rate_to_usrp = samp_rate_to_usrp = int(samp_rate_usrp_rx / 512) self.samp_rate_audio = samp_rate_audio = 11000 self.ntaps = ntaps = 128 self.Sps = Sps = 160 self.Rs = Rs = Rb / Bps self.Rolloff = Rolloff = 0.5 self.NbpS = NbpS = 8 self.samp_rate_0 = samp_rate_0 = int(Rs * Sps) self.samp_rate = samp_rate = Rb * Sps self.run_stop = run_stop = True self.mapinverse = mapinverse = coding.inverse_map(Constelacion) self.mapdirect = mapdirect = coding.direct_map(Constelacion) self.h_rrc = h_rrc = wform.rrcos(Sps, ntaps, Rolloff) self.Vp = Vp = 1. self.Tupdate = Tupdate = 1. / Rb self.Sps_0 = Sps_0 = int(math.floor(samp_rate_to_usrp / Rs)) self.Rb_0 = Rb_0 = NbpS * samp_rate_audio self.P = P = 0. self.NnivelesQ = NnivelesQ = int(math.pow(2, NbpS)) self.Kf = Kf = 200 self.F = F = 0. self.BW = BW = (Rs / 2) * (1 + Rolloff) self.Ar = Ar = 0. self.A = A = 1. ################################################## # Blocks ################################################## self._P_range = Range(-2. * math.pi, 2. * math.pi, (4. * math.pi) / 360., 0., 200) self._P_win = RangeWidget(self._P_range, self.set_P, 'Fase', "counter_slider", float) self.top_grid_layout.addWidget(self._P_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._Ar_range = Range(0, 4., (4.) / 50., 0., 200) self._Ar_win = RangeWidget(self._Ar_range, self.set_Ar, 'Ruido', "counter_slider", float) self.top_grid_layout.addWidget(self._Ar_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._A_range = Range(-1.5, 1.5, (1.5) / 100., 1., 200) self._A_win = RangeWidget(self._A_range, self.set_A, 'A', "counter_slider", float) self.top_grid_layout.addWidget(self._A_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) _run_stop_check_box = Qt.QCheckBox('Inicial/Parar') self._run_stop_choices = {True: True, False: False} self._run_stop_choices_inv = dict( (v, k) for k, v in self._run_stop_choices.items()) self._run_stop_callback = lambda i: Qt.QMetaObject.invokeMethod( _run_stop_check_box, "setChecked", Qt.Q_ARG("bool", self._run_stop_choices_inv[i])) self._run_stop_callback(self.run_stop) _run_stop_check_box.stateChanged.connect( lambda i: self.set_run_stop(self._run_stop_choices[bool(i)])) self.top_grid_layout.addWidget(_run_stop_check_box, 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_0_1 = qtgui.time_sink_f( 1024, #size samp_rate_audio, #samp_rate 'Nuevo', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_1.set_update_time(0.10) self.qtgui_time_sink_x_0_0_1.set_y_axis(-128, 128) self.qtgui_time_sink_x_0_0_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0_1.enable_tags(True) self.qtgui_time_sink_x_0_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_1.enable_autoscale(False) self.qtgui_time_sink_x_0_0_1.enable_grid(False) self.qtgui_time_sink_x_0_0_1.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_1.enable_control_panel(False) self.qtgui_time_sink_x_0_0_1.enable_stem_plot(False) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_1_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_1_win) self.qtgui_time_sink_x_0_0_0_0_0 = qtgui.time_sink_f( 1024, #size (samp_rate), #samp_rate "compararacion entre mensaje y EC", #name 3 #number of inputs ) self.qtgui_time_sink_x_0_0_0_0_0.set_update_time(Tupdate) self.qtgui_time_sink_x_0_0_0_0_0.set_y_axis(-1.5, 1.5) self.qtgui_time_sink_x_0_0_0_0_0.set_y_label('Amplitud', 'volts') self.qtgui_time_sink_x_0_0_0_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0_0_0_0.set_trigger_mode( qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0_0_0_0.enable_stem_plot(False) labels = [ 'Mensaje', 'FSK parte real', 'FSK parte Imaginaria', '', '', '', '', '', '', '' ] widths = [3, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(3): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_0_0_0_win, 4, 1, 1, 2) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0_0_0 = qtgui.time_sink_f( 1024, #size (samp_rate), #samp_rate "Nivel de Amplitud", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0_0.set_update_time(Tupdate) self.qtgui_time_sink_x_0_0_0_0.set_y_axis(-1.5, 1.5) self.qtgui_time_sink_x_0_0_0_0.set_y_label('Amplitud', 'volts') self.qtgui_time_sink_x_0_0_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0_0_0.set_trigger_mode( qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0_0_0.enable_stem_plot(False) labels = ['.', '', '', '', '', '', '', '', '', ''] widths = [3, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_0_0_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.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f( 1024, #size (samp_rate), #samp_rate "Nivel de Fase", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0.set_update_time(Tupdate) self.qtgui_time_sink_x_0_0_0.set_y_axis(-2 * math.pi, 2 * math.pi) self.qtgui_time_sink_x_0_0_0.set_y_label('Fase', 'radianes') self.qtgui_time_sink_x_0_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0_0.enable_stem_plot(False) labels = ['.', '', '', '', '', '', '', '', '', ''] widths = [3, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_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_time_sink_x_0_0 = qtgui.time_sink_f( 1024, #size (samp_rate), #samp_rate "Nivel de frecuencia", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(Tupdate) self.qtgui_time_sink_x_0_0.set_y_axis(-2.5, 2.5) self.qtgui_time_sink_x_0_0.set_y_label('Frecuencia', 'Hz') self.qtgui_time_sink_x_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) labels = ['.', '', '', '', '', '', '', '', '', ''] widths = [3, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 3, 2, 1, 1) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 8, #size '', #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(Tupdate) self.qtgui_const_sink_x_0_0.set_y_axis(-1.5, 1.5) self.qtgui_const_sink_x_0_0.set_x_axis(-1.5, 1.5) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0.enable_axis_labels(True) labels = ['.', '', '', '', '', '', '', '', '', ''] widths = [4, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win, 4, 0, 1, 1) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.epy_block_0 = epy_block_0.blk() self.e_VCO_fase_fc_0 = e_VCO_fase_fc_0.blk() self.digital_map_bb_0 = digital.map_bb(mapdirect) self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(M) self.digital_chunks_to_symbols_xx = digital.chunks_to_symbols_bc( MiconstellationObject.points(), 1) self.d_freq_cf_assign_freq_cf_0 = d_freq_cf.assign_freq_cf() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( Bps, gr.GR_LSB_FIRST) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_0_0_0_1_0_0 = blocks.multiply_const_ff( Kf * 2 * math.pi / samp_rate) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_1 = blocks.add_vcc(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.b_quantizer_fb_0 = b_quantizer_fb( NivelesQ=NnivelesQ, Vmax=Vp, ) self.b_bipolar_to_unipolar_ff_0 = b_bipolar_to_unipolar_ff() self.b_binary_bipolar_source_f_0 = b_binary_bipolar_source_f( Am=1., Spb=Sps, ) self.b_PSD_c_0 = b_PSD_c( Ensayos=1000000, Fc=0, N=1024, Ymax=1e-5, samp_rate_audio=samp_rate, ) self.top_grid_layout.addWidget(self.b_PSD_c_0, 5, 1, 1, 2) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 3): self.top_grid_layout.setColumnStretch(c, 1) self.analog_noise_source_x_1 = analog.noise_source_c( analog.GR_GAUSSIAN, Ar, 0) self.analog_const_source_x_0_0_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, P) self.analog_const_source_x_0_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, A) self._F_range = Range(-2.4, 2.4, (2 * 2.4) / 1000., 0., 200) self._F_win = RangeWidget(self._F_range, self.set_F, 'Frecuencia', "counter_slider", float) self.top_grid_layout.addWidget(self._F_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) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0_0, 0), (self.e_VCO_fase_fc_0, 1)) self.connect((self.analog_const_source_x_0_0, 0), (self.qtgui_time_sink_x_0_0_0_0, 0)) self.connect((self.analog_const_source_x_0_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_const_source_x_0_0_0, 0), (self.qtgui_time_sink_x_0_0_0, 0)) self.connect((self.analog_noise_source_x_1, 0), (self.blocks_add_xx_1, 1)) self.connect((self.b_binary_bipolar_source_f_0, 0), (self.b_bipolar_to_unipolar_ff_0, 0)) self.connect((self.b_bipolar_to_unipolar_ff_0, 0), (self.b_quantizer_fb_0, 0)) self.connect((self.b_bipolar_to_unipolar_ff_0, 0), (self.epy_block_0, 0)) self.connect((self.b_bipolar_to_unipolar_ff_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.b_bipolar_to_unipolar_ff_0, 0), (self.qtgui_time_sink_x_0_0_0_0_0, 0)) self.connect((self.b_quantizer_fb_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.e_VCO_fase_fc_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.qtgui_time_sink_x_0_0_0_0_0, 1)) self.connect((self.blocks_complex_to_float_0, 1), (self.qtgui_time_sink_x_0_0_0_0_0, 2)) self.connect((self.blocks_multiply_const_vxx_0_0_0_1_0_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_diff_encoder_bb_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.d_freq_cf_assign_freq_cf_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.d_freq_cf_assign_freq_cf_0, 0), (self.qtgui_time_sink_x_0_0_1, 0)) self.connect((self.digital_chunks_to_symbols_xx, 0), (self.b_PSD_c_0, 0)) self.connect((self.digital_chunks_to_symbols_xx, 0), (self.d_freq_cf_assign_freq_cf_0, 0)) self.connect((self.digital_chunks_to_symbols_xx, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.digital_diff_encoder_bb_0, 0), (self.digital_map_bb_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.digital_chunks_to_symbols_xx, 0)) self.connect((self.e_VCO_fase_fc_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.epy_block_0, 0), (self.blocks_multiply_const_vxx_0_0_0_1_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 100000 self.noise_level = noise_level = 0 self.cutoff_freq = cutoff_freq = 50000 ################################################## # Blocks ################################################## self._noise_level_range = Range(0, 1, 0.01, 0, 200) self._noise_level_win = RangeWidget(self._noise_level_range, self.set_noise_level, "noise_level", "counter_slider", float) self.top_layout.addWidget(self._noise_level_win) self._cutoff_freq_range = Range(0, 100000, 1000, 50000, 200) self._cutoff_freq_win = RangeWidget(self._cutoff_freq_range, self.set_cutoff_freq, "cutoff_freq", "counter_slider", float) self.top_layout.addWidget(self._cutoff_freq_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2*1): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) 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_layout.addWidget(self._qtgui_const_sink_x_0_win) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, cutoff_freq, 1000, firdes.WIN_HAMMING, 6.76)) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(((complex(1,1),complex(1,-1),complex(-1,1),complex(-1,-1))), 1) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 4, 1000)), True) self.Gausssion = analog.noise_source_c(analog.GR_GAUSSIAN, noise_level, 0) ################################################## # Connections ################################################## self.connect((self.Gausssion, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.low_pass_filter_0, 0), (self.blocks_throttle_0, 0))
def __init__(self): gr.top_block.__init__(self, "Audio Tx") Qt.QWidget.__init__(self) self.setWindowTitle("Audio Tx") 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", "audio_tx") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.sps = sps = 1 self.nfilts = nfilts = 25 self.samp_rate = samp_rate = 32E3 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), 0.35, 45 * nfilts) self.qpsk = qpsk = digital.constellation_rect(([ 0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j ]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.phase_bw = phase_bw = 6.28 / 100.0 self.excess_bw = excess_bw = 0.35 self.BPSK = BPSK = digital.constellation_qpsk().base() ################################################## # Blocks ################################################## self._phase_bw_range = Range(0.0, 1.0, 0.01, 6.28 / 100.0, 200) self._phase_bw_win = RangeWidget(self._phase_bw_range, self.set_phase_bw, 'Phase: Bandwidth', "slider", float) self.top_layout.addWidget(self._phase_bw_win) self.qtgui_time_sink_x_1_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_1.set_update_time(0.10) self.qtgui_time_sink_x_1_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_1.enable_tags(-1, True) self.qtgui_time_sink_x_1_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_1.enable_autoscale(False) self.qtgui_time_sink_x_1_1.enable_grid(False) self.qtgui_time_sink_x_1_1.enable_axis_labels(True) self.qtgui_time_sink_x_1_1.enable_control_panel(False) self.qtgui_time_sink_x_1_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_1_win = sip.wrapinstance( self.qtgui_time_sink_x_1_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_1_1_win) self.qtgui_time_sink_x_1_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0.enable_grid(False) self.qtgui_time_sink_x_1_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0.enable_control_panel(False) self.qtgui_time_sink_x_1_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_win = sip.wrapinstance( self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_1_0_win) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) self.qtgui_time_sink_x_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance( self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(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(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 1024, #size "demod", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(True) self.qtgui_const_sink_x_0_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_0_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "Rx", #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(True) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 0, 1, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 1)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(1, 2)] self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 1.6E3, .6E3, firdes.WIN_HAMMING, 6.76)) self.hilbert_fc_0 = filter.hilbert_fc(65, firdes.WIN_HAMMING, 6.76) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, .063, (rrc_taps), nfilts, nfilts / 2, 1.5, 1) self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc( 8, .01, 1, BPSK) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( phase_bw, 4, False) self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb( BPSK, phase_bw, 0, 2 * 3.14) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=BPSK, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=2, verbose=False, log=False, ) self.blocks_multiply_xx_3_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_3 = blocks.multiply_vff(1) self.blocks_multiply_xx_2_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_2_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_2_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_2 = blocks.multiply_vff(1) self.blocks_multiply_xx_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, '/home/peter/Desktop/acoustic_radio/test_input.txt', True) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_char * 1, '/home/peter/Desktop/output.txt', False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_complex_to_imag_1 = blocks.complex_to_imag(1) self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_3 = blocks.add_vff(1) self.blocks_add_xx_1 = blocks.add_vff(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b( grc_blks2.packet_encoder( samples_per_symbol=sps, bits_per_symbol=1, preamble='', access_code='', pad_for_usrp=False, ), payload_length=1, ) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b( grc_blks2.packet_decoder( access_code='', threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0. recv_pkt(ok, payload), ), ) self.analog_sig_source_x_0_1_0_0 = analog.sig_source_c( samp_rate, analog.GR_SIN_WAVE, 4E3, 1, 0) self.analog_sig_source_x_0_1_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 4E3, 1, 0) self.analog_sig_source_x_0_1 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 4E3, 1, 0) self.analog_sig_source_x_0_0_0 = analog.sig_source_f( samp_rate, analog.GR_SIN_WAVE, 4E3, 1, 0) self.analog_sig_source_x_0_0 = analog.sig_source_f( samp_rate, analog.GR_SIN_WAVE, 4E3, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 4E3, 1, 0) self.analog_feedforward_agc_cc_0 = analog.feedforward_agc_cc( 1024, 1.55) self.analog_const_source_x_0_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, -1) self.analog_const_source_x_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, -1) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.blocks_multiply_xx_3, 1)) self.connect((self.analog_const_source_x_0_0, 0), (self.blocks_multiply_xx_3_0, 1)) self.connect((self.analog_feedforward_agc_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_3_0, 0)) self.connect((self.analog_sig_source_x_0_0_0, 0), (self.blocks_multiply_xx_3, 0)) self.connect((self.analog_sig_source_x_0_1, 0), (self.blocks_multiply_xx_2, 1)) self.connect((self.analog_sig_source_x_0_1_0, 0), (self.blocks_multiply_xx_2_0, 1)) self.connect((self.analog_sig_source_x_0_1_0_0, 0), (self.blocks_multiply_xx_2_0_0, 1)) self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_xx_2, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_xx_2_1, 0)) self.connect((self.blocks_add_xx_0, 0), (self.hilbert_fc_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_add_xx_3, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_1, 0)) self.connect((self.blocks_complex_to_imag_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.blocks_complex_to_imag_1, 0), (self.blocks_add_xx_3, 1)) self.connect((self.blocks_file_source_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_add_xx_1, 1)) self.connect((self.blocks_multiply_xx_2_0, 0), (self.blocks_complex_to_imag_0, 0)) self.connect((self.blocks_multiply_xx_2_0_0, 0), (self.blocks_complex_to_imag_1, 0)) self.connect((self.blocks_multiply_xx_2_1, 0), (self.blocks_add_xx_3, 0)) self.connect((self.blocks_multiply_xx_3, 0), (self.blocks_multiply_xx_2_1, 1)) self.connect((self.blocks_multiply_xx_3_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 4), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 3), (self.qtgui_time_sink_x_1, 0)) self.connect((self.digital_constellation_receiver_cb_0, 1), (self.qtgui_time_sink_x_1_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 2), (self.qtgui_time_sink_x_1_1, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_lms_dd_equalizer_cc_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_0, 0), (self.digital_constellation_receiver_cb_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.hilbert_fc_0, 0), (self.blocks_multiply_xx_2_0, 0)) self.connect((self.hilbert_fc_0, 0), (self.blocks_multiply_xx_2_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_feedforward_agc_cc_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sr_rf = sr_rf = 2500000 self.decimate = decimate = 400 self.sr_lo = sr_lo = sr_rf/decimate self.f_rf = f_rf = 434645000 self.f_lo = f_lo = 455.2 ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, "Tuning") self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, "IQ Display") self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, "PSK Output") self.top_layout.addWidget(self.tab) self._f_rf_layout = Qt.QVBoxLayout() self._f_rf_tool_bar = Qt.QToolBar(self) self._f_rf_layout.addWidget(self._f_rf_tool_bar) self._f_rf_tool_bar.addWidget(Qt.QLabel("RF 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._f_rf_counter = qwt_counter_pyslot() self._f_rf_counter.setRange(434644000, 434646000, 1) self._f_rf_counter.setNumButtons(2) self._f_rf_counter.setValue(self.f_rf) self._f_rf_tool_bar.addWidget(self._f_rf_counter) self._f_rf_counter.valueChanged.connect(self.set_f_rf) self._f_rf_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._f_rf_slider.setRange(434644000, 434646000, 1) self._f_rf_slider.setValue(self.f_rf) self._f_rf_slider.setMinimumWidth(200) self._f_rf_slider.valueChanged.connect(self.set_f_rf) self._f_rf_layout.addWidget(self._f_rf_slider) self.tab_layout_0.addLayout(self._f_rf_layout) self._f_lo_layout = Qt.QVBoxLayout() self._f_lo_tool_bar = Qt.QToolBar(self) self._f_lo_layout.addWidget(self._f_lo_tool_bar) self._f_lo_tool_bar.addWidget(Qt.QLabel("LO 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._f_lo_counter = qwt_counter_pyslot() self._f_lo_counter.setRange(0, 2000, .1) self._f_lo_counter.setNumButtons(2) self._f_lo_counter.setValue(self.f_lo) self._f_lo_tool_bar.addWidget(self._f_lo_counter) self._f_lo_counter.valueChanged.connect(self.set_f_lo) self._f_lo_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._f_lo_slider.setRange(0, 2000, .1) self._f_lo_slider.setValue(self.f_lo) self._f_lo_slider.setMinimumWidth(200) self._f_lo_slider.valueChanged.connect(self.set_f_lo) self._f_lo_layout.addWidget(self._f_lo_slider) self.tab_layout_0.addLayout(self._f_lo_layout) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( sr_lo, #size sr_lo, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(.03) self.qtgui_time_sink_x_0.set_y_axis(-.02, .02) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2*1): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_layout_0.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_number_sink_1 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1 ) self.qtgui_number_sink_1.set_update_time(0.10) self.qtgui_number_sink_1.set_title("") labels = ["Signal RMS", "", "", "", "", "", "", "", "", ""] 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_1.set_min(i, -1) self.qtgui_number_sink_1.set_max(i, 1) self.qtgui_number_sink_1.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_1.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_1.set_label(i, labels[i]) self.qtgui_number_sink_1.set_unit(i, units[i]) self.qtgui_number_sink_1.set_factor(i, factor[i]) self.qtgui_number_sink_1.enable_autoscale(False) self._qtgui_number_sink_1_win = sip.wrapinstance(self.qtgui_number_sink_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_1_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.03) self.qtgui_number_sink_0.set_title("") labels = ["", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.tab_layout_0.addWidget(self._qtgui_number_sink_0_win) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_1.set_update_time(0.10) self.qtgui_const_sink_x_1.set_y_axis(-.02, .02) self.qtgui_const_sink_x_1.set_x_axis(-.02, .02) 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(True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in 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.tab_layout_2.addWidget(self._qtgui_const_sink_x_1_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-.02, .02) self.qtgui_const_sink_x_0.set_x_axis(-.02, .02) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [1, 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.tab_layout_0.addWidget(self._qtgui_const_sink_x_0_win) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "airspy=0" ) self.osmosdr_source_0.set_sample_rate(sr_rf) self.osmosdr_source_0.set_center_freq(f_rf, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(3, 0) self.osmosdr_source_0.set_if_gain(0, 0) self.osmosdr_source_0.set_bb_gain(0, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(100, (firdes.low_pass(1, sr_rf, 2000, 100)), f_lo, sr_rf) self.digital_mpsk_receiver_cc_0 = digital.mpsk_receiver_cc(2, 0, cmath.pi/100.0, -0.5, 0.5, 0.25, 0.01, 2, 0.001, 0.001) self.blocks_rms_xx_0 = blocks.rms_cf(0.0001) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((sr_lo / (2 * 3.14159), )) self.analog_pll_freqdet_cf_0 = analog.pll_freqdet_cf(.06, 0.6, -.6) ################################################## # Connections ################################################## self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_pll_freqdet_cf_0, 0)) self.connect((self.analog_pll_freqdet_cf_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.digital_mpsk_receiver_cc_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.qtgui_number_sink_1, 0))
def __init__(self): gr.top_block.__init__(self, "Multipath Psk") Qt.QWidget.__init__(self) self.setWindowTitle("Multipath Psk") 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", "multipath_psk") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.tap4 = tap4 = 0.6 self.tap3 = tap3 = 0.6 self.tap2 = tap2 = 0.5 self.tap1 = tap1 = 0.25 self.taps = taps = fftpack.ifftshift( fftpack.ifft([ tap3, tap4, 1.0, tap1, tap2, tap3, tap4, 1.0, tap1, tap2, tap3, tap4, 1.0, tap1, tap2 ])) self.sps = sps = 8 self.samp_rate = samp_rate = 32000 self.const = const = digital.constellation_16qam().base() self.cma = cma = -20 ################################################## # Blocks ################################################## self._tap4_range = Range(0, 1, 0.01, 0.6, 200) self._tap4_win = RangeWidget(self._tap4_range, self.set_tap4, "tap4", "slider", float) self.top_grid_layout.addWidget(self._tap4_win, 1, 3, 1, 1) self._tap3_range = Range(0, 1, 0.01, 0.6, 200) self._tap3_win = RangeWidget(self._tap3_range, self.set_tap3, "tap3", "slider", float) self.top_grid_layout.addWidget(self._tap3_win, 1, 2, 1, 1) self._tap2_range = Range(0, 1, 0.01, 0.5, 200) self._tap2_win = RangeWidget(self._tap2_range, self.set_tap2, "tap2", "slider", float) self.top_grid_layout.addWidget(self._tap2_win, 1, 1, 1, 1) self._tap1_range = Range(0, 1, 0.01, 0.25, 200) self._tap1_win = RangeWidget(self._tap1_range, self.set_tap1, "tap1", "slider", float) self.top_grid_layout.addWidget(self._tap1_win, 1, 0, 1, 1) self.root_raised_cosine_filter_0 = filter.fir_filter_ccf( 1, firdes.root_raised_cosine(1.0, sps * 1.0, 1.0, 0.35, 22 * sps)) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-100, 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 "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 1, 2) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 0, 2, 1, 2) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=const, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=0.35, verbose=False, log=False, ) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc( sps * (1 + 0.0), 0.25 * 0.01 * 0.01, 0.5, 0.01, 0.005) self._cma_range = Range(-40, -10, 1, -20, 200) self._cma_win = RangeWidget(self._cma_range, self.set_cma, "cma", "counter_slider", float) self.top_grid_layout.addWidget(self._cma_win, 2, 0, 1, 4) self.channels_channel_model_0 = channels.channel_model( noise_voltage=0.01, frequency_offset=0.0, epsilon=1.0, taps=(1, ), noise_seed=0, block_tags=False) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 256, 1000000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_clock_recovery_mm_xx_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 = 10e6 self.pdu_length = pdu_length = 500 self.lo_offset = lo_offset = 0 self.gain = gain = 0.75 self.freq = freq = 5890000000 self.encoding = encoding = [0,0,0,0,0] self.chan_est = chan_est = 0 ################################################## # Blocks ################################################## self.frequencyAdaptiveOFDM_mac_and_parse_0 = frequencyAdaptiveOFDM.mac_and_parse(([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]), ([0x23, 0x23, 0x23, 0x23, 0x23, 0x23]), ([0xff, 0xff, 0xff, 0xff, 0xff, 0xff]), False, True, '/tmp/tx_packets.csv', '/tmp/rx_packets.csv') self._samp_rate_options = [5e6, 10e6, 20e6] self._samp_rate_labels = ["5 MHz", "10 MHz", "20 MHz"] self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel("samp_rate"+": ")) self._samp_rate_combo_box = Qt.QComboBox() self._samp_rate_tool_bar.addWidget(self._samp_rate_combo_box) for label in self._samp_rate_labels: self._samp_rate_combo_box.addItem(label) self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(self._samp_rate_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._samp_rate_options.index(i))) self._samp_rate_callback(self.samp_rate) self._samp_rate_combo_box.currentIndexChanged.connect( lambda i: self.set_samp_rate(self._samp_rate_options[i])) self.top_layout.addWidget(self._samp_rate_tool_bar) self._pdu_length_range = Range(0, 1500, 1, 500, 200) self._pdu_length_win = RangeWidget(self._pdu_length_range, self.set_pdu_length, "pdu_length", "counter_slider", int) self.top_layout.addWidget(self._pdu_length_win) self._lo_offset_options = (0, 6e6, 11e6, ) self._lo_offset_labels = (str(self._lo_offset_options[0]), str(self._lo_offset_options[1]), str(self._lo_offset_options[2]), ) self._lo_offset_tool_bar = Qt.QToolBar(self) self._lo_offset_tool_bar.addWidget(Qt.QLabel("lo_offset"+": ")) self._lo_offset_combo_box = Qt.QComboBox() self._lo_offset_tool_bar.addWidget(self._lo_offset_combo_box) for label in self._lo_offset_labels: self._lo_offset_combo_box.addItem(label) self._lo_offset_callback = lambda i: Qt.QMetaObject.invokeMethod(self._lo_offset_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._lo_offset_options.index(i))) self._lo_offset_callback(self.lo_offset) self._lo_offset_combo_box.currentIndexChanged.connect( lambda i: self.set_lo_offset(self._lo_offset_options[i])) self.top_layout.addWidget(self._lo_offset_tool_bar) self._gain_range = Range(0, 1, 0.01, 0.75, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain", "counter_slider", float) self.top_layout.addWidget(self._gain_win) self._freq_options = [2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5250000000.0, 5260000000.0, 5270000000.0, 5280000000.0, 5290000000.0, 5300000000.0, 5310000000.0, 5320000000.0, 5500000000.0, 5510000000.0, 5520000000.0, 5530000000.0, 5540000000.0, 5550000000.0, 5560000000.0, 5570000000.0, 5580000000.0, 5590000000.0, 5600000000.0, 5610000000.0, 5620000000.0, 5630000000.0, 5640000000.0, 5660000000.0, 5670000000.0, 5680000000.0, 5690000000.0, 5700000000.0, 5710000000.0, 5720000000.0, 5745000000.0, 5755000000.0, 5765000000.0, 5775000000.0, 5785000000.0, 5795000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0] self._freq_labels = [' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 50 | 5250.0 | 11a', ' 52 | 5260.0 | 11a', ' 54 | 5270.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5290.0 | 11a', ' 60 | 5300.0 | 11a', ' 62 | 5310.0 | 11a', ' 64 | 5320.0 | 11a', '100 | 5500.0 | 11a', '102 | 5510.0 | 11a', '104 | 5520.0 | 11a', '106 | 5530.0 | 11a', '108 | 5540.0 | 11a', '110 | 5550.0 | 11a', '112 | 5560.0 | 11a', '114 | 5570.0 | 11a', '116 | 5580.0 | 11a', '118 | 5590.0 | 11a', '120 | 5600.0 | 11a', '122 | 5610.0 | 11a', '124 | 5620.0 | 11a', '126 | 5630.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '134 | 5670.0 | 11a', '136 | 5680.0 | 11a', '138 | 5690.0 | 11a', '140 | 5700.0 | 11a', '142 | 5710.0 | 11a', '144 | 5720.0 | 11a', '149 | 5745.0 | 11a (SRD)', '151 | 5755.0 | 11a (SRD)', '153 | 5765.0 | 11a (SRD)', '155 | 5775.0 | 11a (SRD)', '157 | 5785.0 | 11a (SRD)', '159 | 5795.0 | 11a (SRD)', '161 | 5805.0 | 11a (SRD)', '165 | 5825.0 | 11a (SRD)', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'] self._freq_tool_bar = Qt.QToolBar(self) self._freq_tool_bar.addWidget(Qt.QLabel("freq"+": ")) self._freq_combo_box = Qt.QComboBox() self._freq_tool_bar.addWidget(self._freq_combo_box) for label in self._freq_labels: self._freq_combo_box.addItem(label) self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(self._freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._freq_options.index(i))) self._freq_callback(self.freq) self._freq_combo_box.currentIndexChanged.connect( lambda i: self.set_freq(self._freq_options[i])) self.top_layout.addWidget(self._freq_tool_bar) def _encoding_probe(): while True: val = self.frequencyAdaptiveOFDM_mac_and_parse_0.get_encoding() try: self.set_encoding(val) except AttributeError: pass time.sleep(1.0 / (1000)) _encoding_thread = threading.Thread(target=_encoding_probe) _encoding_thread.daemon = True _encoding_thread.start() self._chan_est_options = 0, 1, 3, 2 self._chan_est_labels = ["LS", "LMS", "STA", "Linear Comb"] self._chan_est_group_box = Qt.QGroupBox("chan_est") self._chan_est_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._chan_est_button_group = variable_chooser_button_group() self._chan_est_group_box.setLayout(self._chan_est_box) for i, label in enumerate(self._chan_est_labels): radio_button = Qt.QRadioButton(label) self._chan_est_box.addWidget(radio_button) self._chan_est_button_group.addButton(radio_button, i) self._chan_est_callback = lambda i: Qt.QMetaObject.invokeMethod(self._chan_est_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._chan_est_options.index(i))) self._chan_est_callback(self.chan_est) self._chan_est_button_group.buttonClicked[int].connect( lambda i: self.set_chan_est(self._chan_est_options[i])) self.top_layout.addWidget(self._chan_est_group_box) self.wifi_freq_adap_phy_hier_0 = wifi_freq_adap_phy_hier( bandwidth=10e6, chan_est=0, encoding=encoding, frequency=5.89e9, sensitivity=0.56, ) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(('', "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_source_0.set_normalized_gain(gain, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(('', "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), 'packet_len', ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_sink_0.set_normalized_gain(gain, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size 300000, #samp_rate "Data Received", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1 ) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ['Error Rate', '', '', '', '', '', '', '', '', ''] units = ['Percent', '', '', '', '', '', '', '', '', ''] 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, 0) 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.top_layout.addWidget(self._qtgui_number_sink_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 48*10, #size "", #name 4 #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 = ['RB1', 'RB2', 'RB3', 'RB4', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "yellow", "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(4): 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_layout.addWidget(self._qtgui_const_sink_x_0_win) self.frequencyAdaptiveOFDM_write_frame_data_0 = frequencyAdaptiveOFDM.write_frame_data('/tmp/snr.csv', '/tmp/encoding.csv', '/tmp/wifi_frame_delay.csv', True) self.frequencyAdaptiveOFDM_rb_const_demux_stream_0 = frequencyAdaptiveOFDM.rb_const_demux_stream('packet_len') self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 10000, 10000) (self.foo_packet_pad2_0).set_min_output_buffer(100000) self.blocks_vector_source_x_0 = blocks.vector_source_b(range(100), True, 1, []) self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, 'packet_len') self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, pdu_length, 'packet_len') self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", '', '52001', 10000, False) self.blocks_pdu_to_tagged_stream_0_1 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len') self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.float_t, 'packet_len') self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.6, )) (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000) self.adaptiveOFDM_stream_spacer_0 = adaptiveOFDM.stream_spacer(blocks.byte_t, 500) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.frequencyAdaptiveOFDM_mac_and_parse_0, 'app in')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.frequencyAdaptiveOFDM_mac_and_parse_0, 'app in')) self.msg_connect((self.frequencyAdaptiveOFDM_mac_and_parse_0, 'fer'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.frequencyAdaptiveOFDM_mac_and_parse_0, 'app out'), (self.blocks_pdu_to_tagged_stream_0_1, 'pdus')) self.msg_connect((self.frequencyAdaptiveOFDM_mac_and_parse_0, 'frame data'), (self.frequencyAdaptiveOFDM_write_frame_data_0, 'frame data')) self.msg_connect((self.frequencyAdaptiveOFDM_mac_and_parse_0, 'phy out'), (self.wifi_freq_adap_phy_hier_0, 'mac_in')) self.msg_connect((self.wifi_freq_adap_phy_hier_0, 'mac_out'), (self.frequencyAdaptiveOFDM_mac_and_parse_0, 'phy in')) self.msg_connect((self.wifi_freq_adap_phy_hier_0, 'carrier'), (self.frequencyAdaptiveOFDM_rb_const_demux_stream_0, 'symbols_in')) self.connect((self.adaptiveOFDM_stream_spacer_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.foo_packet_pad2_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_1, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.adaptiveOFDM_stream_spacer_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.foo_packet_pad2_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.frequencyAdaptiveOFDM_rb_const_demux_stream_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.frequencyAdaptiveOFDM_rb_const_demux_stream_0, 1), (self.qtgui_const_sink_x_0, 1)) self.connect((self.frequencyAdaptiveOFDM_rb_const_demux_stream_0, 2), (self.qtgui_const_sink_x_0, 2)) self.connect((self.frequencyAdaptiveOFDM_rb_const_demux_stream_0, 3), (self.qtgui_const_sink_x_0, 3)) self.connect((self.uhd_usrp_source_0, 0), (self.wifi_freq_adap_phy_hier_0, 0)) self.connect((self.wifi_freq_adap_phy_hier_0, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self, beta_rrc=0.13, bits_per_symb=2, cfar_thresh=8, cfo_samps=512, corr_reps=1, log_interval=10, packet_len=512, samps_per_symb=2): gr.top_block.__init__(self, "Echo Wrapper Neural") Qt.QWidget.__init__(self) self.setWindowTitle("Echo Wrapper Neural") 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", "echo_wrapper_neural") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.beta_rrc = beta_rrc self.bits_per_symb = bits_per_symb self.cfar_thresh = cfar_thresh self.cfo_samps = cfo_samps self.corr_reps = corr_reps self.log_interval = log_interval self.packet_len = packet_len self.samps_per_symb = samps_per_symb ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1000000 self.cfo_freqs = cfo_freqs = 11. / 256, 43. / 256, 97. / 256 self.body = body = [ 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0 ] self.N0 = N0 = 0.1 ################################################## # Blocks ################################################## self.echo_triggered_vector_source_b_0 = echo.triggered_vector_source_b( (body * 2), "", 1, "pkt") self.echo_preamble_insert_1_0 = echo.preamble_insert((body), 1, 0, 1) self.echo_preamble_insert_1 = echo.preamble_insert((body), 0, 1, 0) self.echo_preamble_insert_0_0 = echo.preamble_insert((body), 0, 1, 0) self.echo_preamble_insert_0 = echo.preamble_insert((body), 1, 0, 1) self.echo_packet_length_check_0_0 = echo.packet_length_check( packet_len / bits_per_symb * 2) self.echo_packet_length_check_0 = echo.packet_length_check( packet_len / bits_per_symb * 2) self.echo_modulator_neural_0 = echo.modulator_neural( 12348907843, (50, ), bits_per_symb, (body), log_interval, "") self.echo_modulator_classic_0 = echo.modulator_classic( bits_per_symb, (body), log_interval) self.echo_demodulator_neural_0 = echo.demodulator_neural( 134214, (50, ), bits_per_symb, (body), log_interval, "") self.echo_demodulator_classic_0 = echo.demodulator_classic( bits_per_symb, 1024, preamble=(body), log_ber_interval=log_interval) self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c( 2048, #size "Channel IQ Scatter", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0.set_update_time(0.0) self.qtgui_const_sink_x_0_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0.enable_grid(True) if not True: self.qtgui_const_sink_x_0_0_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_0_0_0_win) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( packet_len / bits_per_symb * 2, #size "Detected Body Constellation", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.0) self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(True) if not True: self.qtgui_const_sink_x_0_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_0_0_win) self.neural_to_classic_handler = echo.packet_handler( cfo_samps, corr_reps, packet_len / samps_per_symb * 2, cfar_thresh, samps_per_symb, beta_rrc, (cfo_freqs)) self.classic_to_neural_handler = echo.packet_handler( cfo_samps, corr_reps, 2 * packet_len / samps_per_symb, cfar_thresh, samps_per_symb, beta_rrc, (cfo_freqs)) self.channels_channel_model_0_0 = channels.channel_model( noise_voltage=N0, frequency_offset=0.000, epsilon=1, taps=(0.714 + 0.714j, ), noise_seed=0, block_tags=False) self.channels_channel_model_0 = channels.channel_model( noise_voltage=N0, frequency_offset=0.0000, epsilon=1, taps=(0.714 + 0.714j, ), noise_seed=0, block_tags=False) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_tagged_stream_to_pdu_0_0 = blocks.tagged_stream_to_pdu( blocks.byte_t, "pkt") self.blocks_stream_mux_1 = blocks.stream_mux(gr.sizeof_gr_complex * 1, (1152 * 2, 5000)) self.blocks_stream_mux_0 = blocks.stream_mux(gr.sizeof_gr_complex * 1, (1152 * 2, 5000)) self.blocks_pdu_to_tagged_stream_0_1 = blocks.pdu_to_tagged_stream( blocks.complex_t, "pkt") self.analog_const_source_x_0_0 = analog.sig_source_c( 0, analog.GR_CONST_WAVE, 0, 0, 0) self.analog_const_source_x_0 = analog.sig_source_c( 0, analog.GR_CONST_WAVE, 0, 0, 0) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0, 'pdus'), (self.echo_modulator_neural_0, 'bits')) self.msg_connect((self.classic_to_neural_handler, 'unwrap_out'), (self.echo_packet_length_check_0, 'in')) self.msg_connect((self.neural_to_classic_handler, 'unwrap_out'), (self.blocks_pdu_to_tagged_stream_0_1, 'pdus')) self.msg_connect((self.neural_to_classic_handler, 'unwrap_out'), (self.echo_packet_length_check_0_0, 'in')) self.msg_connect((self.echo_demodulator_classic_0, 'bits'), (self.echo_preamble_insert_0, 'in')) self.msg_connect((self.echo_demodulator_classic_0, 'bits'), (self.echo_preamble_insert_0_0, 'in')) self.msg_connect((self.echo_demodulator_neural_0, 'bits'), (self.echo_preamble_insert_1, 'in')) self.msg_connect((self.echo_demodulator_neural_0, 'bits'), (self.echo_preamble_insert_1_0, 'in')) self.msg_connect((self.echo_modulator_classic_0, 'symbols'), (self.classic_to_neural_handler, 'wrap_in')) self.msg_connect((self.echo_modulator_neural_0, 'symbols'), (self.neural_to_classic_handler, 'wrap_in')) self.msg_connect((self.echo_packet_length_check_0, 'validated'), (self.echo_demodulator_neural_0, 'symbols')) self.msg_connect((self.echo_packet_length_check_0, 'failed'), (self.echo_triggered_vector_source_b_0, 'trigger')) self.msg_connect((self.echo_packet_length_check_0_0, 'validated'), (self.echo_demodulator_classic_0, 'symbols')) self.msg_connect((self.echo_packet_length_check_0_0, 'failed'), (self.echo_triggered_vector_source_b_0, 'trigger')) self.msg_connect((self.echo_preamble_insert_0, 'out'), (self.echo_modulator_classic_0, 'bits')) self.msg_connect((self.echo_preamble_insert_0_0, 'out'), (self.echo_modulator_classic_0, 'update')) self.msg_connect((self.echo_preamble_insert_1, 'out'), (self.echo_modulator_neural_0, 'feedback')) self.msg_connect((self.echo_preamble_insert_1_0, 'out'), (self.echo_modulator_neural_0, 'bits')) self.connect((self.analog_const_source_x_0, 0), (self.blocks_stream_mux_1, 1)) self.connect((self.analog_const_source_x_0_0, 0), (self.blocks_stream_mux_0, 1)) self.connect((self.blocks_pdu_to_tagged_stream_0_1, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.blocks_stream_mux_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_stream_mux_1, 0), (self.channels_channel_model_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.neural_to_classic_handler, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_const_sink_x_0_0_0, 0)) self.connect((self.channels_channel_model_0_0, 0), (self.classic_to_neural_handler, 0)) self.connect((self.classic_to_neural_handler, 0), (self.blocks_stream_mux_1, 0)) self.connect((self.neural_to_classic_handler, 0), (self.blocks_stream_mux_0, 0)) self.connect((self.echo_triggered_vector_source_b_0, 0), (self.blocks_tagged_stream_to_pdu_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Stereo Fm") Qt.QWidget.__init__(self) self.setWindowTitle("Stereo Fm") 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", "stereo_fm") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.demod_rate = demod_rate = 192000 self.audio_decimation = audio_decimation = 4 self.audio_rate = audio_rate = demod_rate / audio_decimation self.width_of_transition_band = width_of_transition_band = audio_rate / 32 self.volume = volume = 1 self.stereo_carr_loop_bw = stereo_carr_loop_bw = 2.0 * math.pi * 10 / 100 self.samp_rate = samp_rate = 1000e3 self.range1 = range1 = 88.1 self.max_freq = max_freq = 2.0 * math.pi * (80) * 1e3 / demod_rate self.loop_bw = loop_bw = 2.0 * math.pi * 28 / 100 ################################################## # Blocks ################################################## self._range1_layout = Qt.QVBoxLayout() self._range1_tool_bar = Qt.QToolBar(self) self._range1_layout.addWidget(self._range1_tool_bar) self._range1_tool_bar.addWidget(Qt.QLabel("Tune" + ": ")) 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._range1_counter = qwt_counter_pyslot() self._range1_counter.setRange(88, 108, 0.1) self._range1_counter.setNumButtons(2) self._range1_counter.setValue(self.range1) self._range1_tool_bar.addWidget(self._range1_counter) self._range1_counter.valueChanged.connect(self.set_range1) self._range1_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._range1_slider.setRange(88, 108, 0.1) self._range1_slider.setValue(self.range1) self._range1_slider.setMinimumWidth(200) self._range1_slider.valueChanged.connect(self.set_range1) self._range1_layout.addWidget(self._range1_slider) self.top_layout.addLayout(self._range1_layout) self._volume_layout = Qt.QVBoxLayout() self._volume_tool_bar = Qt.QToolBar(self) self._volume_layout.addWidget(self._volume_tool_bar) self._volume_tool_bar.addWidget(Qt.QLabel("Volume" + ": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot("double") def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._volume_counter = qwt_counter_pyslot() self._volume_counter.setRange(0.000001, 100, 0.01) self._volume_counter.setNumButtons(2) self._volume_counter.setValue(self.volume) self._volume_tool_bar.addWidget(self._volume_counter) self._volume_counter.valueChanged.connect(self.set_volume) self._volume_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._volume_slider.setRange(0.000001, 100, 0.01) self._volume_slider.setValue(self.volume) self._volume_slider.setMinimumWidth(200) self._volume_slider.valueChanged.connect(self.set_volume) self._volume_layout.addWidget(self._volume_slider) self.top_layout.addLayout(self._volume_layout) self.stereo_carrier_pll_recovery = analog.pll_refout_cc( stereo_carr_loop_bw, -2.0 * math.pi * 18990 / demod_rate, -2.0 * math.pi * 19010 / demod_rate ) self.stereo_carrier__filter = filter.fir_filter_fcc( 1, firdes.complex_band_pass(1, demod_rate, -19020, -18980, width_of_transition_band, firdes.WIN_HAMMING, 6.76), ) self.stereo_carr_gen = blocks.multiply_vcc(1) self.rtl2832_source_0 = baz.rtl_source_c(defer_creation=True, output_size=gr.sizeof_gr_complex) self.rtl2832_source_0.set_verbose(True) self.rtl2832_source_0.set_vid(0x0) self.rtl2832_source_0.set_pid(0x0) self.rtl2832_source_0.set_tuner_name("") self.rtl2832_source_0.set_default_timeout(0) self.rtl2832_source_0.set_use_buffer(True) self.rtl2832_source_0.set_fir_coefficients(([])) self.rtl2832_source_0.set_read_length(0) if self.rtl2832_source_0.create() == False: raise Exception("Failed to create RTL2832 Source: rtl2832_source_0") self.rtl2832_source_0.set_sample_rate(samp_rate) self.rtl2832_source_0.set_frequency(range1 * 1e6) self.rtl2832_source_0.set_auto_gain_mode(True) self.rtl2832_source_0.set_relative_gain(True) self.rtl2832_source_0.set_gain(1) self.root_raised_cosine_filter_0 = filter.fir_filter_ccf( 1, firdes.root_raised_cosine(1, 192000, 2375 / 2, 0.4, 100) ) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=demod_rate, decimation=int(samp_rate), taps=None, fractional_bw=None ) self.qtgui_const_sink_x_1 = qtgui.const_sink_c(1024, "", 1) # size # name # 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(True) self.qtgui_const_sink_x_1.enable_grid(True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in 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_layout.addWidget(self._qtgui_const_sink_x_1_win) self.fm_demod = analog.pll_freqdet_cf(loop_bw, max_freq, -max_freq) self.digital_mpsk_receiver_cc_0 = digital.mpsk_receiver_cc( 2, 0, 1 * cmath.pi / 100.0, -0.06, 0.06, 0.5, 0.05, demod_rate / 2375.0, 0.001, 0.005 ) self.RDS_signal_gen = blocks.multiply_vcc(1) self.RDS_sig_filter = filter.fir_filter_fcc( 1, firdes.complex_band_pass( 1, demod_rate, 57000 - 1500, 57000 + 1500, width_of_transition_band, firdes.WIN_HAMMING, 6.76 ), ) self.RDS_carr_gen = blocks.multiply_vcc(1) ################################################## # Connections ################################################## self.connect((self.RDS_carr_gen, 0), (self.RDS_signal_gen, 0)) self.connect((self.RDS_sig_filter, 0), (self.RDS_signal_gen, 1)) self.connect((self.RDS_signal_gen, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.fm_demod, 0), (self.RDS_sig_filter, 0)) self.connect((self.fm_demod, 0), (self.stereo_carrier__filter, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.fm_demod, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_mpsk_receiver_cc_0, 0)) self.connect((self.rtl2832_source_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.stereo_carr_gen, 0), (self.RDS_carr_gen, 1)) self.connect((self.stereo_carrier__filter, 0), (self.stereo_carrier_pll_recovery, 0)) self.connect((self.stereo_carrier_pll_recovery, 0), (self.RDS_carr_gen, 0)) self.connect((self.stereo_carrier_pll_recovery, 0), (self.stereo_carr_gen, 1)) self.connect((self.stereo_carrier_pll_recovery, 0), (self.stereo_carr_gen, 0))
def __init__(self): gr.top_block.__init__(self, "Mpsk Stage2", catch_exceptions=True) Qt.QWidget.__init__(self) self.setWindowTitle("Mpsk Stage2") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "mpsk_stage2") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.time_offset = time_offset = 1.00 self.taps = taps = [ 1.0 + 0.0j, ] self.sps = sps = 4 self.samp_rate = samp_rate = 32000 self.qpsk = qpsk = digital.constellation_rect( [0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j], [0, 1, 2, 3], 4, 2, 2, 1, 1).base() self.noise_volt = noise_volt = 0.0001 self.freq_offset = freq_offset = 0 self.excess_bw = excess_bw = 0.35 self.arity = arity = 4 ################################################## # Blocks ################################################## self._time_offset_range = Range(0.999, 1.001, 0.0001, 1.00, 200) self._time_offset_win = RangeWidget(self._time_offset_range, self.set_time_offset, 'Channel: Timing Offset', "slider", float, QtCore.Qt.Horizontal) self.top_grid_layout.addWidget(self._time_offset_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._noise_volt_range = Range(0, 1, 0.01, 0.0001, 200) self._noise_volt_win = RangeWidget(self._noise_volt_range, self.set_noise_volt, 'Channel: Noise Voltage', "slider", float, QtCore.Qt.Horizontal) self.top_grid_layout.addWidget(self._noise_volt_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._freq_offset_range = Range(-0.1, 0.1, 0.001, 0, 200) self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, 'Channel: Frequency Offset', "slider", float, QtCore.Qt.Horizontal) self.top_grid_layout.addWidget(self._freq_offset_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_c( 200, #size samp_rate, #samp_rate '', #name 1, #number of inputs None # parent ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-2, 2) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(2): if len(labels[i]) == 0: 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, 1, 0, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size window.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw '', #name 1, None # parent ) 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) self.qtgui_freq_sink_x_0.set_fft_window_normalized(False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [2, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 2, 0, 1, 4) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size '', #name 1, #number of inputs None # parent ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(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, 2, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 4): self.top_grid_layout.setColumnStretch(c, 1) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False, truncate=False) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise_volt, frequency_offset=freq_offset, epsilon=time_offset, taps=taps, noise_seed=0, block_tags=False) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.analog_random_source_x_0 = blocks.vector_source_b( list(map(int, numpy.random.randint(0, 256, 10000))), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_throttle_0, 0))
def __init__(self): gr.top_block.__init__(self, "Rx Application") Qt.QWidget.__init__(self) self.setWindowTitle("Rx Application") try: self.setWindowIcon(Qt.QIcon.fromTheme("gnuradio-grc")) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "rx_application") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.preamble = preamble = [ 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, ] self.nfilts = nfilts = 32 self.eb = eb = 0.35 self.usrp_rf_freq = usrp_rf_freq = 2475e6 self.samp_rate = samp_rate = 200000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0 / float(sps), eb, 5 * sps * nfilts) self.preamble_qpsk = preamble_qpsk = map(lambda x: x * (1 + 1j) / pow(2, 0.5), preamble) self.matched_filter = matched_filter = firdes.root_raised_cosine(nfilts, nfilts, 1, eb, int(11 * sps * nfilts)) self.gain = gain = 29 self.digital_gain = digital_gain = 15 self.addr = addr = "addr=192.168.50.2" ################################################## # Blocks ################################################## self._usrp_rf_freq_range = Range(2400e6, 2500e6, 100e3, 2475e6, 200) self._usrp_rf_freq_win = RangeWidget( self._usrp_rf_freq_range, self.set_usrp_rf_freq, "Rx Frequency", "counter_slider" ) self.top_grid_layout.addWidget(self._usrp_rf_freq_win, 3, 0, 1, 2) self._gain_range = Range(0, 40, 0.5, 29, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, "Rx Gain", "counter_slider") self.top_grid_layout.addWidget(self._gain_win, 1, 0, 1, 2) self._digital_gain_range = Range(0, 60, 1, 15, 200) self._digital_gain_win = RangeWidget( self._digital_gain_range, self.set_digital_gain, "Digital Gain", "counter_slider" ) self.top_grid_layout.addWidget(self._digital_gain_win, 2, 0, 1, 2) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join((addr, "")), uhd.stream_args(cpu_format="fc32", channels=range(1)) ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(usrp_rf_freq, 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.uhd_usrp_source_0.set_antenna("J1", 0) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_VERT, 1) self.qtgui_number_sink_0.set_update_time(0.1) self.qtgui_number_sink_0.set_title("Packet Received") labels = [" ", "", "", "", "", "", "", "", "", ""] units = ["packet/sec", "", "", "", "", "", "", "", "", ""] 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, 0) 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.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 0, 1, 1, 1) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c(20000, "", 1) # size # name # number of inputs self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(False) if not False: self.qtgui_const_sink_x_0_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win, 0, 0, 1, 1) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, 2 * 3.14 / 100.0, (rrc_taps), nfilts, 0, 0.5, sps / 4 ) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(sps, eb, 45, 2 * 3.14 / 100.0) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(1 * 3.14 / 50.0, 4, False) self.digital_correlate_and_sync_cc_0 = digital.correlate_and_sync_cc((preamble_qpsk), (matched_filter), sps) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(15, 1, 0.01, 1) self.crew_packet_decoder_cb_0 = crew.packet_decoder_cb((preamble_qpsk)) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char * 1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((digital_gain,)) ################################################## # Connections ################################################## self.connect((self.blocks_multiply_const_vxx_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.crew_packet_decoder_cb_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.crew_packet_decoder_cb_0, 1), (self.qtgui_number_sink_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_correlate_and_sync_cc_0, 1), (self.blocks_null_sink_0_0, 0)) self.connect((self.digital_correlate_and_sync_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.crew_packet_decoder_cb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_correlate_and_sync_cc_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.RXangle = RXangle = 0 self.TXangle = TXangle = 0 self.sps = sps = 4 self.range_tx_gain = range_tx_gain = 0 self.range_rx_gain = range_rx_gain = 10 self.range_mu = range_mu = 0.4 self.range_freq = range_freq = 2.0e9 self.variable_qtgui_label_0 = variable_qtgui_label_0 = "{:2.1f} GHz".format( float((59e9 + range_freq)) / 1e9) self.tx_gain = tx_gain = range_tx_gain self.threshold = threshold = 40 self.samp_rate = samp_rate = 4e6 self.rx_gain = rx_gain = range_rx_gain self.rrc = rrc = firdes.root_raised_cosine(1.0, sps, 1, 0.5, 11 * sps) self.range_noise = range_noise = 0 self.qpsk_mod = qpsk_mod = gnuradio.digital.constellation_qpsk().base() self.preamble = preamble = [ 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0 ] self.mu = mu = range_mu self.freq = freq = range_freq self.diff_preamble_256 = diff_preamble_256 = [ 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0 ] self.diff_preamble_128 = diff_preamble_128 = [ 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0 ][0:128] self.bpsk_mod = bpsk_mod = gnuradio.digital.constellation_bpsk().base() ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, "TX") self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, "RX") self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, "Demod") self.top_layout.addWidget(self.tab) self._range_noise_range = Range(0, 0.1, 0.005, 0, 200) self._range_noise_win = RangeWidget(self._range_noise_range, self.set_range_noise, "noise", "counter_slider", float) self.top_layout.addWidget(self._range_noise_win) self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_formatter = None else: self._variable_qtgui_label_0_formatter = lambda x: x self._variable_qtgui_label_0_tool_bar.addWidget( Qt.QLabel("RF Frequency" + ": ")) self._variable_qtgui_label_0_label = Qt.QLabel( str( self._variable_qtgui_label_0_formatter( self.variable_qtgui_label_0))) self._variable_qtgui_label_0_tool_bar.addWidget( self._variable_qtgui_label_0_label) self.top_grid_layout.addWidget(self._variable_qtgui_label_0_tool_bar, 0, 1, 1, 1) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_gain(rx_gain, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), "packet_len", ) self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(freq, 0) self.uhd_usrp_sink_0.set_gain(tx_gain, 0) self._range_tx_gain_range = Range(0, 15, 1, 0, 200) self._range_tx_gain_win = RangeWidget(self._range_tx_gain_range, self.set_range_tx_gain, "Tx Gain", "counter_slider", float) self.top_grid_layout.addWidget(self._range_tx_gain_win, 1, 1, 1, 1) self._range_rx_gain_range = Range(0, 60, 1, 10, 200) self._range_rx_gain_win = RangeWidget(self._range_rx_gain_range, self.set_range_rx_gain, "Rx Gain", "counter_slider", float) self.top_grid_layout.addWidget(self._range_rx_gain_win, 1, 0, 1, 1) self._range_mu_range = Range(0, 1, 0.01, 0.4, 200) self._range_mu_win = RangeWidget(self._range_mu_range, self.set_range_mu, "BB Derotation Gain", "counter_slider", float) self.top_grid_layout.addWidget(self._range_mu_win, 2, 0, 1, 1) self._range_freq_range = Range(2.4e9, 4e9, 100e6, 3.0e9, 200) self._range_freq_win = RangeWidget(self._range_freq_range, self.set_range_freq, "IF Frequency", "counter_slider", float) self.top_grid_layout.addWidget(self._range_freq_win, 0, 0, 1, 1) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 256, #size 1, #samp_rate "Frequency Offset", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 1, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [0, -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.tab_layout_1.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 100000, #size samp_rate, #samp_rate "Correlation", #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, 200) 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, 20, 0, 1, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: 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.tab_layout_1.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 128, #size "Payload", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 0, "fd") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(True) if not True: self.qtgui_const_sink_x_0_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tab_layout_2.addWidget(self._qtgui_const_sink_x_0_0_win) self.inets_rssi_0 = inets.rssi(0.000001) self.inets_radio_0 = inets_radio( constellation=qpsk_mod, matched_filter_coeff=rrc, mu=mu, preamble=diff_preamble_128, samp_rate=samp_rate, sps=sps, threshold=threshold, ) self.inets_per_logger_0 = inets.per_logger() self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", "localhost", "52001", 10000, False) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char * 1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc( (range_noise, )) self.blocks_complex_to_mag_0_0 = blocks.complex_to_mag(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c( analog.GR_GAUSSIAN, 1, 0, 1024) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.inets_radio_0, 'in')) self.msg_connect((self.inets_radio_0, 'out'), (self.inets_per_logger_0, 'payload_in')) self.msg_connect((self.inets_radio_0, 'snr'), (self.inets_per_logger_0, 'snr_in')) self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.inets_radio_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blocks_complex_to_mag_0_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.inets_rssi_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.inets_radio_0, 2), (self.blocks_complex_to_mag_0, 0)) self.connect((self.inets_radio_0, 1), (self.blocks_complex_to_mag_0_0, 0)) self.connect((self.inets_radio_0, 5), (self.blocks_null_sink_0, 0)) self.connect((self.inets_radio_0, 6), (self.blocks_null_sink_0_0, 0)) self.connect((self.inets_radio_0, 3), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.inets_radio_0, 4), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.inets_radio_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_add_xx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Demo Gmsk") Qt.QWidget.__init__(self) self.setWindowTitle("Demo Gmsk") 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_gmsk") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self.q_ofs = q_ofs = 0 self.phasebal = phasebal = 0 self.phase_noise_mag = phase_noise_mag = -100 self.magbal = magbal = 0 self.i_ofs = i_ofs = 0 self.freq_offset = freq_offset = 0 self.const_size = const_size = 4 self.beta = beta = 0 ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("addr=192.168.10.3", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(1399993750, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.uhd_usrp_source_0.set_antenna("RX2", 0) 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(True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in 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, 4,0,1,1) self._q_ofs_layout = Qt.QVBoxLayout() self._q_ofs_tool_bar = Qt.QToolBar(self) self._q_ofs_layout.addWidget(self._q_ofs_tool_bar) self._q_ofs_tool_bar.addWidget(Qt.QLabel("Q offset"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._q_ofs_counter = qwt_counter_pyslot() self._q_ofs_counter.setRange(-1, 1, 0.001) self._q_ofs_counter.setNumButtons(2) self._q_ofs_counter.setValue(self.q_ofs) self._q_ofs_tool_bar.addWidget(self._q_ofs_counter) self._q_ofs_counter.valueChanged.connect(self.set_q_ofs) self._q_ofs_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._q_ofs_slider.setRange(-1, 1, 0.001) self._q_ofs_slider.setValue(self.q_ofs) self._q_ofs_slider.setMinimumWidth(200) self._q_ofs_slider.valueChanged.connect(self.set_q_ofs) self._q_ofs_layout.addWidget(self._q_ofs_slider) self.top_grid_layout.addLayout(self._q_ofs_layout, 2,1,1,1) self._phasebal_layout = Qt.QVBoxLayout() self._phasebal_tool_bar = Qt.QToolBar(self) self._phasebal_layout.addWidget(self._phasebal_tool_bar) self._phasebal_tool_bar.addWidget(Qt.QLabel("IQ Phase Imbalance"+": ")) 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._phasebal_counter = qwt_counter_pyslot() self._phasebal_counter.setRange(0, 45, 0.1) self._phasebal_counter.setNumButtons(2) self._phasebal_counter.setValue(self.phasebal) self._phasebal_tool_bar.addWidget(self._phasebal_counter) self._phasebal_counter.valueChanged.connect(self.set_phasebal) self._phasebal_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._phasebal_slider.setRange(0, 45, 0.1) self._phasebal_slider.setValue(self.phasebal) self._phasebal_slider.setMinimumWidth(200) self._phasebal_slider.valueChanged.connect(self.set_phasebal) self._phasebal_layout.addWidget(self._phasebal_slider) self.top_grid_layout.addLayout(self._phasebal_layout, 1,1,1,1) self._phase_noise_mag_layout = Qt.QVBoxLayout() self._phase_noise_mag_tool_bar = Qt.QToolBar(self) self._phase_noise_mag_layout.addWidget(self._phase_noise_mag_tool_bar) self._phase_noise_mag_tool_bar.addWidget(Qt.QLabel("Phase Noise Mag (dB)"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._phase_noise_mag_counter = qwt_counter_pyslot() self._phase_noise_mag_counter.setRange(-100, 0, 1) self._phase_noise_mag_counter.setNumButtons(2) self._phase_noise_mag_counter.setValue(self.phase_noise_mag) self._phase_noise_mag_tool_bar.addWidget(self._phase_noise_mag_counter) self._phase_noise_mag_counter.valueChanged.connect(self.set_phase_noise_mag) self._phase_noise_mag_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._phase_noise_mag_slider.setRange(-100, 0, 1) self._phase_noise_mag_slider.setValue(self.phase_noise_mag) self._phase_noise_mag_slider.setMinimumWidth(200) self._phase_noise_mag_slider.valueChanged.connect(self.set_phase_noise_mag) self._phase_noise_mag_layout.addWidget(self._phase_noise_mag_slider) self.top_grid_layout.addLayout(self._phase_noise_mag_layout, 0, 0, 1,1) self._magbal_layout = Qt.QVBoxLayout() self._magbal_tool_bar = Qt.QToolBar(self) self._magbal_layout.addWidget(self._magbal_tool_bar) self._magbal_tool_bar.addWidget(Qt.QLabel("IQ Magnitude Imbalance"+": ")) 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._magbal_counter = qwt_counter_pyslot() self._magbal_counter.setRange(0, 10, 0.1) self._magbal_counter.setNumButtons(2) self._magbal_counter.setValue(self.magbal) self._magbal_tool_bar.addWidget(self._magbal_counter) self._magbal_counter.valueChanged.connect(self.set_magbal) self._magbal_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._magbal_slider.setRange(0, 10, 0.1) self._magbal_slider.setValue(self.magbal) self._magbal_slider.setMinimumWidth(200) self._magbal_slider.valueChanged.connect(self.set_magbal) self._magbal_layout.addWidget(self._magbal_slider) self.top_grid_layout.addLayout(self._magbal_layout, 1,0,1,1) self._i_ofs_layout = Qt.QVBoxLayout() self._i_ofs_tool_bar = Qt.QToolBar(self) self._i_ofs_layout.addWidget(self._i_ofs_tool_bar) self._i_ofs_tool_bar.addWidget(Qt.QLabel("I offset"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._i_ofs_counter = qwt_counter_pyslot() self._i_ofs_counter.setRange(-1, 1, 0.001) self._i_ofs_counter.setNumButtons(2) self._i_ofs_counter.setValue(self.i_ofs) self._i_ofs_tool_bar.addWidget(self._i_ofs_counter) self._i_ofs_counter.valueChanged.connect(self.set_i_ofs) self._i_ofs_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._i_ofs_slider.setRange(-1, 1, 0.001) self._i_ofs_slider.setValue(self.i_ofs) self._i_ofs_slider.setMinimumWidth(200) self._i_ofs_slider.valueChanged.connect(self.set_i_ofs) self._i_ofs_layout.addWidget(self._i_ofs_slider) self.top_grid_layout.addLayout(self._i_ofs_layout, 2,0,1,1) self._freq_offset_layout = Qt.QVBoxLayout() self._freq_offset_tool_bar = Qt.QToolBar(self) self._freq_offset_layout.addWidget(self._freq_offset_tool_bar) self._freq_offset_tool_bar.addWidget(Qt.QLabel("Frequency Offset"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._freq_offset_counter = qwt_counter_pyslot() self._freq_offset_counter.setRange(-0.5, 0.5, 0.001) self._freq_offset_counter.setNumButtons(2) self._freq_offset_counter.setValue(self.freq_offset) self._freq_offset_tool_bar.addWidget(self._freq_offset_counter) self._freq_offset_counter.valueChanged.connect(self.set_freq_offset) self._freq_offset_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._freq_offset_slider.setRange(-0.5, 0.5, 0.001) self._freq_offset_slider.setValue(self.freq_offset) self._freq_offset_slider.setMinimumWidth(200) self._freq_offset_slider.valueChanged.connect(self.set_freq_offset) self._freq_offset_layout.addWidget(self._freq_offset_slider) self.top_grid_layout.addLayout(self._freq_offset_layout, 0,1,1,1) self._beta_layout = Qt.QVBoxLayout() self._beta_tool_bar = Qt.QToolBar(self) self._beta_layout.addWidget(self._beta_tool_bar) self._beta_tool_bar.addWidget(Qt.QLabel("k3 (IP3)"+": ")) 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._beta_counter = qwt_counter_pyslot() self._beta_counter.setRange(-.1, 0, 0.001) self._beta_counter.setNumButtons(2) self._beta_counter.setValue(self.beta) self._beta_tool_bar.addWidget(self._beta_counter) self._beta_counter.valueChanged.connect(self.set_beta) self._beta_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._beta_slider.setRange(-.1, 0, 0.001) self._beta_slider.setValue(self.beta) self._beta_slider.setMinimumWidth(200) self._beta_slider.valueChanged.connect(self.set_beta) self._beta_layout.addWidget(self._beta_slider) self.top_grid_layout.addLayout(self._beta_layout, 3,0,1,1) ################################################## # Connections ################################################## self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_const_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.center_freq = center_freq = 2.4245e9 self.samp_rate = samp_rate = 2e6 self.rfgain = rfgain = 60 self.channel_freq = channel_freq = center_freq ################################################## # Blocks ################################################## self._center_freq_range = Range(2.4245e9 - samp_rate/2, 2.4245e9 +samp_rate/2, 1000, 2.4245e9, 200) self._center_freq_win = RangeWidget(self._center_freq_range, self.set_center_freq, "center_freq", "counter_slider", float) self.top_layout.addWidget(self._center_freq_win) self._rfgain_range = Range(0, 100, 1, 60, 200) self._rfgain_win = RangeWidget(self._rfgain_range, self.set_rfgain, "rfgain", "counter_slider", float) self.top_layout.addWidget(self._rfgain_win) self._channel_freq_range = Range(center_freq - samp_rate/2, center_freq + samp_rate/2, 1000, center_freq, 200) self._channel_freq_win = RangeWidget(self._channel_freq_range, self.set_channel_freq, "channel_freq", "counter_slider", float) self.top_layout.addWidget(self._channel_freq_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2*1): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype center_freq, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) 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_layout.addWidget(self._qtgui_const_sink_x_0_win) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(center_freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(rfgain, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_gr_complex*1, "/home/ascl/sbandtest/text/carrier_freq_2.425GHz/center_freq_2.4245GHz/datarate_250kbps/samp_rate2M", False) self.blocks_file_sink_0_0.set_unbuffered(False) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, channel_freq - center_freq, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Mpsk Stage3") Qt.QWidget.__init__(self) self.setWindowTitle("Mpsk Stage3") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "mpsk_stage3") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 8 self.payload = payload = range(256) self.nfilts = nfilts = 32 self.timing_loop_bw = timing_loop_bw = 6.28/100.0 self.taps = taps = [1.0 + 0.0j, ] self.samp_rate = samp_rate = 250e3 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 45*nfilts) self.qpsk_const = qpsk_const = digital.constellation_rect(([-1, +1]), ([0, 1]), 1, 2, 1, 1, 1).base() self.payload_str = payload_str = ''.join(map(lambda x: "{0:08b}".format(x), payload)) self.gain = gain = 50 self.freq = freq = 2.3e9 self.excess_bw = excess_bw = 0.35 self.delay = delay = 32 self.decim = decim = 1 self.arity = arity = 2 self.access_code_str = access_code_str = "1111100110101" self.access_code = access_code = [31, 53] ################################################## # Blocks ################################################## self._delay_layout = Qt.QVBoxLayout() self._delay_tool_bar = Qt.QToolBar(self) self._delay_layout.addWidget(self._delay_tool_bar) self._delay_tool_bar.addWidget(Qt.QLabel("delay"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._delay_counter = qwt_counter_pyslot() self._delay_counter.setRange(0, 100, 1) self._delay_counter.setNumButtons(2) self._delay_counter.setValue(self.delay) self._delay_tool_bar.addWidget(self._delay_counter) self._delay_counter.valueChanged.connect(self.set_delay) self._delay_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._delay_slider.setRange(0, 100, 1) self._delay_slider.setValue(self.delay) self._delay_slider.setMinimumWidth(200) self._delay_slider.valueChanged.connect(self.set_delay) self._delay_layout.addWidget(self._delay_slider) self.top_layout.addLayout(self._delay_layout) self.west_stream_trigged_pdu_0 = west.stream_trigged_pdu("start_payload", 2048) self.west_ber_pdu_0 = west.ber_pdu(payload_str) self._timing_loop_bw_layout = Qt.QVBoxLayout() self._timing_loop_bw_label = Qt.QLabel("Time: BW") self._timing_loop_bw_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._timing_loop_bw_slider.setRange(0.0, 0.2, 0.005) self._timing_loop_bw_slider.setValue(self.timing_loop_bw) self._timing_loop_bw_slider.setMinimumWidth(200) self._timing_loop_bw_slider.valueChanged.connect(self.set_timing_loop_bw) self._timing_loop_bw_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_label) self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_slider) self.top_grid_layout.addLayout(self._timing_loop_bw_layout, 3,1,1,1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_const_sink_x_1_0 = qtgui.const_sink_c( 1024, #size "Equalizer", #name 1 #number of inputs ) self.qtgui_const_sink_x_1_0.set_update_time(0.10) self.qtgui_const_sink_x_1_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_1_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1_0.enable_autoscale(False) self.qtgui_const_sink_x_1_0.enable_grid(False) 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_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_0_win = sip.wrapinstance(self.qtgui_const_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_1_0_win) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( 1024, #size "Clock Sync Output", #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) 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_layout.addWidget(self._qtgui_const_sink_x_1_win) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 2048, #size "Costas Loop Output", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win, 0,1,1,1) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( 1, taps=(rrc_taps[:-1]), flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self._gain_layout = Qt.QVBoxLayout() self._gain_tool_bar = Qt.QToolBar(self) self._gain_layout.addWidget(self._gain_tool_bar) self._gain_tool_bar.addWidget(Qt.QLabel("RF gain"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._gain_counter = qwt_counter_pyslot() self._gain_counter.setRange(0, 90, 1) self._gain_counter.setNumButtons(2) self._gain_counter.setValue(self.gain) self._gain_tool_bar.addWidget(self._gain_counter) self._gain_counter.valueChanged.connect(self.set_gain) self._gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._gain_slider.setRange(0, 90, 1) self._gain_slider.setValue(self.gain) self._gain_slider.setMinimumWidth(200) self._gain_slider.valueChanged.connect(self.set_gain) self._gain_layout.addWidget(self._gain_slider) self.top_layout.addLayout(self._gain_layout) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(.015, 2) self.digital_correlate_access_code_bb_0 = digital.correlate_access_code_bb(access_code_str, 1) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk_const, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False, ) (self.digital_constellation_modulator_0).set_processor_affinity([2]) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(qpsk_const) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(16, 1, 0.15/100., 1) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc(sps*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.005) self.blocks_vector_source_x_0_0 = blocks.vector_source_b([135, 201]*5000 + access_code + payload*100000, False, 1, []) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((.0001, )) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_char*1, 1) self.blocks_delay_0 = blocks.delay(gr.sizeof_char*1, int(delay)) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(analog.GR_GAUSSIAN, 0.3, 0, 8192) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-1, 1.0, 1) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_cma_equalizer_cc_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.qtgui_const_sink_x_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.digital_correlate_access_code_bb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_correlate_access_code_bb_0, 0), (self.west_stream_trigged_pdu_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.digital_correlate_access_code_bb_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.digital_diff_decoder_bb_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.west_stream_trigged_pdu_0, "pdus", self.west_ber_pdu_0, "pdus")
def get_qtsink(self): snk = qtgui.const_sink_c(self._npts, self._name, self._ncons) snk.enable_autoscale(True) return snk
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.range_tx_gain = range_tx_gain = 15 self.range_rx_gain = range_rx_gain = 18 self.range_mu = range_mu = 0.4 self.range_freq = range_freq = 3.5e9 self.variable_qtgui_label_0 = variable_qtgui_label_0 = "{:2.1f} GHz".format(float((77e9-range_freq))/1e9) self.tx_gain = tx_gain = range_tx_gain self.threshold = threshold = 50 self.samp_rate = samp_rate = 4e6 self.rx_gain = rx_gain = range_rx_gain self.rrc = rrc = firdes.root_raised_cosine(1.0, sps, 1, 0.5, 11*sps) self.range_noise = range_noise = 0 self.qpsk_mod = qpsk_mod = gnuradio.digital.constellation_qpsk().base() self.preamble = preamble = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0] self.mu = mu = range_mu self.freq = freq = range_freq self.diff_preamble_256 = diff_preamble_256 = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0] self.diff_preamble_128 = diff_preamble_128 = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0][0:128] self.bpsk_mod = bpsk_mod = gnuradio.digital.constellation_bpsk().base() ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, "TX") self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, "RX") self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, "Demod") self.top_layout.addWidget(self.tab) self._range_noise_range = Range(0, 0.1, 0.005, 0, 200) self._range_noise_win = RangeWidget(self._range_noise_range, self.set_range_noise, "noise", "counter_slider", float) self.top_layout.addWidget(self._range_noise_win) self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_formatter = None else: self._variable_qtgui_label_0_formatter = lambda x: x self._variable_qtgui_label_0_tool_bar.addWidget(Qt.QLabel("RF Frequency"+": ")) self._variable_qtgui_label_0_label = Qt.QLabel(str(self._variable_qtgui_label_0_formatter(self.variable_qtgui_label_0))) self._variable_qtgui_label_0_tool_bar.addWidget(self._variable_qtgui_label_0_label) self.top_grid_layout.addWidget(self._variable_qtgui_label_0_tool_bar, 0,1,1,1) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(freq+100e6, 0) self.uhd_usrp_source_0.set_gain(rx_gain, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), "packet_len", ) self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(freq, 0) self.uhd_usrp_sink_0.set_gain(tx_gain, 0) self._range_tx_gain_range = Range(0, 15, 1, 15, 200) self._range_tx_gain_win = RangeWidget(self._range_tx_gain_range, self.set_range_tx_gain, "Tx Gain", "counter_slider", float) self.top_grid_layout.addWidget(self._range_tx_gain_win, 1,1,1,1) self._range_rx_gain_range = Range(0, 60, 1, 18, 200) self._range_rx_gain_win = RangeWidget(self._range_rx_gain_range, self.set_range_rx_gain, "Rx Gain", "counter_slider", float) self.top_grid_layout.addWidget(self._range_rx_gain_win, 1,0,1,1) self._range_mu_range = Range(0, 1, 0.01, 0.4, 200) self._range_mu_win = RangeWidget(self._range_mu_range, self.set_range_mu, "BB Derotation Gain", "counter_slider", float) self.top_grid_layout.addWidget(self._range_mu_win, 2,0,1,1) self._range_freq_range = Range(2.5e9, 4e9, 100e6, 3.5e9, 200) self._range_freq_win = RangeWidget(self._range_freq_range, self.set_range_freq, "IF Frequency", "counter_slider", float) self.top_grid_layout.addWidget(self._range_freq_win, 0,0,1,1) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 256, #size 1, #samp_rate "Frequency Offset", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 1, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [0, -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.tab_layout_1.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 100000, #size samp_rate, #samp_rate "Correlation", #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, 200) 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, 20, 0, 1, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: 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.tab_layout_1.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 128, #size "Payload", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 0, "fd") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(True) if not True: self.qtgui_const_sink_x_0_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tab_layout_2.addWidget(self._qtgui_const_sink_x_0_0_win) self.inets_radio_0 = inets_radio( constellation=qpsk_mod, matched_filter_coeff=rrc, mu=mu, preamble=diff_preamble_128, samp_rate=samp_rate, sps=sps, threshold=threshold, ) self.inets_per_logger_0 = inets.per_logger() self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", "localhost", "52001", 10000, False) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char*1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((range_noise, )) self.blocks_complex_to_mag_0_0 = blocks.complex_to_mag(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(analog.GR_GAUSSIAN, 1, 0, 1024) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.inets_radio_0, 'in')) self.msg_connect((self.inets_radio_0, 'out'), (self.inets_per_logger_0, 'payload_in')) self.msg_connect((self.inets_radio_0, 'snr'), (self.inets_per_logger_0, 'snr_in')) self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.inets_radio_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blocks_complex_to_mag_0_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.inets_radio_0, 2), (self.blocks_complex_to_mag_0, 0)) self.connect((self.inets_radio_0, 1), (self.blocks_complex_to_mag_0_0, 0)) self.connect((self.inets_radio_0, 5), (self.blocks_null_sink_0, 0)) self.connect((self.inets_radio_0, 6), (self.blocks_null_sink_0_0, 0)) self.connect((self.inets_radio_0, 3), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.inets_radio_0, 4), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.inets_radio_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_add_xx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Symbol Mapping Demo", catch_exceptions=True) Qt.QWidget.__init__(self) self.setWindowTitle("Symbol Mapping Demo") 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", "symbol_mapping_demo") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self.constellation_order = constellation_order = 6 ################################################## # Blocks ################################################## self.symbolmapping_symbol_mapper_bc_0 = symbolmapping.symbol_mapper_bc( constellation_order, 'GRAY', True) self.symbolmapping_symbol_demapper_cf_0 = symbolmapping.symbol_demapper_cf( constellation_order, 'GRAY', 'snr') self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 2, #number of inputs None # parent ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 260) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(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) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1, #number of inputs None # parent ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(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.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb( 1, gr.GR_MSB_FIRST) self.blocks_uchar_to_float_0_0 = blocks.uchar_to_float() self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True) self.blocks_float_to_char_0 = blocks.float_to_char(1, 1) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, -1) self.blocks_add_const_vxx_0 = blocks.add_const_ff(1) self.analog_random_uniform_source_x_0 = analog.random_uniform_source_b( 0, 256, 0) ################################################## # Connections ################################################## self.connect((self.analog_random_uniform_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.symbolmapping_symbol_mapper_bc_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_uchar_to_float_0_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_uchar_to_float_0_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.symbolmapping_symbol_demapper_cf_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.symbolmapping_symbol_mapper_bc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.symbolmapping_symbol_mapper_bc_0, 0), (self.symbolmapping_symbol_demapper_cf_0, 0))
def __init__(self): gr.top_block.__init__(self, "Transceiver Test for Client Node") Qt.QWidget.__init__(self) self.setWindowTitle("Transceiver Test for Client Node") 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", "inets_transceiver_test_client") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.range_rx_gain = range_rx_gain = 0 self.range_mu = range_mu = 0.6 self.threshold = threshold = 50 self.samp_rate = samp_rate = 4e6 self.rx_gain = rx_gain = range_rx_gain self.rrc = rrc = firdes.root_raised_cosine(1.0, sps, 1, 0.5, 11*sps) self.range_noise = range_noise = 0 self.qpsk_mod = qpsk_mod = gnuradio.digital.constellation_qpsk().base() self.qam16_mod = qam16_mod = gnuradio.digital.qam_constellation(16,False).base() self.preamble = preamble = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0] self.mu = mu = range_mu self.diff_preamble_256 = diff_preamble_256 = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0] self.diff_preamble_128 = diff_preamble_128 = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0][0:128] self.bpsk_mod = bpsk_mod = gnuradio.digital.constellation_bpsk().base() ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, "TX") self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, "RX") self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, "Demod") self.tab_widget_3 = Qt.QWidget() self.tab_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_3) self.tab_grid_layout_3 = Qt.QGridLayout() self.tab_layout_3.addLayout(self.tab_grid_layout_3) self.tab.addTab(self.tab_widget_3, "RSSI") self.top_layout.addWidget(self.tab) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_center_freq(2e9, 0) self.uhd_usrp_source_0.set_gain(rx_gain, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), "packet_len", ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0.set_center_freq(1.5e9, 0) self.uhd_usrp_sink_0.set_gain(0, 0) self._range_rx_gain_range = Range(0, 60, 1, 0, 200) self._range_rx_gain_win = RangeWidget(self._range_rx_gain_range, self.set_range_rx_gain, "Rx Gain", "counter_slider", float) self.top_grid_layout.addWidget(self._range_rx_gain_win, 1,0,1,1) self._range_noise_range = Range(0, 0.01, 0.00001, 0, 200) self._range_noise_win = RangeWidget(self._range_noise_range, self.set_range_noise, "noise", "counter_slider", float) self.top_layout.addWidget(self._range_noise_win) self._range_mu_range = Range(0, 1, 0.01, 0.6, 200) self._range_mu_win = RangeWidget(self._range_mu_range, self.set_range_mu, "BB Derotation Gain", "counter_slider", float) self.top_grid_layout.addWidget(self._range_mu_win, 2,0,1,1) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 1000000, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-80, -40) self.qtgui_time_sink_x_1.set_y_label("Amplitude", "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1.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.tab_layout_3.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 256, #size 1, #samp_rate "Frequency Offset", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 1, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [0, -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.tab_layout_1.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 100000, #size samp_rate / 4, #samp_rate "Correlation", #name 3 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 200) 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, 20, 0, 1, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) 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(3): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_layout_1.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c( 1024, #size "TX Constellation", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0.enable_grid(True) self.qtgui_const_sink_x_0_0_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.tab_layout_0.addWidget(self._qtgui_const_sink_x_0_0_0_win) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 1024, #size "Payload", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "fd") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(True) self.qtgui_const_sink_x_0_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tab_layout_2.addWidget(self._qtgui_const_sink_x_0_0_win) self.inets_rssi_0 = inets.rssi(0.00004) self.inets_radio_0 = inets_radio( constellation=qpsk_mod, matched_filter_coeff=rrc, mu=mu, preamble=diff_preamble_128, samp_rate=samp_rate, sps=sps, threshold=threshold, ) self.inets_per_logger_0 = inets.per_logger() self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", "localhost", "52001", 10000, False) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_float*1) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(1, 1, 0) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((10, )) self.blocks_complex_to_mag_0_0 = blocks.complex_to_mag(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.inets_radio_0, 'in')) self.msg_connect((self.inets_radio_0, 'out'), (self.inets_per_logger_0, 'payload_in')) self.msg_connect((self.inets_radio_0, 'snr'), (self.inets_per_logger_0, 'snr_in')) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0, 2)) self.connect((self.blocks_complex_to_mag_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blocks_complex_to_mag_0_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.inets_radio_0, 5), (self.blocks_char_to_float_0, 0)) self.connect((self.inets_radio_0, 2), (self.blocks_complex_to_mag_0, 0)) self.connect((self.inets_radio_0, 1), (self.blocks_complex_to_mag_0_0, 0)) self.connect((self.inets_radio_0, 3), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.inets_radio_0, 6), (self.qtgui_const_sink_x_0_0_0, 0)) self.connect((self.inets_radio_0, 4), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.inets_radio_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.inets_rssi_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.inets_rssi_0, 1), (self.blocks_null_sink_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.inets_radio_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.inets_rssi_0, 0))
def __init__(self): gr.top_block.__init__(self, "Simulation for SDR TCC") Qt.QWidget.__init__(self) self.setWindowTitle("Simulation for SDR TCC") 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", "sdrSim2") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.eb = eb = 0.35 self.timing_loop_bw = timing_loop_bw = 0.005 self.time_offset = time_offset = 1.00 self.taps = taps = [1.0, 0.25-0.25j, 0.50 + 0.10j, -0.3 + 0.2j] self.samp_rate = samp_rate = 32000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts) self.qpsk = qpsk = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.preamble = preamble = [1,-1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,1,1,1,1,1,1,-1,-1] self.phase_bw = phase_bw = 6.28/100.0 self.payload_size = payload_size = 992 self.noise_volt = noise_volt = 0.0001 self.matched_filter = matched_filter = firdes.root_raised_cosine(nfilts, nfilts, 1, eb, int(11*sps*nfilts)) self.freq_offset = freq_offset = 0 self.freq_bw = freq_bw = 6.28/100.0 self.excess_bw = excess_bw = 0.35 self.eq_gain = eq_gain = 0.01 self.delay = delay = 0 self.arity = arity = 4 ################################################## # Blocks ################################################## self.controls = Qt.QTabWidget() self.controls_widget_0 = Qt.QWidget() self.controls_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_0) self.controls_grid_layout_0 = Qt.QGridLayout() self.controls_layout_0.addLayout(self.controls_grid_layout_0) self.controls.addTab(self.controls_widget_0, "Channel") self.controls_widget_1 = Qt.QWidget() self.controls_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_1) self.controls_grid_layout_1 = Qt.QGridLayout() self.controls_layout_1.addLayout(self.controls_grid_layout_1) self.controls.addTab(self.controls_widget_1, "Receiver") self.top_grid_layout.addWidget(self.controls, 0,0,1,2) self._timing_loop_bw_layout = Qt.QVBoxLayout() self._timing_loop_bw_label = Qt.QLabel("Time: BW") self._timing_loop_bw_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._timing_loop_bw_slider.setRange(0.0, 0.2, 0.005) self._timing_loop_bw_slider.setValue(self.timing_loop_bw) self._timing_loop_bw_slider.setMinimumWidth(200) self._timing_loop_bw_slider.valueChanged.connect(self.set_timing_loop_bw) self._timing_loop_bw_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_label) self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_slider) self.controls_grid_layout_1.addLayout(self._timing_loop_bw_layout, 0,0,1,1) self._time_offset_layout = Qt.QVBoxLayout() self._time_offset_tool_bar = Qt.QToolBar(self) self._time_offset_layout.addWidget(self._time_offset_tool_bar) self._time_offset_tool_bar.addWidget(Qt.QLabel("Timing Offset"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._time_offset_counter = qwt_counter_pyslot() self._time_offset_counter.setRange(0.999, 1.001, 0.0001) self._time_offset_counter.setNumButtons(2) self._time_offset_counter.setValue(self.time_offset) self._time_offset_tool_bar.addWidget(self._time_offset_counter) self._time_offset_counter.valueChanged.connect(self.set_time_offset) self._time_offset_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._time_offset_slider.setRange(0.999, 1.001, 0.0001) self._time_offset_slider.setValue(self.time_offset) self._time_offset_slider.setMinimumWidth(200) self._time_offset_slider.valueChanged.connect(self.set_time_offset) self._time_offset_layout.addWidget(self._time_offset_slider) self.controls_grid_layout_0.addLayout(self._time_offset_layout, 0,2,1,1) self.received = Qt.QTabWidget() self.received_widget_0 = Qt.QWidget() self.received_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.received_widget_0) self.received_grid_layout_0 = Qt.QGridLayout() self.received_layout_0.addLayout(self.received_grid_layout_0) self.received.addTab(self.received_widget_0, "Constellation") self.received_widget_1 = Qt.QWidget() self.received_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.received_widget_1) self.received_grid_layout_1 = Qt.QGridLayout() self.received_layout_1.addLayout(self.received_grid_layout_1) self.received.addTab(self.received_widget_1, "Symbols") self.top_grid_layout.addWidget(self.received, 2,0,1,1) self._phase_bw_layout = Qt.QVBoxLayout() self._phase_bw_label = Qt.QLabel("Phase: Bandwidth") self._phase_bw_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._phase_bw_slider.setRange(0.0, 1.0, 0.01) self._phase_bw_slider.setValue(self.phase_bw) self._phase_bw_slider.setMinimumWidth(200) self._phase_bw_slider.valueChanged.connect(self.set_phase_bw) self._phase_bw_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._phase_bw_layout.addWidget(self._phase_bw_label) self._phase_bw_layout.addWidget(self._phase_bw_slider) self.controls_grid_layout_1.addLayout(self._phase_bw_layout, 0,2,1,1) self._noise_volt_layout = Qt.QVBoxLayout() self._noise_volt_tool_bar = Qt.QToolBar(self) self._noise_volt_layout.addWidget(self._noise_volt_tool_bar) self._noise_volt_tool_bar.addWidget(Qt.QLabel("Noise Voltage"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._noise_volt_counter = qwt_counter_pyslot() self._noise_volt_counter.setRange(0, 1, 0.01) self._noise_volt_counter.setNumButtons(2) self._noise_volt_counter.setValue(self.noise_volt) self._noise_volt_tool_bar.addWidget(self._noise_volt_counter) self._noise_volt_counter.valueChanged.connect(self.set_noise_volt) self._noise_volt_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._noise_volt_slider.setRange(0, 1, 0.01) self._noise_volt_slider.setValue(self.noise_volt) self._noise_volt_slider.setMinimumWidth(200) self._noise_volt_slider.valueChanged.connect(self.set_noise_volt) self._noise_volt_layout.addWidget(self._noise_volt_slider) self.controls_grid_layout_0.addLayout(self._noise_volt_layout, 0,0,1,1) self._freq_offset_layout = Qt.QVBoxLayout() self._freq_offset_tool_bar = Qt.QToolBar(self) self._freq_offset_layout.addWidget(self._freq_offset_tool_bar) self._freq_offset_tool_bar.addWidget(Qt.QLabel("Frequency Offset"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._freq_offset_counter = qwt_counter_pyslot() self._freq_offset_counter.setRange(-0.1, 0.1, 0.001) self._freq_offset_counter.setNumButtons(2) self._freq_offset_counter.setValue(self.freq_offset) self._freq_offset_tool_bar.addWidget(self._freq_offset_counter) self._freq_offset_counter.valueChanged.connect(self.set_freq_offset) self._freq_offset_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._freq_offset_slider.setRange(-0.1, 0.1, 0.001) self._freq_offset_slider.setValue(self.freq_offset) self._freq_offset_slider.setMinimumWidth(200) self._freq_offset_slider.valueChanged.connect(self.set_freq_offset) self._freq_offset_layout.addWidget(self._freq_offset_slider) self.controls_grid_layout_0.addLayout(self._freq_offset_layout, 0,1,1,1) self._eq_gain_layout = Qt.QVBoxLayout() self._eq_gain_label = Qt.QLabel("Equalizer: rate") self._eq_gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._eq_gain_slider.setRange(0.0, 0.1, 0.001) self._eq_gain_slider.setValue(self.eq_gain) self._eq_gain_slider.setMinimumWidth(200) self._eq_gain_slider.valueChanged.connect(self.set_eq_gain) self._eq_gain_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._eq_gain_layout.addWidget(self._eq_gain_label) self._eq_gain_layout.addWidget(self._eq_gain_slider) self.controls_grid_layout_1.addLayout(self._eq_gain_layout, 0,1,1,1) self._delay_layout = Qt.QVBoxLayout() self._delay_tool_bar = Qt.QToolBar(self) self._delay_layout.addWidget(self._delay_tool_bar) self._delay_tool_bar.addWidget(Qt.QLabel("Delay"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._delay_counter = qwt_counter_pyslot() self._delay_counter.setRange(0, 200, 1) self._delay_counter.setNumButtons(2) self._delay_counter.setValue(self.delay) self._delay_tool_bar.addWidget(self._delay_counter) self._delay_counter.valueChanged.connect(self.set_delay) self._delay_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._delay_slider.setRange(0, 200, 1) self._delay_slider.setValue(self.delay) self._delay_slider.setMinimumWidth(200) self._delay_slider.valueChanged.connect(self.set_delay) self._delay_layout.addWidget(self._delay_slider) self.top_grid_layout.addLayout(self._delay_layout, 1,0,1,1) self.tutorial_my_qpsk_demod_cb_1 = tutorial.my_qpsk_demod_cb(True) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 500, #size samp_rate, #samp_rate "", #name 2 #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, 2) 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) 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: 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, 2,1,1,1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 500, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 4) 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) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.received_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_win, 0,0,1,1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.enable_autoscale(False) 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.received_grid_layout_0.addWidget(self._qtgui_const_sink_x_0_win, 0,0,1,1) self._freq_bw_layout = Qt.QVBoxLayout() self._freq_bw_label = Qt.QLabel("Frequency Bandwidth") self._freq_bw_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._freq_bw_slider.setRange(0.0, 1.0, 0.01) self._freq_bw_slider.setValue(self.freq_bw) self._freq_bw_slider.setMinimumWidth(200) self._freq_bw_slider.valueChanged.connect(self.set_freq_bw) self._freq_bw_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._freq_bw_layout.addWidget(self._freq_bw_label) self._freq_bw_layout.addWidget(self._freq_bw_slider) self.controls_grid_layout_1.addLayout(self._freq_bw_layout, 0,3,1,1) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, (rrc_taps), nfilts, nfilts/2, 1.5, 2) self.digital_map_bb_0 = digital.map_bb(([0,1,3,2])) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(phase_bw, arity) self.digital_correlate_and_sync_cc_0 = digital.correlate_and_sync_cc((preamble), (matched_filter), sps) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False, ) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(15, 1, eq_gain, 2) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise_volt, frequency_offset=freq_offset, epsilon=time_offset, taps=(taps), noise_seed=0, block_tags=False ) self.blocks_vector_source_x_0_0 = blocks.vector_source_b(map(lambda x: (-x+1)/2, preamble), True, 1, []) self.blocks_unpack_k_bits_bb_0_0 = blocks.unpack_k_bits_bb(8) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_stream_mux_0_0_0 = blocks.stream_mux(gr.sizeof_char*1, (len(preamble)/8,payload_size)) self.blocks_pack_k_bits_bb_1 = blocks.pack_k_bits_bb(8) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/home/franchz/tcc/gnuradio/tx_teste.txt", True) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/home/franchz/tcc/gnuradio/rx_teste.txt", False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, int(delay)) self.blocks_char_to_float_0_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) ################################################## # Connections ################################################## self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0_0, 0), (self.blocks_char_to_float_0_0_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blocks_stream_mux_0_0_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.digital_correlate_and_sync_cc_0, 0)) self.connect((self.digital_correlate_and_sync_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_correlate_and_sync_cc_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_mux_0_0_0, 1)) self.connect((self.blocks_file_source_0, 0), (self.blocks_unpack_k_bits_bb_0_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_0_0, 1)) self.connect((self.blocks_char_to_float_0_0_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_delay_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_pack_k_bits_bb_1, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_pack_k_bits_bb_1, 0)) self.connect((self.blocks_stream_mux_0_0_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.tutorial_my_qpsk_demod_cb_1, 0), (self.digital_map_bb_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.tutorial_my_qpsk_demod_cb_1, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0))
def __init__(self): gr.top_block.__init__(self, "Sync Test") Qt.QWidget.__init__(self) self.setWindowTitle("Sync Test") 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", "sync_test") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.pream_len = pream_len = 84 self.samp_rate = samp_rate = 32000 self.pream = pream = (mapper.preamble_generator(pream_len,511,1033)).get_preamble() self.SNR = SNR = 40 self.Rotation = Rotation = 0 self.Offset = Offset = 0 ################################################## # Blocks ################################################## self._SNR_tool_bar = Qt.QToolBar(self) self._SNR_tool_bar.addWidget(Qt.QLabel("SNR"+": ")) self._SNR_line_edit = Qt.QLineEdit(str(self.SNR)) self._SNR_tool_bar.addWidget(self._SNR_line_edit) self._SNR_line_edit.returnPressed.connect( lambda: self.set_SNR(eng_notation.str_to_num(self._SNR_line_edit.text().toAscii()))) self.top_layout.addWidget(self._SNR_tool_bar) self._Rotation_layout = Qt.QVBoxLayout() self._Rotation_label = Qt.QLabel("Rotation") self._Rotation_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._Rotation_slider.setRange(0, 2*pi, pi/100) self._Rotation_slider.setValue(self.Rotation) self._Rotation_slider.setMinimumWidth(200) self._Rotation_slider.valueChanged.connect(self.set_Rotation) self._Rotation_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._Rotation_layout.addWidget(self._Rotation_label) self._Rotation_layout.addWidget(self._Rotation_slider) self.top_layout.addLayout(self._Rotation_layout) self._Offset_layout = Qt.QVBoxLayout() self._Offset_tool_bar = Qt.QToolBar(self) self._Offset_layout.addWidget(self._Offset_tool_bar) self._Offset_tool_bar.addWidget(Qt.QLabel("Offset"+": ")) self._Offset_counter = Qwt.QwtCounter() self._Offset_counter.setRange(-100, 100, 1) self._Offset_counter.setNumButtons(2) self._Offset_counter.setValue(self.Offset) self._Offset_tool_bar.addWidget(self._Offset_counter) self._Offset_counter.valueChanged.connect(self.set_Offset) self._Offset_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._Offset_slider.setRange(-100, 100, 1) self._Offset_slider.setValue(self.Offset) self._Offset_slider.setMinimumWidth(200) self._Offset_slider.valueChanged.connect(self.set_Offset) self._Offset_layout.addWidget(self._Offset_slider) self.top_layout.addLayout(self._Offset_layout) self.qtgui_const_sink_x_0_1 = qtgui.const_sink_c( 840-84, #size "QT GUI Plot", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_1.set_update_time(0.10) self.qtgui_const_sink_x_0_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_1.set_x_axis(-2, 2) self._qtgui_const_sink_x_0_1_win = sip.wrapinstance(self.qtgui_const_sink_x_0_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_0_1_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 840-84, #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_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_0_win) self.mapper_preamble_sync_cc_0 = mapper.preamble_sync_cc(pream_len*10, (pream), mapper.PSK8, ([0,1,2,3,4,5,6,7]), .97, .90) self.mapper_preamble_insert_bb_0 = mapper.preamble_insert_bb(pream_len*10, (pream)) self.mapper_mapper_0 = mapper.mapper(mapper.PSK8, ([0,1,2,3,4,5,6,7])) self.mapper_demapper_0 = mapper.demapper(mapper.PSK8, ([0,1,2,3,4,5,6,7])) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(1.5*pi/100, 8) self.channels_channel_model_0 = channels.channel_model( noise_voltage=10**(-SNR/20.0), frequency_offset=Offset, epsilon=1.0, taps=(exp( (0 + 1j*Rotation) ), ), noise_seed=0, block_tags=False ) self.blocks_vector_sink_x_0_0 = blocks.vector_sink_b(1) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(3) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 7, 10000)), True) ################################################## # Connections ################################################## self.connect((self.mapper_preamble_insert_bb_0, 0), (self.mapper_mapper_0, 0)) self.connect((self.mapper_preamble_sync_cc_0, 0), (self.mapper_demapper_0, 0)) self.connect((self.mapper_mapper_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.mapper_preamble_sync_cc_0, 0)) self.connect((self.mapper_preamble_sync_cc_0, 0), (self.qtgui_const_sink_x_0_1, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.mapper_preamble_insert_bb_0, 0)) self.connect((self.mapper_demapper_0, 0), (self.blocks_vector_sink_x_0_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_const_sink_x_0, 0))
def add_visuals(self): gr.top_block.__init__(self, "Tempate Qt") Qt.QWidget.__init__(self) self.setWindowTitle("Tempate Qt") 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", "tempate_qt") self.restoreGeometry(self.settings.value("geometry").toByteArray()) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name self.num_channels #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) 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(self.num_channels): 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_layout.addWidget(self._qtgui_const_sink_x_0_win) ######### self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc self.samp_rate, #bw "", #name (self.num_channels) #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(self.num_channels): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
def __init__(self): gr.top_block.__init__(self, "Tempate Qt") Qt.QWidget.__init__(self) self.setWindowTitle("Tempate Qt") 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", "tempate_qt") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) 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_layout.addWidget(self._qtgui_const_sink_x_0_win) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 1000, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_const_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "zigbee_simulation") Qt.QWidget.__init__(self) self.setWindowTitle("zigbee_simulation") 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", "zigbee_demod_fsk") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.zigbee_channel = zigbee_channel = 11 self.transition_width = transition_width = 100e3 self.samp_rate = samp_rate = 5000000 self.cutoff_freq = cutoff_freq = 750e3 self.channel_spacing = channel_spacing = 5e6 self.central_frequency = central_frequency = 2405e6 self.squelch_threshold = squelch_threshold = -80 self.payload_mod = payload_mod = digital.constellation_qpsk() self.lowpass_filter = lowpass_filter = firdes.low_pass(1, samp_rate, cutoff_freq, transition_width, firdes.WIN_HAMMING, 6.76) self.iq_output = iq_output = "ble2.iq" self.half_preamble_len = half_preamble_len = 2*32*2 self.freq_channel = freq_channel = central_frequency+(zigbee_channel-11)*channel_spacing self.dsss_mode = dsss_mode = 32 self.dsss_4_8 = dsss_4_8 = [(1+1j), (-1+1j), (1-1j), (-1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1-1j), (1-1j), (1+1j), (1-1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j)] self.dsss_4_64 = dsss_4_64 = [(1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j)] self.dsss_4_32_LSB = dsss_4_32_LSB = [(1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j)] self.dsss_4_32 = dsss_4_32 = [(1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j)] self.dsss_4_16 = dsss_4_16 = [(-1-1j), (1+1j), (1+1j), (1-1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (-1+1j), (1-1j), (1-1j), (1+1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (-1-1j), (1+1j), (1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (-1+1j), (1-1j), (1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1+1j), (1+1j), (1-1j), (-1-1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1-1j), (1-1j), (1+1j), (-1+1j), (1+1j), (1+1j), (1-1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (-1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (-1+1j), (1-1j), (-1+1j), (-1-1j), (1+1j), (1+1j), (1-1j), (-1-1j), (1-1j), (-1+1j), (-1-1j), (-1+1j), (1-1j), (1-1j), (1+1j), (-1+1j), (1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (-1-1j), (1+1j), (1+1j), (1+1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (-1+1j), (1-1j), (1-1j), (1-1j), (-1+1j), (-1+1j), (-1-1j), (1+1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (-1-1j), (-1+1j), (1-1j), (1-1j), (1+1j), (-1+1j), (1+1j), (1+1j), (1-1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (1-1j), (1+1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (-1+1j)] self.csv_file = csv_file = "packet_index2.csv" ################################################## # Blocks ################################################## self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(0.00016, 1) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_1.set_update_time(0.10) self.qtgui_const_sink_x_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1.enable_autoscale(False) self.qtgui_const_sink_x_1.enable_grid(False) self.qtgui_const_sink_x_1.enable_axis_labels(True) 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_layout.addWidget(self._qtgui_const_sink_x_1_win) self.qtgui_const_sink_x_0_1 = qtgui.const_sink_c( 1024, #size "after filtering", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_1.set_update_time(0.10) self.qtgui_const_sink_x_0_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_1.enable_autoscale(True) self.qtgui_const_sink_x_0_1.enable_grid(False) self.qtgui_const_sink_x_0_1.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_1_win = sip.wrapinstance(self.qtgui_const_sink_x_0_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_0_1_win) self.qtgui_const_sink_x_0_0_1 = qtgui.const_sink_c( 1024, #size "after filter", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_1.set_update_time(0.10) self.qtgui_const_sink_x_0_0_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_1.enable_autoscale(True) self.qtgui_const_sink_x_0_0_1.enable_grid(False) self.qtgui_const_sink_x_0_0_1.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_1_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_0_0_1_win) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 1024, #size "after filter", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(True) self.qtgui_const_sink_x_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_0_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "after noise", #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(True) 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_layout.addWidget(self._qtgui_const_sink_x_0_win) self.oqpsk_dsss_packet_sink_0 = oqpsk_dsss.packet_sink(12, dsss_mode, 0, 0,csv_file,zigbee_channel,int(samp_rate)) self.oqpsk_dsss_access_code_prefixer_0 = oqpsk_dsss.access_code_prefixer(0x00,0x000000a7) self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(([129]), ([131]), ([132]), ([23,42])) self.ieee802_15_4_mac_0 = ieee802_15_4.mac(True,0x8841,0,0x1aaa,0x0000,0x1780) self.freq_xlating_fir_filter_lp = filter.freq_xlating_fir_filter_ccc(1, (lowpass_filter), 0, samp_rate) self.foo_wireshark_connector_0 = foo.wireshark_connector(195, False) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(2, 0.000225, 0.5, 0.03, 0.0002) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((dsss_4_32), 16) self.digital_burst_shaper_xx_0 = digital.burst_shaper_cc((([])), 0, 4, False, "pdu_length") self.blocks_vector_source_x_0 = blocks.vector_source_c([0, sin(pi/4), 1, sin(3*pi/4)], True, 1, []) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(gr.sizeof_gr_complex*1, 'pdu_length', 512) self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_float * 1, False) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, 4) self.blocks_pdu_to_tagged_stream_0_0_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'pdu_length') self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(4, gr.GR_LSB_FIRST) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_message_strobe_0_0 = blocks.message_strobe(pmt.intern("Hello World!\n"), 120) self.blocks_message_debug_0 = blocks.message_debug() self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_char*1, '/home/ousseynou/ZIGBEE.pcap', False) self.blocks_file_sink_1.set_unbuffered(True) self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, 2) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1) self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, 0.5, 0) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0_0, 'strobe'), (self.ieee802_15_4_rime_stack_0, 'bcin')) self.msg_connect((self.ieee802_15_4_mac_0, 'app out'), (self.ieee802_15_4_rime_stack_0, 'fromMAC')) self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'), (self.oqpsk_dsss_access_code_prefixer_0, 'in')) self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'), (self.ieee802_15_4_mac_0, 'app in')) self.msg_connect((self.oqpsk_dsss_access_code_prefixer_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0_0, 'pdus')) self.msg_connect((self.oqpsk_dsss_packet_sink_0, 'out'), (self.blocks_message_debug_0, 'print')) self.msg_connect((self.oqpsk_dsss_packet_sink_0, 'out'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.oqpsk_dsss_packet_sink_0, 'out'), (self.foo_wireshark_connector_0, 'in')) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.single_pole_iir_filter_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.analog_quadrature_demod_cf_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_const_sink_x_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_delay_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_repeat_0, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.digital_burst_shaper_xx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_lp, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.digital_burst_shaper_xx_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.oqpsk_dsss_packet_sink_0, 0)) self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_1, 0)) self.connect((self.freq_xlating_fir_filter_lp, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.freq_xlating_fir_filter_lp, 0), (self.qtgui_const_sink_x_0_1, 0)) self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_sub_xx_0, 1))
def __init__(self): gr.top_block.__init__(self, "Wifi Rx From Reco 150920") Qt.QWidget.__init__(self) self.setWindowTitle("Wifi Rx From Reco 150920") 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", "wifi_rx_from_reco_150920") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.window_size = window_size = 48 self.threshold = threshold = 1000 self.sync_length = sync_length = 320 self.samp_rate = samp_rate = 0.5e6 self.lo_offset = lo_offset = 0 self.gain = gain = 20 self.freq = freq = 943000000.0 self.decimation = decimation = 40 self.chan_est = chan_est = 1 ################################################## # Blocks ################################################## self._samp_rate_options = [0.5e6, 1e6, 5e6, 10e6, 20e6] self._samp_rate_labels = ["500 KHz", "1 MHz", "5 MHz", "10 MHz", "20 MHz"] self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel("Sample Rate"+": ")) self._samp_rate_combo_box = Qt.QComboBox() self._samp_rate_tool_bar.addWidget(self._samp_rate_combo_box) for label in self._samp_rate_labels: self._samp_rate_combo_box.addItem(label) self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(self._samp_rate_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._samp_rate_options.index(i))) self._samp_rate_callback(self.samp_rate) self._samp_rate_combo_box.currentIndexChanged.connect( lambda i: self.set_samp_rate(self._samp_rate_options[i])) self.top_layout.addWidget(self._samp_rate_tool_bar) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_1.set_update_time(0.10) self.qtgui_const_sink_x_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1.enable_autoscale(False) self.qtgui_const_sink_x_1.enable_grid(False) 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_layout.addWidget(self._qtgui_const_sink_x_1_win) self.ofdm_80211_short_MF_v2_0 = ofdm_80211.short_MF_v2(160, 16) self.ieee802_11_ofdm_sync_long_0 = ieee802_11.ofdm_sync_long(sync_length, False, False) self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac(False, True) self.ieee802_11_ofdm_equalize_symbols_0 = ieee802_11.ofdm_equalize_symbols(ieee802_11.LMS, False) self.ieee802_11_ofdm_decode_signal_0 = ieee802_11.ofdm_decode_signal(False, False) self.ieee802_11_ofdm_decode_mac_0 = ieee802_11.ofdm_decode_mac(False, False) self._gain_range = Range(0, 100, 1, 20, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain", "slider") self.top_layout.addWidget(self._gain_win) self._freq_options = [943000000.0, 2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0] self._freq_labels = [' 0 | 943.0 | ??', ' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'] self._freq_tool_bar = Qt.QToolBar(self) self._freq_tool_bar.addWidget(Qt.QLabel("Channel"+": ")) self._freq_combo_box = Qt.QComboBox() self._freq_tool_bar.addWidget(self._freq_combo_box) for label in self._freq_labels: self._freq_combo_box.addItem(label) self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(self._freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._freq_options.index(i))) self._freq_callback(self.freq) self._freq_combo_box.currentIndexChanged.connect( lambda i: self.set_freq(self._freq_options[i])) self.top_layout.addWidget(self._freq_tool_bar) self.fft_vxx_0 = fft.fft_vcc(64, True, (window.rectangular(64)), True, 1) self.carajito = ofdm_80211.ofdm_sync_short(threshold, 2, False, False) self.blocks_vector_to_stream_2 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, 48) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) (self.blocks_throttle_0).set_min_output_buffer(2048) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 64) self.blocks_null_sink_0_1_0_0_0_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_file_source_0_1_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/home/juan/COWN/waveforms/80211_ofdm_padded_waveform_direct_fromTX_20150930.bin", True) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, sync_length) ################################################## # Connections ################################################## self.msg_connect((self.ieee802_11_ofdm_decode_mac_0, 'out'), (self.ieee802_11_ofdm_parse_mac_0, 'in')) self.connect((self.blocks_delay_0, 0), (self.ieee802_11_ofdm_sync_long_0, 1)) self.connect((self.blocks_file_source_0_1_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.ofdm_80211_short_MF_v2_0, 0)) self.connect((self.blocks_vector_to_stream_2, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.carajito, 0), (self.blocks_delay_0, 0)) self.connect((self.carajito, 0), (self.ieee802_11_ofdm_sync_long_0, 0)) self.connect((self.fft_vxx_0, 0), (self.ieee802_11_ofdm_equalize_symbols_0, 0)) self.connect((self.ieee802_11_ofdm_decode_signal_0, 0), (self.ieee802_11_ofdm_decode_mac_0, 0)) self.connect((self.ieee802_11_ofdm_equalize_symbols_0, 0), (self.blocks_vector_to_stream_2, 0)) self.connect((self.ieee802_11_ofdm_equalize_symbols_0, 0), (self.ieee802_11_ofdm_decode_signal_0, 0)) self.connect((self.ieee802_11_ofdm_sync_long_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.ofdm_80211_short_MF_v2_0, 2), (self.blocks_null_sink_0_1_0_0_0_0, 0)) self.connect((self.ofdm_80211_short_MF_v2_0, 1), (self.carajito, 1)) self.connect((self.ofdm_80211_short_MF_v2_0, 3), (self.carajito, 2)) self.connect((self.ofdm_80211_short_MF_v2_0, 0), (self.carajito, 0))
def __init__(self): gr.top_block.__init__(self, "Mpsk Stage6") Qt.QWidget.__init__(self) self.setWindowTitle("Mpsk Stage6") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "mpsk_stage6") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.samp_rate = samp_rate = 2e6 self.bps = bps = 500e3 self.decimation = decimation = int(samp_rate / (bps * sps)) self.transition_bw = transition_bw = samp_rate / (2 * decimation * 5) self.nfilts = nfilts = 32 self.timing_loop_bw = timing_loop_bw = 6.28 / 100.0 self.time_offset = time_offset = 1.00 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), 0.35, 11 * sps * nfilts) self.qpsk = qpsk = digital.constellation_rect( ([-1, 0 + 1j, 0 - 1j, 1 + 0.0j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.phase_bw = phase_bw = 6.28 / 100.0 self.noise_volt = noise_volt = 0.0001 self.freq_offset = freq_offset = 0 self.fir_taps = fir_taps = firdes.low_pass( 1, samp_rate, samp_rate / (2 * decimation), transition_bw) self.excess_bw = excess_bw = 0.35 self.eq_gain = eq_gain = 0.01 self.delay = delay = 0 self.channel_freq = channel_freq = 2.4e9 self.center_freq = center_freq = 2.3995e9 self.arity = arity = 4 ################################################## # Blocks ################################################## self.controls = Qt.QTabWidget() self.controls_widget_0 = Qt.QWidget() self.controls_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_0) self.controls_grid_layout_0 = Qt.QGridLayout() self.controls_layout_0.addLayout(self.controls_grid_layout_0) self.controls.addTab(self.controls_widget_0, "Channel") self.controls_widget_1 = Qt.QWidget() self.controls_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controls_widget_1) self.controls_grid_layout_1 = Qt.QGridLayout() self.controls_layout_1.addLayout(self.controls_grid_layout_1) self.controls.addTab(self.controls_widget_1, "Receiver") self.top_grid_layout.addWidget(self.controls, 0, 0, 1, 2) self._timing_loop_bw_range = Range(0.0, 0.2, 0.01, 6.28 / 100.0, 200) self._timing_loop_bw_win = RangeWidget(self._timing_loop_bw_range, self.set_timing_loop_bw, "Time: BW", "slider", float) self.controls_grid_layout_1.addWidget(self._timing_loop_bw_win, 0, 0, 1, 1) self.received = Qt.QTabWidget() self.received_widget_0 = Qt.QWidget() self.received_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.received_widget_0) self.received_grid_layout_0 = Qt.QGridLayout() self.received_layout_0.addLayout(self.received_grid_layout_0) self.received.addTab(self.received_widget_0, "Constellation") self.received_widget_1 = Qt.QWidget() self.received_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.received_widget_1) self.received_grid_layout_1 = Qt.QGridLayout() self.received_layout_1.addLayout(self.received_grid_layout_1) self.received.addTab(self.received_widget_1, "Symbols") self.top_grid_layout.addWidget(self.received, 2, 0, 1, 1) self._phase_bw_range = Range(0.0, 1.0, 0.01, 6.28 / 100.0, 200) self._phase_bw_win = RangeWidget(self._phase_bw_range, self.set_phase_bw, "Phase: Bandwidth", "slider", float) self.controls_grid_layout_1.addWidget(self._phase_bw_win, 0, 2, 1, 1) self._eq_gain_range = Range(0.0, 0.1, 0.001, 0.01, 200) self._eq_gain_win = RangeWidget(self._eq_gain_range, self.set_eq_gain, "Equalizer: rate", "slider", float) self.controls_grid_layout_1.addWidget(self._eq_gain_win, 0, 1, 1, 1) self._channel_freq_range = Range(2.4e9 - samp_rate / 2, 2.4e9 + samp_rate / 2, 100, 2.4e9, 200) self._channel_freq_win = RangeWidget(self._channel_freq_range, self.set_channel_freq, "channel_freq", "counter_slider", float) self.top_grid_layout.addWidget(self._channel_freq_win, 2, 2, 1, 1) self._time_offset_range = Range(0.999, 1.001, 0.0001, 1.00, 200) self._time_offset_win = RangeWidget(self._time_offset_range, self.set_time_offset, "Timing Offset", "counter_slider", float) self.controls_grid_layout_0.addWidget(self._time_offset_win, 0, 2, 1, 1) self.rms_agc_0 = rms_agc( alpha=1e-2, reference=0.5, ) self.qtgui_time_sink_x_1 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1.set_y_label("Amplitude", "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2 * 1): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_1.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance( self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_const_sink_x_1_1 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_1_1.set_update_time(0.10) self.qtgui_const_sink_x_1_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_1_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_1_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1_1.enable_autoscale(False) self.qtgui_const_sink_x_1_1.enable_grid(False) if not True: self.qtgui_const_sink_x_1_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_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_1_win = sip.wrapinstance( self.qtgui_const_sink_x_1_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_1_1_win) self.qtgui_const_sink_x_1_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_1_0.set_update_time(0.10) self.qtgui_const_sink_x_1_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_1_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1_0.enable_autoscale(False) self.qtgui_const_sink_x_1_0.enable_grid(False) if not True: self.qtgui_const_sink_x_1_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_1_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_0_win = sip.wrapinstance( self.qtgui_const_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_1_0_win) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_1.set_update_time(0.10) self.qtgui_const_sink_x_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1.enable_autoscale(False) self.qtgui_const_sink_x_1.enable_grid(False) 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_layout.addWidget(self._qtgui_const_sink_x_1_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) 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.received_grid_layout_0.addWidget(self._qtgui_const_sink_x_0_win, 0, 0, 1, 1) self._noise_volt_range = Range(0, 1, 0.01, 0.0001, 200) self._noise_volt_win = RangeWidget(self._noise_volt_range, self.set_noise_volt, "Noise Voltage", "counter_slider", float) self.controls_grid_layout_0.addWidget(self._noise_volt_win, 0, 0, 1, 1) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( decimation, (fir_taps), channel_freq - center_freq, samp_rate) self._freq_offset_range = Range(-0.1, 0.1, 0.001, 0, 200) self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, "Frequency Offset", "counter_slider", float) self.controls_grid_layout_0.addWidget(self._freq_offset_win, 0, 1, 1, 1) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, timing_loop_bw, (rrc_taps), nfilts, nfilts / 2, 1.5, 2) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( phase_bw, arity, False) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc( 15, 1, eq_gain, 2) self._delay_range = Range(0, 200, 1, 0, 200) self._delay_win = RangeWidget(self._delay_range, self.set_delay, "Delay", "counter_slider", float) self.top_grid_layout.addWidget(self._delay_win, 1, 0, 1, 1) self.channels_channel_model_0_0 = channels.channel_model( noise_voltage=0.0, frequency_offset=0.0, epsilon=1.0, taps=(1.0 + 1.0j, ), noise_seed=0, block_tags=False) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_file_source_0_0 = blocks.file_source( gr.sizeof_gr_complex * 1, "/home/ascl/sbandtest/text/fc_2_3995/500kbps/sps2M", True) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_gr_complex * 1, "output", False) self.blocks_file_sink_1.set_unbuffered(False) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.channels_channel_model_0_0, 0)) self.connect((self.channels_channel_model_0_0, 0), (self.rms_agc_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.qtgui_const_sink_x_1_1, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_const_sink_x_1_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_file_sink_1, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.rms_agc_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Mpsk Simul") Qt.QWidget.__init__(self) self.setWindowTitle("Mpsk Simul") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "mpsk_simul") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 8 self.nfilts = nfilts = 32 self.timing_loop_bw = timing_loop_bw = 6.28/100.0 self.time_offset = time_offset = 1.00 self.taps = taps = [1.0 + 0.0j, ] self.samp_rate = samp_rate = 32000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts) self.phase_bw = phase_bw = 6.28/100.0 self.noise_volt = noise_volt = 0.001 self.freq_offset = freq_offset = 0 self.eq_gain = eq_gain = 0.01 self.arity = arity = 8 ################################################## # Blocks ################################################## self._timing_loop_bw_range = Range(0.0, 0.2, 0.01, 6.28/100.0, 200) self._timing_loop_bw_win = RangeWidget(self._timing_loop_bw_range, self.set_timing_loop_bw, "Time: BW", "slider", float) self.top_grid_layout.addWidget(self._timing_loop_bw_win, 3,1,1,1) self._time_offset_range = Range(0.999, 1.001, 0.0001, 1.00, 200) self._time_offset_win = RangeWidget(self._time_offset_range, self.set_time_offset, "Channel: Timing Offset", "slider", float) self.top_grid_layout.addWidget(self._time_offset_win, 3,0,1,1) self._phase_bw_range = Range(0.0, 1.0, 0.01, 6.28/100.0, 200) self._phase_bw_win = RangeWidget(self._phase_bw_range, self.set_phase_bw, "Phase: Bandwidth", "slider", float) self.top_grid_layout.addWidget(self._phase_bw_win, 4,1,1,1) self._noise_volt_range = Range(0, 1, 0.01, 0.001, 200) self._noise_volt_win = RangeWidget(self._noise_volt_range, self.set_noise_volt, "Channel: Noise Voltage", "slider", float) self.top_grid_layout.addWidget(self._noise_volt_win, 2,0,1,1) self._freq_offset_range = Range(-0.1, 0.1, 0.001, 0, 200) self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, "Channel: Frequency Offset", "slider", float) self.top_grid_layout.addWidget(self._freq_offset_win, 2,1,1,1) self._eq_gain_range = Range(0.0, 0.1, 0.001, 0.01, 200) self._eq_gain_win = RangeWidget(self._eq_gain_range, self.set_eq_gain, "Equalizer: rate", "slider", float) self.top_grid_layout.addWidget(self._eq_gain_win, 4,0,1,1) self.snr_mpsk_receiver_snr_est_cc_0 = snr.mpsk_receiver_snr_est_cc(10000, 0.001) self.snr_channel_model_snr_0 = snr.channel_model_snr( noise_voltage=noise_volt, frequency_offset=freq_offset, epsilon=time_offset, taps=(taps), noise_seed=0, block_tags=False ) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 4000, #size samp_rate, #samp_rate "QT GUI Plot", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.01) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 0,0,1,1) 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) 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, 0,1,1,1) self.digital_psk_mod_0 = digital.psk.psk_mod( constellation_points=arity, mod_code="gray", differential=True, samples_per_symbol=sps, excess_bw=0.35, verbose=False, log=False, ) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, (rrc_taps), nfilts, nfilts/2, 1.5, 2) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(phase_bw, arity, False) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(15, 1, eq_gain, 2) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((1+1j, )) self.blocks_message_debug_0 = blocks.message_debug() self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 10000)), True) ################################################## # Connections ################################################## self.msg_connect((self.snr_channel_model_snr_0, 'snr_level_out'), (self.snr_mpsk_receiver_snr_est_cc_0, 'snr_level_in')) self.connect((self.analog_random_source_x_0, 0), (self.digital_psk_mod_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.snr_channel_model_snr_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_costas_loop_cc_0, 1), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0)) self.connect((self.digital_psk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.snr_channel_model_snr_0, 0), (self.snr_mpsk_receiver_snr_est_cc_0, 0)) self.connect((self.snr_mpsk_receiver_snr_est_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 10e6 self.lo_offset = lo_offset = 0 self.gain = gain = 0.75 self.freq = freq = 5890000000 self.encoding = encoding = 0 self.chan_est = chan_est = 0 ################################################## # Blocks ################################################## self.adaptiveOFDM_mac_and_parse_0 = adaptiveOFDM.mac_and_parse( ([0x40, 0xe2, 0x30, 0xd6, 0xec, 0x67]), ([0x40, 0xe2, 0x30, 0xd6, 0xe9, 0xdf]), ([0xff, 0xff, 0xff, 0xff, 0xff, 0xff]), False, True) self._samp_rate_options = [5e6, 10e6, 20e6] self._samp_rate_labels = ["5 MHz", "10 MHz", "20 MHz"] self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel("samp_rate" + ": ")) self._samp_rate_combo_box = Qt.QComboBox() self._samp_rate_tool_bar.addWidget(self._samp_rate_combo_box) for label in self._samp_rate_labels: self._samp_rate_combo_box.addItem(label) self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod( self._samp_rate_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._samp_rate_options.index(i))) self._samp_rate_callback(self.samp_rate) self._samp_rate_combo_box.currentIndexChanged.connect( lambda i: self.set_samp_rate(self._samp_rate_options[i])) self.top_layout.addWidget(self._samp_rate_tool_bar) self._lo_offset_options = ( 0, 6e6, 11e6, ) self._lo_offset_labels = ( str(self._lo_offset_options[0]), str(self._lo_offset_options[1]), str(self._lo_offset_options[2]), ) self._lo_offset_tool_bar = Qt.QToolBar(self) self._lo_offset_tool_bar.addWidget(Qt.QLabel("lo_offset" + ": ")) self._lo_offset_combo_box = Qt.QComboBox() self._lo_offset_tool_bar.addWidget(self._lo_offset_combo_box) for label in self._lo_offset_labels: self._lo_offset_combo_box.addItem(label) self._lo_offset_callback = lambda i: Qt.QMetaObject.invokeMethod( self._lo_offset_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._lo_offset_options.index(i))) self._lo_offset_callback(self.lo_offset) self._lo_offset_combo_box.currentIndexChanged.connect( lambda i: self.set_lo_offset(self._lo_offset_options[i])) self.top_layout.addWidget(self._lo_offset_tool_bar) self._gain_range = Range(0, 1, 0.01, 0.75, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain", "counter_slider", float) self.top_layout.addWidget(self._gain_win) self._freq_options = [ 2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5250000000.0, 5260000000.0, 5270000000.0, 5280000000.0, 5290000000.0, 5300000000.0, 5310000000.0, 5320000000.0, 5500000000.0, 5510000000.0, 5520000000.0, 5530000000.0, 5540000000.0, 5550000000.0, 5560000000.0, 5570000000.0, 5580000000.0, 5590000000.0, 5600000000.0, 5610000000.0, 5620000000.0, 5630000000.0, 5640000000.0, 5660000000.0, 5670000000.0, 5680000000.0, 5690000000.0, 5700000000.0, 5710000000.0, 5720000000.0, 5745000000.0, 5755000000.0, 5765000000.0, 5775000000.0, 5785000000.0, 5795000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0 ] self._freq_labels = [ ' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 50 | 5250.0 | 11a', ' 52 | 5260.0 | 11a', ' 54 | 5270.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5290.0 | 11a', ' 60 | 5300.0 | 11a', ' 62 | 5310.0 | 11a', ' 64 | 5320.0 | 11a', '100 | 5500.0 | 11a', '102 | 5510.0 | 11a', '104 | 5520.0 | 11a', '106 | 5530.0 | 11a', '108 | 5540.0 | 11a', '110 | 5550.0 | 11a', '112 | 5560.0 | 11a', '114 | 5570.0 | 11a', '116 | 5580.0 | 11a', '118 | 5590.0 | 11a', '120 | 5600.0 | 11a', '122 | 5610.0 | 11a', '124 | 5620.0 | 11a', '126 | 5630.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '134 | 5670.0 | 11a', '136 | 5680.0 | 11a', '138 | 5690.0 | 11a', '140 | 5700.0 | 11a', '142 | 5710.0 | 11a', '144 | 5720.0 | 11a', '149 | 5745.0 | 11a (SRD)', '151 | 5755.0 | 11a (SRD)', '153 | 5765.0 | 11a (SRD)', '155 | 5775.0 | 11a (SRD)', '157 | 5785.0 | 11a (SRD)', '159 | 5795.0 | 11a (SRD)', '161 | 5805.0 | 11a (SRD)', '165 | 5825.0 | 11a (SRD)', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p' ] self._freq_tool_bar = Qt.QToolBar(self) self._freq_tool_bar.addWidget(Qt.QLabel("freq" + ": ")) self._freq_combo_box = Qt.QComboBox() self._freq_tool_bar.addWidget(self._freq_combo_box) for label in self._freq_labels: self._freq_combo_box.addItem(label) self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod( self._freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._freq_options.index(i))) self._freq_callback(self.freq) self._freq_combo_box.currentIndexChanged.connect( lambda i: self.set_freq(self._freq_options[i])) self.top_layout.addWidget(self._freq_tool_bar) def _encoding_probe(): while True: val = self.adaptiveOFDM_mac_and_parse_0.get_encoding() try: self.set_encoding(val) except AttributeError: pass time.sleep(1.0 / (10)) _encoding_thread = threading.Thread(target=_encoding_probe) _encoding_thread.daemon = True _encoding_thread.start() self._chan_est_options = 0, 1, 3, 2 self._chan_est_labels = ["LS", "LMS", "STA", "Linear Comb"] self._chan_est_group_box = Qt.QGroupBox("chan_est") self._chan_est_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._chan_est_button_group = variable_chooser_button_group() self._chan_est_group_box.setLayout(self._chan_est_box) for i, label in enumerate(self._chan_est_labels): radio_button = Qt.QRadioButton(label) self._chan_est_box.addWidget(radio_button) self._chan_est_button_group.addButton(radio_button, i) self._chan_est_callback = lambda i: Qt.QMetaObject.invokeMethod( self._chan_est_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._chan_est_options.index(i))) self._chan_est_callback(self.chan_est) self._chan_est_button_group.buttonClicked[int].connect( lambda i: self.set_chan_est(self._chan_est_options[i])) self.top_layout.addWidget(self._chan_est_group_box) self.wifi_freq_adap_phy_hier_0 = wifi_freq_adap_phy_hier( bandwidth=10e6, chan_est=0, encoding=encoding, frequency=5.89e9, sensitivity=0.56, ) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(('', "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_center_freq( uhd.tune_request(freq, rf_freq=freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_source_0.set_normalized_gain(gain, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(('', "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), 'packet_len', ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0.set_center_freq( uhd.tune_request(freq, rf_freq=freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_sink_0.set_normalized_gain(gain, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size 300000, #samp_rate "Data Received", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ['Error Rate', '', '', '', '', '', '', '', '', ''] units = ['Percent', '', '', '', '', '', '', '', '', ''] 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, 0) 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.top_layout.addWidget(self._qtgui_number_sink_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 48 * 10, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_0_win) self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 10000, 10000) (self.foo_packet_pad2_0).set_min_output_buffer(100000) self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", '', '52001', 10000, False) self.blocks_pdu_to_tagged_stream_0_1 = blocks.pdu_to_tagged_stream( blocks.byte_t, 'packet_len') self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream( blocks.complex_t, 'packet_len') self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream( blocks.float_t, 'packet_len') self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.6, )) (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000) ################################################## # Connections ################################################## self.msg_connect((self.adaptiveOFDM_mac_and_parse_0, 'fer'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.adaptiveOFDM_mac_and_parse_0, 'app out'), (self.blocks_pdu_to_tagged_stream_0_1, 'pdus')) self.msg_connect((self.adaptiveOFDM_mac_and_parse_0, 'phy out'), (self.wifi_freq_adap_phy_hier_0, 'mac_in')) self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.adaptiveOFDM_mac_and_parse_0, 'app in')) self.msg_connect((self.wifi_freq_adap_phy_hier_0, 'mac_out'), (self.adaptiveOFDM_mac_and_parse_0, 'phy in')) self.msg_connect((self.wifi_freq_adap_phy_hier_0, 'carrier'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus')) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.foo_packet_pad2_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_1, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.foo_packet_pad2_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wifi_freq_adap_phy_hier_0, 0)) self.connect((self.wifi_freq_adap_phy_hier_0, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Trcbpsk") Qt.QWidget.__init__(self) self.setWindowTitle("Trcbpsk") 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", "trcbpsk") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.taps = taps = [1.0, 0.25-0.25j, 0.50 + 0.10j, -0.3 + 0.2j] self.samp_rate = samp_rate = 32000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts) self.qpsk = qpsk = digital.constellation_rect(([1,1j, -1, -1j]), ([0, 1, 3, 2]), 4, 2, 2, 1, 1).base() self.excess_bw = excess_bw = 0.35 ################################################## # Blocks ################################################## self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024/2, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10/2) 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(True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in 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, 0,0,1,1) self.digital_psk_mod_0 = digital.psk.psk_mod( constellation_points=4, mod_code="gray", differential=True, samples_per_symbol=sps, excess_bw=excess_bw, verbose=False, log=False, ) self.digital_psk_demod_0 = digital.psk.psk_demod( constellation_points=4, differential=True, samples_per_symbol=sps, excess_bw=0.35, phase_bw=6.28/100.0, timing_bw=6.28/100.0, mod_code="gray", verbose=False, log=False, ) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 0.2, (rrc_taps), nfilts, 16, 1.5, sps/4) self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc(21, 0.000001, 4, qpsk) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(4, excess_bw, 45, 0.034) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(0.34, 4, False) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/home/arun/Desktop/Untitled Folder/abc.txt", False) self.blocks_file_sink_0.set_unbuffered(False) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(grc_blks2.packet_decoder( access_code="", threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload), ), ) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 2, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_psk_mod_0, 0)) self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_psk_demod_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_lms_dd_equalizer_cc_0, 0)) self.connect((self.digital_psk_demod_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.digital_psk_mod_0, 0), (self.blocks_throttle_0, 0))
def __init__(self, MCS=9, N_CCE=13, N_dl_prb=25, RB_start_UE_1=0, RB_start_UE_2=70, aggregation1=288, aggregation2=288 * 2, allocation_len_UE_1=60, allocation_len_UE_2=10, cfi_val=2, n_pdcch=2): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.MCS = MCS self.N_CCE = N_CCE self.N_dl_prb = N_dl_prb self.RB_start_UE_1 = RB_start_UE_1 self.RB_start_UE_2 = RB_start_UE_2 self.aggregation1 = aggregation1 self.aggregation2 = aggregation2 self.allocation_len_UE_1 = allocation_len_UE_1 self.allocation_len_UE_2 = allocation_len_UE_2 self.cfi_val = cfi_val self.n_pdcch = n_pdcch ################################################## # Variables ################################################## self.N_id_2 = N_id_2 = 2 self.N_id_1 = N_id_1 = 100 self.tx_mode = tx_mode = 1 self.samp_rate = samp_rate = 30720000 / 40 self.rv_idx = rv_idx = 0 self.rnti = rnti = 1 self.normal_cp = normal_cp = True self.cell_id = cell_id = N_id_1 * 3 + N_id_2 self.TBS = TBS = 2112 self.N_soft = N_soft = 3654144 self.N_e_bits = N_e_bits = 6300 self.N_code_block = N_code_block = 1 self.N_ant = N_ant = 1 self.M_dl_harq = M_dl_harq = 6 ################################################## # Blocks ################################################## self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(True) self.qtgui_const_sink_x_0.enable_grid(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_layout.addWidget(self._qtgui_const_sink_x_0_win) self.pbch_0 = pbch( N_ant=N_ant, RNTI=rnti, cell_id=cell_id, normal_cp=normal_cp, ) self.my_lte_resource_mapper_0 = my_lte.resource_mapper( N_id_1, N_id_2, N_dl_prb) self.my_lte_lte_random_bit_gen_0_0 = my_lte.lte_random_bit_gen( 2112 - 24, 2000) self.my_lte_lte_random_bit_gen_0 = my_lte.lte_random_bit_gen(24, 20000) self.my_lte_cp_adder_0 = my_lte.cp_adder(N_dl_prb, True) self.my_lte_cfi_gen_0 = my_lte.cfi_gen(N_dl_prb, cfi_val) self.blocks_throttle_0_1_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True) self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream( gr.sizeof_gr_complex, 1, N_CCE * 9 * 8, "length") self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_gr_complex, 1, 12 * 3, "length") self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_gr_complex * 1, "/home/mostafa/Desktop/LTE_Signal/matlabfiles/ffo/grc_data_5M.dat", False) self.blocks_file_sink_0.set_unbuffered(False) self.analog_sig_source_x_0_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 1000, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 1000, 1, 0) self.PDSCH_5M_0 = PDSCH_5M( M_dl_harq=M_dl_harq, N_code_block=N_code_block, N_e_bits=N_e_bits, N_soft=N_soft, RNTI=rnti, TBS=TBS, rv_idx=rv_idx, tx_mode=tx_mode, ) self.PCFICH_0 = PCFICH( RNTI=rnti, cell_id=cell_id, ) ################################################## # Connections ################################################## self.connect((self.PCFICH_0, 0), (self.my_lte_resource_mapper_0, 4)) self.connect((self.PDSCH_5M_0, 0), (self.my_lte_resource_mapper_0, 1)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_stream_to_tagged_stream_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.my_lte_resource_mapper_0, 3)) self.connect((self.blocks_stream_to_tagged_stream_0_0, 0), (self.my_lte_resource_mapper_0, 2)) self.connect((self.blocks_throttle_0, 0), (self.pbch_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.PDSCH_5M_0, 0)) self.connect((self.blocks_throttle_0_1_0, 0), (self.PCFICH_0, 0)) self.connect((self.my_lte_cfi_gen_0, 0), (self.blocks_throttle_0_1_0, 0)) self.connect((self.my_lte_cp_adder_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.my_lte_lte_random_bit_gen_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.my_lte_lte_random_bit_gen_0_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.my_lte_resource_mapper_0, 0), (self.my_lte_cp_adder_0, 0)) self.connect((self.pbch_0, 0), (self.my_lte_resource_mapper_0, 0)) self.connect((self.pbch_0, 0), (self.qtgui_const_sink_x_0, 0))
def __init__(self, freq=0, gain=40, loopbw=100, loopbw_0=100, fllbw=0.002): gr.top_block.__init__(self, "Rx Gui") Qt.QWidget.__init__(self) self.setWindowTitle("Rx Gui") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "rx_gui") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.freq = freq self.gain = gain self.loopbw = loopbw self.loopbw_0 = loopbw_0 self.fllbw = fllbw ################################################## # Variables ################################################## self.sps = sps = 8 self.excess_bw = excess_bw = 0.25 self.target_samp_rate = target_samp_rate = sps*(200e3/(1 + excess_bw)) self.qpsk_const = qpsk_const = digital.constellation_qpsk().base() self.dsp_rate = dsp_rate = 100e6 self.const_choice = const_choice = "qpsk" self.bpsk_const = bpsk_const = digital.constellation_bpsk().base() self.barker_code_two_dim = barker_code_two_dim = [-1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j] self.barker_code_one_dim = barker_code_one_dim = sqrt(2)*numpy.real([-1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j]) self.rrc_delay = rrc_delay = int(round(-44*excess_bw + 33)) self.nfilts = nfilts = 32 self.n_barker_rep = n_barker_rep = 10 self.dec_factor = dec_factor = ceil(dsp_rate/target_samp_rate) self.constellation = constellation = qpsk_const if (const_choice=="qpsk") else bpsk_const self.barker_code = barker_code = barker_code_two_dim if (const_choice == "qpsk") else barker_code_one_dim self.preamble_syms = preamble_syms = numpy.matlib.repmat(barker_code, 1, n_barker_rep)[0] self.n_rrc_taps = n_rrc_taps = rrc_delay * int(sps*nfilts) self.n_codewords = n_codewords = 1 self.even_dec_factor = even_dec_factor = dec_factor if (dec_factor % 1 == 1) else (dec_factor+1) self.const_order = const_order = pow(2,constellation.bits_per_symbol()) self.codeword_len = codeword_len = 18444 self.usrp_rx_addr = usrp_rx_addr = "192.168.10.2" self.samp_rate = samp_rate = dsp_rate/even_dec_factor self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts*sps, 1.0, excess_bw, n_rrc_taps) self.rf_center_freq = rf_center_freq = 1428.4309e6 self.preamble_size = preamble_size = len(preamble_syms) self.pmf_peak_threshold = pmf_peak_threshold = 0.6 self.payload_size = payload_size = codeword_len*n_codewords/int(numpy.log2(const_order)) self.dataword_len = dataword_len = 6144 self.barker_len = barker_len = 13 ################################################## # Blocks ################################################## self.tabs = Qt.QTabWidget() self.tabs_widget_0 = Qt.QWidget() self.tabs_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_0) self.tabs_grid_layout_0 = Qt.QGridLayout() self.tabs_layout_0.addLayout(self.tabs_grid_layout_0) self.tabs.addTab(self.tabs_widget_0, 'PMF Out') self.tabs_widget_1 = Qt.QWidget() self.tabs_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_1) self.tabs_grid_layout_1 = Qt.QGridLayout() self.tabs_layout_1.addLayout(self.tabs_grid_layout_1) self.tabs.addTab(self.tabs_widget_1, 'Abs PMF Out') self.tabs_widget_2 = Qt.QWidget() self.tabs_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_2) self.tabs_grid_layout_2 = Qt.QGridLayout() self.tabs_layout_2.addLayout(self.tabs_grid_layout_2) self.tabs.addTab(self.tabs_widget_2, 'FLL In') self.tabs_widget_3 = Qt.QWidget() self.tabs_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_3) self.tabs_grid_layout_3 = Qt.QGridLayout() self.tabs_layout_3.addLayout(self.tabs_grid_layout_3) self.tabs.addTab(self.tabs_widget_3, 'FLL Out') self.tabs_widget_4 = Qt.QWidget() self.tabs_layout_4 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_4) self.tabs_grid_layout_4 = Qt.QGridLayout() self.tabs_layout_4.addLayout(self.tabs_grid_layout_4) self.tabs.addTab(self.tabs_widget_4, 'FLL State') self.tabs_widget_5 = Qt.QWidget() self.tabs_layout_5 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_5) self.tabs_grid_layout_5 = Qt.QGridLayout() self.tabs_layout_5.addLayout(self.tabs_grid_layout_5) self.tabs.addTab(self.tabs_widget_5, 'PFB Sync Out') self.tabs_widget_6 = Qt.QWidget() self.tabs_layout_6 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_6) self.tabs_grid_layout_6 = Qt.QGridLayout() self.tabs_layout_6.addLayout(self.tabs_grid_layout_6) self.tabs.addTab(self.tabs_widget_6, 'Costas State') self.tabs_widget_7 = Qt.QWidget() self.tabs_layout_7 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_7) self.tabs_grid_layout_7 = Qt.QGridLayout() self.tabs_layout_7.addLayout(self.tabs_grid_layout_7) self.tabs.addTab(self.tabs_widget_7, 'Demod Bits') self.tabs_widget_8 = Qt.QWidget() self.tabs_layout_8 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_8) self.tabs_grid_layout_8 = Qt.QGridLayout() self.tabs_layout_8.addLayout(self.tabs_grid_layout_8) self.tabs.addTab(self.tabs_widget_8, 'Costas Sym Out') self.tabs_widget_9 = Qt.QWidget() self.tabs_layout_9 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_9) self.tabs_grid_layout_9 = Qt.QGridLayout() self.tabs_layout_9.addLayout(self.tabs_grid_layout_9) self.tabs.addTab(self.tabs_widget_9, 'Payload Symbols') self.top_layout.addWidget(self.tabs) self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(gain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.qtgui_time_sink_x_2 = qtgui.time_sink_c( preamble_size + payload_size, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_2.set_update_time(0.10) self.qtgui_time_sink_x_2.set_y_axis(-1, 1) self.qtgui_time_sink_x_2.set_y_label('Amplitude', "") self.qtgui_time_sink_x_2.enable_tags(-1, True) self.qtgui_time_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_2.enable_autoscale(True) self.qtgui_time_sink_x_2.enable_grid(False) self.qtgui_time_sink_x_2.enable_axis_labels(True) self.qtgui_time_sink_x_2.enable_control_panel(False) if not True: self.qtgui_time_sink_x_2.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2*1): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_2.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_2.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_2.set_line_label(i, labels[i]) self.qtgui_time_sink_x_2.set_line_width(i, widths[i]) self.qtgui_time_sink_x_2.set_line_color(i, colors[i]) self.qtgui_time_sink_x_2.set_line_style(i, styles[i]) self.qtgui_time_sink_x_2.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_2.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_2_win = sip.wrapinstance(self.qtgui_time_sink_x_2.pyqwidget(), Qt.QWidget) self.tabs_layout_0.addWidget(self._qtgui_time_sink_x_2_win) self.qtgui_time_sink_x_1_0_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0_0.set_y_axis(-128, 128) self.qtgui_time_sink_x_1_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0_0.enable_tags(-1, False) self.qtgui_time_sink_x_1_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0_0.enable_grid(False) self.qtgui_time_sink_x_1_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0_0.pyqwidget(), Qt.QWidget) self.tabs_layout_7.addWidget(self._qtgui_time_sink_x_1_0_0_win) self.qtgui_time_sink_x_1_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0.enable_grid(False) self.qtgui_time_sink_x_1_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget) self.tabs_layout_7.addWidget(self._qtgui_time_sink_x_1_0_win) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 8192, #size samp_rate, #samp_rate "", #name 3 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ['FLL Freq (PI Output)', 'FLL Phase Accum', 'FLL Error', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(3): if len(labels[i]) == 0: self.qtgui_time_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.tabs_layout_4.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0_3 = qtgui.time_sink_f( 1024*4, #size samp_rate, #samp_rate "Error", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_3.set_update_time(0.10) self.qtgui_time_sink_x_0_3.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_3.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_3.enable_tags(-1, True) self.qtgui_time_sink_x_0_3.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_3.enable_autoscale(False) self.qtgui_time_sink_x_0_3.enable_grid(False) self.qtgui_time_sink_x_0_3.enable_axis_labels(True) self.qtgui_time_sink_x_0_3.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_3.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_3.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_3.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_3.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_3.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_3.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_3.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_3.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_3_win = sip.wrapinstance(self.qtgui_time_sink_x_0_3.pyqwidget(), Qt.QWidget) self.tabs_layout_6.addWidget(self._qtgui_time_sink_x_0_3_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( preamble_size + payload_size, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['Mag Sq', 'Mag', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tabs_layout_1.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_sink_x_5 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name True, #plotfreq False, #plotwaterfall False, #plottime True, #plotconst ) self.qtgui_sink_x_5.set_update_time(1.0/10) self._qtgui_sink_x_5_win = sip.wrapinstance(self.qtgui_sink_x_5.pyqwidget(), Qt.QWidget) self.tabs_layout_3.addWidget(self._qtgui_sink_x_5_win) self.qtgui_sink_x_5.enable_rf_freq(False) self.qtgui_sink_x_1 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name True, #plotfreq False, #plotwaterfall False, #plottime True, #plotconst ) self.qtgui_sink_x_1.set_update_time(1.0/10) self._qtgui_sink_x_1_win = sip.wrapinstance(self.qtgui_sink_x_1.pyqwidget(), Qt.QWidget) self.tabs_layout_2.addWidget(self._qtgui_sink_x_1_win) self.qtgui_sink_x_1.enable_rf_freq(False) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name False, #plotfreq False, #plotwaterfall False, #plottime True, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0/10) self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_layout_5.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(False) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_layout_2.addWidget(self._qtgui_freq_sink_x_0_win) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_1.set_update_time(0.10) self.qtgui_const_sink_x_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1.enable_autoscale(False) self.qtgui_const_sink_x_1.enable_grid(False) self.qtgui_const_sink_x_1.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_win = sip.wrapinstance(self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget) self.tabs_layout_9.addWidget(self._qtgui_const_sink_x_1_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_layout_8.addWidget(self._qtgui_const_sink_x_0_win) self.mods_turbo_decoder_0 = mods.turbo_decoder(codeword_len, dataword_len) self.mods_frame_sync_fast_0 = mods.frame_sync_fast(pmf_peak_threshold, preamble_size, payload_size, 0, 1, 1, int(const_order)) self.mods_fifo_async_sink_0 = mods.fifo_async_sink('/tmp/async_rx') self.interp_fir_filter_xxx_0_0 = filter.interp_fir_filter_fff(1, ( numpy.ones(n_barker_rep*barker_len))) self.interp_fir_filter_xxx_0_0.declare_sample_delay(0) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(1, ( numpy.flipud(numpy.conj(preamble_syms)))) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.framers_gr_hdlc_deframer_b_0 = framers.gr_hdlc_deframer_b(0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 2*pi/50, (rrc_taps), nfilts, nfilts/2, pi/8, 1) self.digital_map_bb_0_0_0 = digital.map_bb(([1,- 1])) self.digital_fll_band_edge_cc_1 = digital.fll_band_edge_cc(sps, excess_bw, rrc_delay * int(sps) + 1, fllbw) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0x7F, 16) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(2*pi/loopbw, 2**constellation.bits_per_symbol(), False) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(constellation.base()) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(constellation.bits_per_symbol()) self.blocks_rms_xx_1 = blocks.rms_cf(0.0001) self.blocks_pack_k_bits_bb_1 = blocks.pack_k_bits_bb(8) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_1_1 = blocks.multiply_const_vcc((1.0/sqrt(2), )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((1.0/(preamble_size*sqrt(2)), )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_divide_xx_1 = blocks.divide_ff(1) self.blocks_divide_xx_0 = blocks.divide_cc(1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_1 = blocks.complex_to_mag(1) self.blocks_char_to_float_0_1 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) ################################################## # Connections ################################################## self.msg_connect((self.framers_gr_hdlc_deframer_b_0, 'pdu'), (self.mods_fifo_async_sink_0, 'async_pdu')) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_1_0, 0)) self.connect((self.blocks_char_to_float_0_1, 0), (self.qtgui_time_sink_x_1_0_0, 0)) self.connect((self.blocks_complex_to_mag_1, 0), (self.blocks_divide_xx_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.interp_fir_filter_xxx_0_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.digital_fll_band_edge_cc_1, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.qtgui_sink_x_1, 0)) self.connect((self.blocks_divide_xx_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_divide_xx_1, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.mods_frame_sync_fast_0, 2)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_time_sink_x_2, 0)) self.connect((self.blocks_multiply_const_vxx_1_1, 0), (self.blocks_complex_to_mag_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.mods_frame_sync_fast_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_pack_k_bits_bb_1, 0), (self.blocks_char_to_float_0_1, 0)) self.connect((self.blocks_rms_xx_1, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.digital_map_bb_0_0_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.mods_frame_sync_fast_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_costas_loop_cc_0, 1), (self.qtgui_time_sink_x_0_3, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.blocks_pack_k_bits_bb_1, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.framers_gr_hdlc_deframer_b_0, 0)) self.connect((self.digital_fll_band_edge_cc_1, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_fll_band_edge_cc_1, 0), (self.qtgui_sink_x_5, 0)) self.connect((self.digital_fll_band_edge_cc_1, 3), (self.qtgui_time_sink_x_1, 2)) self.connect((self.digital_fll_band_edge_cc_1, 1), (self.qtgui_time_sink_x_1, 0)) self.connect((self.digital_fll_band_edge_cc_1, 2), (self.qtgui_time_sink_x_1, 1)) self.connect((self.digital_map_bb_0_0_0, 0), (self.mods_turbo_decoder_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_multiply_const_vxx_1_1, 0)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.blocks_divide_xx_1, 1)) self.connect((self.mods_frame_sync_fast_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.mods_frame_sync_fast_0, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.mods_turbo_decoder_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_rms_xx_1, 0)) self.connect((self.rtlsdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
def __init__(self, puncpat='11'): gr.top_block.__init__(self, "Rx") Qt.QWidget.__init__(self) self.setWindowTitle("Rx") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "rx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.puncpat = puncpat ################################################## # Variables ################################################## self.sps = sps = 4 self.samp_rate_array_MCR = samp_rate_array_MCR = [ 7500000, 5000000, 3750000, 3000000, 2500000, 2000000, 1500000, 1000000, 937500, 882352, 833333, 714285, 533333, 500000, 421052, 400000, 380952 ] self.nfilts = nfilts = 32 self.eb = eb = 0.22 self.H_dec = H_dec = fec.ldpc_H_matrix( '/usr/local/share/gnuradio/fec/ldpc/n_1100_k_0442_gap_24.alist', 24) self.variable_qtgui_range_0_1 = variable_qtgui_range_0_1 = 30 self.variable_qtgui_range_0_0 = variable_qtgui_range_0_0 = 52 self.variable_qtgui_check_box_0 = variable_qtgui_check_box_0 = True self.samp_rate = samp_rate = samp_rate_array_MCR[15] self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine( nfilts, nfilts * sps, 1.0, eb, 11 * sps * nfilts) self.pld_dec = pld_dec = map((lambda a: fec.ldpc_bit_flip_decoder.make( H_dec.get_base_sptr(), 100)), range(0, 8)) self.pld_const = pld_const = digital.constellation_rect(([ 0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j ]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.pld_const.gen_soft_dec_lut(8) self.frequencia_usrp = frequencia_usrp = 484e6 self.MCR = MCR = "master_clock_rate=60e6" ################################################## # Blocks ################################################## self._variable_qtgui_range_0_1_range = Range(0, 73, 1, 30, 200) self._variable_qtgui_range_0_1_win = RangeWidget( self._variable_qtgui_range_0_1_range, self.set_variable_qtgui_range_0_1, 'Gain_RX', "counter_slider", float) self.top_grid_layout.addWidget(self._variable_qtgui_range_0_1_win, 0, 2, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self._variable_qtgui_range_0_0_range = Range(0, 90, 1, 52, 200) self._variable_qtgui_range_0_0_win = RangeWidget( self._variable_qtgui_range_0_0_range, self.set_variable_qtgui_range_0_0, 'Gain_Jamming', "counter_slider", float) self.top_grid_layout.addWidget(self._variable_qtgui_range_0_0_win, 0, 3, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) _variable_qtgui_check_box_0_check_box = Qt.QCheckBox('ENABLE JAM') self._variable_qtgui_check_box_0_choices = {True: True, False: False} self._variable_qtgui_check_box_0_choices_inv = dict( (v, k) for k, v in self._variable_qtgui_check_box_0_choices.iteritems()) self._variable_qtgui_check_box_0_callback = lambda i: Qt.QMetaObject.invokeMethod( _variable_qtgui_check_box_0_check_box, "setChecked", Qt.Q_ARG("bool", self._variable_qtgui_check_box_0_choices_inv[i])) self._variable_qtgui_check_box_0_callback( self.variable_qtgui_check_box_0) _variable_qtgui_check_box_0_check_box.stateChanged.connect( lambda i: self.set_variable_qtgui_check_box_0( self._variable_qtgui_check_box_0_choices[bool(i)])) self.top_grid_layout.addWidget(_variable_qtgui_check_box_0_check_box, 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.uhd_usrp_source_0_0 = uhd.usrp_source( ",".join(("serial=F5EAC0", MCR)), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0_0.set_center_freq(frequencia_usrp, 0) self.uhd_usrp_source_0_0.set_gain(variable_qtgui_range_0_1, 0) self.uhd_usrp_source_0_0.set_antenna('TX/RX', 0) self.uhd_usrp_source_0_0.set_auto_dc_offset(True, 0) self.uhd_usrp_source_0_0.set_auto_iq_balance(True, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("serial=F5EAC0", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_subdev_spec('A:B', 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0.set_center_freq(frequencia_usrp, 0) self.uhd_usrp_sink_0.set_gain(variable_qtgui_range_0_0, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.scrambler_cpp_additive_descrambler_0 = scrambler_cpp.additive_descrambler( 0x8A, 0x7F, 7, 440 - 32) self.qtgui_time_sink_x_1_0_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "TX JAMMING USRP", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0_0.enable_grid(False) self.qtgui_time_sink_x_1_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0_0.enable_control_panel(False) self.qtgui_time_sink_x_1_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_1_0_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_1_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_0_win, 1, 1, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_1_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "RX USRP", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0.enable_grid(False) self.qtgui_time_sink_x_1_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0.enable_control_panel(False) self.qtgui_time_sink_x_1_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_1_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_win = sip.wrapinstance( self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_win, 1, 3, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f( 100 * 2, #size samp_rate, #samp_rate 'Rx Data', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_1.set_update_time(0.10) self.qtgui_time_sink_x_0_1.set_y_axis(-1, 256) self.qtgui_time_sink_x_0_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_1.enable_tags(-1, True) self.qtgui_time_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, 'packet_length_tag_key') self.qtgui_time_sink_x_0_1.enable_autoscale(True) self.qtgui_time_sink_x_0_1.enable_grid(True) self.qtgui_time_sink_x_0_1.enable_axis_labels(True) self.qtgui_time_sink_x_0_1.enable_control_panel(False) self.qtgui_time_sink_x_0_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_1_win = sip.wrapinstance( self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_win, 2, 3, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance( self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 1, 2, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0_0_1 = qtgui.const_sink_c( 1024, #size "RX Const", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0_1.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_1.set_trigger_mode( qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0_1.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0_1.enable_grid(False) self.qtgui_const_sink_x_0_0_0_1.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_0_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_1_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_1_win, 2, 1, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c( 1024, #size "RX Treated", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_win, 2, 2, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.interp_fir_filter_xxx_1 = filter.interp_fir_filter_ccc( 4, ([1, 0, 0, 0])) self.interp_fir_filter_xxx_1.declare_sample_delay(0) self.fec_extended_decoder_0_0_1_0_1_0_0 = fec.extended_decoder( decoder_obj_list=pld_dec, threading='capillary', ann=None, puncpat=puncpat, integration_period=10000) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, 6.28 / 100.0, (rx_rrc_taps), nfilts, nfilts / 2, 1.5, 1) self.digital_map_bb_0_0_0_0_0_0 = digital.map_bb(([-1, 1])) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb( pld_const.arity()) self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc( 6.28 / 100.0, pld_const.arity(), False) self.digital_correlate_access_code_xx_ts_0_0 = digital.correlate_access_code_bb_ts( digital.packet_utils.default_access_code, 4, 'packet_len') self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( pld_const) self.custom_corr = correlate_and_delay.corr_and_delay( 200 * sps, 0, 0.99, sps) self.blocks_repack_bits_bb_0_0_0_1_0 = blocks.repack_bits_bb( 1, 8, '', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb( pld_const.bits_per_symbol(), 8, '', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( pld_const.bits_per_symbol(), 1, '', False, gr.GR_MSB_FIRST) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vcc((0.5, )) self.blocks_keep_m_in_n_0_1_1_0 = blocks.keep_m_in_n( gr.sizeof_char, 440, 442, 0) self.blocks_keep_m_in_n_0_0_2_0_0 = blocks.keep_m_in_n( gr.sizeof_char, 1100, 1104, 0) self.blocks_file_sink_0_0_0_0_2 = blocks.file_sink( gr.sizeof_char * 1, '/home/it/Desktop/Trasmited/depois.txt', False) self.blocks_file_sink_0_0_0_0_2.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1, 'rx_ber.txt', False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_copy_0 = blocks.copy(gr.sizeof_gr_complex * 1) self.blocks_copy_0.set_enabled(variable_qtgui_check_box_0) self.blocks_char_to_float_1_0_1 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_2_0_0_0 = blocks.char_to_float(1, 1) self.analog_noise_source_x_0_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 1, -5) self.adapt_lms_filter_xx_0 = adapt.lms_filter_cc( True, 32, 0.0001, 0, 1, True, False, False) ################################################## # Connections ################################################## self.connect((self.adapt_lms_filter_xx_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.adapt_lms_filter_xx_0, 1), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.analog_noise_source_x_0_0, 0), (self.interp_fir_filter_xxx_1, 0)) self.connect((self.blocks_char_to_float_0_2_0_0_0, 0), (self.fec_extended_decoder_0_0_1_0_1_0_0, 0)) self.connect((self.blocks_char_to_float_1_0_1, 0), (self.qtgui_time_sink_x_0_1, 0)) self.connect((self.blocks_copy_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_keep_m_in_n_0_0_2_0_0, 0), (self.digital_map_bb_0_0_0_0_0_0, 0)) self.connect((self.blocks_keep_m_in_n_0_1_1_0, 0), (self.scrambler_cpp_additive_descrambler_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.blocks_copy_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.custom_corr, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.qtgui_time_sink_x_1_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_correlate_access_code_xx_ts_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0_0_1_0, 0), (self.blocks_char_to_float_1_0_1, 0)) self.connect((self.blocks_repack_bits_bb_0_0_0_1_0, 0), (self.blocks_file_sink_0_0_0_0_2, 0)) self.connect((self.custom_corr, 0), (self.adapt_lms_filter_xx_0, 1)) self.connect((self.custom_corr, 1), (self.adapt_lms_filter_xx_0, 0)) self.connect((self.custom_corr, 2), (self.blocks_null_sink_1, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_correlate_access_code_xx_ts_0_0, 0), (self.blocks_keep_m_in_n_0_0_2_0_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.qtgui_const_sink_x_0_0_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect((self.digital_map_bb_0_0_0_0_0_0, 0), (self.blocks_char_to_float_0_2_0_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0_0, 0)) self.connect((self.fec_extended_decoder_0_0_1_0_1_0_0, 0), (self.blocks_keep_m_in_n_0_1_1_0, 0)) self.connect((self.interp_fir_filter_xxx_1, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.scrambler_cpp_additive_descrambler_0, 0), (self.blocks_repack_bits_bb_0_0_0_1_0, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.custom_corr, 1)) self.connect((self.uhd_usrp_source_0_0, 0), (self.qtgui_const_sink_x_0_0_0_1, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.qtgui_time_sink_x_1_0, 0))
def __init__(self): gr.top_block.__init__(self, "Uhd Snr Receiver") Qt.QWidget.__init__(self) self.setWindowTitle("Uhd Snr Receiver") self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "uhd_snr_receiver") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.samp_rate = samp_rate = 1e6 self.rrc_taps = rrc_taps = filter.firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts) self.gain = gain = 15 self.freq = freq = 520e6 self.fine_freq = fine_freq = -28400 ################################################## # Blocks ################################################## self._gain_layout = Qt.QVBoxLayout() self._gain_tool_bar = Qt.QToolBar(self) self._gain_layout.addWidget(self._gain_tool_bar) self._gain_tool_bar.addWidget(Qt.QLabel("RX Gain"+": ")) self._gain_counter = Qwt.QwtCounter() self._gain_counter.setRange(0, 31.5, 0.5) self._gain_counter.setNumButtons(2) self._gain_counter.setValue(self.gain) self._gain_tool_bar.addWidget(self._gain_counter) self._gain_counter.valueChanged.connect(self.set_gain) self._gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._gain_slider.setRange(0, 31.5, 0.5) self._gain_slider.setValue(self.gain) self._gain_slider.setMinimumWidth(200) self._gain_slider.valueChanged.connect(self.set_gain) self._gain_layout.addWidget(self._gain_slider) self.top_layout.addLayout(self._gain_layout) self._freq_layout = Qt.QVBoxLayout() self._freq_tool_bar = Qt.QToolBar(self) self._freq_layout.addWidget(self._freq_tool_bar) self._freq_tool_bar.addWidget(Qt.QLabel("Frequency"+": ")) self._freq_counter = Qwt.QwtCounter() self._freq_counter.setRange(514e6, 526e6, 1e6) self._freq_counter.setNumButtons(2) self._freq_counter.setValue(self.freq) self._freq_tool_bar.addWidget(self._freq_counter) self._freq_counter.valueChanged.connect(self.set_freq) self._freq_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._freq_slider.setRange(514e6, 526e6, 1e6) self._freq_slider.setValue(self.freq) self._freq_slider.setMinimumWidth(200) self._freq_slider.valueChanged.connect(self.set_freq) self._freq_layout.addWidget(self._freq_slider) self.top_grid_layout.addLayout(self._freq_layout, 2,0,1,1) self._fine_freq_layout = Qt.QVBoxLayout() self._fine_freq_tool_bar = Qt.QToolBar(self) self._fine_freq_layout.addWidget(self._fine_freq_tool_bar) self._fine_freq_tool_bar.addWidget(Qt.QLabel("Fine Frequency"+": ")) self._fine_freq_counter = Qwt.QwtCounter() self._fine_freq_counter.setRange(-50e3, 50e3, 100) self._fine_freq_counter.setNumButtons(2) self._fine_freq_counter.setValue(self.fine_freq) self._fine_freq_tool_bar.addWidget(self._fine_freq_counter) self._fine_freq_counter.valueChanged.connect(self.set_fine_freq) self._fine_freq_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._fine_freq_slider.setRange(-50e3, 50e3, 100) self._fine_freq_slider.setValue(self.fine_freq) self._fine_freq_slider.setMinimumWidth(200) self._fine_freq_slider.valueChanged.connect(self.set_fine_freq) self._fine_freq_layout.addWidget(self._fine_freq_slider) self.top_grid_layout.addLayout(self._fine_freq_layout, 2,1,1,1) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(freq + fine_freq, 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c( 500, #size samp_rate, #bw "QT GUI Plot", #name 3 #number of inputs ) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 0,0,1,1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name 1 #number of inputs ) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 1,0,1,2) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "QT GUI Plot", #name 2 #number of inputs ) self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 0,1,1,1) self.gr_multiply_xx_0 = gr.multiply_vcc(1) self.gr_agc2_xx_0 = gr.agc2_cc(1e-1, 1e-2, 1.0, 1.0, 0.0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 2*3.14/100.0, (rrc_taps), nfilts, nfilts/2, 1.5, 1) self.digital_mpsk_snr_est_cc_0_1 = digital.mpsk_snr_est_cc(3, 10000, 0.001) self.digital_mpsk_snr_est_cc_0_0 = digital.mpsk_snr_est_cc(2, 10000, 0.001) self.digital_mpsk_snr_est_cc_0 = digital.mpsk_snr_est_cc(0, 10000, 0.001) self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc(15, 0.010, 1, digital.constellation_qpsk().base()) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(2*3.14/100.0, 4) ################################################## # Connections ################################################## self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_mpsk_snr_est_cc_0, 0)) self.connect((self.gr_multiply_xx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_0, 0), (self.qtgui_const_sink_x_0, 1)) self.connect((self.gr_agc2_xx_0, 0), (self.gr_multiply_xx_0, 3)) self.connect((self.gr_agc2_xx_0, 0), (self.gr_multiply_xx_0, 2)) self.connect((self.gr_agc2_xx_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.gr_agc2_xx_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.gr_agc2_xx_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_lms_dd_equalizer_cc_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.gr_agc2_xx_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_mpsk_snr_est_cc_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_mpsk_snr_est_cc_0_1, 0)) self.connect((self.digital_mpsk_snr_est_cc_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.digital_mpsk_snr_est_cc_0_0, 0), (self.qtgui_time_sink_x_0_0, 1)) self.connect((self.digital_mpsk_snr_est_cc_0_1, 0), (self.qtgui_time_sink_x_0_0, 2))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.ntaps = ntaps = 11 * nfilts * sps self.excess_bw = excess_bw = 0.4 self.tx_taps = tx_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.1, excess_bw, ntaps) self.timing_bw = timing_bw = 2 * pi / 100 self.samp_rate = samp_rate = 80000 self.rx_taps = rx_taps = firdes.root_raised_cosine( nfilts, nfilts * sps, 1.1, excess_bw, ntaps) self.gain2 = gain2 = 0 self.gain = gain = 0.22 self.freq_bw = freq_bw = 2 * pi / 100 self.const_points = const_points = 8 ################################################## # Blocks ################################################## self._gain2_layout = Qt.QVBoxLayout() self._gain2_tool_bar = Qt.QToolBar(self) self._gain2_layout.addWidget(self._gain2_tool_bar) self._gain2_tool_bar.addWidget(Qt.QLabel("gain2" + ": ")) 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._gain2_counter = qwt_counter_pyslot() self._gain2_counter.setRange(-100e6, 100e6, 100e3) self._gain2_counter.setNumButtons(2) self._gain2_counter.setValue(self.gain2) self._gain2_tool_bar.addWidget(self._gain2_counter) self._gain2_counter.valueChanged.connect(self.set_gain2) self._gain2_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._gain2_slider.setRange(-100e6, 100e6, 100e3) self._gain2_slider.setValue(self.gain2) self._gain2_slider.setMinimumWidth(200) self._gain2_slider.valueChanged.connect(self.set_gain2) self._gain2_layout.addWidget(self._gain2_slider) self.top_layout.addLayout(self._gain2_layout) self._gain_layout = Qt.QVBoxLayout() self._gain_tool_bar = Qt.QToolBar(self) self._gain_layout.addWidget(self._gain_tool_bar) self._gain_tool_bar.addWidget(Qt.QLabel("gain" + ": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._gain_counter = qwt_counter_pyslot() self._gain_counter.setRange(0, 1, 0.001) self._gain_counter.setNumButtons(2) self._gain_counter.setValue(self.gain) self._gain_tool_bar.addWidget(self._gain_counter) self._gain_counter.valueChanged.connect(self.set_gain) self._gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._gain_slider.setRange(0, 1, 0.001) self._gain_slider.setValue(self.gain) self._gain_slider.setMinimumWidth(200) self._gain_slider.valueChanged.connect(self.set_gain) self._gain_layout.addWidget(self._gain_slider) self.top_layout.addLayout(self._gain_layout) self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "") self.rtlsdr_source_0.set_sample_rate(1600e3) self.rtlsdr_source_0.set_center_freq(1.2e9 + gain2, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(50, 0) self.rtlsdr_source_0.set_if_gain(50, 0) self.rtlsdr_source_0.set_bb_gain(50, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) 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) 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_layout.addWidget(self._qtgui_const_sink_x_0_win) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, timing_bw, (rx_taps), nfilts, 16, 1.5, 1) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc( 4, 0.4, 55, freq_bw) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(freq_bw, 8) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc( 10, 1, gain, 1) ################################################## # Connections ################################################## self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))
def __init__(self, MCS=9, N_CCE=13, N_dl_prb=25, RB_start_UE_1=0, RB_start_UE_2=70, aggregation1=288, aggregation2=288*2, allocation_len_UE_1=60, allocation_len_UE_2=10, cfi_val=2, n_pdcch=2): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.MCS = MCS self.N_CCE = N_CCE self.N_dl_prb = N_dl_prb self.RB_start_UE_1 = RB_start_UE_1 self.RB_start_UE_2 = RB_start_UE_2 self.aggregation1 = aggregation1 self.aggregation2 = aggregation2 self.allocation_len_UE_1 = allocation_len_UE_1 self.allocation_len_UE_2 = allocation_len_UE_2 self.cfi_val = cfi_val self.n_pdcch = n_pdcch ################################################## # Variables ################################################## self.N_id_2 = N_id_2 = 2 self.N_id_1 = N_id_1 = 100 self.tx_mode = tx_mode = 1 self.samp_rate = samp_rate = 30720000/40 self.rv_idx = rv_idx = 0 self.rnti = rnti = 1 self.normal_cp = normal_cp = True self.cell_id = cell_id = N_id_1 * 3 + N_id_2 self.TBS = TBS = 2112 self.N_soft = N_soft = 3654144 self.N_e_bits = N_e_bits = 6300 self.N_code_block = N_code_block = 1 self.N_ant = N_ant = 1 self.M_dl_harq = M_dl_harq = 6 ################################################## # Blocks ################################################## self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(True) self.qtgui_const_sink_x_0.enable_grid(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_layout.addWidget(self._qtgui_const_sink_x_0_win) self.pbch_0 = pbch( N_ant=N_ant, RNTI=rnti, cell_id=cell_id, normal_cp=normal_cp, ) self.my_lte_resource_mapper_0 = my_lte.resource_mapper(N_id_1, N_id_2, N_dl_prb) self.my_lte_lte_random_bit_gen_0_0 = my_lte.lte_random_bit_gen(2112-24, 2000) self.my_lte_lte_random_bit_gen_0 = my_lte.lte_random_bit_gen(24, 20000) self.my_lte_cp_adder_0 = my_lte.cp_adder(N_dl_prb, True) self.my_lte_cfi_gen_0 = my_lte.cfi_gen(N_dl_prb, cfi_val) self.blocks_throttle_0_1_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True) self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream(gr.sizeof_gr_complex, 1, N_CCE*9*8, "length") self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_gr_complex, 1, 12*3, "length") self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, "/home/mostafa/Desktop/LTE_Signal/matlabfiles/ffo/grc_data_5M.dat", False) self.blocks_file_sink_0.set_unbuffered(False) self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 1000, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 1000, 1, 0) self.PDSCH_5M_0 = PDSCH_5M( M_dl_harq=M_dl_harq, N_code_block=N_code_block, N_e_bits=N_e_bits, N_soft=N_soft, RNTI=rnti, TBS=TBS, rv_idx=rv_idx, tx_mode=tx_mode, ) self.PCFICH_0 = PCFICH( RNTI=rnti, cell_id=cell_id, ) ################################################## # Connections ################################################## self.connect((self.PCFICH_0, 0), (self.my_lte_resource_mapper_0, 4)) self.connect((self.PDSCH_5M_0, 0), (self.my_lte_resource_mapper_0, 1)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_stream_to_tagged_stream_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.my_lte_resource_mapper_0, 3)) self.connect((self.blocks_stream_to_tagged_stream_0_0, 0), (self.my_lte_resource_mapper_0, 2)) self.connect((self.blocks_throttle_0, 0), (self.pbch_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.PDSCH_5M_0, 0)) self.connect((self.blocks_throttle_0_1_0, 0), (self.PCFICH_0, 0)) self.connect((self.my_lte_cfi_gen_0, 0), (self.blocks_throttle_0_1_0, 0)) self.connect((self.my_lte_cp_adder_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.my_lte_lte_random_bit_gen_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.my_lte_lte_random_bit_gen_0_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.my_lte_resource_mapper_0, 0), (self.my_lte_cp_adder_0, 0)) self.connect((self.pbch_0, 0), (self.my_lte_resource_mapper_0, 0)) self.connect((self.pbch_0, 0), (self.qtgui_const_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Lab8") Qt.QWidget.__init__(self) self.setWindowTitle("Lab8") 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", "lab8") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.std_dev = std_dev = 0.05 self.samp_rate = samp_rate = 32000 self.p_xy = p_xy = 0 self.npts = npts = 8192 self.mimo_option = mimo_option = 0 self.lw = lw = 0.5 self.const_qam = const_qam = digital.constellation_calcdist( digital.qam_16()[0], digital.qam_16()[1], 2, 1).base() self.const_psk = const_psk = digital.constellation_calcdist( digital.psk_4()[0], digital.psk_4()[1], 2, 1).base() ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, 'Transmitted') self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, 'Received') self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, 'Histogram') self.top_grid_layout.addWidget(self.tab, 1, 0, 8, 7) for r in range(1, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 7): self.top_grid_layout.setColumnStretch(c, 1) self._std_dev_range = Range(0, 1, 0.001, 0.05, 200) self._std_dev_win = RangeWidget(self._std_dev_range, self.set_std_dev, 'Noise Std. Dev', "counter_slider", float) self.top_grid_layout.addWidget(self._std_dev_win, 0, 0, 1, 3) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 3): self.top_grid_layout.setColumnStretch(c, 1) self._p_xy_range = Range(0, 0.99, 0.001, 0, 200) self._p_xy_win = RangeWidget(self._p_xy_range, self.set_p_xy, 'Correlation Pxy', "counter_slider", float) self.top_grid_layout.addWidget(self._p_xy_win, 0, 3, 1, 3) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 6): self.top_grid_layout.setColumnStretch(c, 1) # Create the options list self._mimo_option_options = ( 0, 1, ) # Create the labels list self._mimo_option_labels = ( 'Alamouti', 'MIMO', ) # Create the combo box # Create the radio buttons self._mimo_option_group_box = Qt.QGroupBox('MIMO Option' + ": ") self._mimo_option_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._mimo_option_button_group = variable_chooser_button_group() self._mimo_option_group_box.setLayout(self._mimo_option_box) for i, _label in enumerate(self._mimo_option_labels): radio_button = Qt.QRadioButton(_label) self._mimo_option_box.addWidget(radio_button) self._mimo_option_button_group.addButton(radio_button, i) self._mimo_option_callback = lambda i: Qt.QMetaObject.invokeMethod( self._mimo_option_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._mimo_option_options.index(i))) self._mimo_option_callback(self.mimo_option) self._mimo_option_button_group.buttonClicked[int].connect( lambda i: self.set_mimo_option(self._mimo_option_options[i])) self.top_grid_layout.addWidget(self._mimo_option_group_box, 0, 6, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 4096, #size 1, #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(0, 20) self.qtgui_time_sink_x_0.set_y_label('Eigenvalue Ratio (dB)', "") self.qtgui_time_sink_x_0.enable_tags(True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(True) self.qtgui_time_sink_x_0.enable_stem_plot(False) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.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, 9, 0, 2, 8) for r in range(9, 11): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_histogram_sink_x_0 = qtgui.histogram_sink_f( npts, 200, -2, 2, "Histogram", 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(True) self.qtgui_histogram_sink_x_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [3, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_histogram_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_histogram_sink_x_0.set_line_label(i, labels[i]) self.qtgui_histogram_sink_x_0.set_line_width(i, widths[i]) self.qtgui_histogram_sink_x_0.set_line_color(i, colors[i]) self.qtgui_histogram_sink_x_0.set_line_style(i, styles[i]) self.qtgui_histogram_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_histogram_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_histogram_sink_x_0_win = sip.wrapinstance( self.qtgui_histogram_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_layout_2.addWidget(self._qtgui_histogram_sink_x_0_win) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( 1024, #size "De-Correlated Constellation", #name 2 #number of inputs ) self.qtgui_const_sink_x_1.set_update_time(0.10) self.qtgui_const_sink_x_1.set_y_axis(-1.5, 1.5) self.qtgui_const_sink_x_1.set_x_axis(-1.5, 1.5) 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(True) self.qtgui_const_sink_x_1.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 2, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, -1, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 0.2, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(2): if len(labels[i]) == 0: self.qtgui_const_sink_x_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.tab_layout_1.addWidget(self._qtgui_const_sink_x_1_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "Correlated Constellation", #name 2 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-4, 4) self.qtgui_const_sink_x_0.set_x_axis(-4, 4) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(True) self.qtgui_const_sink_x_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 2, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, -1, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 0.2, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(2): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_layout_0.addWidget(self._qtgui_const_sink_x_0_win) self.ofdm_alamouti_cc_0 = ofdm.alamouti_cc(p_xy, std_dev, mimo_option) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( const_psk.points(), 1) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( 4096, 1 / 4096, 4096, 1) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_deinterleave_0 = blocks.deinterleave( gr.sizeof_float * 1, 1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.analog_random_source_x_0 = blocks.vector_source_b( list(map(int, numpy.random.randint(0, 4, 1000))), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.qtgui_histogram_sink_x_0, 0)) self.connect((self.blocks_deinterleave_0, 1), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_deinterleave_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.ofdm_alamouti_cc_0, 0)) self.connect((self.ofdm_alamouti_cc_0, 1), (self.blocks_complex_to_real_0, 0)) self.connect((self.ofdm_alamouti_cc_0, 2), (self.blocks_deinterleave_0, 0)) self.connect((self.ofdm_alamouti_cc_0, 0), (self.qtgui_const_sink_x_0, 1)) self.connect((self.ofdm_alamouti_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.ofdm_alamouti_cc_0, 1), (self.qtgui_const_sink_x_1, 0)) self.connect((self.ofdm_alamouti_cc_0, 1), (self.qtgui_const_sink_x_1, 1))
def __init__(self): gr.top_block.__init__(self, "Cr Application") Qt.QWidget.__init__(self) self.setWindowTitle("Cr Application") 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", "cr_application") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.preamble = preamble = [ 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1 ] self.usrp_rf_freq = usrp_rf_freq = 2435000000 self.tx_pkt_rate = tx_pkt_rate = 157 self.samp_rate = samp_rate = 200000 self.preamble_qpsk = preamble_qpsk = map( lambda x: x * (1 + 1j) / pow(2, 0.5), preamble) self.payload_size = payload_size = 50 self.nfilts = nfilts = 32 self.eb = eb = 0.35 self.digital_gain = digital_gain = 1.0 / 8 ################################################## # Blocks ################################################## self.crew_db_channel_selector_0 = crew.db_channel_selector( 'test_crew', 'zigbee', 'max', 0.05) def _usrp_rf_freq_probe(): while True: val = self.crew_db_channel_selector_0.get_freq() try: self.set_usrp_rf_freq(val) except AttributeError: pass time.sleep(1.0 / (10)) _usrp_rf_freq_thread = threading.Thread(target=_usrp_rf_freq_probe) _usrp_rf_freq_thread.daemon = True _usrp_rf_freq_thread.start() self.uhd_usrp_source_0_0 = uhd.usrp_source( ",".join(("addr=192.168.30.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0_0.set_center_freq(usrp_rf_freq, 0) self.uhd_usrp_source_0_0.set_gain(28, 0) self.uhd_usrp_source_0_0.set_antenna("J1", 0) self.uhd_usrp_sink_0_0 = uhd.usrp_sink( ",".join(("addr=192.168.50.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0_0.set_center_freq(usrp_rf_freq, 0) self.uhd_usrp_sink_0_0.set_gain(26, 0) self.uhd_usrp_sink_0_0.set_antenna("J1", 0) self.sync_blocks_0 = sync_blocks(digital_gain=19, ) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_VERT, 1) self.qtgui_number_sink_0.set_update_time(0.2) self.qtgui_number_sink_0.set_title("Packet Reception Rate") labels = [" ", "", "", "", "", "", "", "", "", ""] units = ["%", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [100, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, 0) 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.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 0, 1, 1, 1) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 20000, #size "Rx Constellation", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(True) if not False: self.qtgui_const_sink_x_0_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win, 0, 0, 1, 1) self.packet_gen_0 = packet_gen(payload_size=payload_size, ) self.crew_packet_decoder_cb_0 = crew.packet_decoder_cb((preamble_qpsk)) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char * 1) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff( (1.0 / (tx_pkt_rate), )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff( (-1.0 / (tx_pkt_rate), )) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, "/root/BasicTxRx/wilabt/file_sent.txt", True) self.blocks_add_const_vxx_0 = blocks.add_const_vff((1.0, )) ################################################## # Connections ################################################## self.connect((self.blocks_add_const_vxx_0, 0), (self.crew_db_channel_selector_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.packet_gen_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.crew_packet_decoder_cb_0, 1), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.crew_packet_decoder_cb_0, 1), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.crew_packet_decoder_cb_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.packet_gen_0, 0), (self.uhd_usrp_sink_0_0, 0)) self.connect((self.sync_blocks_0, 0), (self.crew_packet_decoder_cb_0, 0)) self.connect((self.sync_blocks_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.sync_blocks_0, 0))
def __init__(self, puncpat='11'): gr.top_block.__init__(self, "Tx No Gui") Qt.QWidget.__init__(self) self.setWindowTitle("Tx No Gui") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "tx_no_gui") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.puncpat = puncpat ################################################## # Variables ################################################## self.sps = sps = 4 self.samp_rate_array_MCR = samp_rate_array_MCR = [ 7500000, 5000000, 3750000, 3000000, 2500000, 2000000, 1500000, 1000000, 937500, 882352, 833333, 714285, 533333, 500000, 421052, 400000, 380952, 200000 ] self.nfilts = nfilts = 32 self.eb = eb = 0.22 self.H = H = fec.ldpc_H_matrix( '/usr/local/share/gnuradio/fec/ldpc/n_1100_k_0442_gap_24.alist', 24) self.vector = vector = [int(random.random() * 4) for i in range(49600)] self.variable_qtgui_range_0_0 = variable_qtgui_range_0_0 = 43 self.tx_rrc_taps = tx_rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0, eb, 11 * sps * nfilts) self.samp_rate = samp_rate = samp_rate_array_MCR[15] self.pld_enc = pld_enc = map( (lambda a: fec.ldpc_par_mtrx_encoder_make_H(H)), range(0, 4)) self.pld_const = pld_const = digital.constellation_rect(([ 0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j ]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.pld_const.gen_soft_dec_lut(8) self.frequencia_usrp = frequencia_usrp = 484e6 self.MCR = MCR = "master_clock_rate=60e6" ################################################## # Blocks ################################################## self._variable_qtgui_range_0_0_range = Range(0, 90, 1, 43, 200) self._variable_qtgui_range_0_0_win = RangeWidget( self._variable_qtgui_range_0_0_range, self.set_variable_qtgui_range_0_0, 'Gain_TX', "counter_slider", float) self.top_grid_layout.addWidget(self._variable_qtgui_range_0_0_win, 0, 2, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.uhd_usrp_sink_0_0 = uhd.usrp_sink( ",".join(("serial=F5EAE1", MCR)), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0_0.set_center_freq(frequencia_usrp, 0) self.uhd_usrp_sink_0_0.set_gain(variable_qtgui_range_0_0, 0) self.uhd_usrp_sink_0_0.set_antenna('TX/RX', 0) self.scrambler_cpp_additive_scrambler_0 = scrambler_cpp.additive_scrambler( 0x8A, 0x7F, 7, 440 - 32) self.qtgui_time_sink_x_1 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "TX USRP", #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) self.qtgui_time_sink_x_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_1.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance( self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win, 1, 3, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 3, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0_0_0 = qtgui.const_sink_c( 1024, #size "TX Const", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_0.set_trigger_mode( qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0_0_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_0_win, 1, 2, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( sps, taps=(tx_rrc_taps), flt_size=nfilts) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.insert_vec_cpp_new_vec_0 = insert_vec_cpp.new_vec((vector)) self.fec_extended_encoder_0 = fec.extended_encoder( encoder_obj_list=pld_enc, threading='capillary', puncpat=puncpat) self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb( pld_const.arity()) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc( (pld_const.points()), 1) self.blocks_vector_source_x_0_0_0 = blocks.vector_source_b([0], True, 1, []) self.blocks_vector_source_x_0_0 = blocks.vector_source_b([0], True, 1, []) self.blocks_stream_mux_0_1_0_0 = blocks.stream_mux( gr.sizeof_char * 1, (96, 1104)) self.blocks_stream_mux_0_0_0 = blocks.stream_mux( gr.sizeof_char * 1, (1100, 4)) self.blocks_stream_mux_0_0 = blocks.stream_mux(gr.sizeof_char * 1, (440, 2)) self.blocks_repack_bits_bb_1_0_0_1 = blocks.repack_bits_bb( 8, 1, '', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_1_0_0_0 = blocks.repack_bits_bb( 1, pld_const.bits_per_symbol(), '', False, gr.GR_MSB_FIRST) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((0.7, )) self.blocks_file_source_0_0_1_0_0_0 = blocks.file_source( gr.sizeof_char * 1, '/home/andre/Desktop/Files_To_Transmit/video_lion.mpeg', False) self.blocks_file_source_0_0_1_0_0_0.set_begin_tag(pmt.PMT_NIL) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 500000) self.acode_1104_0 = blocks.vector_source_b([ 0x1, 0x0, 0x1, 0x0, 0x1, 0x1, 0x0, 0x0, 0x1, 0x1, 0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x0 ], True, 1, []) ################################################## # Connections ################################################## self.connect((self.acode_1104_0, 0), (self.blocks_stream_mux_0_1_0_0, 0)) self.connect((self.blocks_delay_0, 0), (self.qtgui_const_sink_x_0_0_0_0, 0)) self.connect((self.blocks_delay_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_delay_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_delay_0, 0), (self.uhd_usrp_sink_0_0, 0)) self.connect((self.blocks_file_source_0_0_1_0_0_0, 0), (self.blocks_repack_bits_bb_1_0_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_repack_bits_bb_1_0_0_0, 0), (self.insert_vec_cpp_new_vec_0, 0)) self.connect((self.blocks_repack_bits_bb_1_0_0_1, 0), (self.scrambler_cpp_additive_scrambler_0, 0)) self.connect((self.blocks_stream_mux_0_0, 0), (self.fec_extended_encoder_0, 0)) self.connect((self.blocks_stream_mux_0_0_0, 0), (self.blocks_stream_mux_0_1_0_0, 1)) self.connect((self.blocks_stream_mux_0_1_0_0, 0), (self.blocks_repack_bits_bb_1_0_0_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_stream_mux_0_0, 1)) self.connect((self.blocks_vector_source_x_0_0_0, 0), (self.blocks_stream_mux_0_0_0, 1)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.digital_diff_encoder_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.fec_extended_encoder_0, 0), (self.blocks_stream_mux_0_0_0, 0)) self.connect((self.insert_vec_cpp_new_vec_0, 0), (self.digital_diff_encoder_bb_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.scrambler_cpp_additive_scrambler_0, 0), (self.blocks_stream_mux_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samples_per_symbol = samples_per_symbol = 64 self.samp_rate = samp_rate = 32000 self.noise_voltage = noise_voltage = 0 self.interleave = interleave = 4 self.bitrate = bitrate = 9600 ################################################## # Blocks ################################################## self._noise_voltage_range = Range(0, 0.5, 0.01, 0, 200) self._noise_voltage_win = RangeWidget(self._noise_voltage_range, self.set_noise_voltage, "Noise Voltage", "counter_slider", float) self.top_layout.addWidget(self._noise_voltage_win) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0/10) self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(False) 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_layout.addWidget(self._qtgui_number_sink_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [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_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_layout.addWidget(self._qtgui_const_sink_x_0_win) self.gmsk_demodulator_0 = gmsk_demodulator( samples_per_symbol=samples_per_symbol, symbol_rate=samples_per_symbol*bitrate, ) self.digital_gmsk_mod_0 = digital.gmsk_mod( samples_per_symbol=samples_per_symbol, bt=0.5, verbose=False, log=False, ) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise_voltage, frequency_offset=0.0, epsilon=1.0, taps=(1.0 + 1.0j, ), noise_seed=0, block_tags=False ) self.ccsds_encoding_0 = ccsds_encoding( interleave=interleave, ) self.ccsds_decode_0 = ccsds_decode( hamming_distance=0, interleave=interleave, ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_message_debug_0 = blocks.message_debug() self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 1000)), True) ################################################## # Connections ################################################## self.msg_connect((self.ccsds_decode_0, 'out'), (self.blocks_message_debug_0, 'print_pdu')) self.connect((self.analog_random_source_x_0, 0), (self.ccsds_encoding_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.gmsk_demodulator_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.ccsds_encoding_0, 0), (self.digital_gmsk_mod_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_gmsk_mod_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.digital_gmsk_mod_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.gmsk_demodulator_0, 0), (self.ccsds_decode_0, 0)) self.connect((self.gmsk_demodulator_0, 1), (self.qtgui_const_sink_x_0, 0))