def test_001(self): tb = self.tb src1_data = (0,0.2,-0.3,0,12,0) src2_data = (0,0.0,3.0,0,10,0) src3_data = (0,0.0,3.0,0,1,0) src1 = blocks.vector_source_f(src1_data) s2v1 = blocks.stream_to_vector(gr.sizeof_float, len(src1_data)) tb.connect(src1, s2v1) src2 = blocks.vector_source_f(src2_data) s2v2 = blocks.stream_to_vector(gr.sizeof_float, len(src1_data)) tb.connect(src2, s2v2) src3 = blocks.vector_source_f(src3_data) s2v3 = blocks.stream_to_vector(gr.sizeof_float, len(src1_data)) tb.connect(src3, s2v3) dst1 = blocks.vector_sink_s() dst2 = blocks.vector_sink_s() argmax = blocks.argmax_fs(len(src1_data)) tb.connect(s2v1, (argmax, 0)) tb.connect(s2v2, (argmax, 1)) tb.connect(s2v3, (argmax, 2)) tb.connect((argmax,0), dst1) tb.connect((argmax,1), dst2) tb.run() index = dst1.data() source = dst2.data() self.assertEqual(index, (4,)) self.assertEqual(source, (0,))
def test_001(self): tb = self.tb src1_data = (0, 0.2, -0.3, 0, 12, 0) src2_data = (0, 0.0, 3.0, 0, 10, 0) src3_data = (0, 0.0, 3.0, 0, 1, 0) src1 = blocks.vector_source_f(src1_data) s2v1 = blocks.stream_to_vector(gr.sizeof_float, len(src1_data)) tb.connect(src1, s2v1) src2 = blocks.vector_source_f(src2_data) s2v2 = blocks.stream_to_vector(gr.sizeof_float, len(src1_data)) tb.connect(src2, s2v2) src3 = blocks.vector_source_f(src3_data) s2v3 = blocks.stream_to_vector(gr.sizeof_float, len(src1_data)) tb.connect(src3, s2v3) dst1 = blocks.vector_sink_s() dst2 = blocks.vector_sink_s() argmax = blocks.argmax_fs(len(src1_data)) tb.connect(s2v1, (argmax, 0)) tb.connect(s2v2, (argmax, 1)) tb.connect(s2v3, (argmax, 2)) tb.connect((argmax, 0), dst1) tb.connect((argmax, 1), dst2) tb.run() index = dst1.data() source = dst2.data() self.assertEqual(index, (4, )) self.assertEqual(source, (0, ))
def __init__(self, ts, factor, alpha, samp_rate, freqs): gr.hier_block2.__init__( self, "freq_timing_estimator_hier", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signaturev(3, 3, [gr.sizeof_char*1, gr.sizeof_float*1, gr.sizeof_float*1]), ) ################################################## # Parameters ################################################## self.ts = ts self.factor = factor self.alpha = alpha self.samp_rate = samp_rate self.freqs = freqs self.n = n = len(freqs) ################################################## # Blocks ################################################## self._filter=[0]*self.n self._c2mag2=[0]*self.n for i in range(self.n): self._filter[i]= filter.freq_xlating_fir_filter_ccc(1, (numpy.conjugate(self.ts[::-1])), self.freqs[i], self.samp_rate) self._c2mag2[i] = blocks.complex_to_mag_squared(1) self.blocks_max = blocks.max_ff(1) self.blocks_peak_detector = blocks.peak_detector_fb(self.factor, self.factor, 0, self.alpha) self.blocks_argmax = blocks.argmax_fs(1) self.blocks_null_sink = blocks.null_sink(gr.sizeof_short*1) self.digital_chunks_to_symbols = digital.chunks_to_symbols_sf((freqs), 1) self.blocks_sample_and_hold = blocks.sample_and_hold_ff() ################################################## # Connections ################################################## for i in range(self.n): self.connect((self, 0), (self._filter[i], 0)) self.connect((self._filter[i], 0), (self._c2mag2[i], 0)) self.connect((self._c2mag2[i], 0), (self.blocks_max, i)) self.connect((self._c2mag2[i], 0), (self.blocks_argmax, i)) self.connect((self.blocks_max, 0), (self.blocks_peak_detector, 0)) self.connect((self.blocks_peak_detector, 0), (self, 0)) self.connect((self.blocks_argmax, 0), (self.blocks_null_sink, 0)) self.connect((self.blocks_argmax, 1), (self.digital_chunks_to_symbols, 0)) self.connect((self.digital_chunks_to_symbols, 0), (self.blocks_sample_and_hold, 0)) self.connect((self.blocks_peak_detector, 0), (self.blocks_sample_and_hold, 1)) self.connect((self.blocks_sample_and_hold, 0), (self, 1)) self.connect((self.blocks_max, 0), (self, 2))
def __init__(self, fft_len): gr.hier_block2.__init__(self, "FFT Peak", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signaturev(2, 2, [gr.sizeof_float*1, gr.sizeof_float*1])) ''' Constructor @param fft_len - ''' ################################################## # Parameters ################################################## self.fft_len = fft_len ################################################## # Blocks ################################################## self.fft = fft.fft_vcc(fft_len, True, (window.blackmanharris(fft_len)), False, 1) self.v2s = blocks.vector_to_stream(gr.sizeof_float*1, fft_len) self.s2v = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fft_len) self.s2f = blocks.short_to_float(1, 1) self.repeat = blocks.repeat(gr.sizeof_short*1, fft_len) self.null_0 = blocks.null_sink(gr.sizeof_float*1) self.null_1 = blocks.null_sink(gr.sizeof_short*1) self.c2mag = blocks.complex_to_mag(fft_len) self.argmax = blocks.argmax_fs(fft_len) ################################################## # Connections ################################################## self.connect((self.argmax, 1), (self.null_1, 0)) self.connect((self.argmax, 0), (self.repeat, 0)) self.connect((self.c2mag, 0), (self.argmax, 0)) self.connect((self.c2mag, 0), (self.v2s, 0)) self.connect((self.repeat, 0), (self.s2f, 0)) self.connect((self.s2f, 0), (self, 0)) self.connect((self.s2v, 0), (self.fft, 0)) self.connect((self.v2s, 0), (self.null_0, 0)) self.connect((self.v2s, 0), (self, 1)) self.connect((self.fft, 0), (self.c2mag, 0)) self.connect((self, 0), (self.s2v, 0))
def __init__(self): gr.top_block.__init__(self, "ORBCOMM UHF Beacon RX") Qt.QWidget.__init__(self) self.setWindowTitle("ORBCOMM UHF Beacon RX") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "uhf_rx_exp") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 50e3 self.xlate_taps = xlate_taps = firdes.low_pass(1.0, samp_rate, samp_rate / 2, 1000, firdes.WIN_HAMMING, 6.76) self.ts_str = ts_str = dt.strftime(dt.utcnow(), "%Y%m%d_%H%M%S.%f") + '_UTC' self.rx_gain = rx_gain = 30 self.rx_freq = rx_freq = 400.2e6 self.offset = offset = 0 self.fft_size = fft_size = 4096 * 1 self.delay = delay = 10 ################################################## # Blocks ################################################## self._offset_tool_bar = Qt.QToolBar(self) self._offset_tool_bar.addWidget(Qt.QLabel('OFFSET' + ": ")) self._offset_line_edit = Qt.QLineEdit(str(self.offset)) self._offset_tool_bar.addWidget(self._offset_line_edit) self._offset_line_edit.returnPressed.connect(lambda: self.set_offset( eng_notation.str_to_num( str(self._offset_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._offset_tool_bar, 1, 6, 1, 2) self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff( .005, 1) self._rx_gain_tool_bar = Qt.QToolBar(self) self._rx_gain_tool_bar.addWidget(Qt.QLabel('GAIN' + ": ")) self._rx_gain_line_edit = Qt.QLineEdit(str(self.rx_gain)) self._rx_gain_tool_bar.addWidget(self._rx_gain_line_edit) self._rx_gain_line_edit.returnPressed.connect(lambda: self.set_rx_gain( eng_notation.str_to_num( str(self._rx_gain_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._rx_gain_tool_bar, 2, 6, 1, 2) self._rx_freq_tool_bar = Qt.QToolBar(self) self._rx_freq_tool_bar.addWidget(Qt.QLabel('FREQ' + ": ")) self._rx_freq_line_edit = Qt.QLineEdit(str(self.rx_freq)) self._rx_freq_tool_bar.addWidget(self._rx_freq_line_edit) self._rx_freq_line_edit.returnPressed.connect(lambda: self.set_rx_freq( eng_notation.str_to_num( str(self._rx_freq_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._rx_freq_tool_bar, 0, 6, 1, 2) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0.enable_grid(True) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [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_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-120, -80) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 10, 0, 2, 6) self.qtgui_number_sink_0_0_0_0_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1) self.qtgui_number_sink_0_0_0_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0_0_0_0.set_title("") labels = ['SNR', '', '', '', '', '', '', '', '', ''] 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_0_0_0_0.set_min(i, 0) self.qtgui_number_sink_0_0_0_0_0.set_max(i, 80) self.qtgui_number_sink_0_0_0_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_0_0_0.set_label( i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_0_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0_0_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0_0_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_0_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_0_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_0_0_win, 3, 6, 1, 1) self.qtgui_number_sink_0_0_0_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1) self.qtgui_number_sink_0_0_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0_0_0.set_title("") labels = ['Noise', '', '', '', '', '', '', '', '', ''] units = ['dBFS', '', '', '', '', '', '', '', '', ''] 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_0.set_min(i, 0) self.qtgui_number_sink_0_0_0_0.set_max(i, 80) self.qtgui_number_sink_0_0_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_0_0.set_label( i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_0_win, 4, 7, 1, 1) self.qtgui_number_sink_0_0_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1) self.qtgui_number_sink_0_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0_0.set_title("") labels = ['Signal Power', '', '', '', '', '', '', '', '', ''] units = ['dBFS', '', '', '', '', '', '', '', '', ''] 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, 0) self.qtgui_number_sink_0_0_0.set_max(i, 80) 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, 3, 7, 1, 1) self.qtgui_number_sink_0_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1) self.qtgui_number_sink_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0.set_title("") labels = ['Doppler', '', '', '', '', '', '', '', '', ''] units = ['Hz', '', '', '', '', '', '', '', '', ''] 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.set_min(i, 0) self.qtgui_number_sink_0_0.set_max(i, 80) self.qtgui_number_sink_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_win, 4, 6, 1, 1) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_VERT, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ['Doppler Rate', '', '', '', '', '', '', '', '', ''] units = ['Hz/s', '', '', '', '', '', '', '', '', ''] 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.set_min(i, 0) self.qtgui_number_sink_0.set_max(i, 80) 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, 5, 6, 4, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.010) self.qtgui_freq_sink_x_0.set_y_axis(-130, -90) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.05) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] 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, 10, 6) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 1, (xlate_taps), offset, samp_rate) self.fft_vxx_0 = fft.fft_vcc(fft_size, True, (window.flattop(fft_size)), True, 2) self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_float * 1, fft_size) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate * 4, True) self.blocks_sub_xx_0_0 = blocks.sub_ff(1) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, fft_size) self.blocks_short_to_float_0 = blocks.short_to_float(1, 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_short * 1) self.blocks_nlog10_ff_0 = blocks.nlog10_ff( 10, fft_size, -10 * math.log10(fft_size**2)) self.blocks_multiply_const_vxx_1_0_0 = blocks.multiply_const_vff( ((samp_rate / fft_size) / delay, )) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff( (samp_rate / fft_size, )) self.blocks_moving_average_xx_1 = blocks.moving_average_ff( fft_size, float(1.0 / fft_size), 4000, 1) self.blocks_max_xx_0 = blocks.max_ff(fft_size, 1) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_float * 1, fft_size) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, '/home/zleffke/captures/orbcomm/ORBCOMM_FMXX_USRP_20171203_013912.497704_UTC_50k.fc32', True) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, delay) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared( fft_size) self.blocks_argmax_xx_0 = blocks.argmax_fs(fft_size) self.blocks_add_const_vxx_0_0 = blocks.add_const_vff((5.76, )) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-samp_rate / 2, )) self.blocks_abs_xx_0 = blocks.abs_ff(1) ################################################## # Connections ################################################## self.connect((self.blocks_abs_xx_0, 0), (self.single_pole_iir_filter_xx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_sub_xx_0_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.qtgui_number_sink_0_0, 0)) self.connect((self.blocks_add_const_vxx_0_0, 0), (self.blocks_moving_average_xx_1, 0)) self.connect((self.blocks_argmax_xx_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_argmax_xx_0, 0), (self.blocks_short_to_float_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_sub_xx_0_0, 1)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.qtgui_number_sink_0_0_0_0, 0)) self.connect((self.blocks_max_xx_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_max_xx_0, 0), (self.qtgui_number_sink_0_0_0, 0)) self.connect((self.blocks_moving_average_xx_1, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0_0, 0), (self.blocks_abs_xx_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_argmax_xx_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_max_xx_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.qtgui_number_sink_0_0_0_0_0, 0)) self.connect((self.blocks_sub_xx_0_0, 0), (self.blocks_multiply_const_vxx_1_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_add_const_vxx_0_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.single_pole_iir_filter_xx_0, 0), (self.qtgui_number_sink_0, 0))
def __init__(self, seq1, seq2, factor, alpha, freqs): """ Description: frequency timing estimator class does frequency/timing acquisition from scratch.It uses a bank of parallel correlators at each specified frequency. It then takes the max abs value of all these and passes it through a peak detector to find timing. Args: seq1: sequence1 of kronecker filter, which is the given training sequence. seq2: sequence2 of kronecker filter, which is the pulse for each training symbol. factor: the rise and fall factors in peak detector, which is the factor determining when a peak has started and ended. In the peak detector, an average of the signal is calculated. When the value of the signal goes over factor*average, we start looking for a peak. When the value of the signal goes below factor*average, we stop looking for a peak. alpha: the smoothing factor of a moving average filter used in the peak detector taking values in (0,1). freqs: the vector of normalized center frequencies for each matched filter. Note that for a training sequence of length Nt, each matched filter can recover a sequence with normalized frequency offset ~ 1/(2Nt). """ gr.hier_block2.__init__( self, "freq_timing_estimator", gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), gr.io_signaturev( 3, 3, [gr.sizeof_char * 1, gr.sizeof_float * 1, gr.sizeof_float * 1 ]), ) ################################################## # Parameters ################################################## self.seq1 = seq1 self.seq2 = seq2 self.factor = factor self.alpha = alpha self.freqs = freqs self.n = n = len(freqs) self.on = 1 ################################################## # Blocks ################################################## self._filter = [0] * self.n self._c2mag2 = [0] * self.n for i in range(self.n): #self._filter[i]= cdma.kronecker_filter(seq1,seq2,1,self.freqs[i]) #self._filter[i]= filter.freq_xlating_fir_filter_ccc(1, numpy.kron(seq1,seq2), self.freqs[i], 1) self._filter[i] = filter.freq_xlating_fft_filter_ccc( 1, numpy.kron(seq1, seq2), self.freqs[i], 1) self._c2mag2[i] = blocks.complex_to_mag_squared(1) self.blocks_max = blocks.max_ff(1) self.blocks_peak_detector = cdma.switched_peak_detector_fb( self.factor, self.factor, 0, self.alpha, self.on) self.blocks_argmax = blocks.argmax_fs(1) self.blocks_null_sink = blocks.null_sink(gr.sizeof_short * 1) self.digital_chunks_to_symbols = digital.chunks_to_symbols_sf((freqs), 1) self.blocks_sample_and_hold = blocks.sample_and_hold_ff() ################################################## # Connections ################################################## for i in range(self.n): self.connect((self, 0), (self._filter[i], 0)) self.connect((self._filter[i], 0), (self._c2mag2[i], 0)) self.connect((self._c2mag2[i], 0), (self.blocks_max, i)) self.connect((self._c2mag2[i], 0), (self.blocks_argmax, i)) self.connect((self.blocks_max, 0), (self.blocks_peak_detector, 0)) self.connect((self.blocks_peak_detector, 0), (self, 0)) self.connect((self.blocks_argmax, 0), (self.blocks_null_sink, 0)) self.connect((self.blocks_argmax, 1), (self.digital_chunks_to_symbols, 0)) self.connect((self.digital_chunks_to_symbols, 0), (self.blocks_sample_and_hold, 0)) self.connect((self.blocks_peak_detector, 0), (self.blocks_sample_and_hold, 1)) self.connect((self.blocks_sample_and_hold, 0), (self, 1)) self.connect((self.blocks_max, 0), (self, 2))
def __init__(self, avg_len=256, nfft=2048): gr.top_block.__init__(self, "FFT Power Measure") Qt.QWidget.__init__(self) self.setWindowTitle("FFT Power Measure") 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", "fft_power_meas") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.avg_len = avg_len self.nfft = nfft ################################################## # Variables ################################################## self.samp_rate = samp_rate = 4e6 self.rx_gain = rx_gain = 16 self.rx_freq = rx_freq = 1089.74e6 ################################################## # Blocks ################################################## self._rx_gain_range = Range(0, 90, 1, 16, 200) self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, "rx_gain", "counter_slider", float) self.top_grid_layout.addWidget(self._rx_gain_win, 4, 0, 1, 4) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self._rx_freq_tool_bar = Qt.QToolBar(self) self._rx_freq_tool_bar.addWidget(Qt.QLabel("rx_freq" + ": ")) self._rx_freq_line_edit = Qt.QLineEdit(str(self.rx_freq)) self._rx_freq_tool_bar.addWidget(self._rx_freq_line_edit) self._rx_freq_line_edit.returnPressed.connect(lambda: self.set_rx_freq( eng_notation.str_to_num( str(self._rx_freq_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._rx_freq_tool_bar, 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.uhd_usrp_source_1 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_1.set_samp_rate(samp_rate) self.uhd_usrp_source_1.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_1.set_center_freq( uhd.tune_request(rx_freq, samp_rate / 2), 0) self.uhd_usrp_source_1.set_gain(rx_gain, 0) self.uhd_usrp_source_1.set_antenna('RX2', 0) self.uhd_usrp_source_1.set_auto_dc_offset(True, 0) self.uhd_usrp_source_1.set_auto_iq_balance(True, 0) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 2) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(2): 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, 5, 2, 1, 2) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.001) 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(True) 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 False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "red", "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, 2, 4) for r in range(0, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.fft_vxx_0 = fft.fft_vcc(nfft, True, (window.blackmanharris(nfft)), True, 4) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, nfft) self.blocks_short_to_float_0 = blocks.short_to_float(1, 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_short * 1) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, nfft, -10 * math.log10(nfft)) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( int(avg_len), 1.0 / (avg_len) / nfft, 4000, nfft) self.blocks_max_xx_0 = blocks.max_ff(nfft, 1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared( nfft) self.blocks_argmax_xx_0 = blocks.argmax_fs(nfft) ################################################## # Connections ################################################## self.connect((self.blocks_argmax_xx_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_argmax_xx_0, 0), (self.blocks_short_to_float_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_max_xx_0, 0), (self.qtgui_number_sink_0, 1)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_argmax_xx_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_max_xx_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.uhd_usrp_source_1, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.uhd_usrp_source_1, 0), (self.qtgui_freq_sink_x_0, 0))
def __init__(self, seq1, seq2, factor, lookahead, alpha, freqs): """ Description: frequency timing estimator class does frequency/timing acquisition from scratch.It uses a bank of parallel correlators at each specified frequency. It then takes the max abs value of all these and passes it through a peak detector to find timing. Args: seq1: sequence1 of kronecker filter, which is the given training sequence. seq2: sequence2 of kronecker filter, which is the pulse for each training symbol. factor: the rise and fall factors in peak detector, which is the factor determining when a peak has started and ended. In the peak detector, an average of the signal is calculated. When the value of the signal goes over factor*average, we start looking for a peak. When the value of the signal goes below factor*average, we stop looking for a peak. alpha: the smoothing factor of a moving average filter used in the peak detector taking values in (0,1). freqs: the vector of normalized center frequencies for each matched filter. Note that for a training sequence of length Nt, each matched filter can recover a sequence with normalized frequency offset ~ 1/(2Nt). """ gr.hier_block2.__init__(self, "freq_timing_estimator", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signaturev(3, 3, [gr.sizeof_char*1, gr.sizeof_float*1, gr.sizeof_float*1]), ) ################################################## # Parameters ################################################## self.seq1 = seq1 self.seq2 = seq2 self.factor = factor self.lookahead = lookahead self.alpha = alpha self.freqs = freqs self.n = n = len(freqs) self.on = 1 ################################################## # Blocks ################################################## self._filter=[0]*self.n self._c2mag2=[0]*self.n for i in range(self.n): #self._filter[i]= cdma.kronecker_filter(seq1,seq2,1,self.freqs[i]) #self._filter[i]= filter.freq_xlating_fir_filter_ccc(1, numpy.kron(seq1,seq2), self.freqs[i], 1) self._filter[i]= filter.freq_xlating_fft_filter_ccc(1, numpy.kron(seq1,seq2), self.freqs[i], 1) self._c2mag2[i] = blocks.complex_to_mag_squared(1) self.blocks_max = blocks.max_ff(1) self.blocks_peak_detector = cdma.switched_peak_detector_fb(self.factor, self.factor, self.lookahead, self.alpha, self.on) self.blocks_argmax = blocks.argmax_fs(1) self.blocks_null_sink = blocks.null_sink(gr.sizeof_short*1) self.digital_chunks_to_symbols = digital.chunks_to_symbols_sf((freqs), 1) self.blocks_sample_and_hold = blocks.sample_and_hold_ff() ################################################## # Connections ################################################## for i in range(self.n): self.connect((self, 0), (self._filter[i], 0)) self.connect((self._filter[i], 0), (self._c2mag2[i], 0)) self.connect((self._c2mag2[i], 0), (self.blocks_max, i)) self.connect((self._c2mag2[i], 0), (self.blocks_argmax, i)) self.connect((self.blocks_max, 0), (self.blocks_peak_detector, 0)) self.connect((self.blocks_peak_detector, 0), (self, 0)) self.connect((self.blocks_argmax, 0), (self.blocks_null_sink, 0)) self.connect((self.blocks_argmax, 1), (self.digital_chunks_to_symbols, 0)) self.connect((self.digital_chunks_to_symbols, 0), (self.blocks_sample_and_hold, 0)) self.connect((self.blocks_peak_detector, 0), (self.blocks_sample_and_hold, 1)) self.connect((self.blocks_sample_and_hold, 0), (self, 1)) self.connect((self.blocks_max, 0), (self, 2))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.variable_qtgui_chooser_0_0_0 = variable_qtgui_chooser_0_0_0 = 1 self.variable_qtgui_chooser_0_0 = variable_qtgui_chooser_0_0 = 1 self.snapshots = snapshots = 4096 self.samp_rate = samp_rate = 100000000/32 self.pi = pi = 3.14159265359 self.phase_c2 = phase_c2 = 0 self.phase_c1 = phase_c1 = 0 self.phase_c0 = phase_c0 = 0 self.gain_rx = gain_rx = 20 self.center_freq = center_freq = 2.4e9 self.ant_cal_enable = ant_cal_enable = 1 ################################################## # Blocks ################################################## _variable_qtgui_chooser_0_0_0_check_box = Qt.QCheckBox("TX OTA (Bottom) ") self._variable_qtgui_chooser_0_0_0_choices = {True: 0, False: 1} self._variable_qtgui_chooser_0_0_0_choices_inv = dict((v,k) for k,v in self._variable_qtgui_chooser_0_0_0_choices.iteritems()) self._variable_qtgui_chooser_0_0_0_callback = lambda i: Qt.QMetaObject.invokeMethod(_variable_qtgui_chooser_0_0_0_check_box, "setChecked", Qt.Q_ARG("bool", self._variable_qtgui_chooser_0_0_0_choices_inv[i])) self._variable_qtgui_chooser_0_0_0_callback(self.variable_qtgui_chooser_0_0_0) _variable_qtgui_chooser_0_0_0_check_box.stateChanged.connect(lambda i: self.set_variable_qtgui_chooser_0_0_0(self._variable_qtgui_chooser_0_0_0_choices[bool(i)])) self.top_grid_layout.addWidget(_variable_qtgui_chooser_0_0_0_check_box, 1,0) _variable_qtgui_chooser_0_0_check_box = Qt.QCheckBox("TX Direct (Top)") self._variable_qtgui_chooser_0_0_choices = {True: 0, False: 1} self._variable_qtgui_chooser_0_0_choices_inv = dict((v,k) for k,v in self._variable_qtgui_chooser_0_0_choices.iteritems()) self._variable_qtgui_chooser_0_0_callback = lambda i: Qt.QMetaObject.invokeMethod(_variable_qtgui_chooser_0_0_check_box, "setChecked", Qt.Q_ARG("bool", self._variable_qtgui_chooser_0_0_choices_inv[i])) self._variable_qtgui_chooser_0_0_callback(self.variable_qtgui_chooser_0_0) _variable_qtgui_chooser_0_0_check_box.stateChanged.connect(lambda i: self.set_variable_qtgui_chooser_0_0(self._variable_qtgui_chooser_0_0_choices[bool(i)])) self.top_grid_layout.addWidget(_variable_qtgui_chooser_0_0_check_box, 0,0) self._phase_c2_range = Range(-180, 180, 1, 0, 200) self._phase_c2_win = RangeWidget(self._phase_c2_range, self.set_phase_c2, "Phase Channel2", "counter_slider", float) self.top_layout.addWidget(self._phase_c2_win) self._phase_c1_range = Range(-180, 180, 1, 0, 200) self._phase_c1_win = RangeWidget(self._phase_c1_range, self.set_phase_c1, "Phase Channel1", "counter_slider", float) self.top_layout.addWidget(self._phase_c1_win) self._phase_c0_range = Range(-180, 180, 1, 0, 200) self._phase_c0_win = RangeWidget(self._phase_c0_range, self.set_phase_c0, "Phase Channel0", "counter_slider", float) self.top_layout.addWidget(self._phase_c0_win) _ant_cal_enable_check_box = Qt.QCheckBox("Enable Antenna Calibration") self._ant_cal_enable_choices = {True: 0, False: 1} self._ant_cal_enable_choices_inv = dict((v,k) for k,v in self._ant_cal_enable_choices.iteritems()) self._ant_cal_enable_callback = lambda i: Qt.QMetaObject.invokeMethod(_ant_cal_enable_check_box, "setChecked", Qt.Q_ARG("bool", self._ant_cal_enable_choices_inv[i])) self._ant_cal_enable_callback(self.ant_cal_enable) _ant_cal_enable_check_box.stateChanged.connect(lambda i: self.set_ant_cal_enable(self._ant_cal_enable_choices[bool(i)])) self.top_grid_layout.addWidget(_ant_cal_enable_check_box, 1,4) self.wifius_gen_music_spectrum_vcvf_0 = wifius.gen_music_spectrum_vcvf(3, 1, -90, 90, 1, 0.5, 4096) self.wifius_antenna_array_calibration_cf_0 = wifius.antenna_array_calibration_cf(90, 0.5, 3, snapshots) self.uhd_usrp_source_0_0 = uhd.usrp_source( ",".join(("addr0=192.168.40.2,addr1=192.168.50.2,addr2=192.168.60.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(3), ), ) 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_clock_source("external", 1) self.uhd_usrp_source_0_0.set_time_source("external", 1) self.uhd_usrp_source_0_0.set_clock_source("mimo", 2) self.uhd_usrp_source_0_0.set_time_source("mimo", 2) self.uhd_usrp_source_0_0.set_time_unknown_pps(uhd.time_spec()) self.uhd_usrp_source_0_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0_0.set_center_freq(center_freq, 0) self.uhd_usrp_source_0_0.set_gain(gain_rx, 0) self.uhd_usrp_source_0_0.set_antenna("RX2", 0) self.uhd_usrp_source_0_0.set_center_freq(center_freq, 1) self.uhd_usrp_source_0_0.set_gain(gain_rx, 1) self.uhd_usrp_source_0_0.set_antenna("RX2", 1) self.uhd_usrp_source_0_0.set_center_freq(center_freq, 2) self.uhd_usrp_source_0_0.set_gain(gain_rx, 2) self.uhd_usrp_source_0_0.set_antenna("RX2", 2) self.sync_tx_hier_0_0 = sync_tx_hier( addr0="addr=192.168.30.2", cal_freq=10e3, center_freq=center_freq, gain_tx2=20, samp_rate=samp_rate, tone_type='Real', ) self.sync_tx_hier2_0 = sync_tx_hier2( addr0="addr=192.168.20.2", cal_freq=10e3, center_freq=2.4e9, gain_tx2=20, samp_rate=samp_rate, tone_type='Real', ) self.qtgui_vector_sink_f_0 = qtgui.vector_sink_f( 180, -90, 1.0, "Offset", "dB", "MuSIC Spectrum", 1 # Number of inputs ) self.qtgui_vector_sink_f_0.set_update_time(0.10) self.qtgui_vector_sink_f_0.set_y_axis(-140, 10) self.qtgui_vector_sink_f_0.enable_autoscale(True) self.qtgui_vector_sink_f_0.enable_grid(True) self.qtgui_vector_sink_f_0.set_x_axis_units("") self.qtgui_vector_sink_f_0.set_y_axis_units("") self.qtgui_vector_sink_f_0.set_ref_level(0) 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_vector_sink_f_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_vector_sink_f_0.set_line_label(i, labels[i]) self.qtgui_vector_sink_f_0.set_line_width(i, widths[i]) self.qtgui_vector_sink_f_0.set_line_color(i, colors[i]) self.qtgui_vector_sink_f_0.set_line_alpha(i, alphas[i]) self._qtgui_vector_sink_f_0_win = sip.wrapinstance(self.qtgui_vector_sink_f_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_vector_sink_f_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 300, #size samp_rate, #samp_rate "", #name 3 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(True) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["RX1", "RX2", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(3): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_short, 0, qtgui.NUM_GRAPH_HORIZ, 1 ) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ["", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_win) self.blocks_stream_to_vector_0_0_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, snapshots) self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, snapshots) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, snapshots) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_short*1) self.blocks_multiply_const_vxx_0_0_0 = blocks.multiply_const_vcc((numpy.exp(-1j*phase_c2*pi/180), )) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((numpy.exp(-1j*phase_c1*pi/180), )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((numpy.exp(-1j*phase_c0*pi/180), )) self.blocks_message_strobe_0_3 = blocks.message_strobe(pmt.from_double(ant_cal_enable), 1000) self.blocks_message_strobe_0_0 = blocks.message_strobe(pmt.from_double(variable_qtgui_chooser_0_0), 1000) self.blocks_message_strobe_0 = blocks.message_strobe(pmt.from_double(variable_qtgui_chooser_0_0_0), 1000) self.blocks_complex_to_real_0_0_0 = blocks.complex_to_real(1) self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_argmax_xx_0 = blocks.argmax_fs(180) self.blocks_add_const_vxx_0 = blocks.add_const_vss((-90, )) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.sync_tx_hier2_0, 'Trigger')) self.msg_connect((self.blocks_message_strobe_0_0, 'strobe'), (self.sync_tx_hier_0_0, 'Trigger')) self.msg_connect((self.blocks_message_strobe_0_3, 'strobe'), (self.wifius_antenna_array_calibration_cf_0, 'enable_hold')) self.connect((self.blocks_add_const_vxx_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_argmax_xx_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_argmax_xx_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_complex_to_real_0_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blocks_complex_to_real_0_0_0, 0), (self.qtgui_time_sink_x_0, 2)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wifius_antenna_array_calibration_cf_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_complex_to_real_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_stream_to_vector_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.wifius_antenna_array_calibration_cf_0, 1)) self.connect((self.blocks_multiply_const_vxx_0_0_0, 0), (self.blocks_complex_to_real_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0_0, 0), (self.blocks_stream_to_vector_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0_0, 0), (self.wifius_antenna_array_calibration_cf_0, 2)) self.connect((self.blocks_stream_to_vector_0, 0), (self.wifius_gen_music_spectrum_vcvf_0, 2)) self.connect((self.blocks_stream_to_vector_0_0, 0), (self.wifius_gen_music_spectrum_vcvf_0, 3)) self.connect((self.blocks_stream_to_vector_0_0_0, 0), (self.wifius_gen_music_spectrum_vcvf_0, 4)) self.connect((self.uhd_usrp_source_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.uhd_usrp_source_0_0, 1), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.uhd_usrp_source_0_0, 2), (self.blocks_multiply_const_vxx_0_0_0, 0)) self.connect((self.wifius_antenna_array_calibration_cf_0, 0), (self.wifius_gen_music_spectrum_vcvf_0, 0)) self.connect((self.wifius_antenna_array_calibration_cf_0, 1), (self.wifius_gen_music_spectrum_vcvf_0, 1)) self.connect((self.wifius_gen_music_spectrum_vcvf_0, 0), (self.blocks_argmax_xx_0, 0)) self.connect((self.wifius_gen_music_spectrum_vcvf_0, 0), (self.qtgui_vector_sink_f_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 16000 ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_number_sink_1 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1 ) self.qtgui_number_sink_1.set_update_time(0.10) self.qtgui_number_sink_1.set_title("after float") labels = ["", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_1.set_min(i, -1) self.qtgui_number_sink_1.set_max(i, 1) self.qtgui_number_sink_1.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_1.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_1.set_label(i, labels[i]) self.qtgui_number_sink_1.set_unit(i, units[i]) self.qtgui_number_sink_1.set_factor(i, factor[i]) self.qtgui_number_sink_1.enable_autoscale(False) self._qtgui_number_sink_1_win = sip.wrapinstance(self.qtgui_number_sink_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_1_win) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_char, 0, qtgui.NUM_GRAPH_HORIZ, 1 ) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ["", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if float == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.blocks_unpacked_to_packed_xx_1 = blocks.unpacked_to_packed_bb(8, gr.GR_MSB_FIRST) self.blocks_short_to_float_0 = blocks.short_to_float(1, 1) self.blocks_rms_xx_0_0 = blocks.rms_ff(1) self.blocks_rms_xx_0 = blocks.rms_ff(1) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_short*1) self.blocks_multiply_xx_0_2 = blocks.multiply_vff(1) self.blocks_multiply_xx_0_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_integrate_xx_1 = blocks.integrate_ff(samp_rate/80, 1) self.blocks_integrate_xx_0_1 = blocks.integrate_ff(samp_rate/80, 1) self.blocks_integrate_xx_0_0 = blocks.integrate_ff(samp_rate/80, 1) self.blocks_integrate_xx_0 = blocks.integrate_ff(samp_rate/80, 1) self.blocks_float_to_uchar_0 = blocks.float_to_uchar() self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, "/home/sidekiq/SDR_output", False) self.blocks_file_sink_0_0.set_unbuffered(True) self.blocks_argmax_xx_0 = blocks.argmax_fs(1) self.blocks_add_xx_0_0 = blocks.add_vff(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.blocks_abs_xx_0_2 = blocks.abs_ff(1) self.blocks_abs_xx_0_1 = blocks.abs_ff(1) self.blocks_abs_xx_0_0 = blocks.abs_ff(1) self.blocks_abs_xx_0 = blocks.abs_ff(1) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(grc_blks2.packet_decoder( access_code="11111111", threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload), ), ) self.audio_source_0 = audio.source(16000, "", True) self.analog_sig_source_x_1 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1330, 1, 0) self.analog_sig_source_x_0_1 = analog.sig_source_f(samp_rate, analog.GR_SIN_WAVE, 1330, 1, 0) self.analog_sig_source_x_0_0 = analog.sig_source_f(samp_rate, analog.GR_SIN_WAVE, 2720, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 2720, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_2, 0)) self.connect((self.analog_sig_source_x_0_1, 0), (self.blocks_multiply_xx_0_1, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.audio_source_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.audio_source_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.audio_source_0, 0), (self.blocks_multiply_xx_0_1, 1)) self.connect((self.audio_source_0, 0), (self.blocks_multiply_xx_0_2, 1)) self.connect((self.audio_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.audio_source_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_unpacked_to_packed_xx_1, 0)) self.connect((self.blocks_abs_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_abs_xx_0_0, 0), (self.blocks_add_xx_0_0, 0)) self.connect((self.blocks_abs_xx_0_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_abs_xx_0_2, 0), (self.blocks_add_xx_0_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_rms_xx_0_0, 0)) self.connect((self.blocks_argmax_xx_0, 0), (self.blocks_null_sink_1, 0)) self.connect((self.blocks_argmax_xx_0, 1), (self.blocks_short_to_float_0, 0)) self.connect((self.blocks_float_to_uchar_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.blocks_float_to_uchar_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_integrate_xx_0, 0), (self.blocks_abs_xx_0_2, 0)) self.connect((self.blocks_integrate_xx_0_0, 0), (self.blocks_abs_xx_0, 0)) self.connect((self.blocks_integrate_xx_0_1, 0), (self.blocks_abs_xx_0_0, 0)) self.connect((self.blocks_integrate_xx_1, 0), (self.blocks_abs_xx_0_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_integrate_xx_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_integrate_xx_1, 0)) self.connect((self.blocks_multiply_xx_0_1, 0), (self.blocks_integrate_xx_0_1, 0)) self.connect((self.blocks_multiply_xx_0_2, 0), (self.blocks_integrate_xx_0_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.blocks_argmax_xx_0, 1)) self.connect((self.blocks_rms_xx_0_0, 0), (self.blocks_argmax_xx_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.blocks_float_to_uchar_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.qtgui_number_sink_1, 0)) self.connect((self.blocks_unpacked_to_packed_xx_1, 0), (self.blocks_file_sink_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "receive") Qt.QWidget.__init__(self) self.setWindowTitle("receive") 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", "receive") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 48000 self.freq = freq = 5000 self.fft_size = fft_size = 1024 self.center_freq = center_freq = 90.1e6 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=48000, decimation=8000000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=1, taps=None, fractional_bw=None, ) self.qtgui_time_sink_x_1_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_1_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0.enable_grid(False) self.qtgui_time_sink_x_1_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_win = sip.wrapinstance( self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_1_0_win) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ["", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype center_freq, #fc 4000000, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "rtl=0") self.osmosdr_source_0.set_sample_rate(8000000) self.osmosdr_source_0.set_center_freq(center_freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(10, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 8000, 2000, firdes.WIN_HAMMING, 6.76)) self.logpwrfft_x_0 = logpwrfft.logpwrfft_c( sample_rate=samp_rate, fft_size=fft_size, ref_scale=2, frame_rate=30, avg_alpha=1.0, average=False, ) self._freq_range = Range(0, 110e6, 1, 5000, 200) self._freq_win = RangeWidget(self._freq_range, self.set_freq, "freq", "counter_slider", float) self.top_layout.addWidget(self._freq_win) self.blocks_short_to_float_0 = blocks.short_to_float( 1, float(fft_size) / float(samp_rate)) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_short * 1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_float * 1, "/home/aa274/payload-documentation/test.bin", False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_argmax_xx_0 = blocks.argmax_fs(fft_size) self.analog_sig_source_x_0_0 = analog.sig_source_c( 8000000, analog.GR_COS_WAVE, -1750000, 1, 0) self.analog_nbfm_rx_1 = analog.nbfm_rx( audio_rate=48000, quad_rate=48000, tau=75e-6, max_dev=5e3, ) ################################################## # Connections ################################################## self.connect((self.analog_nbfm_rx_1, 0), (self.qtgui_time_sink_x_1_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_argmax_xx_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_argmax_xx_0, 0), (self.blocks_short_to_float_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.logpwrfft_x_0, 0), (self.blocks_argmax_xx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_nbfm_rx_1, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.logpwrfft_x_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.low_pass_filter_0, 0))
def __init__(self, avg_len=1, nfft=2048 * 8): gr.top_block.__init__( self, "WWV Monitor X310, Start Time [UTC]: 2020-09-08T04:00:55.012868Z") Qt.QWidget.__init__(self) self.setWindowTitle( "WWV Monitor X310, Start Time [UTC]: 2020-09-08T04:00:55.012868Z") 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", "WWV_monitor_X310_fft_2chan") 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.avg_len = avg_len self.nfft = nfft ################################################## # Variables ################################################## self.wwv_freq = wwv_freq = 10e6 self.offset_tune = offset_tune = -10e3 self.usrp_tune_freq = usrp_tune_freq = wwv_freq + offset_tune self.usrp_clk_rate = usrp_clk_rate = 200e6 self.usrp_ddc_freq = usrp_ddc_freq = np.round( usrp_tune_freq / usrp_clk_rate * 2**32) / 2**32 * usrp_clk_rate self.coarse_tune = coarse_tune = 0 self.ts_str = ts_str = dt.strftime(dt.utcnow(), "%Y-%m-%dT%H:%M:%S.%fZ") self.samp_rate = samp_rate = 250e3 self.lo_freq = lo_freq = usrp_ddc_freq + coarse_tune - offset_tune self.decim_2 = decim_2 = 10 self.decim = decim = 10 self.variable_qtgui_label_0 = variable_qtgui_label_0 = ts_str self.title_str = title_str = "WWV Monitor X310, Start Time [UTC]: {:s}".format( ts_str) self.lo_freq_label = lo_freq_label = "{:9f}".format(lo_freq) self.hz_per_bin = hz_per_bin = (samp_rate / decim / decim_2) / nfft self.filter_taps = filter_taps = firdes.low_pass( 1.0, 2.5, 0.1, 0.02, firdes.WIN_HAMMING) self.decay_rate = decay_rate = 100e-6 ################################################## # Blocks ################################################## self.main_tab = Qt.QTabWidget() self.main_tab_widget_0 = Qt.QWidget() self.main_tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.main_tab_widget_0) self.main_tab_grid_layout_0 = Qt.QGridLayout() self.main_tab_layout_0.addLayout(self.main_tab_grid_layout_0) self.main_tab.addTab(self.main_tab_widget_0, 'Controls') self.main_tab_widget_1 = Qt.QWidget() self.main_tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.main_tab_widget_1) self.main_tab_grid_layout_1 = Qt.QGridLayout() self.main_tab_layout_1.addLayout(self.main_tab_grid_layout_1) self.main_tab.addTab(self.main_tab_widget_1, 'NS_EW') self.main_tab_widget_2 = Qt.QWidget() self.main_tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.main_tab_widget_2) self.main_tab_grid_layout_2 = Qt.QGridLayout() self.main_tab_layout_2.addLayout(self.main_tab_grid_layout_2) self.main_tab.addTab(self.main_tab_widget_2, 'RHCP_LHCP') self.top_grid_layout.addWidget(self.main_tab, 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._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel('SAMP_RATE' + ": ")) self._samp_rate_line_edit = Qt.QLineEdit(str(self.samp_rate)) self._samp_rate_tool_bar.addWidget(self._samp_rate_line_edit) self._samp_rate_line_edit.returnPressed.connect( lambda: self.set_samp_rate( eng_notation.str_to_num(str(self._samp_rate_line_edit.text())) )) self.main_tab_grid_layout_0.addWidget(self._samp_rate_tool_bar, 2, 0, 1, 1) for r in range(2, 3): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.main_tab_grid_layout_0.setColumnStretch(c, 1) # Create the options list self._decay_rate_options = ( 100e-6, 65e-3, 20e-3, ) # Create the labels list self._decay_rate_labels = ( 'Fast', 'Medium', 'Slow', ) # Create the combo box self._decay_rate_tool_bar = Qt.QToolBar(self) self._decay_rate_tool_bar.addWidget(Qt.QLabel('decay_rate' + ": ")) self._decay_rate_combo_box = Qt.QComboBox() self._decay_rate_tool_bar.addWidget(self._decay_rate_combo_box) for _label in self._decay_rate_labels: self._decay_rate_combo_box.addItem(_label) self._decay_rate_callback = lambda i: Qt.QMetaObject.invokeMethod( self._decay_rate_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._decay_rate_options.index(i))) self._decay_rate_callback(self.decay_rate) self._decay_rate_combo_box.currentIndexChanged.connect( lambda i: self.set_decay_rate(self._decay_rate_options[i])) # Create the radio buttons self.main_tab_grid_layout_0.addWidget(self._decay_rate_tool_bar, 3, 0, 1, 1) for r in range(3, 4): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.main_tab_grid_layout_0.setColumnStretch(c, 1) # Create the options list self._wwv_freq_options = ( 5e6, 10e6, 15e6, 20e6, 25e6, ) # Create the labels list self._wwv_freq_labels = ( '5 MHz', '10 MHz', '15 MHz', '20 MHz', '25 MHz', ) # Create the combo box self._wwv_freq_tool_bar = Qt.QToolBar(self) self._wwv_freq_tool_bar.addWidget(Qt.QLabel('WWV Freq' + ": ")) self._wwv_freq_combo_box = Qt.QComboBox() self._wwv_freq_tool_bar.addWidget(self._wwv_freq_combo_box) for _label in self._wwv_freq_labels: self._wwv_freq_combo_box.addItem(_label) self._wwv_freq_callback = lambda i: Qt.QMetaObject.invokeMethod( self._wwv_freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._wwv_freq_options.index(i))) self._wwv_freq_callback(self.wwv_freq) self._wwv_freq_combo_box.currentIndexChanged.connect( lambda i: self.set_wwv_freq(self._wwv_freq_options[i])) # Create the radio buttons self.main_tab_grid_layout_0.addWidget(self._wwv_freq_tool_bar, 1, 0, 1, 1) for r in range(1, 2): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.main_tab_grid_layout_0.setColumnStretch(c, 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: str(x) self._variable_qtgui_label_0_tool_bar.addWidget( Qt.QLabel('Start Time [UTC]' + ": ")) 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.main_tab_grid_layout_0.addWidget( self._variable_qtgui_label_0_tool_bar, 0, 0, 1, 1) for r in range(0, 1): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", args='', channels=list(range(0, 2)), ), ) self.uhd_usrp_source_0.set_subdev_spec('A:AB B:AB', 0) self.uhd_usrp_source_0.set_time_source('gpsdo', 0) self.uhd_usrp_source_0.set_clock_source('gpsdo', 0) self.uhd_usrp_source_0.set_center_freq(usrp_tune_freq, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.uhd_usrp_source_0.set_antenna('A', 0) self.uhd_usrp_source_0.set_center_freq(usrp_tune_freq, 1) self.uhd_usrp_source_0.set_gain(0, 1) self.uhd_usrp_source_0.set_antenna('A', 1) self.uhd_usrp_source_0.set_clock_rate(usrp_clk_rate, uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_time_unknown_pps(uhd.time_spec()) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 2, #size samp_rate / decim / decim_2 / nfft, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.0010) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Offset Freq [Hz[', "") 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 = ['N/S', 'E/W', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_2.addWidget(self._qtgui_time_sink_x_0_win, 0, 0, 1, 2) for r in range(0, 1): self.main_tab_grid_layout_2.setRowStretch(r, 1) for c in range(0, 2): self.main_tab_grid_layout_2.setColumnStretch(c, 1) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 2) self.qtgui_number_sink_0.set_update_time(0.00010) self.qtgui_number_sink_0.set_title("") labels = ['N/S Freq', 'E/W Freq', '', '', '', '', '', '', '', ''] 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(2): 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.main_tab_grid_layout_2.addWidget(self._qtgui_number_sink_0_win, 8, 0, 1, 2) for r in range(8, 9): self.main_tab_grid_layout_2.setRowStretch(r, 1) for c in range(0, 2): self.main_tab_grid_layout_2.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim / decim_2, #bw "Narrow", #name 2) self.qtgui_freq_sink_x_0_0.set_update_time(0.010) self.qtgui_freq_sink_x_0_0.set_y_axis(-100, -20) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(True) self.qtgui_freq_sink_x_0_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) self.qtgui_freq_sink_x_0_0.disable_legend() labels = ['N/S', 'E/W', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_1.addWidget(self._qtgui_freq_sink_x_0_0_win, 0, 4, 4, 4) for r in range(0, 4): self.main_tab_grid_layout_1.setRowStretch(r, 1) for c in range(4, 8): self.main_tab_grid_layout_1.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype usrp_ddc_freq, #fc samp_rate, #bw 'Channel', #name 2) self.qtgui_freq_sink_x_0.set_update_time(0.010) self.qtgui_freq_sink_x_0.set_y_axis(-160, -20) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) self.qtgui_freq_sink_x_0.disable_legend() labels = ['N/S', 'E/W', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_1.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 4, 4) for r in range(0, 4): self.main_tab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 4): self.main_tab_grid_layout_1.setColumnStretch(c, 1) self.low_pass_filter_0_1 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 100e3, 20e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0_1 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate / decim, 250, 100, firdes.WIN_BLACKMAN, 6.76)) self.low_pass_filter_0_0_0_0 = filter.fir_filter_ccf( 10, firdes.low_pass(1, samp_rate / decim_2, 75, 50, firdes.WIN_BLACKMAN, 6.76)) self.low_pass_filter_0_0_0 = filter.fir_filter_ccf( 10, firdes.low_pass(1, samp_rate / decim_2, 75, 50, firdes.WIN_BLACKMAN, 6.76)) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate / decim, 250, 100, firdes.WIN_BLACKMAN, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 100e3, 20e3, firdes.WIN_HAMMING, 6.76)) self._lo_freq_label_tool_bar = Qt.QToolBar(self) if None: self._lo_freq_label_formatter = None else: self._lo_freq_label_formatter = lambda x: str(x) self._lo_freq_label_tool_bar.addWidget(Qt.QLabel('LO Freq [Hz]' + ": ")) self._lo_freq_label_label = Qt.QLabel( str(self._lo_freq_label_formatter(self.lo_freq_label))) self._lo_freq_label_tool_bar.addWidget(self._lo_freq_label_label) self.main_tab_grid_layout_0.addWidget(self._lo_freq_label_tool_bar, 4, 0, 1, 1) for r in range(4, 5): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc( decim, filter_taps, lo_freq - usrp_ddc_freq, samp_rate) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( decim, filter_taps, lo_freq - usrp_ddc_freq, samp_rate) self.fft_vxx_0_0 = fft.fft_vcc(nfft, True, window.blackmanharris(nfft), True, 4) self.fft_vxx_0 = fft.fft_vcc(nfft, True, window.blackmanharris(nfft), True, 4) self._coarse_tune_tool_bar = Qt.QToolBar(self) self._coarse_tune_tool_bar.addWidget(Qt.QLabel('coarse_tune' + ": ")) self._coarse_tune_line_edit = Qt.QLineEdit(str(self.coarse_tune)) self._coarse_tune_tool_bar.addWidget(self._coarse_tune_line_edit) self._coarse_tune_line_edit.returnPressed.connect( lambda: self.set_coarse_tune( eng_notation.str_to_num(str(self._coarse_tune_line_edit.text()) ))) self.top_grid_layout.addWidget(self._coarse_tune_tool_bar) self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, nfft) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, nfft) self.blocks_short_to_float_0_0 = blocks.short_to_float(1, 1) self.blocks_short_to_float_0 = blocks.short_to_float(1, 1) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_short * 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_short * 1) self.blocks_nlog10_ff_0_0 = blocks.nlog10_ff(10, nfft, -10 * math.log10(nfft)) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, nfft, -10 * math.log10(nfft)) self.blocks_multiply_const_vxx_0_0_1 = blocks.multiply_const_ff( hz_per_bin) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_ff( hz_per_bin) self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared( nfft) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared( nfft) self.blocks_argmax_xx_0_0 = blocks.argmax_fs(nfft) self.blocks_argmax_xx_0 = blocks.argmax_fs(nfft) self.blocks_add_const_vxx_0_0 = blocks.add_const_ff( -samp_rate / decim / decim_2 / 2) self.blocks_add_const_vxx_0 = blocks.add_const_ff(-samp_rate / decim / decim_2 / 2) self.analog_agc2_xx_0_0 = analog.agc2_cc(0.01, decay_rate, .3, 1000) self.analog_agc2_xx_0_0.set_max_gain(65000) self.analog_agc2_xx_0 = analog.agc2_cc(0.01, decay_rate, .3, 1000) self.analog_agc2_xx_0.set_max_gain(65000) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.analog_agc2_xx_0_0, 0), (self.low_pass_filter_0_0_1, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_add_const_vxx_0_0, 0), (self.qtgui_number_sink_0, 1)) self.connect((self.blocks_add_const_vxx_0_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blocks_argmax_xx_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_argmax_xx_0, 0), (self.blocks_short_to_float_0, 0)) self.connect((self.blocks_argmax_xx_0_0, 1), (self.blocks_null_sink_0_0, 0)) self.connect((self.blocks_argmax_xx_0_0, 0), (self.blocks_short_to_float_0_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0_0, 0), (self.blocks_nlog10_ff_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0_1, 0), (self.blocks_add_const_vxx_0_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_argmax_xx_0, 0)) self.connect((self.blocks_nlog10_ff_0_0, 0), (self.blocks_argmax_xx_0_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_short_to_float_0_0, 0), (self.blocks_multiply_const_vxx_0_0_1, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_stream_to_vector_0_0, 0), (self.fft_vxx_0_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.fft_vxx_0_0, 0), (self.blocks_complex_to_mag_squared_0_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.analog_agc2_xx_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.low_pass_filter_0_0_0, 0)) self.connect((self.low_pass_filter_0_0_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.low_pass_filter_0_0_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.low_pass_filter_0_0_0_0, 0), (self.blocks_stream_to_vector_0_0, 0)) self.connect((self.low_pass_filter_0_0_0_0, 0), (self.qtgui_freq_sink_x_0_0, 1)) self.connect((self.low_pass_filter_0_0_1, 0), (self.low_pass_filter_0_0_0_0, 0)) self.connect((self.low_pass_filter_0_1, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0)) self.connect((self.low_pass_filter_0_1, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.low_pass_filter_0_1, 0))
def __init__(self, ts, factor, alpha, samp_rate, freqs): """ Description: This block is designed to perform frequency and timing acquisition for a known training sequence in the presense of frequency and timing offset and noise. Its input is a complex stream. It has three outputs: 1) a stream of flags (bytes) indicating the begining of the training sequence (to be used from subsequent blocks to "chop" the incoming stream, 2) a stream with the current acquired frequency offset, and 3) a stream with the current acquired peak of the matched filter Internally, it consists of a user defined number of parallel matched filters (as many as the size of the freqs vector), each consistng of a frequency Xlating FIR filter with sample rate samp_rate, filter taps matched to the training sequence ts, and center frequency freqs[i]. The filter outputs are magnitude squared and passed through a max block and then through a peak detector. Args: ts: the training sequence. For example, in DSSS system, it's the chip-based spread training sequence. factor: the rise and fall factors in peak detector, which is the factor determining when a peak has started and ended. In the peak detector, an average of the signal is calculated. When the value of the signal goes over factor*average, we start looking for a peak. When the value of the signal goes below factor*average, we stop looking for a peak. factor takes values in (0,1). alpha: the smoothing factor of a moving average filter used in the peak detector takeng values in (0,1). samp_rate: the sample rate of the system, which is used in the freq_xlating_fir_filter. freqs: the vector of center frequencies for each matched filter. Note that for a training sequence of length Nt, each matched filter can recover a sequence with normalized frequency offset ~ 1/(2Nt). """ gr.hier_block2.__init__( self, "freq_timing_estimator", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signaturev(3, 3, [gr.sizeof_char*1, gr.sizeof_float*1, gr.sizeof_float*1]), ) ################################################## # Parameters ################################################## self.ts = ts self.factor = factor self.alpha = alpha self.samp_rate = samp_rate self.freqs = freqs self.n = n = len(freqs) ################################################## # Blocks ################################################## self._filter=[0]*self.n self._c2mag2=[0]*self.n for i in range(self.n): self._filter[i]= filter.freq_xlating_fir_filter_ccc(1, (numpy.conjugate(self.ts[::-1])), self.freqs[i], self.samp_rate) self._c2mag2[i] = blocks.complex_to_mag_squared(1) self.blocks_max = blocks.max_ff(1) self.blocks_peak_detector = blocks.peak_detector_fb(self.factor, self.factor, 0, self.alpha) self.blocks_argmax = blocks.argmax_fs(1) self.blocks_null_sink = blocks.null_sink(gr.sizeof_short*1) self.digital_chunks_to_symbols = digital.chunks_to_symbols_sf((freqs), 1) self.blocks_sample_and_hold = blocks.sample_and_hold_ff() ################################################## # Connections ################################################## for i in range(self.n): self.connect((self, 0), (self._filter[i], 0)) self.connect((self._filter[i], 0), (self._c2mag2[i], 0)) self.connect((self._c2mag2[i], 0), (self.blocks_max, i)) self.connect((self._c2mag2[i], 0), (self.blocks_argmax, i)) self.connect((self.blocks_max, 0), (self.blocks_peak_detector, 0)) self.connect((self.blocks_peak_detector, 0), (self, 0)) self.connect((self.blocks_argmax, 0), (self.blocks_null_sink, 0)) self.connect((self.blocks_argmax, 1), (self.digital_chunks_to_symbols, 0)) self.connect((self.digital_chunks_to_symbols, 0), (self.blocks_sample_and_hold, 0)) self.connect((self.blocks_peak_detector, 0), (self.blocks_sample_and_hold, 1)) self.connect((self.blocks_sample_and_hold, 0), (self, 1)) self.connect((self.blocks_max, 0), (self, 2))
def __init__(self): gr.top_block.__init__(self, "File Reader Demo") Qt.QWidget.__init__(self) self.setWindowTitle("File Reader Demo") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "file_reader_demo") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 40000 self.fft_size = fft_size = 8192 self.center_freq = center_freq = 400e6 ################################################## # Blocks ################################################## self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype center_freq, #fc samp_rate, #bw "", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_win = sip.wrapinstance( self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(False) self.qtgui_number_sink_0_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0.set_title("") labels = ["", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_0.set_min(i, -1) self.qtgui_number_sink_0_0.set_max(i, 20000) self.qtgui_number_sink_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_0_win) self.logpwrfft_x_0 = logpwrfft.logpwrfft_c( sample_rate=samp_rate, fft_size=fft_size, ref_scale=2, frame_rate=30, avg_alpha=1.0, average=False, ) self.blocks_throttle_1 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_short_to_float_0 = blocks.short_to_float( 1, float(fft_size) / float(samp_rate)) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_short * 1) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, "/home/aa274/Documents/payload-documentation/GNUradio/doppler_curve_test.bin", False) self.blocks_argmax_xx_0 = blocks.argmax_fs(fft_size) ################################################## # Connections ################################################## self.connect((self.blocks_argmax_xx_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_argmax_xx_0, 0), (self.blocks_short_to_float_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_1, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.qtgui_number_sink_0_0, 0)) self.connect((self.blocks_throttle_1, 0), (self.logpwrfft_x_0, 0)) self.connect((self.blocks_throttle_1, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.logpwrfft_x_0, 0), (self.blocks_argmax_xx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 16000 self.repeat = repeat = samp_rate/80 ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-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) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.blocks_unpacked_to_packed_xx_1 = blocks.unpacked_to_packed_bb(8, gr.GR_MSB_FIRST) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8) self.blocks_uchar_to_float_0_0_0 = blocks.uchar_to_float() self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True) self.blocks_short_to_float_0 = blocks.short_to_float(1, 1) self.blocks_short_to_char_0 = blocks.short_to_char(1) self.blocks_rms_xx_0_0 = blocks.rms_ff(1) self.blocks_rms_xx_0 = blocks.rms_ff(1) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_char*1, repeat) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(1, 8, "", False, gr.GR_MSB_FIRST) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_short*1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_multiply_xx_0_2 = blocks.multiply_vff(1) self.blocks_multiply_xx_0_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vss((256, )) self.blocks_integrate_xx_1 = blocks.integrate_ff(repeat) self.blocks_integrate_xx_0_1 = blocks.integrate_ff(repeat) self.blocks_integrate_xx_0_0 = blocks.integrate_ff(repeat) self.blocks_integrate_xx_0 = blocks.integrate_ff(repeat) self.blocks_float_to_uchar_0 = blocks.float_to_uchar() self.blocks_file_source_0 = blocks.file_source(gr.sizeof_short*1, "/home/sidekiq/Documents/Documentation_SDR/sdr.in", True) self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, "/home/sidekiq/Documents/Documentation_SDR/text_output", False) self.blocks_file_sink_0_0.set_unbuffered(True) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_argmax_xx_0 = blocks.argmax_fs(1) self.blocks_add_xx_0_0 = blocks.add_vff(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((1, )) self.blocks_abs_xx_0_2 = blocks.abs_ff(1) self.blocks_abs_xx_0_1 = blocks.abs_ff(1) self.blocks_abs_xx_0_0 = blocks.abs_ff(1) self.blocks_abs_xx_0 = blocks.abs_ff(1) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder( samples_per_symbol=1, bits_per_symbol=1, preamble="11111000", access_code="11111111", pad_for_usrp=False, ), payload_length=1, ) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(grc_blks2.packet_decoder( access_code="", threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload), ), ) self.audio_sink_1 = audio.sink(16000, "", True) self.analog_sig_source_x_1 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1330, 1, 0) self.analog_sig_source_x_0_1 = analog.sig_source_f(samp_rate, analog.GR_SIN_WAVE, 1330, 1, 0) self.analog_sig_source_x_0_0 = analog.sig_source_f(samp_rate, analog.GR_SIN_WAVE, 2720, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 2720, 1, 0) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(100) ################################################## # Connections ################################################## self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_2, 0)) self.connect((self.analog_sig_source_x_0_1, 0), (self.blocks_multiply_xx_0_1, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_unpacked_to_packed_xx_1, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.blocks_abs_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_abs_xx_0_0, 0), (self.blocks_add_xx_0_0, 0)) self.connect((self.blocks_abs_xx_0_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_abs_xx_0_2, 0), (self.blocks_add_xx_0_0, 1)) self.connect((self.blocks_add_const_vxx_0, 0), (self.analog_frequency_modulator_fc_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_rms_xx_0_0, 0)) self.connect((self.blocks_argmax_xx_0, 0), (self.blocks_null_sink_1, 0)) self.connect((self.blocks_argmax_xx_0, 1), (self.blocks_short_to_float_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.audio_sink_1, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_0_1, 1)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_0_2, 1)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_float_to_uchar_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.blocks_integrate_xx_0, 0), (self.blocks_abs_xx_0_2, 0)) self.connect((self.blocks_integrate_xx_0_0, 0), (self.blocks_abs_xx_0, 0)) self.connect((self.blocks_integrate_xx_0_1, 0), (self.blocks_abs_xx_0_0, 0)) self.connect((self.blocks_integrate_xx_1, 0), (self.blocks_abs_xx_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_short_to_char_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_integrate_xx_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_integrate_xx_1, 0)) self.connect((self.blocks_multiply_xx_0_1, 0), (self.blocks_integrate_xx_0_1, 0)) self.connect((self.blocks_multiply_xx_0_2, 0), (self.blocks_integrate_xx_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_uchar_to_float_0_0_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.blocks_argmax_xx_0, 1)) self.connect((self.blocks_rms_xx_0_0, 0), (self.blocks_argmax_xx_0, 0)) self.connect((self.blocks_short_to_char_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.blocks_float_to_uchar_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_uchar_to_float_0_0_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_1, 0), (self.blocks_file_sink_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "udp-recive") Qt.QWidget.__init__(self) self.setWindowTitle("udp-recive") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.samp_rate = samp_rate = 850e3 self.dec = dec = 25 self.freq_0 = freq_0 = 137.50625e6 self.bandwidth = bandwidth = 34e3 self.RF_gain = RF_gain = 40 self.Out_samprate = Out_samprate = samp_rate / dec self.NOAA19 = NOAA19 = -0.40625e6 self.NOAA18 = NOAA18 = 0.40625e6 self.NOAA15 = NOAA15 = 0.11375e6 self.IF_gain = IF_gain = 40 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=11025, decimation=34000, taps=None, fractional_bw=None) self.qtgui_sink_x_0 = qtgui.sink_c( 2048, #fftsize firdes.WIN_HAMMING, #wintype 0, #fc 34e3, #bw "output sink", #name True, #plotfreq True, #plotwaterfall False, #plottime False #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_win = sip.wrapinstance( self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.qtgui_sink_x_0.enable_rf_freq(False) self.top_grid_layout.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.set_block_alias("output sink") self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_short, 0, qtgui.NUM_GRAPH_NONE, 1) self.qtgui_number_sink_0.set_update_time(0.1) self.qtgui_number_sink_0.set_title("Selected channel") 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, 0) self.qtgui_number_sink_0.set_max(i, 2) 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.blocks_udp_source_0_2 = blocks.udp_source( gr.sizeof_gr_complex * 1, '0.0.0.0', 1232, 4000, True) self.blocks_udp_source_0_1 = blocks.udp_source( gr.sizeof_gr_complex * 1, '0.0.0.0', 1230, 4000, True) self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_gr_complex * 1, '0.0.0.0', 1231, 4000, True) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_float * 1, 'localhost', 7355, 1225, True) self.blocks_threshold_ff_0_1 = blocks.threshold_ff(1.5, 2.5, 0) self.blocks_threshold_ff_0_0 = blocks.threshold_ff(0.5, 1.5, 0) self.blocks_threshold_ff_0 = blocks.threshold_ff(-0.5, 0.5, 0) self.blocks_streams_to_vector_0 = blocks.streams_to_vector( gr.sizeof_float * 1, 3) self.blocks_short_to_float_0 = blocks.short_to_float(1, 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_short * 1) self.blocks_multiply_xx_2 = blocks.multiply_vcc(1) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_moving_average_2_0 = blocks.moving_average_ff( 4000, 1, 4000, 1) self.blocks_moving_average_2 = blocks.moving_average_ff( 4000, 1, 4000, 1) self.blocks_moving_average_1 = blocks.moving_average_ff( 4000, 1, 4000, 1) self.blocks_float_to_complex_1_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_1_0 = blocks.float_to_complex(1) self.blocks_float_to_complex_1 = blocks.float_to_complex(1) self.blocks_complex_to_mag_squared_0_1 = blocks.complex_to_mag_squared( 1) self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared( 1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_argmax_xx_0 = blocks.argmax_fs(3) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blocks_add_const_vxx_0_0_0 = blocks.add_const_ff(-1) self.blocks_add_const_vxx_0_0 = blocks.add_const_ff(-1) self.blocks_add_const_vxx_0 = blocks.add_const_ff(-1) self.blocks_abs_xx_0_0_0 = blocks.abs_ff(1) self.blocks_abs_xx_0_0 = blocks.abs_ff(1) self.blocks_abs_xx_0 = blocks.abs_ff(1) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=bandwidth, audio_decimation=1, ) self.NOAA19_fall = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype freq_0 + NOAA19, #fc Out_samprate, #bw "NOAA19 (stream 0)", #name True, #plotfreq True, #plotwaterfall False, #plottime False #plotconst ) self.NOAA19_fall.set_update_time(1.0 / 1) self._NOAA19_fall_win = sip.wrapinstance(self.NOAA19_fall.pyqwidget(), Qt.QWidget) self.NOAA19_fall.enable_rf_freq(True) self.top_grid_layout.addWidget(self._NOAA19_fall_win) self.NOAA18_fall = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype freq_0 + NOAA18, #fc Out_samprate, #bw "NOAA18 (stream 1)", #name True, #plotfreq True, #plotwaterfall False, #plottime False #plotconst ) self.NOAA18_fall.set_update_time(1.0 / 1) self._NOAA18_fall_win = sip.wrapinstance(self.NOAA18_fall.pyqwidget(), Qt.QWidget) self.NOAA18_fall.enable_rf_freq(True) self.top_grid_layout.addWidget(self._NOAA18_fall_win) self.NOAA15_fall = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype freq_0 + NOAA15, #fc Out_samprate, #bw "NOAA15 (stream 2)", #name True, #plotfreq True, #plotwaterfall False, #plottime False #plotconst ) self.NOAA15_fall.set_update_time(1.0 / 1) self._NOAA15_fall_win = sip.wrapinstance(self.NOAA15_fall.pyqwidget(), Qt.QWidget) self.NOAA15_fall.enable_rf_freq(True) self.top_grid_layout.addWidget(self._NOAA15_fall_win) ################################################## # Connections ################################################## self.connect((self.analog_wfm_rcv_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_abs_xx_0, 0), (self.blocks_float_to_complex_1, 0)) self.connect((self.blocks_abs_xx_0_0, 0), (self.blocks_float_to_complex_1_0, 0)) self.connect((self.blocks_abs_xx_0_0_0, 0), (self.blocks_float_to_complex_1_1, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_abs_xx_0, 0)) self.connect((self.blocks_add_const_vxx_0_0, 0), (self.blocks_abs_xx_0_0, 0)) self.connect((self.blocks_add_const_vxx_0_0_0, 0), (self.blocks_abs_xx_0_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.blocks_argmax_xx_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_argmax_xx_0, 0), (self.blocks_short_to_float_0, 0)) self.connect((self.blocks_argmax_xx_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_moving_average_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0_0, 0), (self.blocks_moving_average_2, 0)) self.connect((self.blocks_complex_to_mag_squared_0_1, 0), (self.blocks_moving_average_2_0, 0)) self.connect((self.blocks_float_to_complex_1, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_float_to_complex_1_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.blocks_float_to_complex_1_1, 0), (self.blocks_multiply_xx_2, 1)) self.connect((self.blocks_moving_average_1, 0), (self.blocks_streams_to_vector_0, 0)) self.connect((self.blocks_moving_average_2, 0), (self.blocks_streams_to_vector_0, 1)) self.connect((self.blocks_moving_average_2_0, 0), (self.blocks_streams_to_vector_0, 2)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_add_xx_0, 2)) self.connect((self.blocks_short_to_float_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.blocks_threshold_ff_0_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.blocks_threshold_ff_0_1, 0)) self.connect((self.blocks_streams_to_vector_0, 0), (self.blocks_argmax_xx_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_threshold_ff_0_0, 0), (self.blocks_add_const_vxx_0_0, 0)) self.connect((self.blocks_threshold_ff_0_1, 0), (self.blocks_add_const_vxx_0_0_0, 0)) self.connect((self.blocks_udp_source_0, 0), (self.NOAA19_fall, 0)) self.connect((self.blocks_udp_source_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.blocks_udp_source_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_udp_source_0_1, 0), (self.NOAA18_fall, 0)) self.connect((self.blocks_udp_source_0_1, 0), (self.blocks_complex_to_mag_squared_0_0, 0)) self.connect((self.blocks_udp_source_0_1, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.blocks_udp_source_0_2, 0), (self.NOAA15_fall, 0)) self.connect((self.blocks_udp_source_0_2, 0), (self.blocks_complex_to_mag_squared_0_1, 0)) self.connect((self.blocks_udp_source_0_2, 0), (self.blocks_multiply_xx_2, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_udp_sink_0, 0))
def __init__(self, fsk_dev=10000, lpf_cutoff=12.5e3, lpf_trans=1e3): gr.top_block.__init__(self, "Fsk Rx Udp") Qt.QWidget.__init__(self) self.setWindowTitle("Fsk Rx Udp") 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", "fsk_rx_udp") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.fsk_dev = fsk_dev self.lpf_cutoff = lpf_cutoff self.lpf_trans = lpf_trans ################################################## # Variables ################################################## self.samp_rate = samp_rate = 48e3 self.baud = baud = 9600 self.thresh = thresh = -4 self.smooth_len = smooth_len = 25 self.samps_per_symb = samps_per_symb = int(samp_rate/baud) self.offset = offset = 0 self.num_items = num_items = 1024 self.mult = mult = (samp_rate)/2/3.141593 self.decay = decay = 100e-6 self.bw_factor = bw_factor = 1000 self.attack = attack = 0.001 self.alpha = alpha = 0.5 ################################################## # Blocks ################################################## self._thresh_tool_bar = Qt.QToolBar(self) self._thresh_tool_bar.addWidget(Qt.QLabel('Threshold'+": ")) self._thresh_line_edit = Qt.QLineEdit(str(self.thresh)) self._thresh_tool_bar.addWidget(self._thresh_line_edit) self._thresh_line_edit.returnPressed.connect( lambda: self.set_thresh(eng_notation.str_to_num(str(self._thresh_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._thresh_tool_bar, 0,4,1,2) self._offset_range = Range(-10000, 10000, 1, 0, 200) self._offset_win = RangeWidget(self._offset_range, self.set_offset, "offset", "counter_slider", float) self.top_grid_layout.addWidget(self._offset_win, 3,4,1,4) self._decay_tool_bar = Qt.QToolBar(self) self._decay_tool_bar.addWidget(Qt.QLabel("decay"+": ")) self._decay_line_edit = Qt.QLineEdit(str(self.decay)) self._decay_tool_bar.addWidget(self._decay_line_edit) self._decay_line_edit.returnPressed.connect( lambda: self.set_decay(eng_notation.str_to_num(str(self._decay_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._decay_tool_bar, 1,6,1,2) self._bw_factor_tool_bar = Qt.QToolBar(self) self._bw_factor_tool_bar.addWidget(Qt.QLabel("bw_factor"+": ")) self._bw_factor_line_edit = Qt.QLineEdit(str(self.bw_factor)) self._bw_factor_tool_bar.addWidget(self._bw_factor_line_edit) self._bw_factor_line_edit.returnPressed.connect( lambda: self.set_bw_factor(eng_notation.str_to_num(str(self._bw_factor_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._bw_factor_tool_bar, 2,6,1,2) self._attack_tool_bar = Qt.QToolBar(self) self._attack_tool_bar.addWidget(Qt.QLabel("attack"+": ")) self._attack_line_edit = Qt.QLineEdit(str(self.attack)) self._attack_tool_bar.addWidget(self._attack_line_edit) self._attack_line_edit.returnPressed.connect( lambda: self.set_attack(eng_notation.str_to_num(str(self._attack_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._attack_tool_bar, 1,4,1,2) self.qtgui_time_sink_x_2 = qtgui.time_sink_f( 50, #size samp_rate, #samp_rate "trigger", #name 1 #number of inputs ) self.qtgui_time_sink_x_2.set_update_time(0.10) self.qtgui_time_sink_x_2.set_y_axis(-1, 1) self.qtgui_time_sink_x_2.set_y_label('Amplitude', "") self.qtgui_time_sink_x_2.enable_tags(-1, True) self.qtgui_time_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_2.enable_autoscale(False) self.qtgui_time_sink_x_2.enable_grid(False) self.qtgui_time_sink_x_2.enable_axis_labels(True) self.qtgui_time_sink_x_2.enable_control_panel(False) self.qtgui_time_sink_x_2.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_2.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_2.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_2.set_line_label(i, labels[i]) self.qtgui_time_sink_x_2.set_line_width(i, widths[i]) self.qtgui_time_sink_x_2.set_line_color(i, colors[i]) self.qtgui_time_sink_x_2.set_line_style(i, styles[i]) self.qtgui_time_sink_x_2.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_2.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_2_win = sip.wrapinstance(self.qtgui_time_sink_x_2.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_2_win, 8,0,2,4) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 4096, #size samp_rate, #samp_rate "Freq Error", #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.010) 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(True) 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 False: self.qtgui_time_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win, 4,0,2,4) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 2048, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.010) 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, "packet_len") self.qtgui_time_sink_x_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not False: 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, 4,4,2,4) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 4096, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.010) 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, "packet_len") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 8,4,2,4) self.qtgui_number_sink_1 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1 ) self.qtgui_number_sink_1.set_update_time(0.10) self.qtgui_number_sink_1.set_title("Doppler") labels = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_1.set_min(i, -1) self.qtgui_number_sink_1.set_max(i, 1) self.qtgui_number_sink_1.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_1.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_1.set_label(i, labels[i]) self.qtgui_number_sink_1.set_unit(i, units[i]) self.qtgui_number_sink_1.set_factor(i, factor[i]) self.qtgui_number_sink_1.enable_autoscale(False) self._qtgui_number_sink_1_win = sip.wrapinstance(self.qtgui_number_sink_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_1_win, 2,4,1,2) self.qtgui_number_sink_0_0_1 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1 ) self.qtgui_number_sink_0_0_1.set_update_time(0.010) self.qtgui_number_sink_0_0_1.set_title("SNR") labels = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_0_1.set_min(i, 0) self.qtgui_number_sink_0_0_1.set_max(i, 100) self.qtgui_number_sink_0_0_1.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_1.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_1.set_label(i, labels[i]) self.qtgui_number_sink_0_0_1.set_unit(i, units[i]) self.qtgui_number_sink_0_0_1.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_1.enable_autoscale(False) self._qtgui_number_sink_0_0_1_win = sip.wrapinstance(self.qtgui_number_sink_0_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_1_win, 2,5,1,1) self.qtgui_freq_sink_x_1_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "RX Spectrum", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1_0.set_update_time(0.010) self.qtgui_freq_sink_x_1_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1_0.enable_autoscale(False) self.qtgui_freq_sink_x_1_0.enable_grid(True) self.qtgui_freq_sink_x_1_0.set_fft_average(1.0) self.qtgui_freq_sink_x_1_0.enable_axis_labels(True) self.qtgui_freq_sink_x_1_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_1_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1_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_1_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_0_win, 0,0,4,4) self.pyqt_time_plot_0 = pyqt.time_plot('') self._pyqt_time_plot_0_win = self.pyqt_time_plot_0; self.top_grid_layout.addWidget(self._pyqt_time_plot_0_win, 6,0,2,4) self.pyqt_time_plot_0.line_off() self.pyqt_text_output_0 = pyqt.text_output() self._pyqt_text_output_0_win = self.pyqt_text_output_0; self.top_grid_layout.addWidget(self._pyqt_text_output_0_win, 6,4,2,4) self.kiss_hdlc_deframer_0 = kiss.hdlc_deframer(check_fcs=True, max_length=300) self.es_trigger_edge_f_0 = es.trigger_edge_f(thresh,3500,500,gr.sizeof_float,100) self.es_sink_0 = es.sink(1*[gr.sizeof_float],8,64,0,2,0) self.es_handler_pdu_0 = es.es_make_handler_pdu(es.es_handler_print.TYPE_F32) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(samps_per_symb, .5, 512, math.pi/bw_factor) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0, 16) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(samps_per_symb*(1+0.0), 0.25*0.175*0.175, 0.25, 0.175, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_gr_complex*1, '0.0.0.0', 9001, 1472, True) self.blocks_threshold_ff_0 = blocks.threshold_ff(-100, -100, 0) self.blocks_sub_xx_1_0 = blocks.sub_ff(1) self.blocks_sub_xx_1 = blocks.sub_ff(1) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_float*1, num_items) self.blocks_skiphead_1 = blocks.skiphead(gr.sizeof_gr_complex*1, 500) self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_float*1, 1) self.blocks_short_to_float_0 = blocks.short_to_float(1, 1) self.blocks_pdu_to_tagged_stream_2 = blocks.pdu_to_tagged_stream(blocks.complex_t, 'packet_len') self.blocks_pdu_remove_0_0 = blocks.pdu_remove(pmt.intern("es::event_buffer")) self.blocks_pdu_remove_0 = blocks.pdu_remove(pmt.intern("es::event_buffer")) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_short*1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_nlog10_ff_0_0_0 = blocks.nlog10_ff(10, 1, 0) self.blocks_nlog10_ff_0_0 = blocks.nlog10_ff(10, 1, 0) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((mult, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((mult*-1, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((-1, )) self.blocks_moving_average_xx_2 = blocks.moving_average_ff(num_items, 1.0/num_items, 4000, 1) self.blocks_moving_average_xx_0_1_0_0 = blocks.moving_average_ff(500, 1.0/500, 4000, 1) self.blocks_moving_average_xx_0_1_0 = blocks.moving_average_ff(2000, 1.0/2000, 4000, 1) self.blocks_moving_average_xx_0_0 = blocks.moving_average_ff(smooth_len, 1.0/smooth_len, 4000, 1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(smooth_len, 1.0/smooth_len, 4000, 1) self.blocks_keep_m_in_n_1 = blocks.keep_m_in_n(gr.sizeof_float, 1, num_items, 0) self.blocks_keep_m_in_n_0_1 = blocks.keep_m_in_n(gr.sizeof_gr_complex, 2000, 3500, 10) self.blocks_keep_m_in_n_0_0 = blocks.keep_m_in_n(gr.sizeof_gr_complex, 500, 3500, 10) self.blocks_complex_to_mag_squared_0_0_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_argmax_xx_0 = blocks.argmax_fs(num_items) self.blocks_abs_xx_0 = blocks.abs_ff(1) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 1000, 1, offset) self.analog_quadrature_demod_cf_1 = analog.quadrature_demod_cf((samp_rate)/(2*math.pi*fsk_dev/8.0)) self.analog_agc3_xx_0 = analog.agc3_cc(attack, decay, 1.0, 1.0, 1) self.analog_agc3_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect((self.blocks_pdu_remove_0, 'pdus'), (self.blocks_pdu_remove_0_0, 'pdus')) self.msg_connect((self.blocks_pdu_remove_0, 'pdus'), (self.pyqt_time_plot_0, 'pdus')) self.msg_connect((self.blocks_pdu_remove_0_0, 'pdus'), (self.blocks_pdu_to_tagged_stream_2, 'pdus')) self.msg_connect((self.es_handler_pdu_0, 'pdus_out'), (self.blocks_pdu_remove_0, 'pdus')) self.msg_connect((self.es_trigger_edge_f_0, 'edge_event'), (self.es_handler_pdu_0, 'handle_event')) self.msg_connect((self.es_trigger_edge_f_0, 'which_stream'), (self.es_sink_0, 'schedule_event')) self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.pyqt_text_output_0, 'pdus')) self.connect((self.analog_agc3_xx_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.analog_quadrature_demod_cf_1, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_abs_xx_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_argmax_xx_0, 0), (self.blocks_null_sink_1, 0)) self.connect((self.blocks_argmax_xx_0, 1), (self.blocks_short_to_float_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0_0, 0), (self.blocks_moving_average_xx_0_1_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0_0_0, 0), (self.blocks_moving_average_xx_0_1_0_0, 0)) self.connect((self.blocks_keep_m_in_n_0_0, 0), (self.blocks_complex_to_mag_squared_0_0_0, 0)) self.connect((self.blocks_keep_m_in_n_0_1, 0), (self.blocks_complex_to_mag_squared_0_0, 0)) self.connect((self.blocks_keep_m_in_n_1, 0), (self.blocks_sub_xx_1, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_moving_average_xx_0_0, 0), (self.qtgui_number_sink_1, 0)) self.connect((self.blocks_moving_average_xx_0_1_0, 0), (self.blocks_nlog10_ff_0_0, 0)) self.connect((self.blocks_moving_average_xx_0_1_0_0, 0), (self.blocks_nlog10_ff_0_0_0, 0)) self.connect((self.blocks_moving_average_xx_2, 0), (self.blocks_keep_m_in_n_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.es_trigger_edge_f_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_moving_average_xx_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.analog_agc3_xx_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_moving_average_xx_2, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.blocks_nlog10_ff_0_0, 0), (self.blocks_sub_xx_1_0, 1)) self.connect((self.blocks_nlog10_ff_0_0_0, 0), (self.blocks_sub_xx_1_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_2, 0), (self.blocks_keep_m_in_n_0_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_2, 0), (self.blocks_skiphead_1, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.blocks_sub_xx_1, 1)) self.connect((self.blocks_skiphead_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_skiphead_1, 0), (self.blocks_keep_m_in_n_0_1, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.blocks_argmax_xx_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.blocks_abs_xx_0, 0)) self.connect((self.blocks_sub_xx_1, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_sub_xx_1_0, 0), (self.qtgui_number_sink_0_0_1, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.qtgui_time_sink_x_2, 0)) self.connect((self.blocks_udp_source_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.blocks_udp_source_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.blocks_skiphead_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.es_trigger_edge_f_0, 1)) self.connect((self.digital_descrambler_bb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.kiss_hdlc_deframer_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.analog_quadrature_demod_cf_1, 0)) self.connect((self.digital_fll_band_edge_cc_0, 1), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.digital_fll_band_edge_cc_0, 3), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.digital_fll_band_edge_cc_0, 2), (self.blocks_null_sink_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.qtgui_freq_sink_x_1_0, 0)) self.connect((self.es_trigger_edge_f_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.es_trigger_edge_f_0, 0), (self.es_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "Wwv X310 Corr 1") Qt.QWidget.__init__(self) self.setWindowTitle("Wwv X310 Corr 1") 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", "wwv_x310_corr_1") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.ts_str = ts_str = dt.strftime(dt.utcnow(), "%Y-%m-%dT%H:%M:%S.%fZ") self.y_min = y_min = -60 self.y_max = y_max = 0 self.variable_qtgui_label_0 = variable_qtgui_label_0 = ts_str self.samp_rate = samp_rate = 500e3 self.rx_freq = rx_freq = 4.51e6 self.nfft = nfft = 1024*32 self.lpf_cutoff = lpf_cutoff = 50e3 self.delay = delay = 0 self.decim = decim = 1 self.decay_rate = decay_rate = 20e-3 self.c_ms = c_ms = 299792458 ################################################## # Blocks ################################################## self.main_tab = Qt.QTabWidget() self.main_tab_widget_0 = Qt.QWidget() self.main_tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.main_tab_widget_0) self.main_tab_grid_layout_0 = Qt.QGridLayout() self.main_tab_layout_0.addLayout(self.main_tab_grid_layout_0) self.main_tab.addTab(self.main_tab_widget_0, 'Main') self.main_tab_widget_1 = Qt.QWidget() self.main_tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.main_tab_widget_1) self.main_tab_grid_layout_1 = Qt.QGridLayout() self.main_tab_layout_1.addLayout(self.main_tab_grid_layout_1) self.main_tab.addTab(self.main_tab_widget_1, 'Corr') self.top_grid_layout.addWidget(self.main_tab, 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._y_min_tool_bar = Qt.QToolBar(self) self._y_min_tool_bar.addWidget(Qt.QLabel('FREQ'+": ")) self._y_min_line_edit = Qt.QLineEdit(str(self.y_min)) self._y_min_tool_bar.addWidget(self._y_min_line_edit) self._y_min_line_edit.returnPressed.connect( lambda: self.set_y_min(eng_notation.str_to_num(str(self._y_min_line_edit.text().toAscii())))) self.main_tab_grid_layout_0.addWidget(self._y_min_tool_bar, 8, 4, 1, 1) for r in range(8, 9): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(4, 5): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self._y_max_tool_bar = Qt.QToolBar(self) self._y_max_tool_bar.addWidget(Qt.QLabel('FREQ'+": ")) self._y_max_line_edit = Qt.QLineEdit(str(self.y_max)) self._y_max_tool_bar.addWidget(self._y_max_line_edit) self._y_max_line_edit.returnPressed.connect( lambda: self.set_y_max(eng_notation.str_to_num(str(self._y_max_line_edit.text().toAscii())))) self.main_tab_grid_layout_0.addWidget(self._y_max_tool_bar, 8, 5, 1, 1) for r in range(8, 9): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(5, 6): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel('SAMP_RATE'+": ")) self._samp_rate_line_edit = Qt.QLineEdit(str(self.samp_rate)) self._samp_rate_tool_bar.addWidget(self._samp_rate_line_edit) self._samp_rate_line_edit.returnPressed.connect( lambda: self.set_samp_rate(eng_notation.str_to_num(str(self._samp_rate_line_edit.text().toAscii())))) self.main_tab_grid_layout_0.addWidget(self._samp_rate_tool_bar, 8, 0, 1, 1) for r in range(8, 9): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self._rx_freq_tool_bar = Qt.QToolBar(self) self._rx_freq_tool_bar.addWidget(Qt.QLabel('FREQ'+": ")) self._rx_freq_line_edit = Qt.QLineEdit(str(self.rx_freq)) self._rx_freq_tool_bar.addWidget(self._rx_freq_line_edit) self._rx_freq_line_edit.returnPressed.connect( lambda: self.set_rx_freq(eng_notation.str_to_num(str(self._rx_freq_line_edit.text().toAscii())))) self.main_tab_grid_layout_0.addWidget(self._rx_freq_tool_bar, 8, 1, 1, 1) for r in range(8, 9): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(1, 2): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self._lpf_cutoff_tool_bar = Qt.QToolBar(self) self._lpf_cutoff_tool_bar.addWidget(Qt.QLabel("lpf_cutoff"+": ")) self._lpf_cutoff_line_edit = Qt.QLineEdit(str(self.lpf_cutoff)) self._lpf_cutoff_tool_bar.addWidget(self._lpf_cutoff_line_edit) self._lpf_cutoff_line_edit.returnPressed.connect( lambda: self.set_lpf_cutoff(eng_notation.str_to_num(str(self._lpf_cutoff_line_edit.text().toAscii())))) self.main_tab_grid_layout_0.addWidget(self._lpf_cutoff_tool_bar, 8, 3, 1, 1) for r in range(8, 9): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(3, 4): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self._delay_tool_bar = Qt.QToolBar(self) self._delay_tool_bar.addWidget(Qt.QLabel('corr_delay'+": ")) self._delay_line_edit = Qt.QLineEdit(str(self.delay)) self._delay_tool_bar.addWidget(self._delay_line_edit) self._delay_line_edit.returnPressed.connect( lambda: self.set_delay(eng_notation.str_to_num(str(self._delay_line_edit.text().toAscii())))) self.main_tab_grid_layout_1.addWidget(self._delay_tool_bar, 8, 0, 1, 1) for r in range(8, 9): self.main_tab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.main_tab_grid_layout_1.setColumnStretch(c, 1) self._decay_rate_options = (100e-6, 65e-3, 20e-3, ) self._decay_rate_labels = ('Fast', 'Medium', 'Slow', ) self._decay_rate_group_box = Qt.QGroupBox("decay_rate") self._decay_rate_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._decay_rate_button_group = variable_chooser_button_group() self._decay_rate_group_box.setLayout(self._decay_rate_box) for i, label in enumerate(self._decay_rate_labels): radio_button = Qt.QRadioButton(label) self._decay_rate_box.addWidget(radio_button) self._decay_rate_button_group.addButton(radio_button, i) self._decay_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(self._decay_rate_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._decay_rate_options.index(i))) self._decay_rate_callback(self.decay_rate) self._decay_rate_button_group.buttonClicked[int].connect( lambda i: self.set_decay_rate(self._decay_rate_options[i])) self.main_tab_grid_layout_0.addWidget(self._decay_rate_group_box, 8, 2, 1, 1) for r in range(8, 9): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(2, 3): self.main_tab_grid_layout_0.setColumnStretch(c, 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: str(x) self._variable_qtgui_label_0_tool_bar.addWidget(Qt.QLabel('Start Time [UTC]'+": ")) 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.main_tab_grid_layout_0.addWidget(self._variable_qtgui_label_0_tool_bar, 8, 6, 1, 2) for r in range(8, 9): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(6, 8): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self.uhd_usrp_source_1 = uhd.usrp_source( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_1.set_clock_source('gpsdo', 0) self.uhd_usrp_source_1.set_time_source('gpsdo', 0) self.uhd_usrp_source_1.set_subdev_spec('A:AB B:AB', 0) self.uhd_usrp_source_1.set_samp_rate(samp_rate) self.uhd_usrp_source_1.set_time_unknown_pps(uhd.time_spec()) self.uhd_usrp_source_1.set_center_freq(uhd.tune_request(rx_freq), 0) self.uhd_usrp_source_1.set_gain(0, 0) self.uhd_usrp_source_1.set_antenna('A', 0) self.uhd_usrp_source_1.set_auto_dc_offset(True, 0) self.uhd_usrp_source_1.set_auto_iq_balance(True, 0) self.uhd_usrp_source_1.set_center_freq(uhd.tune_request(rx_freq), 1) self.uhd_usrp_source_1.set_gain(0, 1) self.uhd_usrp_source_1.set_antenna('A', 1) self.uhd_usrp_source_1.set_auto_dc_offset(True, 1) self.uhd_usrp_source_1.set_auto_iq_balance(True, 1) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0_0 = qtgui.waterfall_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc samp_rate / decim, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0_0.enable_grid(False) self.qtgui_waterfall_sink_x_0_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [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_waterfall_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0_0.set_intensity_range(-140, -40) self._qtgui_waterfall_sink_x_0_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_0_win, 4, 4, 4, 4) for r in range(4, 8): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(4, 8): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc samp_rate / decim, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [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_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, -40) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_win, 4, 0, 4, 4) for r in range(4, 8): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 4): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 10, #size samp_rate/decim, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.010) self.qtgui_time_sink_x_0_0.set_y_axis(-20, 20) self.qtgui_time_sink_x_0_0.set_y_label('Range Delta [km]', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: 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.main_tab_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_0_win, 4, 0, 2, 4) for r in range(4, 6): self.main_tab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 4): self.main_tab_grid_layout_1.setColumnStretch(c, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( nfft, #size samp_rate/decim, #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('Correlation', "") 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(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_win, 0, 4, 4, 4) for r in range(0, 4): self.main_tab_grid_layout_1.setRowStretch(r, 1) for c in range(4, 8): self.main_tab_grid_layout_1.setColumnStretch(c, 1) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 3 ) self.qtgui_number_sink_0.set_update_time(0.010) self.qtgui_number_sink_0.set_title("") labels = ['Delay', '', 'Range Delta', '', '', '', '', '', '', ''] units = ['[usec]', '', '[km]', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(3): 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(True) self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_1.addWidget(self._qtgui_number_sink_0_win, 6, 0, 1, 2) for r in range(6, 7): self.main_tab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 2): self.main_tab_grid_layout_1.setColumnStretch(c, 1) self.qtgui_histogram_sink_x_0_0 = qtgui.histogram_sink_f( 20, 1000, 0, 100e4, "", 1 ) self.qtgui_histogram_sink_x_0_0.set_update_time(0.010) self.qtgui_histogram_sink_x_0_0.enable_autoscale(True) self.qtgui_histogram_sink_x_0_0.enable_accumulate(True) self.qtgui_histogram_sink_x_0_0.enable_grid(False) self.qtgui_histogram_sink_x_0_0.enable_axis_labels(True) if not True: self.qtgui_histogram_sink_x_0_0.disable_legend() labels = ['Correlation Magnitude', 'Corr Mag', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_histogram_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_histogram_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_histogram_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_histogram_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_histogram_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_histogram_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_histogram_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_histogram_sink_x_0_0_win = sip.wrapinstance(self.qtgui_histogram_sink_x_0_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_1.addWidget(self._qtgui_histogram_sink_x_0_0_win, 0, 0, 4, 4) for r in range(0, 4): self.main_tab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 4): self.main_tab_grid_layout_1.setColumnStretch(c, 1) self.qtgui_histogram_sink_x_0 = qtgui.histogram_sink_f( 20, 2000, -25*1/(samp_rate/decim) *c_ms / 1000.0, 25*1/(samp_rate/decim) *c_ms / 1000.0, "", 1 ) self.qtgui_histogram_sink_x_0.set_update_time(0.010) self.qtgui_histogram_sink_x_0.enable_autoscale(True) self.qtgui_histogram_sink_x_0.enable_accumulate(True) self.qtgui_histogram_sink_x_0.enable_grid(False) self.qtgui_histogram_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_histogram_sink_x_0.disable_legend() labels = ['Range Delta [km]', 'Corr Mag', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_histogram_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_histogram_sink_x_0.set_line_label(i, labels[i]) self.qtgui_histogram_sink_x_0.set_line_width(i, widths[i]) self.qtgui_histogram_sink_x_0.set_line_color(i, colors[i]) self.qtgui_histogram_sink_x_0.set_line_style(i, styles[i]) self.qtgui_histogram_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_histogram_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_histogram_sink_x_0_win = sip.wrapinstance(self.qtgui_histogram_sink_x_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_1.addWidget(self._qtgui_histogram_sink_x_0_win, 4, 4, 2, 4) for r in range(4, 6): self.main_tab_grid_layout_1.setRowStretch(r, 1) for c in range(4, 8): self.main_tab_grid_layout_1.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc samp_rate /decim, #bw "E/W Dipole", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.010) self.qtgui_freq_sink_x_0_0.set_y_axis(y_min, y_max) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(True) self.qtgui_freq_sink_x_0_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_0_win, 0, 4, 4, 4) for r in range(0, 4): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(4, 8): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc samp_rate / decim, #bw "N/S Dipole", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.010) self.qtgui_freq_sink_x_0.set_y_axis(y_min, y_max) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 4, 4) for r in range(0, 4): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 4): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self.low_pass_filter_1 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate/decim, lpf_cutoff, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate/decim, lpf_cutoff, 1e3, firdes.WIN_HAMMING, 6.76)) self.fft_vxx_2 = fft.fft_vcc(nfft, True, (window.blackmanharris(nfft)), True, 4) self.fft_vxx_1 = fft.fft_vcc(nfft, False, (window.blackmanharris(nfft)), False, 4) self.fft_vxx_0 = fft.fft_vcc(nfft, False, (window.blackmanharris(nfft)), False, 4) self.blocks_vector_to_stream_1 = blocks.vector_to_stream(gr.sizeof_float*1, nfft) self.blocks_stream_to_vector_1 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, nfft) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, nfft) self.blocks_short_to_float_0 = blocks.short_to_float(1, 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_short*1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((1/(samp_rate/decim) *c_ms / 1000.0, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((1/(samp_rate/decim) * 1e6, )) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(nfft) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(10, .1, 4000, 1) self.blocks_max_xx_0 = blocks.max_ff(nfft,1) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, int(delay)) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(nfft) self.blocks_argmax_xx_0 = blocks.argmax_fs(nfft) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-nfft/2.0, )) self.analog_agc2_xx_0_0 = analog.agc2_cc(decay_rate, decay_rate, 1.0, .5) self.analog_agc2_xx_0_0.set_max_gain(65536) self.analog_agc2_xx_0 = analog.agc2_cc(decay_rate, decay_rate, 1.0, .5) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.analog_agc2_xx_0_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_argmax_xx_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_argmax_xx_0, 0), (self.blocks_short_to_float_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_argmax_xx_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_max_xx_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_vector_to_stream_1, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_stream_to_vector_1, 0)) self.connect((self.blocks_max_xx_0, 0), (self.qtgui_histogram_sink_x_0_0, 0)) self.connect((self.blocks_max_xx_0, 0), (self.qtgui_number_sink_0, 1)) self.connect((self.blocks_max_xx_0, 0), (self.qtgui_time_sink_x_0_0, 1)) self.connect((self.blocks_moving_average_xx_0, 0), (self.qtgui_histogram_sink_x_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.qtgui_number_sink_0, 2)) self.connect((self.blocks_moving_average_xx_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.fft_vxx_2, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_stream_to_vector_1, 0), (self.fft_vxx_1, 0)) self.connect((self.blocks_vector_to_stream_1, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.fft_vxx_1, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.fft_vxx_2, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.low_pass_filter_1, 0), (self.blocks_delay_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.qtgui_freq_sink_x_0_0, 1)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_waterfall_sink_x_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.uhd_usrp_source_1, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.uhd_usrp_source_1, 1), (self.analog_agc2_xx_0_0, 0))
def __init__(self, seq1, seq2, factor, alpha, freqs, debug_onoff, debug_port, prefix): """ Description: frequency timing estimator class does frequency/timing acquisition from scratch.It uses a bank of parallel correlators at each specified frequency. It then takes the max abs value of all these and passes it through a peak detector to find timing. Args: seq1: sequence1 of kronecker filter, which is the given training sequence. seq2: sequence2 of kronecker filter, which is the pulse for each training symbol. factor: the rise and fall factors in peak detector, which is the factor determining when a peak has started and ended. In the peak detector, an average of the signal is calculated. When the value of the signal goes over factor*average, we start looking for a peak. When the value of the signal goes below factor*average, we stop looking for a peak. alpha: the smoothing factor of a moving average filter used in the peak detector taking values in (0,1). freqs: the vector of normalized center frequencies for each matched filter. Note that for a training sequence of length Nt, each matched filter can recover a sequence with normalized frequency offset ~ 1/(2Nt). """ gr.hier_block2.__init__(self, "freq_timing_estimator", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signaturev(3, 3, [gr.sizeof_char*1, gr.sizeof_float*1, gr.sizeof_float*1]), ) ################################################## # Parameters ################################################## self.seq1 = seq1 self.seq2 = seq2 self.factor = factor self.alpha = alpha self.freqs = freqs self.n = n = len(freqs) self.on = 1 self.debug_onoff = debug_onoff # 1: dump ports info to file 0: no debug output self.debug_port = debug_port # 0-n_filt-1 is the output of each filter branck; n_filter is the output of maximum self.prefix = prefix ################################################## # Blocks ################################################## self._filter=[0]*self.n self._c2mag2=[0]*self.n for i in range(self.n): #self._filter[i]= cdma.kronecker_filter(seq1,seq2,1,self.freqs[i]) #self._filter[i]= filter.freq_xlating_fir_filter_ccc(1, numpy.kron(seq1,seq2), self.freqs[i], 1) self._filter[i]= filter.freq_xlating_fft_filter_ccc(1, numpy.kron(seq1,seq2), self.freqs[i], 1) self._c2mag2[i] = blocks.complex_to_mag_squared(1) self.blocks_max = blocks.max_ff(1) self.blocks_peak_detector = cdma.switched_peak_detector_fb(self.factor, self.factor, 0, self.alpha, self.on) self.blocks_argmax = blocks.argmax_fs(1) self.blocks_null_sink = blocks.null_sink(gr.sizeof_short*1) self.digital_chunks_to_symbols = digital.chunks_to_symbols_sf((freqs), 1) self.blocks_sample_and_hold = blocks.sample_and_hold_ff() if self.debug_onoff == True: num_of_file_sinks = len(self.debug_port) self._filesink = [0]*num_of_file_sinks for i in range(num_of_file_sinks): if self.debug_port[i] == self.n: filename = prefix+"max.dat" else: filename = prefix+"filter"+str(i)+".dat" print filename self._filesink[i] = blocks.file_sink(gr.sizeof_float*1, filename, False) self._filesink[i].set_unbuffered(False) # this is the block for bundling the outputs of each branch of filters and the input of peak detector ################################################## # Connections ################################################## for i in range(self.n): self.connect((self, 0), (self._filter[i], 0)) self.connect((self._filter[i], 0), (self._c2mag2[i], 0)) self.connect((self._c2mag2[i], 0), (self.blocks_max, i)) self.connect((self._c2mag2[i], 0), (self.blocks_argmax, i)) self.connect((self.blocks_max, 0), (self.blocks_peak_detector, 0)) self.connect((self.blocks_peak_detector, 0), (self, 0)) self.connect((self.blocks_argmax, 0), (self.blocks_null_sink, 0)) self.connect((self.blocks_argmax, 1), (self.digital_chunks_to_symbols, 0)) self.connect((self.digital_chunks_to_symbols, 0), (self.blocks_sample_and_hold, 0)) self.connect((self.blocks_peak_detector, 0), (self.blocks_sample_and_hold, 1)) self.connect((self.blocks_sample_and_hold, 0), (self, 1)) self.connect((self.blocks_max, 0), (self, 2)) if self.debug_onoff == True: for i in range(num_of_file_sinks): port_index = self.debug_port[i] if port_index == self.n: self.connect((self.blocks_max, 0), (self._filesink[i], 0)) else: self.connect((self._c2mag2[port_index], 0), (self._filesink[i], 0))
def __init__(self, seq1, seq2, factor, alpha, samp_rate, freqs): """ Description: This block is functionally equivalent to the frequency_timing_estimator block, except from the fact that each filter is matched to a sequence that can be written as the kronecker product of seq1 and seq2. Args: seq1: sequence1 of kronecker filter, which is the given training sequence. seq2: sequence2 of kronecker filter, which is the pulse for each training symbol. factor: the rise and fall factors in peak detector, which is the factor determining when a peak has started and ended. In the peak detector, an average of the signal is calculated. When the value of the signal goes over factor*average, we start looking for a peak. When the value of the signal goes below factor*average, we stop looking for a peak. factor takes values in (0,1). alpha: the smoothing factor of a moving average filter used in the peak detector takeng values in (0,1). samp_rate: the sample rate of the system, which is used in the kronecker_filter. freqs: the vector of center frequencies for each matched filter. Note that for a training sequence of length Nt, each matched filter can recover a sequence with normalized frequency offset ~ 1/(2Nt). """ gr.hier_block2.__init__(self, "freq_timing_estimator", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signaturev(3, 3, [gr.sizeof_char*1, gr.sizeof_float*1, gr.sizeof_float*1]), ) ################################################## # Parameters ################################################## self.seq1 = seq1 self.seq2 = seq2 self.factor = factor self.alpha = alpha self.samp_rate = samp_rate self.freqs = freqs self.n = n = len(freqs) ################################################## # Blocks ################################################## self._filter=[0]*self.n self._c2mag2=[0]*self.n for i in range(self.n): self._filter[i]= cdma.kronecker_filter(seq1,seq2,samp_rate,self.freqs[i]) #self._filter[i]= filter.freq_xlating_fir_filter_ccc(1, (numpy.conjugate(self.ts[::-1])), self.freqs[i], self.samp_rate) self._c2mag2[i] = blocks.complex_to_mag_squared(1) self.blocks_max = blocks.max_ff(1) self.blocks_peak_detector = blocks.peak_detector_fb(self.factor, self.factor, 0, self.alpha) self.blocks_argmax = blocks.argmax_fs(1) self.blocks_null_sink = blocks.null_sink(gr.sizeof_short*1) self.digital_chunks_to_symbols = digital.chunks_to_symbols_sf((freqs), 1) self.blocks_sample_and_hold = blocks.sample_and_hold_ff() ################################################## # Connections ################################################## for i in range(self.n): self.connect((self, 0), (self._filter[i], 0)) self.connect((self._filter[i], 0), (self._c2mag2[i], 0)) self.connect((self._c2mag2[i], 0), (self.blocks_max, i)) self.connect((self._c2mag2[i], 0), (self.blocks_argmax, i)) self.connect((self.blocks_max, 0), (self.blocks_peak_detector, 0)) self.connect((self.blocks_peak_detector, 0), (self, 0)) self.connect((self.blocks_argmax, 0), (self.blocks_null_sink, 0)) self.connect((self.blocks_argmax, 1), (self.digital_chunks_to_symbols, 0)) self.connect((self.digital_chunks_to_symbols, 0), (self.blocks_sample_and_hold, 0)) self.connect((self.blocks_peak_detector, 0), (self.blocks_sample_and_hold, 1)) self.connect((self.blocks_sample_and_hold, 0), (self, 1)) self.connect((self.blocks_max, 0), (self, 2))
def __init__(self): gr.top_block.__init__(self, "Receive And Track") Qt.QWidget.__init__(self) self.setWindowTitle("Receive And Track") 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", "receive_and_track") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sdr_samp = sdr_samp = 1.8e6 self.samp_rate = samp_rate = 40e3 self.fft_size = fft_size = 1024 self.center_freq = center_freq = 430e6 - 9e3 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=int(1.8e6 / 40e3), taps=None, fractional_bw=None, ) self.qtgui_sink_x_0 = qtgui.sink_c( fft_size, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype center_freq, #fc samp_rate, #bw "", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_win = sip.wrapinstance( self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(True) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ["", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_win) self.logpwrfft_x_0 = logpwrfft.logpwrfft_c( sample_rate=samp_rate, fft_size=fft_size, ref_scale=2, frame_rate=30, avg_alpha=1.0, average=False, ) self.blocks_short_to_float_0 = blocks.short_to_float( 1, float(fft_size / samp_rate)) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_short * 1) self.blocks_argmax_xx_0 = blocks.argmax_fs(fft_size) self.NANO_SDR = osmosdr.source(args="numchan=" + str(1) + " " + "rtl=0") self.NANO_SDR.set_time_unknown_pps(osmosdr.time_spec_t()) self.NANO_SDR.set_sample_rate(sdr_samp) self.NANO_SDR.set_center_freq(center_freq, 0) self.NANO_SDR.set_freq_corr(0, 0) self.NANO_SDR.set_dc_offset_mode(0, 0) self.NANO_SDR.set_iq_balance_mode(0, 0) self.NANO_SDR.set_gain_mode(False, 0) self.NANO_SDR.set_gain(10, 0) self.NANO_SDR.set_if_gain(10, 0) self.NANO_SDR.set_bb_gain(10, 0) self.NANO_SDR.set_antenna("", 0) self.NANO_SDR.set_bandwidth(0, 0) ################################################## # Connections ################################################## self.connect((self.NANO_SDR, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_argmax_xx_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_argmax_xx_0, 0), (self.blocks_short_to_float_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.logpwrfft_x_0, 0), (self.blocks_argmax_xx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.logpwrfft_x_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_sink_x_0, 0))