def __init__(self, bitrate, constellation, samples_per_symbol, differential, excess_bw, gray_coded, freq_bw, timing_bw, phase_bw, verbose, log): gr.hier_block2.__init__(self, "bert_receive", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(0, 0, 0)) # Output signature self._bitrate = bitrate self._demod = digital.generic_demod(constellation, differential, samples_per_symbol, gray_coded, excess_bw, freq_bw, timing_bw, phase_bw, verbose, log) self._symbol_rate = self._bitrate / self._demod.bits_per_symbol() self._sample_rate = self._symbol_rate * samples_per_symbol # Add an SNR probe on the demodulated constellation self._snr_probe = digital.probe_mpsk_snr_est_c(digital.SNR_EST_M2M4, 1000, alpha=10.0/self._symbol_rate) self.connect(self._demod.time_recov, self._snr_probe) # Descramble BERT sequence. A channel error will create 3 incorrect bits self._descrambler = digital.descrambler_bb(0x8A, 0x7F, 7) # CCSDS 7-bit descrambler # Measure BER by the density of 0s in the stream self._ber = digital.probe_density_b(1.0/self._symbol_rate) self.connect(self, self._demod, self._descrambler, self._ber)
def __init__(self, bitrate, constellation, samples_per_symbol, differential, excess_bw, gray_coded, freq_bw, timing_bw, phase_bw, verbose, log): gr.hier_block2.__init__( self, "bert_receive", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(0, 0, 0)) # Output signature self._bitrate = bitrate self._demod = digital.generic_demod(constellation, differential, samples_per_symbol, gray_coded, excess_bw, freq_bw, timing_bw, phase_bw, verbose, log) self._symbol_rate = self._bitrate / self._demod.bits_per_symbol() self._sample_rate = self._symbol_rate * samples_per_symbol # Add an SNR probe on the demodulated constellation self._snr_probe = digital.probe_mpsk_snr_est_c(digital.SNR_EST_M2M4, 1000, alpha=10.0 / self._symbol_rate) self.connect(self._demod.time_recov, self._snr_probe) # Descramble BERT sequence. A channel error will create 3 incorrect bits self._descrambler = digital.descrambler_bb( 0x8A, 0x7F, 7) # CCSDS 7-bit descrambler # Measure BER by the density of 0s in the stream self._ber = digital.probe_density_b(1.0 / self._symbol_rate) self.connect(self, self._demod, self._descrambler, self._ber)
def test_probe_mpsk_snr_est_m2m4(self): expected_result = [8.01, 3.19, 1.97, 2.15, 2.65] actual_result = [] for i in xrange(1,6): src_data = [b+(i*n) for b,n in zip(self._bits, self._noise)] src = blocks.vector_source_c(src_data) N = 10000 alpha = 0.001 op = digital.probe_mpsk_snr_est_c(digital.SNR_EST_M2M4, N, alpha) tb = gr.top_block() tb.connect(src, op) tb.run() # run the graph and wait for it to finish actual_result.append(op.snr()) self.assertFloatTuplesAlmostEqual(expected_result, actual_result, 2)
def __init__(self, name="SNREstimator", algorithm=SVR, alpha=0.001): """ CTOR @param name @param algorithm @param alpha """ self._estimator = digital.probe_mpsk_snr_est_c(algorithm, 10000, alpha) UHDGenericArch.__init__(self, name=name, input_signature=self._estimator.input_signature(), output_signature=self._estimator.output_signature()) Logger.register(name, ['snr', ]) self.register_scheduling(lambda: Logger.append(name, 'snr', self.get_snr()), delay_sec=0.2) #pylint: disable=E1101
def __init__(self, fD=10, id_user=0): gr.top_block.__init__(self, "Polar Coding with Coded Caching") ################################################## # Parameters ################################################## self.fD = fD self.id_user = id_user ################################################## # Variables ################################################## self.snr = snr = 14 + 20 * numpy.log10(4) self.pilot_symbols = pilot_symbols = (( 1, 1, 1, -1, ), ) self.pilot_carriers = pilot_carriers = (( -21, -7, 7, 21, ), ) self.payload_mod = payload_mod = digital.constellation_qpsk() self.packet_length_tag_key = packet_length_tag_key = "packet_len" self.occupied_carriers = occupied_carriers = ( range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27), ) self.length_tag_key = length_tag_key = "frame_len" self.header_mod = header_mod = digital.constellation_bpsk() self.fft_len = fft_len = 64 self.variance = variance = 1 / pow(10, snr / 10.0) self.sync_word2 = sync_word2 = [ 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 0, 0, 0, 0, 0 ] self.sync_word1 = sync_word1 = [ 0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0. ] self.small_packet_len = small_packet_len = 52 self.samp_rate = samp_rate = int(1e6) self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe( fft_len, payload_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 0, 1) self.header_formatter = header_formatter = digital.packet_header_ofdm( occupied_carriers, n_syms=1, len_tag_key=packet_length_tag_key, frame_len_tag_key=length_tag_key, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=payload_mod.bits_per_symbol(), scramble_header=False) self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe( fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 0, 1) self.gain = gain = 25 self.freq = freq = 2450e6 self.coderate = coderate = [1, 2, 2, 3, 4] self.Users = Users = 4 self.Nbfiles = Nbfiles = 20 self.NbStrgUsers = NbStrgUsers = 1 self.NbChuncks = NbChuncks = 200 self.N = N = 2048 ################################################## # Blocks ################################################## self.zeromq_sub_source_0 = zeromq.sub_source(gr.sizeof_gr_complex, 1, 'tcp://localhost:5565', 100, False, -1) self.zeromq_sub_msg_source_0_0_0 = zeromq.sub_msg_source( 'tcp://localhost:5575', 10) self.zeromq_sub_msg_source_0_0 = zeromq.sub_msg_source( 'tcp://localhost:5555', 10) self.projectCACHE_ofdm_frame_equalizer1_vcvc_0 = projectCACHE.ofdm_frame_equalizer1_vcvc( fft_len, fft_len / 4, length_tag_key, True, occupied_carriers, pilot_carriers, pilot_symbols, 0, True) self.projectCACHE_PolarDec_b_0_0 = projectCACHE.PolarDec_b( N, Nbfiles, NbChuncks, id_user, Users, small_packet_len, 42, coderate[id_user], packet_length_tag_key) self.projectCACHE_PC_Error_Rate_0_0 = projectCACHE.PC_Error_Rate( id_user, 200) self.fft_vxx_1 = fft.fft_vcc(fft_len, True, (), True, 1) self.fft_vxx_0 = fft.fft_vcc(fft_len, True, (()), True, 1) self.digital_probe_mpsk_snr_est_c_0 = digital.probe_mpsk_snr_est_c( 3, 1000, 0.0001) self.digital_packet_headerparser_b_0 = digital.packet_headerparser_b( header_formatter.base()) self.digital_ofdm_sync_sc_cfb_0 = digital.ofdm_sync_sc_cfb( fft_len, fft_len / 4, False, 0.9) self.digital_ofdm_serializer_vcc_payload_0 = digital.ofdm_serializer_vcc( fft_len, occupied_carriers, length_tag_key, packet_length_tag_key, 1, '', True) self.digital_ofdm_serializer_vcc_payload = digital.ofdm_serializer_vcc( fft_len, occupied_carriers, length_tag_key, packet_length_tag_key, 1, '', True) self.digital_ofdm_serializer_vcc_header = digital.ofdm_serializer_vcc( fft_len, occupied_carriers, length_tag_key, '', 0, '', True) self.digital_ofdm_frame_equalizer_vcvc_0 = digital.ofdm_frame_equalizer_vcvc( header_equalizer.base(), fft_len / 4, length_tag_key, True, 1) self.digital_ofdm_chanest_vcvc_0 = digital.ofdm_chanest_vcvc( (sync_word1), (sync_word2), 1, 0, 3, False) self.digital_header_payload_demux_0 = digital.header_payload_demux( 3, fft_len, fft_len / 4, length_tag_key, "", True, gr.sizeof_gr_complex, "rx_time", samp_rate, (), 0, ) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( header_mod.base()) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, fft_len + fft_len / 4) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc( -2.0 / fft_len) ################################################## # Connections ################################################## self.msg_connect((self.digital_packet_headerparser_b_0, 'header_data'), (self.digital_header_payload_demux_0, 'header_data')) self.msg_connect((self.digital_probe_mpsk_snr_est_c_0, 'snr'), (self.projectCACHE_PC_Error_Rate_0_0, 'SNR')) self.msg_connect((self.zeromq_sub_msg_source_0_0, 'out'), (self.projectCACHE_PC_Error_Rate_0_0, 'BER_INFO')) self.msg_connect((self.zeromq_sub_msg_source_0_0_0, 'out'), (self.projectCACHE_PC_Error_Rate_0_0, 'CH_USE')) self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.digital_header_payload_demux_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_packet_headerparser_b_0, 0)) self.connect((self.digital_header_payload_demux_0, 0), (self.fft_vxx_0, 0)) self.connect((self.digital_header_payload_demux_0, 1), (self.fft_vxx_1, 0)) self.connect((self.digital_ofdm_chanest_vcvc_0, 0), (self.digital_ofdm_frame_equalizer_vcvc_0, 0)) self.connect((self.digital_ofdm_frame_equalizer_vcvc_0, 0), (self.digital_ofdm_serializer_vcc_header, 0)) self.connect((self.digital_ofdm_serializer_vcc_header, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_ofdm_serializer_vcc_payload, 0), (self.projectCACHE_PolarDec_b_0_0, 0)) self.connect((self.digital_ofdm_serializer_vcc_payload_0, 0), (self.digital_probe_mpsk_snr_est_c_0, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_0, 0), (self.analog_frequency_modulator_fc_0, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_0, 1), (self.digital_header_payload_demux_0, 1)) self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_chanest_vcvc_0, 0)) self.connect((self.fft_vxx_1, 0), (self.digital_ofdm_serializer_vcc_payload_0, 0)) self.connect((self.fft_vxx_1, 0), (self.projectCACHE_ofdm_frame_equalizer1_vcvc_0, 0)) self.connect((self.projectCACHE_ofdm_frame_equalizer1_vcvc_0, 0), (self.digital_ofdm_serializer_vcc_payload, 0)) self.connect((self.zeromq_sub_source_0, 0), (self.blocks_delay_0, 0)) self.connect((self.zeromq_sub_source_0, 0), (self.digital_ofdm_sync_sc_cfb_0, 0))
def __init__(self, fc=436e6, mx=4, my=4, n=1): gr.top_block.__init__(self, "DoA Esprit Estimation - Test") Qt.QWidget.__init__(self) self.setWindowTitle("DoA Esprit Estimation - Test") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "doaesprit_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 ################################################## # Variables ################################################## self.const = const = digital.constellation_qpsk().base() self.theta = theta = 45 self.samp_rate = samp_rate = 150000 self.phi = phi = 70 self.noise_voltage = noise_voltage = 0 self.element_separation = element_separation = 0 self.bps = bps = const.bits_per_symbol() ################################################## # Blocks ################################################## self._theta_range = Range(0, 90, 1, 45, 200) self._theta_win = RangeWidget(self._theta_range, self.set_theta, 'Elevation Angle', "counter_slider", float) self.top_grid_layout.addWidget(self._theta_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_range = Range(-180, 180, 1, 70, 200) self._phi_win = RangeWidget(self._phi_range, self.set_phi, 'Azimut Angle', "counter_slider", float) self.top_grid_layout.addWidget(self._phi_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._noise_voltage_range = Range(0, 10, 0.001, 0, 200) self._noise_voltage_win = RangeWidget(self._noise_voltage_range, self.set_noise_voltage, 'Noise Voltage', "counter_slider", float) self.top_grid_layout.addWidget(self._noise_voltage_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._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, 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_time_sink_x_0_0 = qtgui.time_sink_c( 128, #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(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) 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, 6, 0, 1, 1) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 128, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) labels = ['Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10'] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ['blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue'] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 7, 0, 1, 1) for r in range(7, 8): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] 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, 8, 0, 1, 1) for r in range(8, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.digital_probe_mpsk_snr_est_c_0 = digital.probe_mpsk_snr_est_c(0, 10000, 0.001) 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.blocks_message_debug_0 = blocks.message_debug() self.blocks_file_source_0_0 = blocks.file_source(gr.sizeof_char*1, '/home/grigosback/Documents/GNURadio/examples/source.txt', True, 0, 0) self.blocks_file_source_0_0.set_begin_tag(pmt.PMT_NIL) self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, '/home/grigosback/Documents/GNURadio/examples/sink.txt', False) self.blocks_file_sink_0_0.set_unbuffered(False) self.blocks_add_xx_0 = blocks.add_vcc(mx*my) self.beamforming_randomsampler_0 = beamforming.randomsampler(mx*my, 8) self.beamforming_phasedarray_0 = beamforming.phasedarray(mx, my, theta, phi, 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 = beamforming.beamformer(mx, my, 0) self.analog_vectornoise_source_0 = analog.vectornoise_source(noise_voltage, mx*my) ################################################## # Connections ################################################## self.msg_connect((self.beamforming_doaesprit_py_cf_0, 'doa_port'), (self.beamforming_beamformer_0, 'doa_port')) self.msg_connect((self.digital_probe_mpsk_snr_est_c_0, 'snr'), (self.blocks_message_debug_0, 'print')) self.connect((self.analog_vectornoise_source_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.beamforming_beamformer_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.beamforming_beamformer_0, 0), (self.digital_probe_mpsk_snr_est_c_0, 0)) self.connect((self.beamforming_beamformer_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.beamforming_beamformer_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.beamforming_phasedarray_0, 0), (self.blocks_add_xx_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.beamforming_beamformer_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.beamforming_randomsampler_0, 0)) self.connect((self.blocks_file_source_0_0, 0), (self.blocks_throttle_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_unpacked_to_packed_xx_0, 0), (self.blocks_file_sink_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), (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))
def __init__(self, id_user=0): gr.top_block.__init__(self, "Polar Coding with Coded Caching") ################################################## # Parameters ################################################## self.id_user = id_user ################################################## # Variables ################################################## self.snr = snr = 50 self.pilot_symbols = pilot_symbols = (( 1, 1, 1, -1, ), ) self.pilot_carriers = pilot_carriers = (( -21, -7, 7, 21, ), ) self.payload_mod = payload_mod = digital.constellation_qpsk() self.packet_length_tag_key = packet_length_tag_key = "packet_len" self.occupied_carriers = occupied_carriers = ( range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27), ) self.length_tag_key = length_tag_key = "frame_len" self.header_mod = header_mod = digital.constellation_bpsk() self.fft_len = fft_len = 64 self.Kw = Kw = 70 * 8 self.variance = variance = 1 / pow(10, snr / 10.0) self.sync_word2 = sync_word2 = [ 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 0, 0, 0, 0, 0 ] self.sync_word1 = sync_word1 = [ 0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0. ] self.small_packet_len = small_packet_len = 52 self.samp_rate = samp_rate = 32000 self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe( fft_len, payload_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 0, 1) self.header_formatter = header_formatter = digital.packet_header_ofdm( occupied_carriers, n_syms=1, len_tag_key=packet_length_tag_key, frame_len_tag_key=length_tag_key, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=payload_mod.bits_per_symbol(), scramble_header=False) self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe( fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 0, 1) self.coderate = coderate = [1, 2, 3, 3, 4] self.Users = Users = 4 self.Nbfiles = Nbfiles = 20 self.NbStrgUsers = NbStrgUsers = 1 self.NbChuncks = NbChuncks = 200 self.N = N = 2048 self.Ks = Ks = 2 * Kw ################################################## # Blocks ################################################## self.zeromq_sub_msg_source_0_0_0 = zeromq.sub_msg_source( 'tcp://localhost:5575', 10) self.zeromq_sub_msg_source_0_0 = zeromq.sub_msg_source( 'tcp://localhost:5555', 10) self.zeromq_pub_msg_sink_0_0_0 = zeromq.pub_msg_sink( 'tcp://*:5575', 10) self.zeromq_pub_msg_sink_0_0 = zeromq.pub_msg_sink('tcp://*:5555', 10) self.projectCACHE_polarEnc_b_0_0 = projectCACHE.polarEnc_b( N, Nbfiles, NbChuncks, NbStrgUsers, id_user, small_packet_len, packet_length_tag_key) self.projectCACHE_ofdm_frame_equalizer1_vcvc_0 = projectCACHE.ofdm_frame_equalizer1_vcvc( fft_len, fft_len / 4, length_tag_key, True, occupied_carriers, pilot_carriers, pilot_symbols, 0, True) self.projectCACHE_map_header_payload_bc_0 = projectCACHE.map_header_payload_bc( 4, 2, packet_length_tag_key) self.projectCACHE_PolarDec_b_0_0 = projectCACHE.PolarDec_b( N, Nbfiles, NbChuncks, id_user, Users, small_packet_len, 42, coderate[id_user], packet_length_tag_key) self.projectCACHE_PC_Error_Rate_0_0 = projectCACHE.PC_Error_Rate( id_user, 200) self.fft_vxx_1 = fft.fft_vcc(fft_len, True, (), True, 1) self.fft_vxx_0_0 = fft.fft_vcc(fft_len, False, (()), True, 1) self.fft_vxx_0 = fft.fft_vcc(fft_len, True, (()), True, 1) self.digital_probe_mpsk_snr_est_c_0 = digital.probe_mpsk_snr_est_c( 3, 1000, 0.0001) self.digital_packet_headerparser_b_0 = digital.packet_headerparser_b( header_formatter.base()) self.digital_packet_headergenerator_bb_0 = digital.packet_headergenerator_bb( header_formatter.formatter(), packet_length_tag_key) self.digital_ofdm_sync_sc_cfb_0 = digital.ofdm_sync_sc_cfb( fft_len, fft_len / 4, False, 0.9) self.digital_ofdm_serializer_vcc_payload_0 = digital.ofdm_serializer_vcc( fft_len, occupied_carriers, length_tag_key, packet_length_tag_key, 1, '', True) self.digital_ofdm_serializer_vcc_payload = digital.ofdm_serializer_vcc( fft_len, occupied_carriers, length_tag_key, packet_length_tag_key, 1, '', True) self.digital_ofdm_serializer_vcc_header = digital.ofdm_serializer_vcc( fft_len, occupied_carriers, length_tag_key, '', 0, '', True) self.digital_ofdm_frame_equalizer_vcvc_0 = digital.ofdm_frame_equalizer_vcvc( header_equalizer.base(), fft_len / 4, length_tag_key, True, 1) self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer( fft_len, fft_len + fft_len / 4, 0, packet_length_tag_key) self.digital_ofdm_chanest_vcvc_0 = digital.ofdm_chanest_vcvc( (sync_word1), (sync_word2), 1, 0, 3, False) self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (sync_word1, sync_word2), packet_length_tag_key) self.digital_header_payload_demux_0 = digital.header_payload_demux( 3, fft_len, fft_len / 4, length_tag_key, "", True, gr.sizeof_gr_complex, "rx_time", samp_rate, (), 0, ) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( header_mod.base()) self.digital_chunks_to_symbols_xx_0_1 = digital.chunks_to_symbols_bc( (header_mod.points()), 1) self.channels_channel_model_0_0 = channels.channel_model( noise_voltage=numpy.sqrt(variance), frequency_offset=1.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_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.complex_t, 'packet_len') self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_gr_complex * 1, packet_length_tag_key, 0) (self.blocks_tagged_stream_mux_0).set_max_output_buffer(8192) self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_tag_gate_0.set_single_key("") self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((0.05, )) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, fft_len + fft_len / 4) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc( -2.0 / fft_len) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.zeromq_pub_msg_sink_0_0_0, 'in')) self.msg_connect((self.digital_packet_headerparser_b_0, 'header_data'), (self.digital_header_payload_demux_0, 'header_data')) self.msg_connect((self.digital_probe_mpsk_snr_est_c_0, 'snr'), (self.projectCACHE_PC_Error_Rate_0_0, 'SNR')) self.msg_connect((self.projectCACHE_polarEnc_b_0_0, 'BER_INFO'), (self.zeromq_pub_msg_sink_0_0, 'in')) self.msg_connect((self.zeromq_sub_msg_source_0_0, 'out'), (self.projectCACHE_PC_Error_Rate_0_0, 'BER_INFO')) self.msg_connect((self.zeromq_sub_msg_source_0_0_0, 'out'), (self.projectCACHE_PC_Error_Rate_0_0, 'CH_USE')) self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.digital_header_payload_demux_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_ofdm_carrier_allocator_cvc_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.channels_channel_model_0_0, 0)) self.connect((self.channels_channel_model_0_0, 0), (self.blocks_delay_0, 0)) self.connect((self.channels_channel_model_0_0, 0), (self.digital_ofdm_sync_sc_cfb_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_1, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_packet_headerparser_b_0, 0)) self.connect((self.digital_header_payload_demux_0, 0), (self.fft_vxx_0, 0)) self.connect((self.digital_header_payload_demux_0, 1), (self.fft_vxx_1, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0), (self.fft_vxx_0_0, 0)) self.connect((self.digital_ofdm_chanest_vcvc_0, 0), (self.digital_ofdm_frame_equalizer_vcvc_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.digital_ofdm_frame_equalizer_vcvc_0, 0), (self.digital_ofdm_serializer_vcc_header, 0)) self.connect((self.digital_ofdm_serializer_vcc_header, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_ofdm_serializer_vcc_payload, 0), (self.projectCACHE_PolarDec_b_0_0, 0)) self.connect((self.digital_ofdm_serializer_vcc_payload_0, 0), (self.digital_probe_mpsk_snr_est_c_0, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_0, 0), (self.analog_frequency_modulator_fc_0, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_0, 1), (self.digital_header_payload_demux_0, 1)) self.connect((self.digital_packet_headergenerator_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_1, 0)) self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_chanest_vcvc_0, 0)) self.connect((self.fft_vxx_0_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0)) self.connect((self.fft_vxx_1, 0), (self.digital_ofdm_serializer_vcc_payload_0, 0)) self.connect((self.fft_vxx_1, 0), (self.projectCACHE_ofdm_frame_equalizer1_vcvc_0, 0)) self.connect((self.projectCACHE_map_header_payload_bc_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.projectCACHE_ofdm_frame_equalizer1_vcvc_0, 0), (self.digital_ofdm_serializer_vcc_payload, 0)) self.connect((self.projectCACHE_polarEnc_b_0_0, 0), (self.digital_packet_headergenerator_bb_0, 0)) self.connect((self.projectCACHE_polarEnc_b_0_0, 0), (self.projectCACHE_map_header_payload_bc_0, 0))
def __init__(self, options): gr.hier_block2.__init__(self, "bpsk_demodulator", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(0, 0, 0)) # Output signature grc_wxgui.top_block_gui.__init__(self, title="Top Block") self._samples_per_symbol = options.samples_per_symbol # Number of bits per symbol self._bits_per_symbol = 1 # Create AGC to scale input to unity self._agc = gr.agc_cc(1e-5, 1.0, 1.0, 1.0) # Create RRC with specified excess bandwidth taps = gr.firdes.root_raised_cosine(1.0, # Gain self._samples_per_symbol, # Sampling rate 1.0, # Symbol rate 0.35, # Roll-off factor 11*self._samples_per_symbol) # Number of taps self._rrc = gr.fir_filter_ccf(1, taps) # Create a Costas loop frequency/phase recovery block self._costas = digital.costas_loop_cc(6.28/100.0, 2) self.gr_null_sink_f1 = gr.null_sink(gr.sizeof_float*1) # Create a M&M bit synchronization retiming block self._mm = digital.clock_recovery_mm_cc(self._samples_per_symbol, # Initial samples/symbol 1e-06, # Second order gain 0.5, # Initial symbol phase 0.001, # First order gain 0.0001) # Maximum timing offset # Add an SNR probe on the demodulated constellation #self._snr_probe = gr.probe_mpsk_snr_c(10.0/symbol_rate) self._symbol_rate = options.data_rate / self._bits_per_symbol #self._snr_probe = digital.mpsk_snr_est_cc(0, 10000, 0.001) # 0 at the first mean Simple self._snr_probe = digital.probe_mpsk_snr_est_c(digital.SNR_EST_M2M4, alpha=10.0/self._symbol_rate) #self._snr_probe = digital.mpsk_snr_est_cc(digital.SNR_EST_SIMPLE, alpha=10.0/self._symbol_rate) # Slice the resulting constellation into bits. # Get inphase channel and make decision about 0 self._c2r = gr.complex_to_real() self._slicer = digital.binary_slicer_fb() # Descramble BERT sequence. A channel error will create 3 incorrect bits self._descrambler = gr.descrambler_bb(0x8A, 0x7F, 31) # CCSDS 7-bit descrambler # Measure BER by the density of 0s in the stream # self._ber = gr.probe_density_b(1.0/symbol_rate) self._ber = grc_blks2.error_rate(type='BER', win_size=1000, bits_per_symbol=1) #self.create_number_sink(self._samples_per_symbol) self.gr_null_sink_f2 = gr.null_sink(gr.sizeof_float*1) #Create a vector source reference to calculate BER self._vector_source_ref = gr.vector_source_b(([1,]), True, 1) #create a comparator self.comparator = howto.compare_vector_cci((1, 1, 1, 1 ,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, 1), (0,0, 1, 1, 0,0), 5, 0, True) #Connection of blocks #"""""""""""""""""""""""""""""""""-->_snr_probe-->gr_null_sink_cc # agc --> _rrc --> costas --> _mm --> _c2r --> _slicer --> _descrambler --> _ber --> gr_null_sink_f2 #"""""""""""""""""""""""""--> gr_null_sink_f1 "" _vector_source_ref--> # # self.connect(self, self._agc, self._rrc, self._costas, self._mm, # self._c2r, self._slicer, self._descrambler, self.comparator, (self._ber, 1)) # self.connect(self, self._agc, self._rrc, self._costas, self._mm, self._c2r, self._slicer, self._descrambler, (self._ber, 1)) self.connect((self._costas, 1), (self.gr_null_sink_f1, 0)) self.connect(self._mm, self._snr_probe) self.connect(self._vector_source_ref, (self._ber,0)) self.connect(self._ber, self.gr_null_sink_f2)
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.x310 = x310 = "B:0" self.samp_rate = samp_rate = 2e6 self.gain = gain = 0 self.b210 = b210 = "A:B" ################################################## # Blocks ################################################## self._gain_range = Range(0, 70, 5, 0, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain", "counter_slider", float) self.top_layout.addWidget(self._gain_win) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_subdev_spec(b210, 0) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(72e6, 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.digital_probe_mpsk_snr_est_c_0 = digital.probe_mpsk_snr_est_c( 2, 10000000, 0.01) self.blocks_message_debug_0 = blocks.message_debug() ################################################## # Connections ################################################## self.msg_connect((self.digital_probe_mpsk_snr_est_c_0, 'snr'), (self.blocks_message_debug_0, 'print')) self.connect((self.uhd_usrp_source_0, 0), (self.digital_probe_mpsk_snr_est_c_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
def __init__(self, gain=5, id_user=0): gr.top_block.__init__(self, "Polar Coding with Coded Caching") ################################################## # Parameters ################################################## self.gain = gain self.id_user = id_user ################################################## # Variables ################################################## self.pilot_symbols = pilot_symbols = ((1, 1, 1, -1,),) self.pilot_carriers = pilot_carriers = ((-21, -7, 7, 21,),) self.payload_mod = payload_mod = digital.constellation_qpsk() self.packet_length_tag_key = packet_length_tag_key = "packet_len" self.occupied_carriers = occupied_carriers = (range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27),) self.length_tag_key = length_tag_key = "frame_len" self.header_mod = header_mod = digital.constellation_bpsk() self.fft_len = fft_len = 64 self.Kw = Kw = 70*8 self.sync_word2 = sync_word2 = [0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 0, 0, 0, 0, 0] self.sync_word1 = sync_word1 = [0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0.] self.small_packet_len = small_packet_len = 52 self.samp_rate = samp_rate = int(1e6) self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe(fft_len, payload_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 0, 1) self.header_formatter = header_formatter = digital.packet_header_ofdm(occupied_carriers, n_syms=1, len_tag_key=packet_length_tag_key, frame_len_tag_key=length_tag_key, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=payload_mod.bits_per_symbol(), scramble_header=False) self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe(fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 0, 1) self.freq = freq = 2450e6 self.coderate = coderate = [3,3,3,3,4] self.Users = Users = 4 self.Nbfiles = Nbfiles = 20 self.NbStrgUsers = NbStrgUsers = 1 self.NbChuncks = NbChuncks = 200 self.N = N = 2048 self.Ks = Ks = 2*Kw ################################################## # Blocks ################################################## self.zeromq_sub_msg_source_0_0_0 = zeromq.sub_msg_source('tcp://mnode16:5575', 10) self.zeromq_sub_msg_source_0_0 = zeromq.sub_msg_source('tcp://mnode16:5555', 100) self.uhd_usrp_source_0_0 = uhd.usrp_source( ",".join(('', "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0_0.set_clock_source('external', 0) self.uhd_usrp_source_0_0.set_time_source('external', 0) self.uhd_usrp_source_0_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0_0.set_time_unknown_pps(uhd.time_spec()) self.uhd_usrp_source_0_0.set_center_freq(freq, 0) self.uhd_usrp_source_0_0.set_gain(gain, 0) self.uhd_usrp_source_0_0.set_antenna('TX/RX', 0) self.uhd_usrp_source_0_0.set_auto_dc_offset(True, 0) self.uhd_usrp_source_0_0.set_auto_iq_balance(True, 0) self.projectCACHE_ofdm_frame_equalizer1_vcvc_0 = projectCACHE.ofdm_frame_equalizer1_vcvc(fft_len, fft_len/4, length_tag_key, True, occupied_carriers, pilot_carriers, pilot_symbols, 0, True) self.projectCACHE_PolarDec_b_0_0 = projectCACHE.PolarDec_b(N, Nbfiles, NbChuncks, id_user, Users, small_packet_len, 42, coderate[id_user], packet_length_tag_key) self.projectCACHE_PC_Error_Rate_0 = projectCACHE.PC_Error_Rate(id_user, 200) self.fft_vxx_1 = fft.fft_vcc(fft_len, True, (), True, 1) self.fft_vxx_0 = fft.fft_vcc(fft_len, True, (()), True, 1) self.digital_probe_mpsk_snr_est_c_0 = digital.probe_mpsk_snr_est_c(3, 1000, 0.001) self.digital_packet_headerparser_b_0 = digital.packet_headerparser_b(header_formatter.base()) self.digital_ofdm_sync_sc_cfb_0 = digital.ofdm_sync_sc_cfb(fft_len, fft_len/4, False, 0.9) self.digital_ofdm_serializer_vcc_payload = digital.ofdm_serializer_vcc(fft_len, occupied_carriers, length_tag_key, packet_length_tag_key, 1, '', True) self.digital_ofdm_serializer_vcc_header = digital.ofdm_serializer_vcc(fft_len, occupied_carriers, length_tag_key, '', 0, '', True) self.digital_ofdm_frame_equalizer_vcvc_0 = digital.ofdm_frame_equalizer_vcvc(header_equalizer.base(), fft_len/4, length_tag_key, True, 1) self.digital_ofdm_chanest_vcvc_0 = digital.ofdm_chanest_vcvc((sync_word1), (sync_word2), 1, 0, 3, False) self.digital_header_payload_demux_0 = digital.header_payload_demux( 3, fft_len, fft_len/4, length_tag_key, "", True, gr.sizeof_gr_complex, "rx_time", samp_rate, (), 0, ) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(2*3.14/100, 2, False) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(header_mod.base()) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, fft_len+fft_len/4) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(-2.0/fft_len) ################################################## # Connections ################################################## self.msg_connect((self.digital_packet_headerparser_b_0, 'header_data'), (self.digital_header_payload_demux_0, 'header_data')) self.msg_connect((self.digital_probe_mpsk_snr_est_c_0, 'snr'), (self.projectCACHE_PC_Error_Rate_0, 'SNR')) self.msg_connect((self.zeromq_sub_msg_source_0_0, 'out'), (self.projectCACHE_PC_Error_Rate_0, 'BER_INFO')) self.msg_connect((self.zeromq_sub_msg_source_0_0_0, 'out'), (self.projectCACHE_PC_Error_Rate_0, 'CH_USE')) self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.digital_header_payload_demux_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_packet_headerparser_b_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.blocks_delay_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_ofdm_sync_sc_cfb_0, 0)) self.connect((self.digital_header_payload_demux_0, 0), (self.fft_vxx_0, 0)) self.connect((self.digital_header_payload_demux_0, 1), (self.fft_vxx_1, 0)) self.connect((self.digital_ofdm_chanest_vcvc_0, 0), (self.digital_ofdm_frame_equalizer_vcvc_0, 0)) self.connect((self.digital_ofdm_frame_equalizer_vcvc_0, 0), (self.digital_ofdm_serializer_vcc_header, 0)) self.connect((self.digital_ofdm_serializer_vcc_header, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_ofdm_serializer_vcc_payload, 0), (self.digital_probe_mpsk_snr_est_c_0, 0)) self.connect((self.digital_ofdm_serializer_vcc_payload, 0), (self.projectCACHE_PolarDec_b_0_0, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_0, 0), (self.analog_frequency_modulator_fc_0, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_0, 1), (self.digital_header_payload_demux_0, 1)) self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_chanest_vcvc_0, 0)) self.connect((self.fft_vxx_1, 0), (self.projectCACHE_ofdm_frame_equalizer1_vcvc_0, 0)) self.connect((self.projectCACHE_ofdm_frame_equalizer1_vcvc_0, 0), (self.digital_ofdm_serializer_vcc_payload, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.digital_costas_loop_cc_0, 0))
def __init__(self, freq=2480000000, gain=48, method=7): gr.top_block.__init__(self, "IEEE 802.15.4 Transceiver using OQPSK PHY") ################################################## # Parameters ################################################## self.freq = freq self.gain = gain self.method = method ################################################## # Blocks ################################################## self.uhdgps_cpdu_average_power_0 = uhdgps.cpdu_average_power(-60) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(('', "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(5000000) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(('', "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(5000000) self.uhd_usrp_sink_0.set_center_freq(freq, 0) self.uhd_usrp_sink_0.set_gain(gain, 0) self.lqe_powerControl_0 = lqe.powerControl( gain, '/home/wendley/SerieGanho100ms.txt', False) self.lqe_getRSSI_0 = lqe.getRSSI(False, 2, 2, 40, -108, -67, 0.500, 0.2, 0.1, 0.05) self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack( ([129]), ([131]), ([132]), ([23, 42])) self.ieee802_15_4_oqpsk_phy_0 = ieee802_15_4_oqpsk_phy() self.ieee802_15_4_mac_0 = ieee802_15_4.mac(True) self.foo_periodic_msg_source_1 = foo.periodic_msg_source( pmt.intern( "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" ), 400, 1000, True, False) self.es_trigger_sample_timer_0 = es.trigger_sample_timer( gr.sizeof_gr_complex, int(2000), 2, int(4000000), 512) self.es_sink_0 = es.sink(1 * [gr.sizeof_gr_complex], 8, 64, 0, 2, 0) self.es_handler_pdu_0 = es.es_make_handler_pdu( es.es_handler_print.TYPE_C32) self.digital_probe_mpsk_snr_est_c_0 = digital.probe_mpsk_snr_est_c( 2, 1000, 0.001) self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", '', '52001', 10000, False) self.blocks_pdu_remove_0 = blocks.pdu_remove( pmt.intern("es::event_buffer")) ################################################## # Connections ################################################## self.msg_connect((self.blocks_pdu_remove_0, 'pdus'), (self.ieee802_15_4_mac_0, 'cs in')) self.msg_connect((self.blocks_socket_pdu_0_0, 'pdus'), (self.ieee802_15_4_rime_stack_0, 'bcin')) self.msg_connect((self.digital_probe_mpsk_snr_est_c_0, 'snr'), (self.lqe_getRSSI_0, 'SNR')) self.msg_connect((self.es_handler_pdu_0, 'pdus_out'), (self.uhdgps_cpdu_average_power_0, 'cpdus')) self.msg_connect( (self.es_trigger_sample_timer_0, 'sample_timer_event'), (self.es_handler_pdu_0, 'handle_event')) self.msg_connect((self.es_trigger_sample_timer_0, 'which_stream'), (self.es_sink_0, 'schedule_event')) self.msg_connect((self.foo_periodic_msg_source_1, 'out'), (self.ieee802_15_4_rime_stack_0, 'bcin')) self.msg_connect((self.foo_periodic_msg_source_1, 'out'), (self.lqe_getRSSI_0, 'sendOrder')) self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'), (self.ieee802_15_4_oqpsk_phy_0, 'txin')) self.msg_connect((self.ieee802_15_4_mac_0, 'app out'), (self.ieee802_15_4_rime_stack_0, 'fromMAC')) self.msg_connect((self.ieee802_15_4_mac_0, 'ackOut'), (self.lqe_getRSSI_0, 'Ackin')) self.msg_connect((self.ieee802_15_4_mac_0, 'packLost'), (self.lqe_getRSSI_0, 'lostPacks')) self.msg_connect((self.ieee802_15_4_mac_0, 'resendPck'), (self.lqe_getRSSI_0, 'sendPacks')) self.msg_connect((self.ieee802_15_4_mac_0, 'ackOut'), (self.lqe_powerControl_0, 'saveGain')) self.msg_connect((self.ieee802_15_4_mac_0, 'resendPck'), (self.lqe_powerControl_0, 'saveGain')) self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'), (self.ieee802_15_4_mac_0, 'pdu in')) self.msg_connect((self.ieee802_15_4_rime_stack_0, 'bcout'), (self.blocks_socket_pdu_0_0, 'pdus')) self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'), (self.ieee802_15_4_mac_0, 'app in')) self.msg_connect((self.lqe_getRSSI_0, 'estimation'), (self.lqe_powerControl_0, 'estimation')) self.msg_connect((self.uhdgps_cpdu_average_power_0, 'cpdus'), (self.blocks_pdu_remove_0, 'pdus')) self.msg_connect((self.uhdgps_cpdu_average_power_0, 'rssi'), (self.lqe_getRSSI_0, 'RSSIin')) self.connect((self.es_trigger_sample_timer_0, 0), (self.es_sink_0, 0)) self.connect((self.ieee802_15_4_oqpsk_phy_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.digital_probe_mpsk_snr_est_c_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.es_trigger_sample_timer_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.ieee802_15_4_oqpsk_phy_0, 0))
def __init__(self, address='serial=30AD34D'): gr.top_block.__init__(self, "MPSK TX RX") Qt.QWidget.__init__(self) self.setWindowTitle("MPSK TX RX") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "MPSK_TX_RX") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.address = address ################################################## # Variables ################################################## self.const_type = const_type = 2 self.bits_per_symbol = bits_per_symbol = int(const_type + 1) self.samples_per_symbol = samples_per_symbol = int(2 * (bits_per_symbol)) self.probe_SNR = probe_SNR = 0 self.nfilts = nfilts = 32 self.bitrate = bitrate = 64e3 self.variable_qtgui_label_0 = variable_qtgui_label_0 = { 0: 'BPSK', 1: 'QPSK', 2: '8-PSK' }[const_type] + " - Change const_type for different constellation types!" self.tun_gain_tx = tun_gain_tx = 40 self.tun_freq_tx = tun_freq_tx = 2.39e9 self.timing_bw = timing_bw = 2 * math.pi / 100.0 self.samp_rate = samp_rate = samples_per_symbol * bitrate self.phase_bw = phase_bw = 2 * math.pi / 100.0 self.ntaps = ntaps = 11 * int(samples_per_symbol * nfilts) self.lo_offset = lo_offset = 6e6 self.gain_rx = gain_rx = 0.75 self.freq_rx = freq_rx = 2390e6 self.freq_bw = freq_bw = 2 * math.pi / 100.0 self.fll_ntaps = fll_ntaps = 55 self.excess_bw = excess_bw = 0.35 self.constellation = constellation = (digital.constellation_bpsk(), digital.constellation_qpsk(), digital.constellation_8psk()) self.arrity = arrity = pow(2, bits_per_symbol) self.ampl = ampl = 0.7 self.SNR = SNR = probe_SNR ################################################## # Blocks ################################################## self._tun_gain_tx_range = Range(0, 80, 1, 40, 200) self._tun_gain_tx_win = RangeWidget(self._tun_gain_tx_range, self.set_tun_gain_tx, 'UHD Tx Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._tun_gain_tx_win, 1, 0, 1, 1) self._tun_freq_tx_range = Range(2.3e9, 2.5e9, 1, 2.39e9, 200) self._tun_freq_tx_win = RangeWidget(self._tun_freq_tx_range, self.set_tun_freq_tx, 'UHD Tx Freq (Hz)', "counter_slider", float) self.top_grid_layout.addWidget(self._tun_freq_tx_win, 0, 0, 1, 1) self._lo_offset_options = ( 0, 6e6, 11e6, ) self._lo_offset_labels = ( str(self._lo_offset_options[0]), str(self._lo_offset_options[1]), str(self._lo_offset_options[2]), ) self._lo_offset_tool_bar = Qt.QToolBar(self) self._lo_offset_tool_bar.addWidget(Qt.QLabel("lo_offset" + ": ")) self._lo_offset_combo_box = Qt.QComboBox() self._lo_offset_tool_bar.addWidget(self._lo_offset_combo_box) for label in self._lo_offset_labels: self._lo_offset_combo_box.addItem(label) self._lo_offset_callback = lambda i: Qt.QMetaObject.invokeMethod( self._lo_offset_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._lo_offset_options.index(i))) self._lo_offset_callback(self.lo_offset) self._lo_offset_combo_box.currentIndexChanged.connect( lambda i: self.set_lo_offset(self._lo_offset_options[i])) self.top_grid_layout.addWidget(self._lo_offset_tool_bar, 2, 1, 1, 1) self._gain_rx_range = Range(0, 1, 0.01, 0.75, 200) self._gain_rx_win = RangeWidget(self._gain_rx_range, self.set_gain_rx, 'UHD Rx Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._gain_rx_win, 1, 1, 1, 1) self._freq_rx_range = Range(2350e6, 2500e6, 10e6, 2390e6, 200) self._freq_rx_win = RangeWidget(self._freq_rx_range, self.set_freq_rx, 'UHD Rx Freq (Hz)', "counter_slider", float) self.top_grid_layout.addWidget(self._freq_rx_win, 0, 1, 1, 1) self.digital_probe_mpsk_snr_est_c_0 = digital.probe_mpsk_snr_est_c( 2, 1000, 10 / bitrate) self._const_type_options = ( 0, 1, 2, ) self._const_type_labels = ( 'DBPSK', 'DQPSK', 'D8PSK', ) self._const_type_tool_bar = Qt.QToolBar(self) self._const_type_tool_bar.addWidget(Qt.QLabel("const_type" + ": ")) self._const_type_combo_box = Qt.QComboBox() self._const_type_tool_bar.addWidget(self._const_type_combo_box) for label in self._const_type_labels: self._const_type_combo_box.addItem(label) self._const_type_callback = lambda i: Qt.QMetaObject.invokeMethod( self._const_type_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._const_type_options.index(i))) self._const_type_callback(self.const_type) self._const_type_combo_box.currentIndexChanged.connect( lambda i: self.set_const_type(self._const_type_options[i])) self.top_layout.addWidget(self._const_type_tool_bar) self._ampl_range = Range(0, 1, 0.01, 0.7, 200) self._ampl_win = RangeWidget(self._ampl_range, self.set_ampl, 'Amplitude', "counter_slider", float) self.top_grid_layout.addWidget(self._ampl_win, 2, 0, 1, 1) self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_formatter = None else: self._variable_qtgui_label_0_formatter = lambda x: x self._variable_qtgui_label_0_tool_bar.addWidget( Qt.QLabel('Constellation Type' + ": ")) self._variable_qtgui_label_0_label = Qt.QLabel( str( self._variable_qtgui_label_0_formatter( self.variable_qtgui_label_0))) self._variable_qtgui_label_0_tool_bar.addWidget( self._variable_qtgui_label_0_label) self.top_layout.addWidget(self._variable_qtgui_label_0_tool_bar) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join((address, "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_clock_rate(30.72e6, uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_subdev_spec('A:A', 0) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq( uhd.tune_request(freq_rx, rf_freq=freq_rx - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_source_0.set_normalized_gain(gain_rx, 0) self.uhd_usrp_source_0.set_antenna('TX/RX', 0) self.uhd_usrp_sink_0_0 = uhd.usrp_sink( ",".join((address, "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0_0.set_clock_rate(30.72e6, uhd.ALL_MBOARDS) self.uhd_usrp_sink_0_0.set_subdev_spec('A:B', 0) self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0_0.set_center_freq(tun_freq_tx, 0) self.uhd_usrp_sink_0_0.set_gain(tun_gain_tx, 0) self.uhd_usrp_sink_0_0.set_antenna('TX/RX', 0) self.qtgui_number_sink_0_1 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0_1.set_update_time(0.10) self.qtgui_number_sink_0_1.set_title("BER") labels = ['BER', '', '', '', '', '', '', '', '', ''] units = ['x10^-6', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1e6, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_1.set_min(i, 0) self.qtgui_number_sink_0_1.set_max(i, 1) self.qtgui_number_sink_0_1.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_1.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_1.set_label(i, labels[i]) self.qtgui_number_sink_0_1.set_unit(i, units[i]) self.qtgui_number_sink_0_1.set_factor(i, factor[i]) self.qtgui_number_sink_0_1.enable_autoscale(True) self._qtgui_number_sink_0_1_win = sip.wrapinstance( self.qtgui_number_sink_0_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_1_win) 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_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win, 3, 0, 1, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.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, 3, 1, 1, 1) def _probe_SNR_probe(): while True: val = self.digital_probe_mpsk_snr_est_c_0.snr() try: self.set_probe_SNR(val) except AttributeError: pass time.sleep(1.0 / (10)) _probe_SNR_thread = threading.Thread(target=_probe_SNR_probe) _probe_SNR_thread.daemon = True _probe_SNR_thread.start() self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( samples_per_symbol, taps=(firdes.root_raised_cosine(nfilts, nfilts, 1.0, 0.35, ntaps)), flt_size=nfilts) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.digital_scrambler_bb_0 = digital.scrambler_bb(0x8A, 0x7F, 7) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( samples_per_symbol, timing_bw, (firdes.root_raised_cosine( nfilts, nfilts * samples_per_symbol, 1.0, 0.35, ntaps)), nfilts, nfilts // 2, 1.5, 1) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc( samples_per_symbol, excess_bw, fll_ntaps, freq_bw) self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(arrity) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(arrity) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x8A, 0x7F, 7) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( timing_bw, pow(2, bits_per_symbol), False) self.digital_constellation_decoder_cb_0_0 = digital.constellation_decoder_cb( constellation[const_type].base()) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (constellation[const_type].points()), 1) self.blocks_vector_source_x_0_0 = blocks.vector_source_b([ 1, ], True, 1, []) self.blocks_vector_source_x_0 = blocks.vector_source_b([ 1, ], True, 1, []) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb( bits_per_symbol) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(bits_per_symbol) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((ampl, )) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=10000, bits_per_symbol=1, ) self.analog_agc2_xx_0 = analog.agc2_cc(0.6e-1, 1e-3, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) self._SNR_tool_bar = Qt.QToolBar(self) if None: self._SNR_formatter = None else: self._SNR_formatter = lambda x: x self._SNR_tool_bar.addWidget(Qt.QLabel("SNR" + ": ")) self._SNR_label = Qt.QLabel(str(self._SNR_formatter(self.SNR))) self._SNR_tool_bar.addWidget(self._SNR_label) self.top_layout.addWidget(self._SNR_tool_bar) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.qtgui_number_sink_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.digital_diff_encoder_bb_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.digital_scrambler_bb_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.digital_constellation_decoder_cb_0_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_constellation_decoder_cb_0_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_probe_mpsk_snr_est_c_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.blks2_error_rate_0, 1)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_diff_encoder_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_scrambler_bb_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.analog_agc2_xx_0, 0))