def get_constellation_from_string(self, const_string): self.const = { 'bpsk': digital.constellation_bpsk().base(), 'qpsk': digital.constellation_qpsk().base(), '8psk': digital.constellation_8psk().base(), '16qam': digital.constellation_16qam().base() }.get(const_string, digital.constellation_bpsk().base())
def test_qam16_channel(self): upper_bound = tuple(50.0 * numpy.ones((self.num_data, ))) lower_bound = tuple(0.0 * numpy.zeros((self.num_data, ))) self.cons = cons = digital.constellation_16qam().base() self.data = data = [ random.randrange(len(cons.points())) for x in range(self.num_data) ] self.symbols = symbols = numpy.squeeze( [cons.map_to_points_v(i) for i in data]) chan = channels.channel_model(noise_voltage=0.1, frequency_offset=0.0, epsilon=1.0, taps=[1.0 + 0.0j], noise_seed=0, block_tags=False) evm = digital.meas_evm_cc(cons, digital.evm_measurement_t_EVM_PERCENT) vso = blocks.vector_source_c(symbols, False, 1, []) mc = blocks.multiply_const_cc(3.0 + 2.0j) vsi = blocks.vector_sink_f() self.tb.connect(vso, chan, evm, vsi) self.tb.run() # check data output_data = vsi.data() self.assertLess(output_data, upper_bound) self.assertGreater(output_data, lower_bound)
def __init__(self, snr_db_ae = 15, signal_len = 1024, samp_rate = 100000, samples = 1000, const_index = 3): gr.top_block.__init__(self, "Eve Sim") ################################################## # Variables ################################################## self.const_qpsk = const_qpsk = digital.constellation_qpsk().base() self.const_bpsk = const_bpsk = digital.constellation_bpsk().base() self.const_8psk = const_8psk = digital.constellation_8psk().base() self.const_16qam = const_16qam = digital.constellation_16qam().base() self.snr_db_ae = snr_db_ae # = 15 self.signal_len = signal_len # = 1024 self.samp_rate = samp_rate # = 100000 self.constellations = constellations = [const_bpsk, const_qpsk, const_8psk, const_16qam] self.const_index = const_index ################################################## # Blocks ################################################## self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((constellations[const_index].points()), 1) self.classify_trained_model_classifier_vc_0 = classify.trained_model_classifier_vc(64, '/home/gvanhoy/gr-classify/apps/cumulant_classifier.pkl') self.channels_channel_model_0_0 = channels.channel_model( noise_voltage=numpy.sqrt(10.0**(-snr_db_ae/10.0)/2), frequency_offset=0.0, epsilon=1.0, taps=(1.0, ), noise_seed=0, block_tags=False ) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 64) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(8, int(np.log2(constellations[const_index].arity())), "", False, gr.GR_MSB_FIRST) self.blocks_head_1 = blocks.head(gr.sizeof_gr_complex*64, samples) #message block to pull messages out of 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.classify_trained_model_classifier_vc_0, 'classification_info'), (self.blocks_message_debug_0, 'print')) self.msg_connect((self.classify_trained_model_classifier_vc_0, 'classification_info'), (self.blocks_message_debug_0, 'store')) self.connect((self.analog_random_source_x_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) #self.connect((self.blocks_stream_to_vector_0, 0), (self.classify_trained_model_classifier_vc_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.blocks_head_1, 0)) self.connect((self.blocks_head_1, 0), (self.classify_trained_model_classifier_vc_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.channels_channel_model_0_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.channels_channel_model_0_0, 0))
def __init__(self): constellation_source.__init__(self, mod_name="16pam", samp_per_sym=2, excess_bw=.35) self.const = digital.constellation_16qam().base() self.pack = blocks.packed_to_unpacked_bb(self.const.bits_per_symbol(), gr.GR_MSB_FIRST) self.map = digital.chunks_to_symbols_bc((self.const.points()), 1) self.connect(self.random_source, self.pack, self.map, self.rrc_filter, self)
def get_constellation_from_string(self, const_string): self.const = { 'ook': constellations.constellation_ook(), 'bpsk': digital.constellation_bpsk().base(), 'qpsk': digital.constellation_qpsk().base(), '4ask': constellations.constellation_4_ask(), '8psk': digital.constellation_8psk().base(), '8qam_cross': constellations.constellation_8qam_cross(), '8qam_circular': constellations.constellation_8qam_circular(), '16qam': digital.constellation_16qam().base(), '16psk': constellations.constellation_16_psk(), '32qam_cross': constellations.constellation_32qam_cross(), '64qam': constellations.constellation_64qam(), }.get(const_string, digital.constellation_bpsk().base())
def __init__(self, fc=436e6, mx=4, my=4, n=2, phi_2=41, theta_2=75): gr.top_block.__init__(self, "Eigenvalues Grabber") Qt.QWidget.__init__(self) self.setWindowTitle("Eigenvalues Grabber") 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", "eigenvalues_grabber") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Parameters ################################################## self.fc = fc self.mx = mx self.my = my self.n = n self.phi_2 = phi_2 self.theta_2 = theta_2 ################################################## # Variables ################################################## self.const_2 = const_2 = digital.constellation_16qam().base() self.const_1 = const_1 = digital.constellation_qpsk().base() self.theta_1 = theta_1 = 45 self.samp_rate = samp_rate = 150000 self.phi_1 = phi_1 = 70 self.noise_voltage_2 = noise_voltage_2 = 0.05 self.noise_voltage_1 = noise_voltage_1 = 0.05 self.element_separation = element_separation = 0 self.bps_2 = bps_2 = const_2.bits_per_symbol() self.bps_1 = bps_1 = const_1.bits_per_symbol() ################################################## # Blocks ################################################## self._theta_1_range = Range(0, 90, 1, 45, 200) self._theta_1_win = RangeWidget(self._theta_1_range, self.set_theta_1, 'Elevation Angle', "counter_slider", float) self.top_grid_layout.addWidget(self._theta_1_win, 0, 0, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._phi_1_range = Range(-180, 180, 1, 70, 200) self._phi_1_win = RangeWidget(self._phi_1_range, self.set_phi_1, 'Azimut Angle', "counter_slider", float) self.top_grid_layout.addWidget(self._phi_1_win, 1, 0, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._noise_voltage_2_range = Range(0, 10, 0.001, 0.05, 200) self._noise_voltage_2_win = RangeWidget(self._noise_voltage_2_range, self.set_noise_voltage_2, 'Noise Voltage 2', "counter_slider", float) self.top_grid_layout.addWidget(self._noise_voltage_2_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._noise_voltage_1_range = Range(0, 10, 0.001, 0.05, 200) self._noise_voltage_1_win = RangeWidget(self._noise_voltage_1_range, self.set_noise_voltage_1, 'Noise Voltage 1', "counter_slider", float) self.top_grid_layout.addWidget(self._noise_voltage_1_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._element_separation_range = Range(0, 10, 0.01, 0, 200) self._element_separation_win = RangeWidget( self._element_separation_range, self.set_element_separation, 'Element separation distance [%', "counter_slider", float) self.top_grid_layout.addWidget(self._element_separation_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.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-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) 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_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, 5, 1, 1, 1) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] 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, 5, 0, 1, 1) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.digital_constellation_decoder_cb_0_0 = digital.constellation_decoder_cb( const_2.base()) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( const_1.base()) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc( const_2.points(), 1) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( const_1.points(), 1) self.blocks_unpacked_to_packed_xx_0_0 = blocks.unpacked_to_packed_bb( bps_2, gr.GR_MSB_FIRST) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb( bps_1, gr.GR_MSB_FIRST) 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_packed_to_unpacked_xx_0_0 = blocks.packed_to_unpacked_bb( bps_2, gr.GR_MSB_FIRST) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( bps_1, gr.GR_MSB_FIRST) self.blocks_file_sink_0_0_0 = blocks.file_sink( gr.sizeof_char * 1, '/home/grigosback/Documents/GNURadio/examples/sink2.txt', False) self.blocks_file_sink_0_0_0.set_unbuffered(False) self.blocks_file_sink_0_0 = blocks.file_sink( gr.sizeof_char * 1, '/home/grigosback/Documents/GNURadio/examples/sink1.txt', False) self.blocks_file_sink_0_0.set_unbuffered(False) self.blocks_add_xx_1 = blocks.add_vcc(mx * my) self.blocks_add_xx_0_0 = blocks.add_vcc(mx * my) self.blocks_add_xx_0 = blocks.add_vcc(mx * my) self.beamforming_randomsampler_0 = beamforming.randomsampler( mx * my, 8) self.beamforming_phasedarray_0_0 = beamforming.phasedarray( mx, my, theta_2, phi_2, 436e6, (299792458 / (2 * fc)), element_separation) self.beamforming_phasedarray_0 = beamforming.phasedarray( mx, my, theta_1, phi_1, 436e6, (299792458 / (2 * fc)), element_separation) self.beamforming_doaesprit_py_cf_0 = beamforming.doaesprit_py_cf( mx, my, fc, (299792458 / (2 * fc)), n, 128) self.beamforming_beamformer_0_0 = beamforming.beamformer(mx, my, 1) self.beamforming_beamformer_0 = beamforming.beamformer(mx, my, 0) self.analog_vectornoise_source_0_0 = analog.vectornoise_source( noise_voltage_2, mx * my) self.analog_vectornoise_source_0 = analog.vectornoise_source( noise_voltage_1, mx * my) self.analog_random_source_x_0_0 = blocks.vector_source_b( list(map(int, numpy.random.randint(0, 256, 100))), True) self.analog_random_source_x_0 = blocks.vector_source_b( list(map(int, numpy.random.randint(0, 256, 1000))), True) ################################################## # Connections ################################################## self.msg_connect((self.beamforming_doaesprit_py_cf_0, 'doa_port'), (self.beamforming_beamformer_0, 'doa_port')) self.msg_connect((self.beamforming_doaesprit_py_cf_0, 'doa_port'), (self.beamforming_beamformer_0_0, 'doa_port')) self.connect((self.analog_random_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.analog_random_source_x_0_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.analog_vectornoise_source_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_vectornoise_source_0_0, 0), (self.blocks_add_xx_0_0, 1)) self.connect((self.beamforming_beamformer_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.beamforming_beamformer_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.beamforming_beamformer_0_0, 0), (self.digital_constellation_decoder_cb_0_0, 0)) self.connect((self.beamforming_beamformer_0_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.beamforming_phasedarray_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.beamforming_phasedarray_0_0, 0), (self.blocks_add_xx_0_0, 0)) self.connect((self.beamforming_randomsampler_0, 0), (self.beamforming_doaesprit_py_cf_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.blocks_add_xx_1, 0), (self.beamforming_beamformer_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.beamforming_beamformer_0_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.beamforming_randomsampler_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.blocks_packed_to_unpacked_xx_0_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0_0, 0), (self.blocks_file_sink_0_0_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.beamforming_phasedarray_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.beamforming_phasedarray_0_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.digital_constellation_decoder_cb_0_0, 0), (self.blocks_unpacked_to_packed_xx_0_0, 0))
def __init__(self): 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()) ################################################## # Variables ################################################## self.const_qpsk = const_qpsk = digital.constellation_qpsk().base() self.const_bpsk = const_bpsk = digital.constellation_bpsk().base() self.const_8psk = const_8psk = digital.constellation_8psk().base() self.const_16qam = const_16qam = digital.constellation_16qam().base() self.snr_db_ae = snr_db_ae = 10 self.snr_db_ab = snr_db_ab = 10 self.signal_len = signal_len = 1024 self.samp_rate = samp_rate = 100000 self.constellations = constellations = [ const_bpsk, const_qpsk, const_8psk, const_16qam ] self.const_index = const_index = 3 self.ab_mute = ab_mute = False ################################################## # Blocks ################################################## self._snr_db_ae_range = Range(-10, 15, 1, 10, 200) self._snr_db_ae_win = RangeWidget(self._snr_db_ae_range, self.set_snr_db_ae, "snr_db_ae", "counter_slider", float) self.top_layout.addWidget(self._snr_db_ae_win) self._snr_db_ab_range = Range(-10, 15, 1, 10, 200) self._snr_db_ab_win = RangeWidget(self._snr_db_ab_range, self.set_snr_db_ab, "snr_db_ab", "counter_slider", float) self.top_layout.addWidget(self._snr_db_ab_win) self._const_index_options = ( 0, 1, 2, 3, ) self._const_index_labels = ( 'BPSK', 'QPSK', '8PSK', '16QAM', ) self._const_index_group_box = Qt.QGroupBox('Constellation') self._const_index_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._const_index_button_group = variable_chooser_button_group() self._const_index_group_box.setLayout(self._const_index_box) for i, label in enumerate(self._const_index_labels): radio_button = Qt.QRadioButton(label) self._const_index_box.addWidget(radio_button) self._const_index_button_group.addButton(radio_button, i) self._const_index_callback = lambda i: Qt.QMetaObject.invokeMethod( self._const_index_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._const_index_options.index(i))) self._const_index_callback(self.const_index) self._const_index_button_group.buttonClicked[int].connect( lambda i: self.set_const_index(self._const_index_options[i])) self.top_layout.addWidget(self._const_index_group_box) self._ab_mute_options = ( False, True, ) self._ab_mute_labels = ( "Don't Block", 'Block', ) self._ab_mute_group_box = Qt.QGroupBox('Mute AB Output') self._ab_mute_box = Qt.QVBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._ab_mute_button_group = variable_chooser_button_group() self._ab_mute_group_box.setLayout(self._ab_mute_box) for i, label in enumerate(self._ab_mute_labels): radio_button = Qt.QRadioButton(label) self._ab_mute_box.addWidget(radio_button) self._ab_mute_button_group.addButton(radio_button, i) self._ab_mute_callback = lambda i: Qt.QMetaObject.invokeMethod( self._ab_mute_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._ab_mute_options.index(i))) self._ab_mute_callback(self.ab_mute) self._ab_mute_button_group.buttonClicked[int].connect( lambda i: self.set_ab_mute(self._ab_mute_options[i])) self.top_layout.addWidget(self._ab_mute_group_box) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-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_layout.addWidget(self._qtgui_const_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.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_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (constellations[const_index].points()), 1) self.classify_trained_model_classifier_vc_0 = classify.trained_model_classifier_vc( 64, '/home/gvanhoy/gr-classify/apps/cumulant_classifier.pkl') self.channels_channel_model_0_0 = channels.channel_model( noise_voltage=numpy.sqrt(10.0**(-snr_db_ae / 10.0) / 2), frequency_offset=0.0, epsilon=1.0, taps=(1.0, ), noise_seed=0, block_tags=False) self.channels_channel_model_0 = channels.channel_model( noise_voltage=numpy.sqrt(10.0**(-snr_db_ab / 10.0) / 2), frequency_offset=0.0, epsilon=1.0, taps=(1.0, ), noise_seed=0, block_tags=False) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, 64) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( 8, int(np.log2(constellations[const_index].arity())), "", False, gr.GR_MSB_FIRST) self.blocks_mute_xx_0 = blocks.mute_cc(bool(ab_mute)) 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.classify_trained_model_classifier_vc_0, 'classification_info'), (self.blocks_message_debug_0, 'print')) self.connect((self.analog_random_source_x_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.blocks_mute_xx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.classify_trained_model_classifier_vc_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_mute_xx_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.channels_channel_model_0_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.channels_channel_model_0_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.fft_len = fft_len = 64 self.vec_len = vec_len = 63 self.variable_constellation_rect_0 = variable_constellation_rect_0 = digital.constellation_rect(([-1-1j, -1+1j, 1+1j, 1-1j]), ([0, 1, 3, 2]), 4, 2, 2, 1, 1).base() self.short_field_preamble = short_field_preamble = [(0,0), (0,0), (0,0), (0,0), (0, 0), (0, 0), (0, 0), (0, 0), (1.472,1.472j), (0, 0), (0, 0), (0, 0), (-1.472,-1.472j), (0, 0), (0, 0), (0, 0), (1.472,1.472j), (0, 0), (0, 0), (0, 0), (-1.472,-1.472j), (0, 0), (0, 0), (0, 0), (-1.472,-1.472j), (0, 0), (0, 0), (0, 0), (1.472,1.472j), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (-1.472,-1.472j), (0, 0), (0, 0), (0, 0), (-1.472,-1.472j), (0, 0), (0, 0), (0, 0), (1.472,1.472j), (0, 0), (0, 0), (0, 0), (1.472,1.472j), (0, 0), (0, 0), (0, 0), (1.472,1.472j), (0, 0), (0, 0), (0, 0), (1.472,1.472j), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0)] self.short_field_obj = short_field_obj = struct({'sequence': np.array([1,-1,1,-1,-1,1,-1,-1,1,1,1,1] ,dtype=np.complex64) * complex(1,1) * 1.472, 'subcarriers': ([-24,-20,-16,-12,-8,-4,4,8,12,16,20,24],), 'periodicExtendTo': 161, }) self.samp_rate = samp_rate = 32e3 self.ofdm_params = ofdm_params = struct({'bandwidth': 20, 'dataRate': 6, 'ncbpsc': 4, 'ncbps': 192, 'ndbps': 144, 'rate': 3.0/4.0, 'rateCode': 'idk', 'modulationType': "16qam", }) self.long_field_obj = long_field_obj = struct({'sequence': np.array([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],dtype=np.complex64), 'subcarriers': (range(-26,0) + range(1,27),), 'cyclicPrefixLen': fft_len/4, 'periodicExtendTo': 161, }) self.fft_len_0 = fft_len_0 = 64 self.conv_wifi_coder = conv_wifi_coder = fec.cc_encoder_make(864, 7, 2, ([0133,0171]), 0, fec.CC_STREAMING, False) self.constellation = constellation = digital.constellation_16qam().base() self.a1 = a1 = satcom_gmu.utils.OFDM_Params() ################################################## # Blocks ################################################## self.satcom_gmu_wifi_scrambler_0 = satcom_gmu.wifi_scrambler("1011101") self.satcom_gmu_data_formatter_0 = satcom_gmu.data_formatter(ofdm_params) self.satcom_gmu_conv_coder_0 = satcom_gmu.conv_coder() self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) 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.ofdm_wifi_preamble_0 = ofdm_wifi_preamble() self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_char*1, 'Packet Length', "packet_len"); self.blocks_tag_debug_0.set_display(True) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(8, 1, "", False, gr.GR_LSB_FIRST) self.blocks_null_sink_2 = blocks.null_sink(gr.sizeof_char*1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_message_strobe_0 = blocks.message_strobe(a1.vec_test(), 5000) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.ofdm_wifi_preamble_0, 'data_in')) self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.satcom_gmu_data_formatter_0, 'MPDU')) self.connect((self.blocks_repack_bits_bb_0, 0), (self.satcom_gmu_wifi_scrambler_0, 0)) self.connect((self.ofdm_wifi_preamble_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.ofdm_wifi_preamble_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.satcom_gmu_conv_coder_0, 0), (self.blocks_null_sink_2, 0)) self.connect((self.satcom_gmu_conv_coder_0, 0), (self.blocks_tag_debug_0, 0)) self.connect((self.satcom_gmu_data_formatter_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.satcom_gmu_wifi_scrambler_0, 0), (self.satcom_gmu_conv_coder_0, 0))
def __init__(self): gr.top_block.__init__(self, "Pam Sync") Qt.QWidget.__init__(self) self.setWindowTitle("Pam Sync") 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", "pam_sync") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.spb = spb = 4.0 self.rolloff = rolloff = 0.35 self.nfilts = nfilts = 32 self.time_bw = time_bw = 0 self.sig_amp = sig_amp = 1.0 self.samp_rate = samp_rate = 128000 self.rrctaps = rrctaps = firdes.root_raised_cosine( nfilts, 1.0, 1.0 / (nfilts * spb), rolloff, int(11 * spb * nfilts)) self.phase_bw = phase_bw = 0 self.noise_amp = noise_amp = 0 self.interpratio = interpratio = 1 self.freq_offset = freq_offset = 0 self.freq_bw = freq_bw = 0 self.const = const = digital.constellation_16qam().base() ################################################## # Blocks ################################################## self._time_bw_range = Range(0, .1, .001, 0, 200) self._time_bw_win = RangeWidget(self._time_bw_range, self.set_time_bw, 'Timing Loop BW', "counter_slider", float) self.top_grid_layout.addWidget(self._time_bw_win, 5, 2, 1, 1) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) 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, 'Synched Signal') 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, 'Received Signal') self.top_grid_layout.addWidget(self.notebook, 1, 1, 8, 1) for r in range(1, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._noise_amp_range = Range(0, 1, .001, 0, 200) self._noise_amp_win = RangeWidget(self._noise_amp_range, self.set_noise_amp, 'Channel Noise', "counter_slider", float) self.top_grid_layout.addWidget(self._noise_amp_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._interpratio_range = Range(.99, 1.01, 0.0001, 1, 200) self._interpratio_win = RangeWidget(self._interpratio_range, self.set_interpratio, 'Timing Offset', "counter_slider", float) self.top_grid_layout.addWidget(self._interpratio_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._freq_offset_range = Range(-.5, .5, .01, 0, 200) self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, 'Frequency Offset', "counter_slider", float) self.top_grid_layout.addWidget(self._freq_offset_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._freq_bw_range = Range(0, .05, .001, 0, 200) self._freq_bw_win = RangeWidget(self._freq_bw_range, self.set_freq_bw, 'FLL Bandwidth', "counter_slider", float) self.top_grid_layout.addWidget(self._freq_bw_win, 4, 2, 1, 1) for r in range(4, 5): 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_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate 'Pre-sync Signal', #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) 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.notebook_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate 'Post-sync 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, 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) 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.notebook_grid_layout_0.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw 'Received Spectrum', #name 1 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(True) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(0.2) 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.notebook_grid_layout_1.addWidget(self._qtgui_freq_sink_x_1_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw 'Post-sync Spectrum', #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(True) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(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.notebook_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win) self._phase_bw_range = Range(0, .1, .001, 0, 200) self._phase_bw_win = RangeWidget(self._phase_bw_range, self.set_phase_bw, 'Costas Loop (Phase) Bandwidth', "counter_slider", float) self.top_grid_layout.addWidget(self._phase_bw_win, 7, 2, 1, 1) for r in range(7, 8): 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( spb, taps=(firdes.root_raised_cosine(nfilts, 1.0, 1.0 / nfilts, rolloff, int(11 * spb * nfilts))), flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( spb, time_bw, (rrctaps), nfilts, 16, 1.5, 1) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc( spb, rolloff, 44, freq_bw) self.digital_chunks_to_symbols_xx = digital.chunks_to_symbols_bc( (const.points()), 1) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise_amp, frequency_offset=freq_offset, epsilon=interpratio, taps=(1.0, ), noise_seed=42, 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( (sig_amp, )) self.analog_random_source_x = blocks.vector_source_b( map(int, numpy.random.randint(0, const.arity(), 10000000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x, 0), (self.digital_chunks_to_symbols_xx, 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_fll_band_edge_cc_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.digital_chunks_to_symbols_xx, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
bits_per_header=(symbols_per_header+1)*header_mod.bits_per_symbol() symbols_per_header = bits_per_header/header_mod.bits_per_symbol() #header_formatter = cdma.packet_header(bits_per_header,length_tag_name,num_tag_name,header_mod.bits_per_symbol()); #header_formatter = digital.packet_header_default(bits_per_header, length_tag_name,num_tag_name,header_mod.bits_per_symbol()); #tcm_indicator_symbols_per_frame=4; #Zhe added, 4 bits are used as tcm mode indicator, it is used as a part of header. # Achilles' comment: this may change later when filler bits are introduced... print "bits_per_header=",bits_per_header print "symbols_per_header=",symbols_per_header #print "tcm_indicator_symbols_per_frame=",tcm_indicator_symbols_per_frame print "\n" #trellis coding and modulation info payload_mod = [digital.constellation_qpsk(),digital.constellation_8psk(),digital.constellation_16qam()] pdir=prefix+"/python/fsm_files/" fsm=[pdir+"awgn2o2_1.fsm", pdir+"awgn2o3_8ungerboecka.fsm",pdir+"awgn2o4_8_ungerboeckc.fsm"] uncoded_fsm=[trellis.fsm(2,2,[1,0,0,1]),trellis.fsm(3,3,[1,0,0,0,1,0,0,0,1]),trellis.fsm(4,4,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])] bits_per_coded_symbol=[int(math.log(trellis.fsm(fsm[i]).O(),2)) for i in range(len(payload_mod))] #coding_rate=[Fraction(int(math.log(trellis.fsm(fsm[i]).I(),2)), int(math.log(trellis.fsm(fsm[i]).O(),2))) for i in range(len(fsm))] if bits_per_coded_symbol!=[payload_mod[i].bits_per_symbol() for i in range(len(payload_mod))]: print "Error in selecting trellis code and modulation pairs." print "bits_per_coded_symbol =", bits_per_coded_symbol, " for [uncoded QPSK, rate 2/3 cc &8PSK, rate 2/4 cc &16QAM] respectively.\n" #print "coding rates for trellis codes =", coding_rate, " for [uncoded QPSK, rate 2/3 cc &8PSK, rate 2/4 cc &16QAM] respectively.\n"
def __init__(self): gr.top_block.__init__(self, "Z Ofdm Multiusuario") Qt.QWidget.__init__(self) self.setWindowTitle("Z Ofdm Multiusuario") 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", "z_OFDM_Multiusuario") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 4000 self.run_stop = run_stop = True self.f = f = 1000 self.Rs = Rs = samp_rate self.N = N = 32 self.Constelacion4 = Constelacion4 = digital.constellation_16qam( ).points() ################################################## # Blocks ################################################## _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.iteritems()) 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) self.qtgui_number_sink_0_2 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0_2.set_update_time(0.10) self.qtgui_number_sink_0_2.set_title("Pontencia dB") labels = ["Pr", "", "", "", "", "", "", "", "", ""] units = ["dB", "", "", "", "", "", "", "", "", ""] colors = [("blue", "red"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_2.set_min(i, -50) self.qtgui_number_sink_0_2.set_max(i, 20) self.qtgui_number_sink_0_2.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_2.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_2.set_label(i, labels[i]) self.qtgui_number_sink_0_2.set_unit(i, units[i]) self.qtgui_number_sink_0_2.set_factor(i, factor[i]) self.qtgui_number_sink_0_2.enable_autoscale(False) self._qtgui_number_sink_0_2_win = sip.wrapinstance( self.qtgui_number_sink_0_2.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_2_win, 1, 0) self.qtgui_number_sink_0_1_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0_1_0.set_update_time(0.10) self.qtgui_number_sink_0_1_0.set_title("Pontencia") labels = ["Pr", "", "", "", "", "", "", "", "", ""] units = ["Watts", "", "", "", "", "", "", "", "", ""] colors = [("blue", "red"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_1_0.set_min(i, -50) self.qtgui_number_sink_0_1_0.set_max(i, 20) self.qtgui_number_sink_0_1_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_1_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_1_0.set_label(i, labels[i]) self.qtgui_number_sink_0_1_0.set_unit(i, units[i]) self.qtgui_number_sink_0_1_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_1_0.enable_autoscale(False) self._qtgui_number_sink_0_1_0_win = sip.wrapinstance( self.qtgui_number_sink_0_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_1_0_win, 2, 0) self.qtgui_number_sink_0_0_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0_0.set_title("Valor RMS") labels = ["VRMS", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("blue", "red"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_0_0.set_min(i, -50) self.qtgui_number_sink_0_0_0.set_max(i, 20) self.qtgui_number_sink_0_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_win, 0, 0) self._f_range = Range(0, samp_rate * 4, samp_rate / N, 1000, 200) self._f_win = RangeWidget(self._f_range, self.set_f, "frecuencia", "counter_slider", float) self.top_grid_layout.addWidget(self._f_win, 1, 0, 1, 1) self.b_meter_power_cc_0 = b_meter_power_cc(G_prom=0.0001, ) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.b_meter_power_cc_0, 0)) self.connect((self.b_meter_power_cc_0, 2), (self.qtgui_number_sink_0_0_0, 0)) self.connect((self.b_meter_power_cc_0, 0), (self.qtgui_number_sink_0_1_0, 0)) self.connect((self.b_meter_power_cc_0, 1), (self.qtgui_number_sink_0_2, 0))
def __init__(self): gr.top_block.__init__(self, "OFDM Tx") Qt.QWidget.__init__(self) self.setWindowTitle("OFDM Tx") 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_ofdm") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.occupied_carriers = occupied_carriers = ( range(-61, -42) + range(-41, -14) + range(-13, -7) + range(-6, 0) + range(1, 7) + range(7, 14) + range(15, 42) + range(43, 62), ) self.length_tag_key = length_tag_key = "packet_len" self.sync_word1 = sync_word1 = [ (0.7071 - 0.7071j), (-0.7071 + 0.7071j), (0.7071 + 0.7071j), (-0.7071 - 0.7071j), (-0.7071 + 0.7071j), (0.7071 + -0.7071j), (0.7071 + 0.7071j), (-0.7071 + 0.7071j), (-0.7071 - 0.7071j), (-0.7071 + 0.7071j), (0.7071 + 0.7071j), (-0.7071 + 0.7071j), (-0.7071 - 0.7071j), (-0.7071 + 0.7071j), (0.7071 + 0.7071j), (0.7071 + 0.7071j), (0.7071 - 0.7071j), (0.7071 + 0.7071j), (-0.7071 + 0.7071j), (-0.7071 - 0.7071j), (-0.7071 + 0.7071j), (-0.7071 - 0.7071j), (0.7071 - 0.7071j), (-0.7071 - 0.7071j), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ] self.samp_rate = samp_rate = 100000 self.rolloff = rolloff = 0 self.pilot_symbols = pilot_symbols = (( (-1 + 1j), (1 - 1j), (-1 + 1j), (-1 - 1j), ), ) self.pilot_carriers = pilot_carriers = (( -42, -14, 14, 42, ), ) self.payload_mod = payload_mod = digital.constellation_16qam() self.packet_len = packet_len = 144 self.header_mod = header_mod = digital.constellation_bpsk() self.hdr_format = hdr_format = digital.header_format_ofdm( occupied_carriers, 1, length_tag_key, ) self.fft_len = fft_len = 128 self.ctr_freq = ctr_freq = 1.8e9 ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("serial=30AD372", "")), 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(ctr_freq, 0) self.uhd_usrp_sink_0.set_gain(50, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.uhd_usrp_sink_0.set_bandwidth(20e6, 0) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate 'Scope Plot', #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(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 = ['Scope Plot', '', '', '', '', '', '', '', '', ''] 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 ctr_freq, #fc samp_rate, #bw 'FFT Plot', #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(True) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.fft_vxx_0 = fft.fft_vcc(fft_len, False, (()), True, 1) self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb( hdr_format, length_tag_key) self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer( fft_len, fft_len + fft_len / 4, rolloff, length_tag_key) self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (sync_word1, ), length_tag_key) self.digital_crc32_bb_0 = digital.crc32_bb(False, length_tag_key, True) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc( (payload_mod.points()), 1) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (header_mod.points()), 1) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_gr_complex * 1, length_tag_key, 0) self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, packet_len, length_tag_key) self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb( 8, 1, length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( 8, payload_mod.bits_per_symbol(), length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.05, )) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 255, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_crc32_bb_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_ofdm_carrier_allocator_cvc_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.digital_crc32_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.digital_protocol_formatter_bb_0, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0), (self.fft_vxx_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0))
bits_per_header=(symbols_per_header+1)*header_mod.bits_per_symbol() symbols_per_header = bits_per_header/header_mod.bits_per_symbol() tcm_type_selector_default = 0 local_header_obj = cdma.packet_header2(bits_per_header,length_tag_name,num_tag_name, header_mod.bits_per_symbol(),tcm_type_selector_default, "tcm_type") #tcm_indicator_symbols_per_frame=4; #Zhe added, 4 bits are used as tcm mode indicator, it is used as a part of header. # Achilles' comment: this may change later when filler bits are introduced... #print "bits_per_header=",bits_per_header #print "symbols_per_header=",symbols_per_header #print "tcm_indicator_symbols_per_frame=",tcm_indicator_symbols_per_frame #print "\n" #========================================== #trellis coding and modulation info modulation_names=["uncoded QPSK", "rate 2/3 cc &8PSK", "rate 2/4 cc &16QAM"] payload_mod = [digital.constellation_qpsk(),digital.constellation_8psk(),digital.constellation_16qam()] pdir=prefix+"/python/fsm_files/" fsm=[pdir+"awgn2o2_1.fsm", pdir+"awgn2o3_8ungerboecka.fsm",pdir+"awgn2o4_8_ungerboeckc.fsm"] uncoded_fsm=[trellis.fsm(2,2,[1,0,0,1]),trellis.fsm(3,3,[1,0,0,0,1,0,0,0,1]),trellis.fsm(4,4,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])] bits_per_coded_symbol=[int(math.log(trellis.fsm(fsm[i]).O(),2)) for i in range(len(payload_mod))] coding_rate=[Fraction(int(math.log(trellis.fsm(fsm[i]).I(),2)), int(math.log(trellis.fsm(fsm[i]).O(),2))) for i in range(len(fsm))] if bits_per_coded_symbol!=[payload_mod[i].bits_per_symbol() for i in range(len(payload_mod))]: print "Error in selecting trellis code and modulation pairs." #print "bits_per_coded_symbol =", bits_per_coded_symbol, " for ", modulation_names, " respectively.\n" #print "coding rates for trellis codes =", coding_rate, " for ", modulation_names, " respectively.\n"
def __init__(self): gr.top_block.__init__(self, "Random Fec Fam") ################################################## # Variables ################################################## self.rate = rate = 2 self.polys = polys = [109, 79] self.k = k = 7 self.frame_size = frame_size = 500 self.Np = Np = 32 self.snr_db = snr_db = 10 self.samp_rate = samp_rate = 100000 self.puncpat = puncpat = '11' self.enc_cc = enc_cc = fec.cc_encoder_make(frame_size*8, k, rate, (polys), 0, fec.CC_TERMINATED, False) self.const = const = digital.constellation_16qam().base() self.P = P = 256 self.L = L = Np/4 ################################################## # Blocks ################################################## self.specest_cyclo_fam_0 = specest.cyclo_fam(Np, P, Np/4) self.random = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 10000)), True) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(4, (firdes.low_pass_2(1, 1, 1/8.0, 1/16.0, 80))) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.fec_extended_encoder_0_0_0 = fec.extended_encoder(encoder_obj_list=enc_cc, threading= None, puncpat=puncpat) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((const.points()), 1) self.channels_channel_model_0 = channels.channel_model( noise_voltage=10.0**(-snr_db/20.0), frequency_offset=0.0, epsilon=1.0, taps=(1.0, ), noise_seed=0, block_tags=False ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(1, int(np.log2(const.arity())), "", False, gr.GR_MSB_FIRST) self.blocks_null_source_0 = blocks.null_source(gr.sizeof_float*1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*2*Np) self.blocks_multiply_xx_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.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, samp_rate/4, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.specest_cyclo_fam_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_null_source_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.fec_extended_encoder_0_0_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.random, 0), (self.fec_extended_encoder_0_0_0, 0)) self.connect((self.specest_cyclo_fam_0, 0), (self.blocks_null_sink_0, 0))
from gnuradio import channels from gnuradio import digital from gnuradio import gr from gnuradio import filter import numpy samp_rate_base = int(1e6) sps = 10 bps = 4 upsamp_rate = int(10e6) noise_amplitude = 0.01 signal_amp = 1 freq = [0, -2.5e6, 2.5e6] constellation_variable = digital.constellation_16qam().base() for snr in [0, 10, 20, 30, 40]: for file_num in xrange(1, 101): freq = numpy.random.permutation([0, -2.5e6, 2.5e6]) snr_new = numpy.random.permutation([snr - 5, snr + 5]) source_A = blocks.vector_source_b( map(int, numpy.random.randint(0, 255, 1000000)), True) source_B = blocks.vector_source_b( map(int, numpy.random.randint(0, 255, 1000000)), True) #source_C = blocks.vector_source_b(map(int, numpy.random.randint(0, 255, 1000000)), True) #source_D = blocks.vector_source_b(map(int, numpy.random.randint(0, 255, 1000000)), True) #source_E = blocks.vector_source_b(map(int, numpy.random.randint(0, 255, 1000000)), True)
def __init__( self, const_1_name="BPSK", const_2_name="QPSK", element_separation=0, file_name="eigenvalues5.csv", noise_voltage_1=0, noise_voltage_2=0, phi_1=70, phi_2=41, theta_1=45, theta_2=75, ): gr.top_block.__init__(self, "Eigenvalues Grabber") ################################################## # Parameters ################################################## self.const_1_name = const_1_name self.const_2_name = const_2_name self.element_separation = element_separation self.file_name = file_name self.noise_voltage_1 = noise_voltage_1 self.noise_voltage_2 = noise_voltage_2 self.phi_1 = phi_1 self.phi_2 = phi_2 self.theta_1 = theta_1 self.theta_2 = theta_2 ################################################## # Variables ################################################## if const_1_name == "bpsk": self.const_1 = const_1 = digital.constellation_bpsk().base() elif const_1_name == "qpsk": self.const_1 = const_1 = digital.constellation_qpsk().base() elif const_1_name == "dqpsk": self.const_1 = const_1 = digital.constellation_dqpsk().base() elif const_1_name == "8psk": self.const_1 = const_1 = digital.constellation_8psk().base() elif const_1_name == "16qam": self.const_1 = const_1 = digital.constellation_16qam().base() if const_2_name == "bpsk": self.const_2 = const_2 = digital.constellation_bpsk().base() elif const_2_name == "qpsk": self.const_2 = const_2 = digital.constellation_qpsk().base() elif const_2_name == "dqpsk": self.const_2 = const_2 = digital.constellation_dqpsk().base() elif const_2_name == "8psk": self.const_2 = const_2 = digital.constellation_8psk().base() elif const_2_name == "16qam": self.const_2 = const_2 = digital.constellation_16qam().base() self.samp_rate = samp_rate = 150000 self.n = n = 2 self.my = my = 4 self.mx = mx = 4 self.fc = fc = 436e6 self.bps_2 = bps_2 = const_2.bits_per_symbol() self.bps_1 = bps_1 = const_1.bits_per_symbol() ################################################## # Blocks ################################################## self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc( const_2.points(), 1 ) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( const_1.points(), 1 ) 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_packed_to_unpacked_xx_0_0 = blocks.packed_to_unpacked_bb( bps_2, gr.GR_MSB_FIRST ) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( bps_1, gr.GR_MSB_FIRST ) self.blocks_add_xx_1 = blocks.add_vcc(mx * my) self.blocks_add_xx_0_0 = blocks.add_vcc(mx * my) self.blocks_add_xx_0 = blocks.add_vcc(mx * my) self.beamforming_randomsampler_0 = beamforming.randomsampler(mx * my, 8) self.beamforming_phasedarray_0_0 = beamforming.phasedarray( mx, my, theta_2, phi_2, 436e6, (299792458 / (2 * fc)), element_separation ) self.beamforming_phasedarray_0 = beamforming.phasedarray( mx, my, theta_1, phi_1, 436e6, (299792458 / (2 * fc)), element_separation ) self.beamforming_doaesprit_py_cf_0 = beamforming.doaesprit_py_cf( mx, my, fc, (299792458 / (2 * fc)), n, 128, file_name ) self.analog_vectornoise_source_0_0 = analog.vectornoise_source( noise_voltage_2, mx * my ) self.analog_vectornoise_source_0 = analog.vectornoise_source( noise_voltage_1, mx * my ) self.analog_random_source_x_0_0 = blocks.vector_source_b( list(map(int, numpy.random.randint(0, 256, 1000))), False ) self.analog_random_source_x_0 = blocks.vector_source_b( list(map(int, numpy.random.randint(0, 256, 1000))), False ) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect( (self.analog_random_source_x_0_0, 0), (self.blocks_throttle_0_0, 0) ) self.connect((self.analog_vectornoise_source_0, 0), (self.blocks_add_xx_0, 1)) self.connect( (self.analog_vectornoise_source_0_0, 0), (self.blocks_add_xx_0_0, 1) ) self.connect((self.beamforming_phasedarray_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.beamforming_phasedarray_0_0, 0), (self.blocks_add_xx_0_0, 0)) self.connect( (self.beamforming_randomsampler_0, 0), (self.beamforming_doaesprit_py_cf_0, 0), ) self.connect((self.blocks_add_xx_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.blocks_add_xx_1, 0), (self.beamforming_randomsampler_0, 0)) self.connect( (self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_chunks_to_symbols_xx_0, 0), ) self.connect( (self.blocks_packed_to_unpacked_xx_0_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0), ) self.connect( (self.blocks_throttle_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0) ) self.connect( (self.blocks_throttle_0_0, 0), (self.blocks_packed_to_unpacked_xx_0_0, 0) ) self.connect( (self.digital_chunks_to_symbols_xx_0, 0), (self.beamforming_phasedarray_0, 0), ) self.connect( (self.digital_chunks_to_symbols_xx_0_0, 0), (self.beamforming_phasedarray_0_0, 0), )
#header_formatter = digital.packet_header_default(bits_per_header, length_tag_name,num_tag_name,header_mod.bits_per_symbol()); #tcm_indicator_symbols_per_frame=4; #Zhe added, 4 bits are used as tcm mode indicator, it is used as a part of header. # Achilles' comment: this may change later when filler bits are introduced... print "bits_per_header=", bits_per_header print "symbols_per_header=", symbols_per_header #print "tcm_indicator_symbols_per_frame=",tcm_indicator_symbols_per_frame print "\n" #trellis coding and modulation info payload_mod = [ digital.constellation_qpsk(), digital.constellation_8psk(), digital.constellation_16qam() ] pdir = prefix + "/python/fsm_files/" fsm = [ pdir + "awgn2o2_1.fsm", pdir + "awgn2o3_8ungerboecka.fsm", pdir + "awgn2o4_8_ungerboeckc.fsm" ] uncoded_fsm = [ trellis.fsm(2, 2, [1, 0, 0, 1]), trellis.fsm(3, 3, [1, 0, 0, 0, 1, 0, 0, 0, 1]), trellis.fsm(4, 4, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]) ] bits_per_coded_symbol = [ int(math.log(trellis.fsm(fsm[i]).O(), 2)) for i in range(len(payload_mod))
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, puncpat='11'): gr.top_block.__init__(self, "Tutorial") Qt.QWidget.__init__(self) self.setWindowTitle("Tutorial") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "tutorial_10") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.puncpat = puncpat ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.eb = eb = 0.22 self.tx_rrc_taps = tx_rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0, eb, 5 * sps * nfilts) self.taps_per_filt = taps_per_filt = len(tx_rrc_taps) / nfilts self.samp_rate_array_MCR = samp_rate_array_MCR = [ 7500000, 5000000, 3750000, 3000000, 2500000, 2000000, 1500000, 1000000, 937500, 882352, 833333, 714285, 533333, 500000, 421052, 400000, 380952 ] self.rate = rate = 2 self.polys = polys = [109, 79] self.k = k = 7 self.vector = vector = [int(random.random() * 7) for i in range(49600)] self.variable_qtgui_range_0_1 = variable_qtgui_range_0_1 = 38 self.variable_qtgui_range_0 = variable_qtgui_range_0 = 50 self.samp_rate = samp_rate = samp_rate_array_MCR[3] self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine( nfilts, nfilts * sps, 1.0, eb, 11 * sps * nfilts) self.pld_enc = pld_enc = map((lambda a: fec.cc_encoder_make( 440, k, rate, (polys), 0, fec.CC_TERMINATED, False)), range(0, 4)) self.pld_dec = pld_dec = map((lambda a: fec.cc_decoder.make( 440, k, rate, (polys), 0, -1, fec.CC_TERMINATED, False)), range(0, 8)) self.pld_const = pld_const = digital.constellation_16qam().base() self.pld_const.gen_soft_dec_lut(8) self.frequencia_usrp = frequencia_usrp = 484e6 self.filt_delay = filt_delay = 1 + (taps_per_filt - 1) / 2 self.copy = copy = True self.MCR = MCR = "master_clock_rate=60e6" ################################################## # Blocks ################################################## _copy_check_box = Qt.QCheckBox("copy") self._copy_choices = {True: True, False: False} self._copy_choices_inv = dict( (v, k) for k, v in self._copy_choices.iteritems()) self._copy_callback = lambda i: Qt.QMetaObject.invokeMethod( _copy_check_box, "setChecked", Qt.Q_ARG("bool", self._copy_choices_inv[i])) self._copy_callback(self.copy) _copy_check_box.stateChanged.connect( lambda i: self.set_copy(self._copy_choices[bool(i)])) self.top_grid_layout.addWidget(_copy_check_box, 0, 4, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 5): self.top_grid_layout.setColumnStretch(c, 1) self._variable_qtgui_range_0_1_range = Range(0, 73, 1, 38, 200) self._variable_qtgui_range_0_1_win = RangeWidget( self._variable_qtgui_range_0_1_range, self.set_variable_qtgui_range_0_1, 'Gain_RX', "counter_slider", float) self.top_grid_layout.addWidget(self._variable_qtgui_range_0_1_win, 0, 2, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self._variable_qtgui_range_0_range = Range(0, 90, 1, 50, 200) self._variable_qtgui_range_0_win = RangeWidget( self._variable_qtgui_range_0_range, self.set_variable_qtgui_range_0, 'Gain_TX', "counter_slider", float) self.top_grid_layout.addWidget(self._variable_qtgui_range_0_win, 0, 1, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.scrambler_packets_same_seed_scramble_packetize_0 = scrambler_packets_same_seed.scramble_packetize( 0x8A, 0x7F, 7, 440) self.scrambler_packets_same_seed_descramble_packetize_0 = scrambler_packets_same_seed.descramble_packetize( 0x8A, 0x7F, 7, 440) 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, 4, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 5): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_1 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "TX USRP", #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) self.qtgui_time_sink_x_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_1.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance( self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win, 1, 3, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f( 100 * 2, #size samp_rate, #samp_rate 'Rx Data', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_1.set_update_time(0.10) self.qtgui_time_sink_x_0_1.set_y_axis(-1, 256) self.qtgui_time_sink_x_0_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_1.enable_tags(-1, True) self.qtgui_time_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, 'packet_length_tag_key') self.qtgui_time_sink_x_0_1.enable_autoscale(True) self.qtgui_time_sink_x_0_1.enable_grid(True) self.qtgui_time_sink_x_0_1.enable_axis_labels(True) self.qtgui_time_sink_x_0_1.enable_control_panel(False) self.qtgui_time_sink_x_0_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_1_win = sip.wrapinstance( self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_win, 2, 3, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 100 * 2, #size samp_rate, #samp_rate 'Tx Data', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 256) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, 'packet_length_tag_key') self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 1, 1, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0_0_1_0 = qtgui.const_sink_c( 1024, #size "RX Treated Constellation", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0_1_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0_1_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_1_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_1_0.set_trigger_mode( qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0_1_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0_1_0.enable_grid(False) self.qtgui_const_sink_x_0_0_0_1_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_0_1_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0_0_1_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0_1_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0_1_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0_1_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0_1_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0_1_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0_1_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_1_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_1_0_win, 2, 2, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0_0_1 = qtgui.const_sink_c( 1024, #size "RX Constellation", #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_0 = qtgui.const_sink_c( 1024, #size "TX Constellation", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_0.set_trigger_mode( qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0_0_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_0_win, 1, 2, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.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(filt_delay) 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.fec_extended_decoder_0_0_1_0_1_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 / 400.0, (rx_rrc_taps), nfilts, nfilts / 2, 1.5, 1) self.digital_map_bb_0_0_0_0_0 = digital.map_bb(([-1, 1])) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc( sps, eb, 44, 0) self.digital_correlate_access_code_xx_ts_0_0 = digital.correlate_access_code_bb_ts( digital.packet_utils.default_access_code, 1, 'packet_len') self.digital_constellation_decoder_cb_0_0 = digital.constellation_decoder_cb( pld_const) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc( (pld_const.points()), 1) self.blocks_vector_source_x_0_0_0 = blocks.vector_source_b([0], True, 1, []) self.blocks_stream_mux_0_1_0 = blocks.stream_mux( gr.sizeof_char * 1, (96, 896)) self.blocks_stream_mux_0_0 = blocks.stream_mux(gr.sizeof_char * 1, (892, 4)) self.blocks_repack_bits_bb_1_0_0_1 = blocks.repack_bits_bb( 8, 1, '', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_0_1 = blocks.repack_bits_bb( 1, pld_const.bits_per_symbol(), '', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb( 1, 8, '', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( pld_const.bits_per_symbol(), 1, '', False, gr.GR_MSB_FIRST) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((0.7, )) self.blocks_keep_m_in_n_0_0_2_0 = blocks.keep_m_in_n( gr.sizeof_char, 892, 896, 0) self.blocks_file_source_0_0_1_0 = blocks.file_source( gr.sizeof_char * 1, '/home/andre/Desktop/Files_To_Transmit/trasmit_10_mb.txt', False) self.blocks_file_source_0_0_1_0.set_begin_tag(pmt.PMT_NIL) self.blocks_file_sink_0_0_0_2 = blocks.file_sink( gr.sizeof_char * 1, '/home/andre/Desktop/Trasmited/depois.txt', False) self.blocks_file_sink_0_0_0_2.set_unbuffered(False) self.blocks_copy_0 = blocks.copy(gr.sizeof_gr_complex * 1) self.blocks_copy_0.set_enabled(copy) self.blocks_char_to_float_1_0_1 = blocks.char_to_float(1, 1) self.blocks_char_to_float_1_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_2_0_0 = blocks.char_to_float(1, 1) self.acode_1104 = blocks.vector_source_b([ 0x1, 0x0, 0x1, 0x0, 0x1, 0x1, 0x0, 0x0, 0x1, 0x1, 0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0 ], True, 1, []) ################################################## # Connections ################################################## self.connect((self.acode_1104, 0), (self.blocks_stream_mux_0_1_0, 0)) self.connect((self.blocks_char_to_float_0_2_0_0, 0), (self.fec_extended_decoder_0_0_1_0_1_0, 0)) self.connect((self.blocks_char_to_float_1_0_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_char_to_float_1_0_1, 0), (self.qtgui_time_sink_x_0_1, 0)) self.connect((self.blocks_copy_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_file_source_0_0_1_0, 0), (self.blocks_char_to_float_1_0_0, 0)) self.connect((self.blocks_file_source_0_0_1_0, 0), (self.blocks_repack_bits_bb_1_0_0_1, 0)) self.connect((self.blocks_keep_m_in_n_0_0_2_0, 0), (self.digital_map_bb_0_0_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_const_sink_x_0_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_correlate_access_code_xx_ts_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.blocks_char_to_float_1_0_1, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.blocks_file_sink_0_0_0_2, 0)) self.connect((self.blocks_repack_bits_bb_0_1, 0), (self.insert_vec_cpp_new_vec_0, 0)) self.connect( (self.blocks_repack_bits_bb_1_0_0_1, 0), (self.scrambler_packets_same_seed_scramble_packetize_0, 0)) self.connect((self.blocks_stream_mux_0_0, 0), (self.blocks_stream_mux_0_1_0, 1)) self.connect((self.blocks_stream_mux_0_1_0, 0), (self.blocks_repack_bits_bb_0_1, 0)) self.connect((self.blocks_vector_source_x_0_0_0, 0), (self.blocks_stream_mux_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_constellation_decoder_cb_0_0, 0), (self.blocks_repack_bits_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)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_map_bb_0_0_0_0_0, 0), (self.blocks_char_to_float_0_2_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_constellation_decoder_cb_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_const_sink_x_0_0_0_1_0, 0)) self.connect( (self.fec_extended_decoder_0_0_1_0_1_0, 0), (self.scrambler_packets_same_seed_descramble_packetize_0, 0)) self.connect((self.fec_extended_encoder_0, 0), (self.blocks_stream_mux_0_0, 0)) self.connect((self.insert_vec_cpp_new_vec_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_copy_0, 0)) self.connect( (self.scrambler_packets_same_seed_descramble_packetize_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect( (self.scrambler_packets_same_seed_scramble_packetize_0, 0), (self.fec_extended_encoder_0, 0))