def __init__(self, sample_rate, fac_size, fac_rate): gr.hier_block2.__init__(self, "fast_autocorrelator_c", gr.io_signature(1, 1, gr.sizeof_float), gr.io_signature(1, 1, gr.sizeof_float)) # Parameters self.sample_rate = sample_rate self.fac_size = fac_size self.fac_rate = fac_rate self.window = () # Block Objects For Float Fast Autocorrelator self.stream_to_vector = blocks.stream_to_vector( gr.sizeof_float, fac_size) self.keep_one_in_n = blocks.keep_one_in_n( gr.sizeof_float * fac_size, max(1, int(sample_rate / fac_size / fac_rate))) self.fac_fft = fft.fft_vfc(fac_size, True, self.window) self.complex_to_mag = blocks.complex_to_mag(fac_size) self.fac_complex_to_mag = blocks.complex_to_mag(fac_size) self.nlog10_ff = blocks.nlog10_ff(20, fac_size, -20 * math.log10(fac_size)) self.single_pole_iir_filter_ff = filter.single_pole_iir_filter_ff( 1, fac_size) self.fft_vfc = fft.fft_vfc(fac_size, True, self.window) self.vector_to_stream = blocks.vector_to_stream( gr.sizeof_float, self.fac_size) # Connections for Auto Correlator self.connect(self, self.stream_to_vector, self.keep_one_in_n, self.fft_vfc, self.complex_to_mag, self.fac_fft, self.fac_complex_to_mag, self.single_pole_iir_filter_ff, self.nlog10_ff, self.vector_to_stream, self)
def __init__(self, window_size): gr.hier_block2.__init__(self, "FFT_IFFT", gr.io_signature(1, 1, gr.sizeof_float), gr.io_signature(1, 1, gr.sizeof_float)) vector_to_stream = blocks.vector_to_stream(gr.sizeof_gr_complex, window_size) stream_to_vector = blocks.stream_to_vector(gr.sizeof_float, window_size) divide = blocks.divide_cc(1) complex_to_float = blocks.complex_to_float(1) fft_forward = fft.fft_vfc(window_size, True, (fft.window.blackmanharris(window_size)), 1) fft_backward = fft.fft_vcc( window_size, False, (fft.window.blackmanharris(window_size)), False, 1) constant = analog.sig_source_c(0, analog.GR_CONST_WAVE, 0, 0, window_size) #print("1. Connect self to stream_to_vector") self.connect((self, 0), (stream_to_vector, 0)) #print("2. Connect stream_to_vector to fft_forward") self.connect((stream_to_vector, 0), (fft_forward, 0)) #print("3. Connect fft_forward to fft_backward") self.connect((fft_forward, 0), (fft_backward, 0)) #print("4. Connect fft_backward to vector_to_stream") self.connect((fft_backward, 0), (vector_to_stream, 0)) #print("5. Connect vector_to_stream to port 0 of divide") self.connect((vector_to_stream, 0), (divide, 0)) #print("6. Connect constant to port 1 of divide") self.connect(constant, (divide, 1)) #print("7. Connect divide to complex_to_float") self.connect((divide, 0), (complex_to_float, 0)) #print("8. Connect complex_to_float to self") self.connect((complex_to_float, 0), (self, 0))
def __init__(self, ber_block, ncorrelations, lfsr_bits = 16): gr.top_block.__init__(self) prn_len = 2**lfsr_bits prn = np.concatenate((scipy.signal.max_len_seq(lfsr_bits)[0], [1])) prn_fft_conj = np.conjugate(np.fft.fft(2*prn-1)) self.source = blocks.vector_source_b(prn, True, 1, []) self.ber_block = ber_block self.char2float = blocks.char_to_float(1, 0.5) self.add_const = blocks.add_const_ff(-1.0) self.source_vector = blocks.stream_to_vector(gr.sizeof_float, prn_len) self.fft = fft.fft_vfc(prn_len, True, window.rectangular(prn_len), 1) self.prn_fft_source = blocks.vector_source_c(prn_fft_conj, True, prn_len, []) self.multiply_ffts = blocks.multiply_vcc(prn_len) self.ifft = fft.fft_vcc(prn_len, False, np.ones(prn_len)/prn_len**2, False, 1) self.corr_mag = blocks.complex_to_mag(prn_len) self.max_corr = blocks.max_ff(prn_len, 1) self.multiply_const = blocks.multiply_const_ff(-0.5) self.add_const2 = blocks.add_const_ff(0.5) self.head = blocks.head(gr.sizeof_float, ncorrelations) self.sink = blocks.vector_sink_f() self.connect(self.source, self.ber_block, self.char2float, self.add_const, self.source_vector, self.fft, (self.multiply_ffts,0), self.ifft, self.corr_mag, self.max_corr, self.multiply_const, self.add_const2, self.head, self.sink) self.connect(self.prn_fft_source, (self.multiply_ffts,1))
def __init__(self, parent, baseband_freq=0, y_per_div=10, ref_level=50, sample_rate=1, fft_size=512, fft_rate=default_fft_rate, average=False, avg_alpha=None, title='', size=default_fftsink_size, **kwargs): gr.hier_block2.__init__(self, "waterfall_sink_f", gr.io_signature(1, 1, gr.sizeof_float), gr.io_signature(0,0,0)) waterfall_sink_base.__init__(self, input_is_real=True, baseband_freq=baseband_freq, sample_rate=sample_rate, fft_size=fft_size, fft_rate=fft_rate, average=average, avg_alpha=avg_alpha, title=title) self.s2p = gr.serial_to_parallel(gr.sizeof_float, self.fft_size) self.one_in_n = gr.keep_one_in_n(gr.sizeof_float * self.fft_size, max(1, int(self.sample_rate/self.fft_size/self.fft_rate))) mywindow = window.blackmanharris(self.fft_size) self.fft = fft.fft_vfc(self.fft_size, True, mywindow) self.c2mag = gr.complex_to_mag(self.fft_size) self.avg = filter.single_pole_iir_filter_ff(1.0, self.fft_size) self.log = gr.nlog10_ff(20, self.fft_size, -20*math.log10(self.fft_size)) self.sink = gr.message_sink(gr.sizeof_float * self.fft_size, self.msgq, True) self.connect(self, self.s2p, self.one_in_n, self.fft, self.c2mag, self.avg, self.log, self.sink) self.win = waterfall_window(self, parent, size=size) self.set_average(self.average)
def __init__(self, window_size): gr.hier_block2.__init__(self, "FFT_IFFT", gr.io_signature(1,1,gr.sizeof_float), gr.io_signature(1,1,gr.sizeof_float)) vector_to_stream = blocks.vector_to_stream(gr.sizeof_gr_complex, window_size) stream_to_vector = blocks.stream_to_vector(gr.sizeof_float, window_size) divide = blocks.divide_cc(1) complex_to_float = blocks.complex_to_float(1) fft_forward = fft.fft_vfc(window_size, True, (fft.window.blackmanharris(window_size)), 1) fft_backward = fft.fft_vcc(window_size, False, (fft.window.blackmanharris(window_size)), False, 1) constant = analog.sig_source_c(0, analog.GR_CONST_WAVE, 0, 0, window_size) #print("1. Connect self to stream_to_vector") self.connect((self, 0), (stream_to_vector, 0)) #print("2. Connect stream_to_vector to fft_forward") self.connect((stream_to_vector, 0), (fft_forward, 0)) #print("3. Connect fft_forward to fft_backward") self.connect((fft_forward, 0), (fft_backward, 0)) #print("4. Connect fft_backward to vector_to_stream") self.connect((fft_backward, 0), (vector_to_stream, 0)) #print("5. Connect vector_to_stream to port 0 of divide") self.connect((vector_to_stream, 0), (divide, 0)) #print("6. Connect constant to port 1 of divide") self.connect(constant, (divide, 1)) #print("7. Connect divide to complex_to_float") self.connect((divide, 0), (complex_to_float, 0)) #print("8. Connect complex_to_float to self") self.connect((complex_to_float, 0), (self, 0))
def __init__(self, parent, baseband_freq=0, y_per_div=10, ref_level=50, sample_rate=1, fac_size=512, fac_rate=default_fac_rate, average=False, avg_alpha=None, title='', size=default_facsink_size, peak_hold=False): fac_sink_base.__init__(self, input_is_real=True, baseband_freq=baseband_freq, y_per_div=y_per_div, ref_level=ref_level, sample_rate=sample_rate, fac_size=fac_size, fac_rate=fac_rate, average=average, avg_alpha=avg_alpha, title=title, peak_hold=peak_hold) s2p = blocks.stream_to_vector(gr.sizeof_float, self.fac_size) self.one_in_n = blocks.keep_one_in_n(gr.sizeof_float * self.fac_size, max(1, int(self.sample_rate/self.fac_size/self.fac_rate))) # windowing removed... #fac = gr.fft_vfc(self.fac_size, True, ()) fac = fft.fft_vfc(self.fac_size, True, ()) c2mag = blocks.complex_to_mag(self.fac_size) self.avg = filter.single_pole_iir_filter_ff_make(1.0, self.fac_size) fac_fac = fft.fft_vfc(self.fac_size, True, ()) fac_c2mag = blocks.complex_to_mag_make(fac_size) # FIXME We need to add 3dB to all bins but the DC bin log = blocks.nlog10_ff_make(20, self.fac_size, -20*math.log10(self.fac_size) ) sink = blocks.message_sink(gr.sizeof_float * self.fac_size, self.msgq, True) self.connect(s2p, self.one_in_n, fac, c2mag, fac_fac, fac_c2mag, self.avg, log, sink) # gr.hier_block.__init__(self, fg, s2p, sink) self.win = fac_window(self, parent, size=size) self.set_average(self.average) self.wxgui_connect(self, s2p)
def __init__(self, config): gr.top_block.__init__(self, self.__class__.__name__) self._start_time = -1 self._end_time = 0 self._running = False self.source = RadioSource(preferred_sample_rate=config.sample_rate, gains=config.gains, frequency_offset=config.frequency_offset) self.fft = fft.fft_vfc(config.fft_resolution, True, (window.rectangular(config.fft_resolution)), 1) self.stream_to_vector = blocks.stream_to_vector( gr.sizeof_float * 1, config.fft_resolution) self.psd = blocks.multiply_vcc(config.fft_resolution) self.complex_to_real = blocks.complex_to_real(1) self.complex_to_mag = blocks.complex_to_mag(config.fft_resolution) self.bpf = filter.fir_filter_ccf( 1, firdes.band_pass( 100, config.sample_rate, self.source.frequency_offset - (config.signal_bandwidth / 2), self.source.frequency_offset + (config.signal_bandwidth / 2), 600, firdes.WIN_RECTANGULAR, 6.76)) self.processing = select_detection_method(config.detection_method)( num_bins=config.fft_resolution, center_frequency=0, signal_frequency=config.frequency_offset, signal_bandwidth=config.signal_bandwidth, threshold=config.snr_threshold, decay_time=config.decay_time, decay_strength=config.decay_strength) self.extract = AsyncSink() self.connect(self.source, self.bpf) self.connect(self.bpf, self.complex_to_real) self.connect(self.complex_to_real, self.stream_to_vector) self.connect(self.stream_to_vector, self.fft) self.connect((self.fft, 0), (self.psd, 1)) self.connect((self.fft, 0), (self.psd, 0)) self.connect(self.psd, self.complex_to_mag) self.connect(self.complex_to_mag, self.processing) self.connect(self.processing, self.extract) self.processing.set_sample_rate(config.sample_rate / config.fft_resolution)
def __init__(self, parent, baseband_freq=0, y_per_div=10, ref_level=50, sample_rate=1, fft_size=512, fft_rate=default_fft_rate, average=False, avg_alpha=None, title='', size=default_fftsink_size, **kwargs): gr.hier_block2.__init__(self, "waterfall_sink_f", gr.io_signature(1, 1, gr.sizeof_float), gr.io_signature(0, 0, 0)) waterfall_sink_base.__init__(self, input_is_real=True, baseband_freq=baseband_freq, sample_rate=sample_rate, fft_size=fft_size, fft_rate=fft_rate, average=average, avg_alpha=avg_alpha, title=title) self.s2p = blocks.stream_to_vector(gr.sizeof_float, self.fft_size) self.one_in_n = blocks.keep_one_in_n( gr.sizeof_float * self.fft_size, max(1, int(self.sample_rate / self.fft_size / self.fft_rate))) mywindow = window.blackmanharris(self.fft_size) self.fft = fft.fft_vfc(self.fft_size, True, mywindow) self.c2mag = blocks.complex_to_mag(self.fft_size) self.avg = filter.single_pole_iir_filter_ff(1.0, self.fft_size) self.log = blocks.nlog10_ff(20, self.fft_size, -20 * math.log10(self.fft_size)) self.sink = blocks.message_sink(gr.sizeof_float * self.fft_size, self.msgq, True) self.connect(self, self.s2p, self.one_in_n, self.fft, self.c2mag, self.avg, self.log, self.sink) self.win = waterfall_window(self, parent, size=size) self.set_average(self.average)
def __init__(self, parent, baseband_freq=0, ref_scale=2.0, y_per_div=10, y_divs=8, ref_level=50, sample_rate=1, fft_size=512, fft_rate=default_fft_rate, average=False, avg_alpha=None, title='', size=default_fftsink_size, peak_hold=False, use_persistence=False, persist_alpha=0.2, **kwargs): gr.hier_block2.__init__(self, "fft_sink_f", gr.io_signature(1, 1, gr.sizeof_float), gr.io_signature(0,0,0)) fft_sink_base.__init__(self, input_is_real=True, baseband_freq=baseband_freq, y_per_div=y_per_div, y_divs=y_divs, ref_level=ref_level, sample_rate=sample_rate, fft_size=fft_size, fft_rate=fft_rate, average=average, avg_alpha=avg_alpha, title=title, peak_hold=peak_hold, use_persistence=use_persistence, persist_alpha=persist_alpha) self.s2p = blocks.stream_to_vector(gr.sizeof_float, self.fft_size) self.one_in_n = blocks.keep_one_in_n(gr.sizeof_float * self.fft_size, max(1, int(self.sample_rate/self.fft_size/self.fft_rate))) mywindow = window.blackmanharris(self.fft_size) self.fft = fft.fft_vfc(self.fft_size, True, mywindow) power = 0 for tap in mywindow: power += tap*tap self.c2magsq = blocks.complex_to_mag_squared(self.fft_size) self.avg = grfilter.single_pole_iir_filter_ff(1.0, self.fft_size) # FIXME We need to add 3dB to all bins but the DC bin self.log = blocks.nlog10_ff(10, self.fft_size, -20*math.log10(self.fft_size) # Adjust for number of bins -10*math.log10(power/self.fft_size) # Adjust for windowing loss -20*math.log10(ref_scale/2)) # Adjust for reference scale self.sink = blocks.message_sink(gr.sizeof_float * self.fft_size, self.msgq, True) self.connect(self, self.s2p, self.one_in_n, self.fft, self.c2magsq, self.avg, self.log, self.sink) self.win = fft_window(self, parent, size=size) self.set_average(self.average) self.set_peak_hold(self.peak_hold) self.set_use_persistence(self.use_persistence) self.set_persist_alpha(self.persist_alpha)
def __init__(self, sample_rate, fac_size, fac_decimation, useDB): gr.hier_block2.__init__( self, "AutoCorrelator", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_float * fac_size)) # Output signature self.fac_size = fac_size self.fac_decimation = fac_decimation self.sample_rate = sample_rate streamToVec = blocks.stream_to_vector(gr.sizeof_gr_complex, self.fac_size) # Make sure N is at least 1 decimation = int(self.sample_rate / self.fac_size / self.fac_decimation) self.one_in_n = blocks.keep_one_in_n( gr.sizeof_gr_complex * self.fac_size, max(1, decimation)) # FFT Note: No windowing. fac = fft.fft_vcc(self.fac_size, True, ()) complex2Mag = blocks.complex_to_mag(self.fac_size) self.avg = filter.single_pole_iir_filter_ff_make(1.0, self.fac_size) fac_fac = fft.fft_vfc(self.fac_size, True, ()) fac_c2mag = blocks.complex_to_mag_make(fac_size) # There's a note in Baz's block about needing to add 3 dB to each bin but the DC bin, however it was never implemented n = 20 k = -20 * math.log10(self.fac_size) log = blocks.nlog10_ff_make(n, self.fac_size, k) if useDB: self.connect(self, streamToVec, self.one_in_n, fac, complex2Mag, fac_fac, fac_c2mag, self.avg, log, self) else: self.connect(self, streamToVec, self.one_in_n, fac, complex2Mag, fac_fac, fac_c2mag, self.avg, self)
def __init__(self, parent, baseband_freq=0, y_per_div=10, ref_level=50, sample_rate=1, fac_size=512, fac_rate=default_fac_rate, average=False, avg_alpha=None, title='', size=default_facsink_size, peak_hold=False): fac_sink_base.__init__(self, input_is_real=False, baseband_freq=baseband_freq, y_per_div=y_per_div, ref_level=ref_level, sample_rate=sample_rate, fac_size=fac_size, fac_rate=fac_rate, average=average, avg_alpha=avg_alpha, title=title, peak_hold=peak_hold) s2p = blocks.stream_to_vector(gr.sizeof_gr_complex, self.fac_size) self.one_in_n = blocks.keep_one_in_n(gr.sizeof_gr_complex * self.fac_size, max(1, int(self.sample_rate/self.fac_size/self.fac_rate))) # windowing removed ... fac = fft.fft_vcc(self.fac_size, True, ()) c2mag = blocks.complex_to_mag_make(fac_size) # Things go off into the weeds if we try for an inverse FFT so a forward FFT will have to do... fac_fac = fft.fft_vfc(self.fac_size, True, ()) fac_c2mag = blocks.complex_to_mag_make(fac_size) self.avg = filter.single_pole_iir_filter_ff_make(1.0, fac_size) log = blocks.nlog10_ff_make(20, self.fac_size, -20*math.log10(self.fac_size) ) # - 20*math.log10(norm) ) # - self.avg[0] ) sink = blocks.message_sink_make(gr.sizeof_float * fac_size, self.msgq, True) self.connect(s2p, self.one_in_n, fac, c2mag, fac_fac, fac_c2mag, self.avg, log, sink) # gr.hier_block2.__init__(self, fg, s2p, sink) self.win = fac_window(self, parent, size=size) self.set_average(self.average) self.wxgui_connect(self, s2p)
def __init__(self, path=None, output_path=None): gr.top_block.__init__(self, "Rx") if path != None: am_demod = blocks.file_source(gr.sizeof_float * 1, path) else: osmosdr_h = osmosdr.source(args="numchan=" + str(1) + " " + "") osmosdr_h.set_sample_rate(Fs) osmosdr_h.set_center_freq(Fc, 0) osmosdr_h.set_gain_mode(True) # enable hw agc lpf_carrier = firdes.low_pass(1.0, Fs, 10000, 1000, firdes.WIN_HAMMING, 6.76) carrier_xlate = filter.freq_xlating_fir_filter_ccc( xlate_decim, lpf_carrier, Foffset, Fs) am_demod = blocks.complex_to_mag(1) self.connect(osmosdr_h, carrier_xlate, am_demod) if options.output_path: file_sink = blocks.file_sink(gr.sizeof_float * 1, output_path, False) self.connect(am_demod, file_sink) if PLAY_AUDIO: audio_sink = audio.sink(Fa, "", True) self.connect(am_demod, audio_sink) audio_to_vec = blocks.stream_to_vector(gr.sizeof_float * 1, fft_width) audio_fft = fft.fft_vfc(fft_width, True, (window.blackmanharris(fft_width)), 1) fft_mag = blocks.complex_to_mag(fft_width) self.connect(am_demod, audio_to_vec, audio_fft, fft_mag) decoder = Decoder() self.connect(fft_mag, decoder)
def init(self, bins=256): self.gr_block = fft.fft_vfc(256, forward=True, window=fft.window.blackmanharris(bins))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 44100 ################################################## # Blocks ################################################## self.qtgui_vector_sink_f_0 = qtgui.vector_sink_f( 1024, 0, 1.0, "x-Axis", "y-Axis", "vector sink", 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(False) self.qtgui_vector_sink_f_0.enable_grid(False) 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_freq_sink_x_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "freq_sink", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "float" == "float" or "float" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.fft_vxx_0 = fft.fft_vfc(1024, True, (window.blackmanharris(1024)), 1) self.blocks_wavfile_source_1 = blocks.wavfile_source( '/home/jsarp4/Documents/gnu_radio_flowcharts/CSS_USRP_impl/chirps/1.wav', True) self.blocks_wavfile_source_0 = blocks.wavfile_source( '/home/jsarp4/Documents/gnu_radio_flowcharts/CSS_USRP_impl/chirps/inv.wav', True) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_float * 1, 1024) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1024) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_float_0, 0), (self.qtgui_vector_sink_f_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_wavfile_source_1, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_float_0, 0))
def __init__(self, alsa_dev="default:CARD=Device", averaging_period=1.0, zscore_period=300.0, trigger_threshold=1.0, trigger_holdoff=2.0, debug_print_period=3.0, logfile_path=None, NFFT = 128, audio_rate=48000, audio_decim=6): gr.top_block.__init__(self) ################################################## # Variables ################################################## self.samp_rate = samp_rate = audio_rate/audio_decim ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=1, decimation=audio_decim, taps=None, fractional_bw=None, ) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.audio_source_0 = audio.source(audio_rate, alsa_dev, True) self.pack_for_fft = blocks.stream_to_vector(gr.sizeof_float*1, NFFT) self.fft = fft.fft_vfc(NFFT, True, (fft.window.blackmanharris(NFFT)), 1) self.unpack_fft = blocks.vector_to_stream(gr.sizeof_gr_complex*1, NFFT) self.mag = blocks.complex_to_mag(1) self.median = np_median(NFFT) averaging_samples = int(averaging_period * self.samp_rate / NFFT) self.moving_average = blocks.moving_average_ff(averaging_samples, 1.0/averaging_samples) z_score_samples = int(zscore_period * self.samp_rate / NFFT) self.z_score = jbm_z_score(z_score_samples) debug_print_samples = int(debug_print_period * self.samp_rate/NFFT) self.print_decim = jbm_print_decim(debug_print_samples) if logfile_path == None: logfile_path = ("carlog_%d.txt" % time.time()) logfile = file(logfile_path, "a") self.threshold_ts = jbm_threshold_timestamp(time.time(), self.samp_rate/NFFT, trigger_threshold, trigger_holdoff, logfile) ################################################## # Connections ################################################## self.connect((self.audio_source_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect(self.rational_resampler_xxx_0, self.pack_for_fft) self.connect(self.pack_for_fft, self.fft, self.unpack_fft, self.mag) self.connect(self.mag, self.median) self.connect(self.median, self.moving_average, self.z_score) self.connect((self.z_score,0), self.threshold_ts) if debug_print_period != 0: for i in range(3): self.connect((self.z_score, i), (self.print_decim, i)) else: for i in range(3): dummy_null_sink = blocks.null_sink(gr.sizeof_float) self.connect((self.z_score, i), dummy_null_sink)
def __init__(self, parent, baseband_freq=0, ref_scale=2.0, y_per_div=10, y_divs=8, ref_level=50, sample_rate=1, fft_size=512, fft_rate=default_fft_rate, average=False, avg_alpha=None, title='', size=default_fftsink_size, peak_hold=False, use_persistence=False, persist_alpha=0.2, **kwargs): gr.hier_block2.__init__(self, "fft_sink_f", gr.io_signature(1, 1, gr.sizeof_float), gr.io_signature(0, 0, 0)) fft_sink_base.__init__(self, input_is_real=True, baseband_freq=baseband_freq, y_per_div=y_per_div, y_divs=y_divs, ref_level=ref_level, sample_rate=sample_rate, fft_size=fft_size, fft_rate=fft_rate, average=average, avg_alpha=avg_alpha, title=title, peak_hold=peak_hold, use_persistence=use_persistence, persist_alpha=persist_alpha) self.s2p = blocks.stream_to_vector(gr.sizeof_float, self.fft_size) self.one_in_n = blocks.keep_one_in_n( gr.sizeof_float * self.fft_size, max(1, int(self.sample_rate / self.fft_size / self.fft_rate))) mywindow = window.blackmanharris(self.fft_size) self.fft = fft.fft_vfc(self.fft_size, True, mywindow) power = 0 for tap in mywindow: power += tap * tap self.c2mag = blocks.complex_to_mag(self.fft_size) self.avg = grfilter.single_pole_iir_filter_ff(1.0, self.fft_size) # FIXME We need to add 3dB to all bins but the DC bin self.log = blocks.nlog10_ff( 20, self.fft_size, -20 * math.log10(self.fft_size) # Adjust for number of bins - 10 * math.log10(power / self.fft_size) # Adjust for windowing loss - 20 * math.log10(ref_scale / 2)) # Adjust for reference scale self.sink = blocks.message_sink(gr.sizeof_float * self.fft_size, self.msgq, True) self.connect(self, self.s2p, self.one_in_n, self.fft, self.c2mag, self.avg, self.log, self.sink) self.win = fft_window(self, parent, size=size) self.set_average(self.average) self.set_peak_hold(self.peak_hold) self.set_use_persistence(self.use_persistence) self.set_persist_alpha(self.persist_alpha)
def __init__(self): gr.top_block.__init__(self) self.sample_rate = 3000 self.ampl = 1 self.freq = 1900 self.cen_freq = 0 self.counter = 0 # --- Sources ---- self.src0 = analog.sig_source_f(self.sample_rate, analog.GR_COS_WAVE, self.freq, 1, 0) self.src1 = analog.sig_source_f(self.sample_rate, analog.GR_COS_WAVE, self.freq/2, 1, 0) # --- Audio Out --- self.audioOut = audio.sink(32000, "", True) # --- Blocks ----- self.add = blocks.add_vff(1) #Add Block #self.throttle = blocks.throttle(gr.sizeof_float*1, self.sample_rate,True) self.streamToVector = blocks.stream_to_vector_decimator( item_size=gr.sizeof_float, sample_rate=self.sample_rate, vec_rate=30, vec_len=1024, ) self.fft = fft.fft_vfc(1024, True, (window.blackmanharris(1024)), 1) self.complexToMag = blocks.complex_to_mag_squared(1024) self.probe = blocks.probe_signal_vf(1024) # --- Functions ---- def fft_cal(): while 1: val = self.probe.level() print "Index: {}".format(val.index(max(val))) freq = (val.index(max(val))) * (self.sample_rate/1024.0) print freq print len(val) time.sleep(1) #self.set_freq(self.freq+100) pow_ran = [] freq_ran = [] if self.counter: for i in val: pow_ran.append(float(i)/max(val)) for i in range(1024): freq_ran.append(i*self.sample_rate/1024.0) fig = plt.plot(freq_ran,pow_ran) plt.ylim(-0.3,1.2) plt.xlim(min(freq_ran),max(freq_ran)) plt.show() self.counter+=1 # --- Start Thread --- fft_thread = threading.Thread(target=fft_cal) fft_thread.daemon = True fft_thread.start() # --- Conections --- #self.connect((self.src0, 0), (self.add, 0)) #self.connect((self.src1, 0), (self.add, 1)) #self.connect((self.add, 0), (self.audioOut, 0)) #self.connect((self.src0, 0), (self.throttle, 0)) #self.connect((self.throttle, 0), (self.streamToVector, 0)) self.connect((self.src0, 0), (self.streamToVector, 0)) self.connect((self.streamToVector, 0), (self.fft, 0)) self.connect((self.fft, 0),(self.complexToMag, 0)) self.connect((self.complexToMag, 0),(self.probe, 0))
def __init__(self): gr.top_block.__init__(self, "VOR Decoder") Qt.QWidget.__init__(self) self.setWindowTitle("VOR Decoder") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "vor_playback_sigmf_3") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 250e3 self.throttle_rate = throttle_rate = 1 self.nfft = nfft = 512 self.fine = fine = 1e3 self.delay = delay = 440 self.avg = avg = 100.0 self.audio_rate = audio_rate = samp_rate / 5 / 25 * 24 self.audio_gain = audio_gain = 1 ################################################## # Blocks ################################################## self._throttle_rate_tool_bar = Qt.QToolBar(self) self._throttle_rate_tool_bar.addWidget( Qt.QLabel("throttle_rate" + ": ")) self._throttle_rate_line_edit = Qt.QLineEdit(str(self.throttle_rate)) self._throttle_rate_tool_bar.addWidget(self._throttle_rate_line_edit) self._throttle_rate_line_edit.returnPressed.connect( lambda: self.set_throttle_rate( eng_notation.str_to_num( str(self._throttle_rate_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._throttle_rate_tool_bar, 0, 6, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 8): self.top_grid_layout.setColumnStretch(c, 1) self._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.top_grid_layout.addWidget(self._samp_rate_tool_bar, 0, 4, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self._delay_tool_bar = Qt.QToolBar(self) self._delay_tool_bar.addWidget(Qt.QLabel('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( int(str(self._delay_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._delay_tool_bar, 2, 4, 1, 2) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self._avg_tool_bar = Qt.QToolBar(self) self._avg_tool_bar.addWidget(Qt.QLabel('avg' + ": ")) self._avg_line_edit = Qt.QLineEdit(str(self.avg)) self._avg_tool_bar.addWidget(self._avg_line_edit) self._avg_line_edit.returnPressed.connect(lambda: self.set_avg( eng_notation.str_to_num(str(self._avg_line_edit.text().toAscii()))) ) self.top_grid_layout.addWidget(self._avg_tool_bar, 1, 6, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 7): self.top_grid_layout.setColumnStretch(c, 1) self.sigmf_source_0 = gr_sigmf.source( '/captures/20191228/VOR_2019-12-28T19:07:15Z.sigmf-data', "cf32" + ("_le" if sys.byteorder == "little" else "_be"), True) self.rational_resampler_xxx_0_0_0 = filter.rational_resampler_ccc( interpolation=24, decimation=25 * 5, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc audio_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(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, 10) 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, 4, 0, 4, 4) for r in range(4, 8): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 512, #size audio_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.0010) self.qtgui_time_sink_x_0_0.set_y_axis(-180, 180) 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_NORM, qtgui.TRIG_SLOPE_POS, 0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['Reference', 'Variable', '', '', '', '', '', '', '', ''] 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, 5, 4, 2, 4) for r in range(5, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 8192, #size audio_rate, #samp_rate "30 Hz Signals", #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('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, 0, 0, 1, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['var', 'ref', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 3, 4, 2, 4) for r in range(3, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_1_0 = qtgui.freq_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc audio_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1_0.set_update_time(0.10) 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(False) 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 True: 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 False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_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) for r in range(0, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.low_pass_filter_1_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, audio_rate, 750, 250, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_1 = filter.fir_filter_ccf( 1, firdes.low_pass(1, audio_rate, 500, 250, firdes.WIN_HAMMING, 6.76)) self._fine_tool_bar = Qt.QToolBar(self) self._fine_tool_bar.addWidget(Qt.QLabel('Fine [Hz]' + ": ")) self._fine_line_edit = Qt.QLineEdit(str(self.fine)) self._fine_tool_bar.addWidget(self._fine_line_edit) self._fine_line_edit.returnPressed.connect(lambda: self.set_fine( eng_notation.str_to_num(str(self._fine_line_edit.text().toAscii())) )) self.top_grid_layout.addWidget(self._fine_tool_bar, 1, 4, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self.fft_vxx_0_0 = fft.fft_vfc(nfft, True, (window.blackmanharris(nfft)), 1) self.fft_vxx_0 = fft.fft_vfc(nfft, True, (window.blackmanharris(nfft)), 1) self.dc_blocker_xx_0_0 = filter.dc_blocker_ff(1024, True) self.dc_blocker_xx_0 = filter.dc_blocker_ff(256, True) self.blocks_vector_to_stream_1 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, nfft) self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, nfft) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate * throttle_rate, True) self.blocks_stream_to_vector_1 = blocks.stream_to_vector( gr.sizeof_float * 1, nfft) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_float * 1, nfft) self.blocks_skiphead_0_0 = blocks.skiphead(gr.sizeof_gr_complex * 1, 30) self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_gr_complex * 1, 30) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff( (180 / math.pi, )) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_moving_average_xx_0_0 = blocks.moving_average_ff( int(avg), 1 / avg, 4000, 1) self.blocks_keep_one_in_n_0_0 = blocks.keep_one_in_n( gr.sizeof_gr_complex * 1, nfft) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_gr_complex * 1, nfft) self.blocks_delay_2 = blocks.delay(gr.sizeof_gr_complex * 1, delay) self.blocks_complex_to_arg_0_0_0 = blocks.complex_to_arg(1) self.band_pass_filter_0_0 = filter.fir_filter_fff( 1, firdes.band_pass(1, audio_rate, 25, 35, 5, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0 = filter.fir_filter_fff( 1, firdes.band_pass(1, audio_rate, 25, 35, 5, firdes.WIN_HAMMING, 6.76)) self._audio_gain_tool_bar = Qt.QToolBar(self) self._audio_gain_tool_bar.addWidget(Qt.QLabel('vol30' + ": ")) self._audio_gain_line_edit = Qt.QLineEdit(str(self.audio_gain)) self._audio_gain_tool_bar.addWidget(self._audio_gain_line_edit) self._audio_gain_line_edit.returnPressed.connect( lambda: self.set_audio_gain( eng_notation.str_to_num( str(self._audio_gain_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._audio_gain_tool_bar, 1, 7, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(7, 8): self.top_grid_layout.setColumnStretch(c, 1) self.analog_sig_source_x_1 = analog.sig_source_c( audio_rate, analog.GR_COS_WAVE, 9960, 1, 0) self.analog_pll_carriertracking_cc_0 = analog.pll_carriertracking_cc( math.pi / 200, math.pi / 10, -math.pi / 10) self.analog_fm_demod_cf_0 = analog.fm_demod_cf( channel_rate=audio_rate, audio_decim=1, deviation=480, audio_pass=30, audio_stop=100, gain=1.0, tau=75e-6, ) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=48e3, audio_decim=1, audio_pass=35, audio_stop=100, ) self.analog_agc2_xx_0_0_0 = analog.agc2_ff(1e-3, 1e-3, .65, 1) self.analog_agc2_xx_0_0_0.set_max_gain(65536) self.analog_agc2_xx_0_0 = analog.agc2_ff(1e-1, 1e-2, .65, 1) self.analog_agc2_xx_0_0.set_max_gain(65536) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.analog_pll_carriertracking_cc_0, 0)) self.connect((self.analog_agc2_xx_0_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.analog_agc2_xx_0_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.analog_agc2_xx_0_0_0, 0), (self.blocks_stream_to_vector_1, 0)) self.connect((self.analog_agc2_xx_0_0_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.analog_fm_demod_cf_0, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.analog_pll_carriertracking_cc_0, 0), (self.rational_resampler_xxx_0_0_0, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.band_pass_filter_0, 0), (self.dc_blocker_xx_0, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.dc_blocker_xx_0_0, 0)) self.connect((self.blocks_complex_to_arg_0_0_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_delay_2, 0), (self.low_pass_filter_1, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.blocks_keep_one_in_n_0_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.blocks_moving_average_xx_0_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_arg_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_moving_average_xx_0_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.low_pass_filter_1_0, 0)) self.connect((self.blocks_skiphead_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_skiphead_0_0, 0), (self.blocks_keep_one_in_n_0_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_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_skiphead_0, 0)) self.connect((self.blocks_vector_to_stream_1, 0), (self.blocks_skiphead_0_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.analog_agc2_xx_0_0, 0)) self.connect((self.dc_blocker_xx_0_0, 0), (self.analog_agc2_xx_0_0_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.fft_vxx_0_0, 0), (self.blocks_vector_to_stream_1, 0)) self.connect((self.low_pass_filter_1, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.low_pass_filter_1_0, 0), (self.analog_fm_demod_cf_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.blocks_delay_2, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.qtgui_freq_sink_x_1_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.sigmf_source_0, 0), (self.blocks_throttle_0, 0))
def __init__(self): gr.top_block.__init__(self, "VOR Radio") Qt.QWidget.__init__(self) self.setWindowTitle("VOR Radio") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "vor_radio") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.tone_samp_rate = tone_samp_rate = 2**9 self.tone_freq = tone_freq = 30 self.tone_bandpass_width = tone_bandpass_width = 5 self.pll_tracking_range = pll_tracking_range = 100 self.pll_bandwidth = pll_bandwidth = (1.5 * math.pi) / 200 self.input_samp_rate = input_samp_rate = 2**15 self.ident_freq = ident_freq = 1020 self.fm_ref_freq = fm_ref_freq = 9960 self.fm_ref_deviation = fm_ref_deviation = 480 self.fm_lowpass_width = fm_lowpass_width = 1000 self.fm_lowpass_cutoff = fm_lowpass_cutoff = 5000 self.fm_demod_samp_rate = fm_demod_samp_rate = 2**12 self.am_demod_lowpass_width = am_demod_lowpass_width = 400 self.am_demod_lowpass_cutoff = am_demod_lowpass_cutoff = 500 ################################################## # Blocks ################################################## self.monitoring_tabs = Qt.QTabWidget() self.monitoring_tabs_widget_0 = Qt.QWidget() self.monitoring_tabs_layout_0 = Qt.QBoxLayout( Qt.QBoxLayout.TopToBottom, self.monitoring_tabs_widget_0) self.monitoring_tabs_grid_layout_0 = Qt.QGridLayout() self.monitoring_tabs_layout_0.addLayout( self.monitoring_tabs_grid_layout_0) self.monitoring_tabs.addTab(self.monitoring_tabs_widget_0, "Baseband") self.monitoring_tabs_widget_1 = Qt.QWidget() self.monitoring_tabs_layout_1 = Qt.QBoxLayout( Qt.QBoxLayout.TopToBottom, self.monitoring_tabs_widget_1) self.monitoring_tabs_grid_layout_1 = Qt.QGridLayout() self.monitoring_tabs_layout_1.addLayout( self.monitoring_tabs_grid_layout_1) self.monitoring_tabs.addTab(self.monitoring_tabs_widget_1, "Ident Signal") self.monitoring_tabs_widget_2 = Qt.QWidget() self.monitoring_tabs_layout_2 = Qt.QBoxLayout( Qt.QBoxLayout.TopToBottom, self.monitoring_tabs_widget_2) self.monitoring_tabs_grid_layout_2 = Qt.QGridLayout() self.monitoring_tabs_layout_2.addLayout( self.monitoring_tabs_grid_layout_2) self.monitoring_tabs.addTab(self.monitoring_tabs_widget_2, "Phase Compare") self.monitoring_tabs_widget_3 = Qt.QWidget() self.monitoring_tabs_layout_3 = Qt.QBoxLayout( Qt.QBoxLayout.TopToBottom, self.monitoring_tabs_widget_3) self.monitoring_tabs_grid_layout_3 = Qt.QGridLayout() self.monitoring_tabs_layout_3.addLayout( self.monitoring_tabs_grid_layout_3) self.monitoring_tabs.addTab(self.monitoring_tabs_widget_3, "Scratch") self.top_layout.addWidget(self.monitoring_tabs) self.baseband_tabs = Qt.QTabWidget() self.baseband_tabs_widget_0 = Qt.QWidget() self.baseband_tabs_layout_0 = Qt.QBoxLayout( Qt.QBoxLayout.TopToBottom, self.baseband_tabs_widget_0) self.baseband_tabs_grid_layout_0 = Qt.QGridLayout() self.baseband_tabs_layout_0.addLayout(self.baseband_tabs_grid_layout_0) self.baseband_tabs.addTab(self.baseband_tabs_widget_0, "Spectrum") self.baseband_tabs_widget_1 = Qt.QWidget() self.baseband_tabs_layout_1 = Qt.QBoxLayout( Qt.QBoxLayout.TopToBottom, self.baseband_tabs_widget_1) self.baseband_tabs_grid_layout_1 = Qt.QGridLayout() self.baseband_tabs_layout_1.addLayout(self.baseband_tabs_grid_layout_1) self.baseband_tabs.addTab(self.baseband_tabs_widget_1, "Waterfall") self.monitoring_tabs_layout_0.addWidget(self.baseband_tabs) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=1, decimation=2**10 // 40, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc input_samp_rate, #bw "VOR Baseband Waterfall", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) 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 = [6, 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(-130, -60) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.baseband_tabs_layout_1.addWidget( self._qtgui_waterfall_sink_x_0_win) self.qtgui_time_sink_x_2 = qtgui.time_sink_f( 40 * 4, #size 40, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_2.set_update_time(0.10) self.qtgui_time_sink_x_2.set_y_axis(-2.5, 2.5) 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_AUTO, qtgui.TRIG_SLOPE_POS, 0.1, 0.1, 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_control_panel(False) if not True: self.qtgui_time_sink_x_2.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(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.monitoring_tabs_layout_1.addWidget(self._qtgui_time_sink_x_2_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( tone_samp_rate, #size tone_samp_rate, #samp_rate "Compared Signals", #name 2 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-25, 25) 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 = ["Variable", "Reference", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.monitoring_tabs_layout_2.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ["Radial", "", "", "", "", "", "", "", "", ""] units = ["degrees", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, 0) self.qtgui_number_sink_0.set_max(i, 360) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc input_samp_rate, #bw "VOR Baseband Signal", #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(-150, -60) 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.baseband_tabs_layout_0.addWidget(self._qtgui_freq_sink_x_0_win) self.low_pass_filter_1 = filter.fir_filter_ccf( 1, firdes.low_pass(1, 2**10, 16, 16, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, input_samp_rate, am_demod_lowpass_cutoff, am_demod_lowpass_width, firdes.WIN_HAMMING, 6.76)) self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccf( input_samp_rate // 2**10, (firdes.low_pass(10000, input_samp_rate, 500, 500)), ident_freq, input_samp_rate) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccf( input_samp_rate // fm_demod_samp_rate, (firdes.low_pass( 1000, input_samp_rate, fm_lowpass_cutoff, fm_lowpass_width)), fm_ref_freq, input_samp_rate) self.fft_vxx_0_0 = fft.fft_vfc(tone_samp_rate, True, (window.blackmanharris(tone_samp_rate)), 1) self.fft_vxx_0 = fft.fft_vfc(tone_samp_rate, True, (window.blackmanharris(tone_samp_rate)), 1) self.dc_blocker_xx_1 = filter.dc_blocker_ff(32, True) self.dc_blocker_xx_0 = filter.dc_blocker_ff(32, True) self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, tone_samp_rate) self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, tone_samp_rate) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, input_samp_rate, True) self.blocks_threshold_ff_0 = blocks.threshold_ff(1, 1, 0) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector( gr.sizeof_float * 1, tone_samp_rate) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_float * 1, tone_samp_rate) self.blocks_skiphead_0_0 = blocks.skiphead(gr.sizeof_gr_complex * 1, tone_freq) self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_gr_complex * 1, tone_freq) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff( (180 / math.pi, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((500, )) self.blocks_keep_one_in_n_0_0 = blocks.keep_one_in_n( gr.sizeof_gr_complex * 1, tone_samp_rate) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_gr_complex * 1, tone_samp_rate) self.blocks_float_to_uchar_0 = blocks.float_to_uchar() self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, "/home/brian/gnur-projects/gr-vor/sample_data/RBT_VOR_Sample_32768kHz.raw", True) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 82) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_arg_0_0 = blocks.complex_to_arg(1) self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) self.band_pass_filter_0_0_0 = filter.fir_filter_fff( 1, firdes.band_pass(1, tone_samp_rate, tone_freq - tone_bandpass_width, tone_freq + tone_bandpass_width, tone_bandpass_width, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0_0 = filter.fir_filter_fff( input_samp_rate // tone_samp_rate, firdes.band_pass(800, input_samp_rate, tone_freq - tone_bandpass_width, tone_freq + tone_bandpass_width, tone_bandpass_width, firdes.WIN_HAMMING, 6.76)) self.analog_pll_carriertracking_cc_0_0 = analog.pll_carriertracking_cc( pll_bandwidth, utility.hz_to_rad_per_sample(pll_tracking_range, input_samp_rate), utility.hz_to_rad_per_sample(-pll_tracking_range, input_samp_rate)) self.analog_fm_demod_cf_0 = analog.fm_demod_cf( channel_rate=fm_demod_samp_rate, audio_decim=fm_demod_samp_rate // tone_samp_rate, deviation=fm_ref_deviation, audio_pass=tone_freq, audio_stop=tone_freq * 2, gain=1.0, tau=0.0, ) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=input_samp_rate, audio_decim=1, audio_pass=tone_freq, audio_stop=tone_freq * 2, ) self.analog_agc2_xx_0_0 = analog.agc2_ff(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_0.set_max_gain(65536) self.analog_agc2_xx_0 = analog.agc2_ff(1e-1, 1e-2, 1.0, 1) self.analog_agc2_xx_0.set_max_gain(65536) self.airnav_unitcircle_ff_0 = airnav.unitcircle_ff() self.airnav_qt_ident_0 = self.airnav_qt_ident_0 = airnav.qt_ident() self.top_layout.addWidget(self.airnav_qt_ident_0) self.airnav_morse_decode_0 = airnav.morse_decode(10, 40) ################################################## # Connections ################################################## self.msg_connect((self.airnav_morse_decode_0, 'out'), (self.airnav_qt_ident_0, 'in')) self.connect((self.airnav_unitcircle_ff_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.blocks_stream_to_vector_0_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.analog_agc2_xx_0_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.analog_agc2_xx_0_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.analog_fm_demod_cf_0, 0), (self.band_pass_filter_0_0_0, 0)) self.connect((self.analog_pll_carriertracking_cc_0_0, 0), (self.blocks_delay_0, 0)) self.connect((self.analog_pll_carriertracking_cc_0_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.analog_pll_carriertracking_cc_0_0, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0)) self.connect((self.analog_pll_carriertracking_cc_0_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.analog_pll_carriertracking_cc_0_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.dc_blocker_xx_0, 0)) self.connect((self.band_pass_filter_0_0_0, 0), (self.dc_blocker_xx_1, 0)) self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_complex_to_arg_0_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_delay_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_float_to_uchar_0, 0), (self.airnav_morse_decode_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.blocks_keep_one_in_n_0_0, 0), (self.blocks_complex_to_arg_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_skiphead_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_skiphead_0_0, 0), (self.blocks_keep_one_in_n_0_0, 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.blocks_sub_xx_0, 0), (self.airnav_unitcircle_ff_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_float_to_uchar_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.qtgui_time_sink_x_2, 0)) self.connect((self.blocks_throttle_0, 0), (self.analog_pll_carriertracking_cc_0_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_skiphead_0, 0)) self.connect((self.blocks_vector_to_stream_0_0, 0), (self.blocks_skiphead_0_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.analog_agc2_xx_0_0, 0)) self.connect((self.dc_blocker_xx_1, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.fft_vxx_0_0, 0), (self.blocks_vector_to_stream_0_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_fm_demod_cf_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_threshold_ff_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## # type characters into this text box self.variable_text_box_0 = variable_text_box_0 = 0 # the same characters (hopefully) show up here self.variable_static_text_0 = variable_static_text_0 = 0 self.samp_rate = samp_rate = 44100 self.fft_size = 1024 # assuming we're using 915MHz band, can change to 2.4GHz depending on antenna self.center_freq = 915000000 # no idea what this will need to be self.gain = 0 # TODO variables to pass into custom fft_decoder self.coeff_0 # y-intercept of decode function self.coeff_1 #slope of decode function ################################################## # Blocks ################################################## self._variable_text_box_0_text_box = forms.text_box( parent=self.GetWin(), value=self.variable_text_box_0, #fancy custom callback! (see below) callback=self.input_text_callback, label='data to transmit', converter=forms.float_converter(), ) self.Add(self._variable_text_box_0_text_box) self._variable_static_text_0_static_text = forms.static_text( parent=self.GetWin(), value=self.variable_static_text_0, callback=self.set_variable_static_text_0, label='received data', converter=forms.float_converter(), ) self.Add(self._variable_static_text_0_static_text) # transmitter self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="sc16", channels=range(1), ), ) # receiver self.uhd_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="sc16", channels=range(1), ), ) # fft block for decoding received shirp self.fft_0 = fft.fft_vfc(fft_size, True, fft.window.blackmanharris(fft_size)) # TODO create simple sink block to convert output from fft to a character value self.fft_decoder = fft_decoder( self.coeff_1, # slope of function relating fft to ascii self.coeff_0, # y-intercept of function relating fft to ascii set_received_text #callback to set gui text value ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(center_freq, 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(center_freq, 0) self.uhd_usrp_sink_0.set_gain(gain, 0) # load wavfile to push to transmitter, will need to make new one for each different file self.blocks_wavfile_source_0 = blocks.wavfile_source( 'chirps/1.wav', False) # inv chirp for decoding, will be the same no matter what we are transmitting self.blocks_wavfile_source_inv = blocks.wavfile_source( 'chirps/inv.wav', False) # multipier for raw inv * received chirp self.blocks_multiply_xx_0 = blocks.multiply_vff(1) ################################################## # Connections ################################################## # loaded chirp pushes to transmitter self.connect((self.blocks_wavfile_source_0, 0), (self.uhd_usrp_sink_0, 0)) # receiver pushes to multiplier self.connect((self.uhd_source_0, 0), (self.blocks_multiply_xx_0, 0)) # inverse chirp pushes to multiplier self.connect((self.blocks_wavfile_source_inv, 0), (self.blocks_multiply_xx_0, 1)) # multiplier pushes to fft self.connect((self.blocks_multiply_xx_0, 0)), (self.fft_0, 0)
def __init__(self, inptype, inpveclen, blocksize, relinvovl, throughput_channels, activity_controlled_channels, act_contr_threshold, fs, centerfrequency, freqmode, windowtype, msgoutput, fileoutput, outputpath, threaded, activity_detection_segments, act_det_threshold, minchandist, act_det_deactivation_delay, minchanflankpuffer, verbose, pow_act_deactivation_delay, pow_act_maxblocks, act_det_maxblocks, debug): #from GRC #$type.size, $blocksize, $relinvovl, $throughput_channels, $activity_controlled_channels, $act_contr_threshold, $fs, $centerfrequency, $freqmode, $windowtype, $msgoutput, $fileoutput, $outputpath, $threaded, $activity_detection_segments, $act_det_threshold, $minchandist, $act_det_deactivation_delay, $minchanflankpuffer, $verbose, $pow_act_deactivation_delay, $pow_act_maxblocks, $act_det_maxblocks self.verbose = int(verbose) self.itemsize = inptype self.debug = bool(debug) #all frequencies are stored normalized, thus we need conversion #maybe further distinction to real signals(though FFT is complex) self.get_freq = lambda f: (f + 0.5) % 1.0 #conversion to FDC self.set_freq = lambda f: f - 0.5 #from FDC to output self.get_bw = lambda bw: bw % 1.0 self.set_bw = lambda bw: bw if freqmode == FREQMODE.normalized or freqmode == 'normalized': self.freqmode = FREQMODE.normalized elif freqmode == FREQMODE.basebandfs or freqmode == 'basebandfs': self.freqmode = FREQMODE.basebandfs self.get_freq = lambda f: (f / fs + 0.5) % 1.0 self.set_freq = lambda f: (f - 0.5) * fs self.get_bw = lambda bw: (bw / fs) % 1.0 self.set_bw = lambda bw: bw * fs elif freqmode == FREQMODE.centerfreqfs or freqmode == 'centerfreqfs': self.freqmode = FREQMODE.centerfreqfs self.get_freq = lambda f: ((f - centerfrequency) / fs + 0.5) % 1.0 self.set_freq = lambda f: (f - 0.5) * fs + centerfrequency self.get_bw = lambda bw: (bw / fs) % 1.0 self.set_bw = lambda bw: bw * fs else: raise ValueError('Unknown Frequency mode. Exiting...') #get all throughput channels self.throughput_channels = [] if throughput_channels is None: pass elif isinstance(throughput_channels, (list, tuple)): self.throughput_channels = [] for k in throughput_channels: c = self.get_channel(k) if c is None: raise ValueError( 'Cannot convert {} to channel. must be list or tuple with channel frequency and bandwidth. ' .format(k)) self.throughput_channels.append(c) else: raise ValueError('Throughput channels are invalid. Exiting...') #get all activity controlled channels self.activity_controlled_channels = [] if activity_controlled_channels is None: pass elif isinstance(activity_controlled_channels, (list, tuple)): self.activity_controlled_channels = [] for k in activity_controlled_channels: c = self.get_channel(k) if c is None: raise ValueError( 'Cannot convert {} to channel. must be list or tuple with channel frequency and bandwidth. ' .format(k)) self.activity_controlled_channels.append(c) else: raise ValueError( 'Activity controlled channels are invalid. Exiting...') #get all activity detection segments self.activity_detection_segments = [] if activity_detection_segments is None: pass elif isinstance(activity_detection_segments, (list, tuple)): self.activity_detection_segments = [] for k in activity_detection_segments: c = self.get_segment(k) if c is None: raise ValueError( 'Cannot convert {} to segment. must be list or tuple with channel start and stop frequency. ' .format(k)) self.activity_detection_segments.append(c) else: raise ValueError( 'Activity detection segments are invalid. Exiting...') self.inpveclen = int(inpveclen) if int(inpveclen) > 0 else 1 self.blocksize = nextpow2(blocksize) self.relinvovl = nextpow2(relinvovl) self.ovllen = self.blocksize // self.relinvovl self.inpblocklen = self.blocksize - self.ovllen #define output stream signature depending on throughput channels and debug output. outsig = gr.io_signature(0, 0, 0) gr.hier_block2.__init__( self, "FreqDomChan", gr.io_signature_make(1, 1, self.itemsize * self.inpveclen), outsig) if len(self.throughput_channels) > 0: if self.debug: outsig = gr.io_signature_make2( len(self.throughput_channels) + 1, len(self.throughput_channels) + 1, gr.sizeof_gr_complex * self.blocksize, gr.sizeof_gr_complex) else: outsig = gr.io_signature_make(len(self.throughput_channels), len(self.throughput_channels), gr.sizeof_gr_complex) elif self.debug: outsig = gr.io_signature_make( 1, 1, gr.sizeof_gr_complex * self.blocksize) gr.hier_block2.__init__( self, "FreqDomChan", gr.io_signature_make(1, 1, self.itemsize * self.inpveclen), outsig) #register message port if used if (msgoutput): self.msgport = "msgout" self.message_port_register_hier_out(self.msgport) #debug info if (self.verbose): self.log('\n' + '#' * 32 + '\n') self.log( '# gr-FDC Frequency Domain Channelizer Runtime Information') self.log('\n' + '#' * 32 + '\n') self.log('Blocksize = {}'.format(self.blocksize)) self.log('InputVecLen = {}'.format(self.inpveclen)) self.log('Relinvovl = {}'.format(self.relinvovl)) self.log('Ovllen = {}'.format(self.ovllen)) self.log('MsgOutput = {}'.format(msgoutput)) self.log('FileOutput = {}'.format(fileoutput)) self.log('Outputpath = {}'.format(outputpath)) self.log('Threaded = {}'.format(threaded)) self.log('Debugoutput = {}'.format(self.debug)) self.log('\n' + '#' * 32 + '\n') self.log('# Throughput channels: {}'.format( str(self.throughput_channels))) self.log('# Activity control channels: {}'.format( str(self.activity_controlled_channels))) self.log('# Activity detection segments: {}'.format( str(self.activity_detection_segments))) self.log('\n' + '#' * 32 + '\n') #define blocks if self.inpveclen == 1: self.inp_block_distr = blocks.stream_to_vector( self.itemsize, self.inpblocklen) self.overlap_save = overlap_save(self.itemsize, self.blocksize, self.ovllen) self.fft = None if self.itemsize == gr.sizeof_gr_complex: self.fft = fft.fft_vcc( self.blocksize, True, (fft.window.rectangular(self.blocksize)), True, 4) elif self.itemsize == gr.sizeof_gr_complex: self.fft = fft.fft_vfc( self.blocksize, True, (fft.window.rectangular(self.blocksize)), True, 4) else: raise ValueError('Unknown input type. ') if self.itemsize == gr.sizeof_float: self.normalize_input = blocks.multiply_const_ff( 1.0 / float(self.blocksize), self.blocksize) else: self.normalize_input = blocks.multiply_const_cc( 1.0 / float(self.blocksize), self.blocksize) self.throughput_channelizers = [ [None] * 6 for i in range(len(self.throughput_channels)) ] for i, (freq, bw) in enumerate(self.throughput_channels): f, l, lout, pbw, sbw = self.get_opt_channelparams(freq, bw) dec = self.blocksize / l if self.verbose: self.log( '# Throughput Channel {}: dec={}, f={}, l={}, lout={}, bw=({}, {})' .format(i, dec, f, l, lout, pbw, sbw)) self.throughput_channelizers[i][0] = vector_cut_vxx( gr.sizeof_gr_complex, self.blocksize, f, l) self.throughput_channelizers[i][1] = phase_shifting_windowing_vcc( l, self.relinvovl, f, pbw, sbw, windowtype) self.throughput_channelizers[i][2] = fft.fft_vcc( l, False, (fft.window.rectangular(l)), True, 1) self.throughput_channelizers[i][3] = vector_cut_vxx( gr.sizeof_gr_complex, l, l - lout, lout) self.throughput_channelizers[i][4] = blocks.vector_to_stream( gr.sizeof_gr_complex, lout) self.throughput_channelizers[i][5] = blocks.multiply_const_cc( self.blocksize / dec, 1) self.N_throughput_channelizers = len(self.throughput_channelizers) #create activity controlled channelizer if valid channels are present if len(self.activity_controlled_channels): self.PowerActChans = [None] * len( self.activity_controlled_channels) for i, (cfreq, bw) in enumerate(self.activity_controlled_channels): self.PowerActChans[i] = PowerActivationChannel( self.blocksize, cfreq, bw, self.relinvovl, float(act_contr_threshold), int(pow_act_maxblocks), int(pow_act_deactivation_delay) if int(pow_act_deactivation_delay) >= 0 else 0, bool(msgoutput), bool(fileoutput), str(outputpath), self.verbose, i) #int v_blocklen, float v_cfreq, float v_bw, int v_relinvovl, float v_thresh, int v_maxblocks, #int v_deactivation_delay, bool v_msg, bool v_fileoutput, std::string v_path, int verbose, int v_ID #create Segment Detection channelizer if valid segments are present if len(self.activity_detection_segments): self.SegmentDetectionChans = [None] * len( self.activity_detection_segments) for i, (startf, stopf) in enumerate(self.activity_detection_segments): self.SegmentDetectionChans[i] = SegmentDetection( i, self.blocksize, self.relinvovl, startf, stopf, float(act_det_threshold), self.get_bw(minchandist), float(minchanflankpuffer) if 0.0 <= float(minchanflankpuffer) else 0.2, int(act_det_maxblocks), int(act_det_deactivation_delay) if int(act_det_deactivation_delay) >= 0 else 0, bool(msgoutput), bool(fileoutput), str(outputpath), bool(threaded), self.verbose) #define connections if self.inpveclen == 1: self.connect((self, 0), (self.inp_block_distr, 0)) self.connect((self.inp_block_distr, 0), (self.overlap_save, 0)) self.connect((self.overlap_save, 0), (self.fft, 0)) self.connect((self.fft, 0), (self.normalize_input, 0)) else: self.connect((self, 0), (self.normalize_input, 0)) for i in list(range(self.N_throughput_channelizers)): self.connect((self.normalize_input, 0), (self.throughput_channelizers[i][0], 0)) self.connect((self.throughput_channelizers[i][0], 0), (self.throughput_channelizers[i][1], 0)) self.connect((self.throughput_channelizers[i][1], 0), (self.throughput_channelizers[i][2], 0)) self.connect((self.throughput_channelizers[i][2], 0), (self.throughput_channelizers[i][3], 0)) self.connect((self.throughput_channelizers[i][3], 0), (self.throughput_channelizers[i][4], 0)) self.connect((self.throughput_channelizers[i][4], 0), (self.throughput_channelizers[i][5], 0)) self.connect((self.throughput_channelizers[i][5], 0), (self, i + int(self.debug))) if len(self.activity_controlled_channels): for i in range(len(self.PowerActChans)): self.connect((self.normalize_input, 0), (self.PowerActChans[i], 0)) if msgoutput: self.msg_connect(self.PowerActChans[i], pmt.intern("msgout"), self, pmt.intern(self.msgport)) if len(self.activity_detection_segments): for i in range(len(self.SegmentDetectionChans)): self.connect((self.normalize_input, 0), (self.SegmentDetectionChans[i], 0)) if msgoutput: self.msg_connect(self.SegmentDetectionChans[i], pmt.intern("msgout"), self, pmt.intern(self.msgport)) if self.debug: self.connect((self.normalize_input, 0), (self, 0))
def __init__(self): gr.top_block.__init__(self, "ACF") Qt.QWidget.__init__(self) self.setWindowTitle("ACF") 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", "Lime_Auto") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 50e3 self.fft_0 = fft_0 = 32 * 32768 / 32 ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0 = qtgui.time_sink_f( fft_0, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(1) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(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) 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.01) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.limesdr_source_0 = limesdr.source('', 0, '') self.limesdr_source_0.set_sample_rate(samp_rate) self.limesdr_source_0.set_center_freq(393.525e6, 0) self.limesdr_source_0.set_bandwidth(5e6, 0) self.limesdr_source_0.set_gain(49, 0) self.limesdr_source_0.set_antenna(3, 0) self.limesdr_source_0.calibrate(5e6, 0) self.fft_vxx_0_1 = fft.fft_vfc(fft_0, False, (), 1) self.fft_vxx_0 = fft.fft_vcc(fft_0, True, (), True, 1) self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_float * 1, fft_0) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, fft_0) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(20, 1, 0) self.blocks_delay_0_0_0 = blocks.delay(gr.sizeof_gr_complex * 1, 0) self.blocks_complex_to_mag_1 = blocks.complex_to_mag(fft_0) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(fft_0) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.blocks_complex_to_mag_1, 0), (self.fft_vxx_0_1, 0)) self.connect((self.blocks_delay_0_0_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_1, 0)) self.connect((self.fft_vxx_0_1, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.limesdr_source_0, 0), (self.blocks_delay_0_0_0, 0)) self.connect((self.limesdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Rdf Detection No Gui") ################################################## # Variables ################################################## global fft_size global samp_rate global collar_freq global freq_offset global bandwidth global gains global SNR self.fft_size = fft_size self.samp_rate = samp_rate self.collar_freq = collar_freq self.freq_offset = freq_offset self.bandwidth = bandwidth self.gains = gains self.SNR = SNR ################################################## # Blocks ################################################## self.source = RadioSource(preferred_sample_rate=self.samp_rate, gains=self.gains, frequency_offset=self.freq_offset, signal_frequency=self.collar_freq) #self.fcdproplus_fcdproplus_0 = fcdproplus.fcdproplus("",1) #self.fcdproplus_fcdproplus_0.set_lna(1) #self.fcdproplus_fcdproplus_0.set_mixer_gain(1) #self.fcdproplus_fcdproplus_0.set_if_gain(gain) #20 #self.fcdproplus_fcdproplus_0.set_freq_corr(0) #self.fcdproplus_fcdproplus_0.set_freq(collar_freq - 3000) self.fft_vxx_0 = fft.fft_vfc(self.fft_size, True, (window.rectangular(self.fft_size)), 1) self.collar_detect_Burst_Detection_0 = collar_detect( self.samp_rate, self.fft_size, self.freq_offset, self.bandwidth, self.SNR) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_float * 1, self.fft_size) self.blocks_multiply_xx_0 = blocks.multiply_vcc(self.fft_size) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(self.fft_size) self.band_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.band_pass( #1 instead of 12 to keep 93750 rate 100, self.samp_rate, self.freq_offset - (self.bandwidth / 2), self.freq_offset + (self.bandwidth / 2), 600, firdes.WIN_RECTANGULAR, 6.76)) ################################################## # Connections ################################################## self.connect((self.source, 0), (self.band_pass_filter_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_stream_to_vector_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_multiply_xx_0, 1)) self.connect((self.fft_vxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.collar_detect_Burst_Detection_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block", catch_exceptions=True) Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1953125 self.Sps = Sps = 32 self.run_stop = run_stop = True self.h = h = wform.rect(Sps) self.Rb = Rb = samp_rate / Sps self.N = N = 16 * Sps self.Mean_reset = Mean_reset = 1 self.Ensayos = Ensayos = 1000000 ################################################## # Blocks ################################################## self.Menu = Qt.QTabWidget() self.Menu_widget_0 = Qt.QWidget() self.Menu_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.Menu_widget_0) self.Menu_grid_layout_0 = Qt.QGridLayout() self.Menu_layout_0.addLayout(self.Menu_grid_layout_0) self.Menu.addTab(self.Menu_widget_0, 'banary random signal') self.top_grid_layout.addWidget(self.Menu, 1, 0, 1, 4) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) _run_stop_check_box = Qt.QCheckBox('Inicial/Parar') self._run_stop_choices = {True: True, False: False} self._run_stop_choices_inv = dict( (v, k) for k, v in self._run_stop_choices.items()) self._run_stop_callback = lambda i: Qt.QMetaObject.invokeMethod( _run_stop_check_box, "setChecked", Qt.Q_ARG("bool", self._run_stop_choices_inv[i])) self._run_stop_callback(self.run_stop) _run_stop_check_box.stateChanged.connect( lambda i: self.set_run_stop(self._run_stop_choices[bool(i)])) self.top_grid_layout.addWidget(_run_stop_check_box, 0, 0, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_vector_sink_f_0_1 = qtgui.vector_sink_f( N, -samp_rate / 2, (samp_rate - 1) / N, "Frecuencia", "Amplitud (Watt/Hz)", 'PSD', 1, # Number of inputs None # parent ) self.qtgui_vector_sink_f_0_1.set_update_time(0.10) self.qtgui_vector_sink_f_0_1.set_y_axis(0., 1 / Rb) self.qtgui_vector_sink_f_0_1.enable_autoscale(False) self.qtgui_vector_sink_f_0_1.enable_grid(False) self.qtgui_vector_sink_f_0_1.set_x_axis_units("Hz") self.qtgui_vector_sink_f_0_1.set_y_axis_units("Watt/Hz") self.qtgui_vector_sink_f_0_1.set_ref_level(0) labels = ['.', '', '', '', '', '', '', '', '', ''] widths = [4, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_vector_sink_f_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_vector_sink_f_0_1.set_line_label(i, labels[i]) self.qtgui_vector_sink_f_0_1.set_line_width(i, widths[i]) self.qtgui_vector_sink_f_0_1.set_line_color(i, colors[i]) self.qtgui_vector_sink_f_0_1.set_line_alpha(i, alphas[i]) self._qtgui_vector_sink_f_0_1_win = sip.wrapinstance( self.qtgui_vector_sink_f_0_1.pyqwidget(), Qt.QWidget) self.Menu_grid_layout_0.addWidget(self._qtgui_vector_sink_f_0_1_win, 2, 0, 1, 1) for r in range(2, 3): self.Menu_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.Menu_grid_layout_0.setColumnStretch(c, 1) self.qtgui_vector_sink_f_0 = qtgui.vector_sink_f( N, -(N / 2) / samp_rate, (N / 2) / samp_rate, "Rx(T)", "Amplitud", 'Autocorrelacin', 1, # Number of inputs None # parent ) self.qtgui_vector_sink_f_0.set_update_time(0.10) self.qtgui_vector_sink_f_0.set_y_axis(-1, 2) self.qtgui_vector_sink_f_0.enable_autoscale(False) self.qtgui_vector_sink_f_0.enable_grid(False) self.qtgui_vector_sink_f_0.set_x_axis_units("T") self.qtgui_vector_sink_f_0.set_y_axis_units("Watt/Hz") self.qtgui_vector_sink_f_0.set_ref_level(0) labels = ['.', '', '', '', '', '', '', '', '', ''] widths = [4, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_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.Menu_grid_layout_0.addWidget(self._qtgui_vector_sink_f_0_win, 1, 0, 1, 1) for r in range(1, 2): self.Menu_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.Menu_grid_layout_0.setColumnStretch(c, 1) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_fff(Sps, h) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.fft_vxx_1 = fft.fft_vfc(N, True, window.rectangular(N), True, 1) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_float * 1, N) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(N * [ 1 / samp_rate, ]) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(N) self.b_binary_bipolar_source1_f_0 = b_binary_bipolar_source1_f(Am=1., ) _Mean_reset_push_button = Qt.QPushButton( 'Push here to restart averaging procces') _Mean_reset_push_button = Qt.QPushButton( 'Push here to restart averaging procces') self._Mean_reset_choices = {'Pressed': 0, 'Released': 1} _Mean_reset_push_button.pressed.connect( lambda: self.set_Mean_reset(self._Mean_reset_choices['Pressed'])) _Mean_reset_push_button.released.connect( lambda: self.set_Mean_reset(self._Mean_reset_choices['Released'])) self.top_grid_layout.addWidget(_Mean_reset_push_button, 0, 3, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.E3TRadio_vector_average_hob_0 = E3TRadio.vector_average_hob( N, Ensayos) self.E3TRadio_v_autocorr_ff_0 = E3TRadio.v_autocorr_ff(N) ################################################## # Connections ################################################## self.connect((self.E3TRadio_v_autocorr_ff_0, 0), (self.E3TRadio_vector_average_hob_0, 0)) self.connect((self.E3TRadio_vector_average_hob_0, 0), (self.fft_vxx_1, 0)) self.connect((self.E3TRadio_vector_average_hob_0, 0), (self.qtgui_vector_sink_f_0, 0)) self.connect((self.b_binary_bipolar_source1_f_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_vector_sink_f_0_1, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.E3TRadio_v_autocorr_ff_0, 0)) self.connect((self.fft_vxx_1, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_stream_to_vector_0, 0))
def __init__(self): gr.top_block.__init__(self, "Testaudiostreamport") self.freq_wavelength = 8000 ################################################## # Variables ################################################## self.samp_rate = samp_rate = 48000 self.fundamental_wavelength_samples = fundamental_wavelength_samples = 800 self.freq_wavelength = freq_wavelength = 8000 self.myVectorLength = myVectorLength = 32 self.lowpass_cutoff_freq = 4000 self.n_keep = (self.samp_rate/2)/self.lowpass_cutoff_freq # allow the rms post suppression thread to track if changes aren't happening, which suggests a dead flowgraph. self.rmspostsup_nochange_count = 0 ################################################## # Blocks ################################################## self.probe_avg_frequency = blocks.probe_signal_f() if ("getfreq_alpha" in SETTINGS["streamer"]): myGetfreqAlpha = SETTINGS["streamer"]["getfreq_alpha"] else: myGetfreqAlpha = 0.1 self.powerquality_getfreqcpp_0 = powerquality.getfreqcpp(myGetfreqAlpha) self.fractional_interpolator_xx_0_0 = filter.fractional_interpolator_ff(0, 0.1) self.fractional_interpolator_xx_0 = filter.fractional_interpolator_ff(0, 0.1) self.blocks_wavfile_sink_0 = blocks.wavfile_sink('/dev/stdout', 2, samp_rate, 16) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_float*1, samp_rate*10,True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate*10,True) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((-1, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((-1, )) # self.blocks_getfreq_average_value = blocks.moving_average_ff(1000, 0.001, 40) self.blocks_keep_one_in_n_0_0 = blocks.keep_one_in_n(gr.sizeof_float*1, 10) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_float*1, 10) self.blocks_delay_1 = blocks.delay(gr.sizeof_float*1, int(round(freq_wavelength))) self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, int(round(freq_wavelength))) self.blocks_add_xx_1 = blocks.add_vff(1) self.blocks_add_xx_0 = blocks.add_vff(1) # Calculation of RMS power post-suppression (amplitude of harmonics), also will vary based on effectiveness of the muting. rmsPostSuppressionAlpha = SETTINGS["streamer"]["rmsPostSuppressionAlpha"] # TODO: tune this rmsPostSuppressionAverageLength = SETTINGS["streamer"]["rmsPostSuppressionAverageLength"] # TODO: tune this rmsPostSuppressionAverageScale = SETTINGS["streamer"]["rmsPostSuppressionAverageScale"] # TODO: tune this log("TODO: Tune the Post suppression Alpha value for both RMS and average RMS. Or even remove the averaging if possible.") # Channel 1: Define the blocks needed to calculate and probe the average RMS harmonic power self.blocks_rmsPostSuppression_ch1 = blocks.rms_ff(rmsPostSuppressionAlpha) self.blocks_averagePostSuppression_ch1 = blocks.moving_average_ff(rmsPostSuppressionAverageLength,rmsPostSuppressionAverageScale,4000) # TODO: tune this self.probe_rmsPostSuppression_ch1 = blocks.probe_signal_f() # Channel 2: Define the blocks needed to calculate and probe the average RMS harmonic power self.blocks_rmsPostSuppression_ch2 = blocks.rms_ff(rmsPostSuppressionAlpha) self.blocks_averagePostSuppression_ch2 = blocks.moving_average_ff(rmsPostSuppressionAverageLength,rmsPostSuppressionAverageScale,4000) # TODO: tune this self.probe_rmsPostSuppression_ch2 = blocks.probe_signal_f() # channel 1: Connect the RMS harmonic blocks self.connect((self.blocks_rmsPostSuppression_ch1,0),(self.blocks_averagePostSuppression_ch1,0)) self.connect((self.blocks_averagePostSuppression_ch1,0),(self.probe_rmsPostSuppression_ch1,0)) # Channel 2: Connect the RMS harmonic blocks self.connect((self.blocks_rmsPostSuppression_ch2,0),(self.blocks_averagePostSuppression_ch2,0)) self.connect((self.blocks_averagePostSuppression_ch2,0),(self.probe_rmsPostSuppression_ch2,0)) # Connect Channels 1 and 2 to the larger flow. self.connect((self.blocks_keep_one_in_n_0,0),(self.blocks_rmsPostSuppression_ch1,0)) self.connect((self.blocks_keep_one_in_n_0_0,0),(self.blocks_rmsPostSuppression_ch2,0)) # Left channel TCP connection # log("Connecting to " + getConfigValue("pqserver") + ":" + str(getConfigValue("left_channel_tap_port"))) # self.blocks_socket_pdu_left_inputchannel = blocks.socket_pdu( # "TCP_CLIENT", # getConfigValue("pqserver"), # str(getConfigValue("left_channel_tap_port")), # 10000, # this arg is unused because we are client # False) # this arg is unused because we are client # self.blocks_pdu_to_tagged_stream_left = blocks.pdu_to_tagged_stream( # blocks.float_t, # SETTINGS["networking_tap1"]["length_tag_name"]) self.zeromq_sub_source_left = zeromq.sub_source(gr.sizeof_float, 1, SETTINGS["streamer"]["zmq_server_uri_left_channel"], 5000, True, -1) # optimization: if left and right channels are specified as the same source then make a single connection to the source. if SETTINGS["streamer"]["zmq_server_uri_left_channel"] == SETTINGS["streamer"]["zmq_server_uri_right_channel"]: self.zeromq_sub_source_right = self.zeromq_sub_source_left log("Optimization: Only making a single connection to PQ server since left and right streamer channels have same ZMQ URI.") else: # Connection URI/address to server is different for left and right channel so make a second connection for right channel. self.zeromq_sub_source_right = zeromq.sub_source(gr.sizeof_float, 1, SETTINGS["streamer"]["zmq_server_uri_right_channel"], 5000, True, -1) # self.msg_connect((self.blocks_socket_pdu_left_inputchannel,"pdus"),(self.blocks_pdu_to_tagged_stream_left,"pdus")) # # # Right Channel TCP connection # log("Connecting to " + getConfigValue("pqserver") + ":" + str(getConfigValue("right_channel_tap_port"))) # self.blocks_socket_pdu_right_inputchannel = blocks.socket_pdu( # "TCP_CLIENT", # getConfigValue("pqserver"), # str(getConfigValue("right_channel_tap_port")), # 10000, # this arg is unused because we are client # False) # this arg is unused because we are client # self.blocks_pdu_to_tagged_stream_right = blocks.pdu_to_tagged_stream( # blocks.float_t, # SETTINGS["networking_tap1"]["length_tag_name"]) # self.msg_connect((self.blocks_socket_pdu_right_inputchannel, "pdus"), (self.blocks_pdu_to_tagged_stream_right, "pdus")) self.analog_rail_ff_1 = analog.rail_ff(-0.8, 0.8) self.analog_rail_ff_0 = analog.rail_ff(-0.8, 0.8) # myDecay of 1e-2 (0.01) sounds great when input voltage to the Pi is clean (dirty rectifier voltage can introduce periodic bumps and thumbs that mess up AGC). # myDecay of 0.1: pretty quick. Useful for exposing the thumb phenomenon that I'm currently investigating. 1e-2 (0.01) gets drown down due to thump but thump not very audible. # Sensible default myDecay = 1e-2 # Allow overriding in config file. if ("agc_decay_rate" in SETTINGS["streamer"]): myDecay = SETTINGS["streamer"]["agc_decay_rate"] self.analog_agc2_xx_1 = analog.agc2_ff(0.1, myDecay, 0.1, 1.0) self.analog_agc2_xx_1.set_max_gain(65536) self.analog_agc2_xx_0 = analog.agc2_ff(0.1, myDecay, 0.1, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.analog_rail_ff_0, 0)) self.connect((self.analog_agc2_xx_1, 0), (self.analog_rail_ff_1, 0)) self.connect((self.analog_rail_ff_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.analog_rail_ff_1, 0), (self.blocks_wavfile_sink_0, 1)) self.connect((self.zeromq_sub_source_left, 0), (self.fractional_interpolator_xx_0, 0)) self.connect((self.zeromq_sub_source_right, 0), (self.fractional_interpolator_xx_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.blocks_keep_one_in_n_0_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_delay_1, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.blocks_keep_one_in_n_0_0, 0), (self.analog_agc2_xx_1, 0)) self.connect((self.powerquality_getfreqcpp_0, 0), (self.probe_avg_frequency, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_xx_1, 1)) self.connect((self.blocks_throttle_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.powerquality_getfreqcpp_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.blocks_delay_1, 0)) self.connect((self.fractional_interpolator_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.fractional_interpolator_xx_0_0, 0), (self.blocks_throttle_0_0, 0)) # self.connect((self.powerquality_getfreqcpp_0, 0), (self.blocks_getfreq_average_value, 0)) ### Define FFT related blocks LEFT-CHANNEL ONLY FOR NOW. self.fft_vxx_0 = fft.fft_vfc(myVectorLength, True, (window.blackmanharris(myVectorLength)), 1) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_float*1, myVectorLength) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_float*1, self.n_keep) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(myVectorLength) self.blocks_throttle = blocks.throttle(gr.sizeof_float * 1, self.samp_rate, True) self.blocks_fft_vector_sink_0 = blocks.vector_sink_f(self.myVectorLength) ### Connect FFT BLOCKS. # Down-sample / decimate the input. We pick up the flowgraph after AGC but before the rail. self.connect((self.analog_agc2_xx_0, 0), (self.blocks_keep_one_in_n_0, 0)) # Convert the stream to a vector in preparation for FFT self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_stream_to_vector_0, 0)) # Perform FFT analysis of the stream. self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) # Send FFT data (phase and magnitude) into a mag^2 block to get strength of each bin self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) # Send the final result (magnitudes in each fft bin) into vector sink. # self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_fft_vector_sink_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_fft_vector_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "Vor Sim") Qt.QWidget.__init__(self) self.setWindowTitle("Vor Sim") 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", "vor_sim") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.angle = angle = 0 self.samp_rate = samp_rate = 48e3 self.angle_degree = angle_degree = angle * 1.0 ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, 'RF Spectrum') self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, 'VOR Baseband') self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, 'REF/VAR Signal') self.tab_widget_3 = Qt.QWidget() self.tab_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_3) self.tab_grid_layout_3 = Qt.QGridLayout() self.tab_layout_3.addLayout(self.tab_grid_layout_3) self.tab.addTab(self.tab_widget_3, 'Bearing Estimation') self.top_layout.addWidget(self.tab) self.vor_generator_0 = vor_generator( am_carrier=5e3, angle_degree=angle_degree, samp_rate=samp_rate, ) self.rational_resampler_xxx_2 = filter.rational_resampler_fff( interpolation=512, decimation=3000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_1 = filter.rational_resampler_fff( interpolation=512, decimation=3000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff( interpolation=3000, decimation=int(samp_rate), taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=3000, decimation=int(samp_rate), taps=None, fractional_bw=None, ) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 2048, #size 3e3, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1, 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(True) 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) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance( self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.tab_layout_2.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 2048, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2 * 1): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_0.addWidget(self._qtgui_time_sink_x_0_win, 1, 0, 1, 1) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.tab_layout_3.addWidget(self._qtgui_number_sink_0_win) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 8192, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(0.1) self.qtgui_freq_sink_x_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance( self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.tab_grid_layout_1.addWidget(self._qtgui_freq_sink_x_1_win, 0, 0, 1, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 8192, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 1, 1) self.fft_vxx_0_0 = fft.fft_vfc(512, True, (window.blackmanharris(512)), 1) self.fft_vxx_0 = fft.fft_vfc(512, True, (window.blackmanharris(512)), 1) self.fft_filter_xxx_3 = filter.fft_filter_ccc( 1, (firdes.low_pass(1, samp_rate, 2e3, 1e3, firdes.WIN_BLACKMAN)), 1) self.fft_filter_xxx_3.declare_sample_delay(0) self.fft_filter_xxx_2 = filter.fft_filter_ccc( 1, (firdes.low_pass(-1, samp_rate, 2e3, 1e3, firdes.WIN_BLACKMAN)), 1) self.fft_filter_xxx_2.declare_sample_delay(0) self.fft_filter_xxx_0_0 = filter.fft_filter_fff( 1, (firdes.low_pass(1, 3e3, 60, 10, firdes.WIN_BLACKMAN)), 1) self.fft_filter_xxx_0_0.declare_sample_delay(0) self.fft_filter_xxx_0 = filter.fft_filter_fff( 1, (firdes.low_pass(1, 3e3, 60, 10, firdes.WIN_BLACKMAN)), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.dc_blocker_xx_0_0 = filter.dc_blocker_ff(32, True) self.dc_blocker_xx_0 = filter.dc_blocker_ff(32, True) self.channels_channel_model_0 = channels.channel_model( noise_voltage=0.01, frequency_offset=0.0, epsilon=1.0, taps=(1.0 + 1.0j, ), noise_seed=0, block_tags=False) self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, 512) self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, 512) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector( gr.sizeof_float * 1, 512) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_float * 1, 512) self.blocks_skiphead_0_0 = blocks.skiphead(gr.sizeof_gr_complex * 1, 30) self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_gr_complex * 1, 30) self.blocks_rotator_cc_1 = blocks.rotator_cc(-(9960.0 / samp_rate) * 2 * math.pi) self.blocks_rotator_cc_0 = blocks.rotator_cc( (-5e3 / samp_rate) * 2 * math.pi) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float * 1, 1000) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (180.0 / math.pi, )) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( 10000, 1e-4, 4000) self.blocks_keep_one_in_n_0_0 = blocks.keep_one_in_n( gr.sizeof_gr_complex * 1, 512) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_gr_complex * 1, 512) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_arg_0_0 = blocks.complex_to_arg(1) self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((0.0, )) self._angle_range = Range(-180, 180, 1, 0, 200) self._angle_win = RangeWidget(self._angle_range, self.set_angle, "angle", "counter_slider", float) self.top_layout.addWidget(self._angle_win) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf( samp_rate / (2 * math.pi * 500 / 8.0)) self.analog_agc_xx_0_0 = analog.agc_ff(1e-3, 1.0, 1.0) self.analog_agc_xx_0_0.set_max_gain(65536) self.analog_agc_xx_0 = analog.agc_ff(1e-3, 1.0, 1.0) self.analog_agc_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.analog_agc_xx_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.analog_agc_xx_0_0, 0), (self.qtgui_time_sink_x_1, 1)) self.connect((self.analog_agc_xx_0_0, 0), (self.rational_resampler_xxx_2, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_complex_to_arg_0_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_complex_to_real_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_delay_0, 0), (self.fft_filter_xxx_2, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.blocks_keep_one_in_n_0_0, 0), (self.blocks_complex_to_arg_0_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_rotator_cc_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_rotator_cc_0, 0), (self.blocks_rotator_cc_1, 0)) self.connect((self.blocks_rotator_cc_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.blocks_rotator_cc_1, 0), (self.fft_filter_xxx_3, 0)) self.connect((self.blocks_skiphead_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_skiphead_0_0, 0), (self.blocks_keep_one_in_n_0_0, 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.blocks_sub_xx_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_skiphead_0, 0)) self.connect((self.blocks_vector_to_stream_0_0, 0), (self.blocks_skiphead_0_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_rotator_cc_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.dc_blocker_xx_0_0, 0), (self.fft_filter_xxx_0_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.fft_filter_xxx_0_0, 0), (self.analog_agc_xx_0_0, 0)) self.connect((self.fft_filter_xxx_2, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.fft_filter_xxx_3, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.fft_vxx_0_0, 0), (self.blocks_vector_to_stream_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.dc_blocker_xx_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.dc_blocker_xx_0_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.rational_resampler_xxx_2, 0), (self.blocks_stream_to_vector_0_0, 0)) self.connect((self.vor_generator_0, 0), (self.blocks_throttle_0, 0))