def __init__(self): gr.top_block.__init__(self, "Not titled yet") Qt.QWidget.__init__(self) self.setWindowTitle("Not titled yet") 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", "phasedarray_test") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.blocks_vector_source_x_0 = blocks.vector_source_c( range(10), False, 1, []) self.blocks_vector_sink_x_0 = blocks.vector_sink_c(16, 1024) self.beamforming_phasedarray_py_cc_0 = beamforming.phasedarray_py_cc( 4, 4, 30, 60, 436e6) ################################################## # Connections ################################################## self.connect((self.beamforming_phasedarray_py_cc_0, 0), (self.blocks_vector_sink_x_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.beamforming_phasedarray_py_cc_0, 0))
def __init__(self, fc=436e6, mx=4, my=4, n=1, noise=0, phi=50, theta=45): gr.top_block.__init__(self, "BER Curve Generator") ################################################## # Parameters ################################################## self.fc = fc self.mx = mx self.my = my self.n = n self.noise = noise self.phi = phi self.theta = theta ################################################## # Variables ################################################## self.const = const = digital.constellation_bpsk().base() self.samp_rate = samp_rate = 32000 self.packet_len = packet_len = 1 self.bps = bps = const.bits_per_symbol() ################################################## # Blocks ################################################## self.fec_ber_bf_0 = fec.ber_bf(False, 100, -7.0) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( const.base()) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( const.points(), 1) self.blocks_vector_sink_x_0_1 = blocks.vector_sink_f(1, 128) self.blocks_vector_sink_x_0_0 = blocks.vector_sink_b(1, 128) self.blocks_vector_sink_x_0 = blocks.vector_sink_b(1, 128) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb( bps, gr.GR_MSB_FIRST) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( bps, gr.GR_MSB_FIRST) self.beamforming_randomsampler_py_cc_0_0 = beamforming.randomsampler_py_cc( mx * my, 8) self.beamforming_phasedarray_py_cc_0 = beamforming.phasedarray_py_cc( mx, my, theta, phi, fc, noise) self.beamforming_doaesprit_py_cf_0 = beamforming.doaesprit_py_cf( 128, mx, my, fc, n) self.beamforming_beamformer_py_cc_0 = beamforming.beamformer_py_cc( mx, my, fc, 0, 0, 8 * 128) self.analog_random_source_x_0 = blocks.vector_source_b( list(map(int, numpy.random.randint(0, const.arity(), int(1e2)))), False) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_vector_sink_x_0_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.fec_ber_bf_0, 0)) self.connect((self.beamforming_beamformer_py_cc_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.beamforming_doaesprit_py_cf_0, 1), (self.beamforming_beamformer_py_cc_0, 2)) self.connect((self.beamforming_doaesprit_py_cf_0, 0), (self.beamforming_beamformer_py_cc_0, 1)) self.connect((self.beamforming_phasedarray_py_cc_0, 0), (self.beamforming_beamformer_py_cc_0, 0)) self.connect((self.beamforming_phasedarray_py_cc_0, 0), (self.beamforming_randomsampler_py_cc_0_0, 0)) self.connect((self.beamforming_randomsampler_py_cc_0_0, 0), (self.beamforming_doaesprit_py_cf_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_vector_sink_x_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.fec_ber_bf_0, 1)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.beamforming_phasedarray_py_cc_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.fec_ber_bf_0, 0), (self.blocks_vector_sink_x_0_1, 0))
def __init__(self, fc=436e6, mx=4, my=4, n=1, noise=0, phi=50, theta=45): gr.top_block.__init__(self, "BER Curve Generator") Qt.QWidget.__init__(self) self.setWindowTitle("BER Curve Generator") 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", "bercurve_test") 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.noise = noise self.phi = phi self.theta = theta ################################################## # Variables ################################################## self.const = const = digital.constellation_qpsk().base() self.samp_rate = samp_rate = 32000 self.bps = bps = const.bits_per_symbol() ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c( 512, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) labels = ['Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10'] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ['blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue'] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_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.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1 ) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in range(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win) self.fec_ber_bf_0 = fec.ber_bf(False, 100, -7.0) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(const.base()) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(const.points(), 1) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(bps, gr.GR_MSB_FIRST) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(bps, gr.GR_MSB_FIRST) self.beamforming_randomsampler_py_cc_0_0 = beamforming.randomsampler_py_cc(mx*my,8) self.beamforming_phasedarray_py_cc_0 = beamforming.phasedarray_py_cc(mx, my, theta, phi, fc, noise) self.beamforming_doaesprit_py_cf_0 = beamforming.doaesprit_py_cf(128, mx, my, fc, n) self.beamforming_beamformer_py_cc_0 = beamforming.beamformer_py_cc(mx, my, fc, 0, 0, 8*128) self.analog_random_source_x_0 = blocks.vector_source_b(list(map(int, numpy.random.randint(0, const.arity(), int(1e6)))), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.beamforming_beamformer_py_cc_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.beamforming_doaesprit_py_cf_0, 1), (self.beamforming_beamformer_py_cc_0, 2)) self.connect((self.beamforming_doaesprit_py_cf_0, 0), (self.beamforming_beamformer_py_cc_0, 1)) self.connect((self.beamforming_phasedarray_py_cc_0, 0), (self.beamforming_beamformer_py_cc_0, 0)) self.connect((self.beamforming_phasedarray_py_cc_0, 0), (self.beamforming_randomsampler_py_cc_0_0, 0)) self.connect((self.beamforming_randomsampler_py_cc_0_0, 0), (self.beamforming_doaesprit_py_cf_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.fec_ber_bf_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.fec_ber_bf_0, 1)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.beamforming_phasedarray_py_cc_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.fec_ber_bf_0, 0), (self.qtgui_number_sink_0, 0))
def __init__( self, EbN0=0, esprit_decimation=128, fc=436e6, mx=4, my=4, n=1, phi=50, rs_decimation=8, theta=30, ): gr.top_block.__init__(self, "BER Simulation") ################################################## # Parameters ################################################## self.EbN0 = EbN0 self.esprit_decimation = esprit_decimation self.fc = fc self.mx = mx self.my = my self.n = n self.phi = phi self.rs_decimation = rs_decimation self.theta = theta ################################################## # Variables ################################################## self.sps = sps = 5 self.N_BITS = N_BITS = 1e5 self.samp_rate = samp_rate = 32000 self.noise_voltage = noise_voltage = 1.0 / math.sqrt( 1 / float(sps) * 10**(float(EbN0) / 10)) self.intdump_decim = intdump_decim = min(int(N_BITS / 10), 100000) self.const = const = digital.constellation_bpsk().base() self.alpha = alpha = 0.35 self.SKIP = SKIP = 1000 self.RAND_SEED = RAND_SEED = 42 ################################################## # Blocks ################################################## self.lilacsat1_ber_bpsk_0 = lilacsat1_ber_bpsk( bfo=12000, callsign="", ip="::", latitude=0, longitude=0, port=7355, recstart="", ) self.digital_scrambler_bb_0 = digital.scrambler_bb(0x21, 0x0, 16) self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0x00, 16) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=const, differential=False, samples_per_symbol=sps, pre_diff_code=True, excess_bw=alpha, verbose=False, log=False, ) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise_voltage, frequency_offset=0.0, epsilon=1.0, taps=( 0, 0, (1 + 1j) / numpy.sqrt(2), ), noise_seed=RAND_SEED, block_tags=False, ) self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, mx * my) self.blocks_vector_source_x_0 = blocks.vector_source_b([1], True, 1, []) self.blocks_vector_sink_x_0_0_0 = blocks.vector_sink_f(1, 1024) self.blocks_vector_sink_x_0_0 = blocks.vector_sink_f(1, 1024) self.blocks_vector_sink_x_0 = blocks.vector_sink_f(1, 1024) self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, mx * my) self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_char * 1, SKIP) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_not_xx_0 = blocks.not_bb() self.blocks_multiply_const_vxx_1 = blocks.multiply_const_cc(0.1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff( 1.0 / intdump_decim) self.blocks_integrate_xx_0 = blocks.integrate_ff(intdump_decim, 1) self.blocks_head_0 = blocks.head(gr.sizeof_char * 1, int(N_BITS)) self.blocks_and_const_xx_0 = blocks.and_const_bb(1) self.beamforming_randomsampler_py_cc_0_0 = beamforming.randomsampler_py_cc( mx * my, rs_decimation) self.beamforming_phasedarray_py_cc_0 = beamforming.phasedarray_py_cc( mx, my, theta, phi, fc, 0) self.beamforming_doaesprit_py_cf_0 = beamforming.doaesprit_py_cf( 128, mx, my, fc, n) self.beamforming_beamformer_py_cc_0 = beamforming.beamformer_py_cc( mx, my, fc, 0, 0, 8 * 128) ################################################## # Connections ################################################## self.connect( (self.beamforming_beamformer_py_cc_0, 0), (self.blocks_multiply_const_vxx_1, 0), ) self.connect( (self.beamforming_doaesprit_py_cf_0, 0), (self.beamforming_beamformer_py_cc_0, 1), ) self.connect( (self.beamforming_doaesprit_py_cf_0, 1), (self.beamforming_beamformer_py_cc_0, 2), ) self.connect((self.beamforming_doaesprit_py_cf_0, 0), (self.blocks_vector_sink_x_0_0, 0)) self.connect( (self.beamforming_doaesprit_py_cf_0, 1), (self.blocks_vector_sink_x_0_0_0, 0), ) self.connect( (self.beamforming_phasedarray_py_cc_0, 0), (self.blocks_vector_to_stream_0, 0), ) self.connect( (self.beamforming_randomsampler_py_cc_0_0, 0), (self.beamforming_doaesprit_py_cf_0, 0), ) self.connect((self.blocks_and_const_xx_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_head_0, 0), (self.digital_scrambler_bb_0, 0)) self.connect((self.blocks_integrate_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_vector_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.lilacsat1_ber_bpsk_0, 0)) self.connect((self.blocks_not_xx_0, 0), (self.blocks_and_const_xx_0, 0)) self.connect( (self.blocks_pack_k_bits_bb_0, 0), (self.digital_constellation_modulator_0, 0), ) self.connect((self.blocks_skiphead_0, 0), (self.blocks_not_xx_0, 0)) self.connect( (self.blocks_stream_to_vector_0, 0), (self.beamforming_beamformer_py_cc_0, 0), ) self.connect( (self.blocks_stream_to_vector_0, 0), (self.beamforming_randomsampler_py_cc_0_0, 0), ) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_integrate_xx_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_head_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect( (self.digital_constellation_modulator_0, 0), (self.beamforming_phasedarray_py_cc_0, 0), ) self.connect((self.digital_descrambler_bb_0, 0), (self.blocks_skiphead_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.digital_diff_encoder_bb_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.digital_scrambler_bb_0, 0), (self.digital_diff_encoder_bb_0, 0)) self.connect((self.lilacsat1_ber_bpsk_0, 0), (self.digital_diff_decoder_bb_0, 0))