def __init__(self, win, sat_name, mode_name): gr.hier_block2.__init__(self, "Channel "+str(sat_name)+" "+str(mode_name)+" SSB", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_gr_complex)) self.trans = trans = 500 self.sample_rate = sample_rate = 2048000 self.low_ssb = low_ssb = 200 self.high_ssb = high_ssb = 2800 self.decim = decim = 8 self.agc_decay = agc_decay = 50e-6 ################################################## # Blocks ################################################## self.fftsink_audio = fftsink2.fft_sink_f( win, baseband_freq=0, y_per_div=5, y_divs=10, ref_level=-20, ref_scale=2.0, sample_rate=32000, fft_size=1024, fft_rate=15, average=True, avg_alpha=None, title="FFT Plot (Audio - "+sat_name+" "+str(mode_name)+")", peak_hold=True, ) self.multiply_const_64 = blocks.multiply_const_vff((0.1, )) self.complex_to_real = blocks.complex_to_real(1) self.rational_resampler = filter.rational_resampler_ccc( interpolation=32, decimation=64, taps=None, fractional_bw=None, ) self.band_pass_filter = filter.fir_filter_ccc(4, filter.firdes.complex_band_pass( 1, sample_rate/decim, low_ssb, high_ssb, trans, filter.firdes.WIN_HAMMING, 6.76)) self.agc = analog.agc2_cc(0.1, agc_decay, 0.9, 1.0) ################################################## # Connections ################################################## #self.connect(self, (self.gr_throttle_0, 0)) self.connect(self, (self.band_pass_filter, 0)) self.connect((self.band_pass_filter, 0), (self.agc, 0)) self.connect((self.agc, 0), (self.rational_resampler, 0)) self.connect((self.rational_resampler, 0), (self.complex_to_real, 0)) self.connect((self.complex_to_real, 0), (self.multiply_const_64, 0)) self.connect((self.multiply_const_64, 0), (self.fftsink_audio, 0)) self.connect((self.multiply_const_64, 0), self)
def __init__(self, fft_len=64, payload_bps=2): gr.hier_block2.__init__( self, "OFDM TX RX Hier paths", gr.io_signaturev(2, 2, [gr.sizeof_char*1, gr.sizeof_gr_complex*1]), gr.io_signaturev(2, 2, [gr.sizeof_char*1, gr.sizeof_gr_complex*1]), ) ################################################## # Parameters ################################################## self.fft_len = fft_len self.payload_bps = payload_bps ################################################## # Variables ################################################## self.len_tag_key = len_tag_key = "packet_len" ################################################## # Blocks ################################################## self.tag_gate_tx = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.ofdm_tx = ofdm_tools.ofdm_txrx_modules.ofdm_tx( fft_len=fft_len, cp_len=fft_len/4, packet_length_tag_key=len_tag_key, bps_header=1, bps_payload=payload_bps, rolloff=0, debug_log=False, scramble_bits=False ) self.ofdm_rx = ofdm_tools.ofdm_txrx_modules.ofdm_rx( fft_len=fft_len, cp_len=fft_len/4, frame_length_tag_key='frame_'+"rx_len", packet_length_tag_key="rx_len", bps_header=1, bps_payload=payload_bps, debug_log=False, scramble_bits=False ) self.multiply_const_tx = blocks.multiply_const_vcc((.01, )) self.agc_rx = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.agc_rx.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self, 0), (self.ofdm_tx, 0)) self.connect((self, 1), (self.agc_rx, 0)) self.connect((self.agc_rx, 0), (self.ofdm_rx, 0)) self.connect((self.ofdm_rx, 0), (self, 0)) self.connect((self.multiply_const_tx, 0), (self, 1)) self.connect((self.ofdm_tx, 0), (self.tag_gate_tx, 0)) self.connect((self.tag_gate_tx, 0), (self.multiply_const_tx, 0))
def __init__(self, bw_clock_sync=2*math.pi/100, bw_fll=math.pi/1600, bw_costas=2*math.pi/100, n_filts=32, len_sym_srrc=7, constellation=digital.constellation_calcdist([-1-1j, 1-1j, 1+1j, -1+1j], [], 4, 1).base(), samp_per_sym=3, alfa=0.35, bits_per_sym=2, alpha_probe=0.1, th_probe=0): gr.hier_block2.__init__( self, "Hier Rx", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_char*1), ) ################################################## # Parameters ################################################## self.bw_clock_sync = bw_clock_sync self.bw_fll = bw_fll self.bw_costas = bw_costas self.n_filts = n_filts self.len_sym_srrc = len_sym_srrc self.constellation = constellation self.samp_per_sym = samp_per_sym self.alfa = alfa self.bits_per_sym = bits_per_sym self.alpha_probe = alpha_probe self.th_probe = th_probe ################################################## # Variables ################################################## self.filtro_srrc = filtro_srrc = firdes.root_raised_cosine(n_filts,samp_per_sym*n_filts,1.0,alfa,samp_per_sym*len_sym_srrc*n_filts) ################################################## # Blocks ################################################## self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(samp_per_sym, bw_clock_sync, (filtro_srrc), n_filts, 16, 5, 1) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(samp_per_sym, alfa, len_sym_srrc*samp_per_sym, bw_fll) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2**bits_per_sym) self.digital_costas_loop_cc_0_0_0 = digital.costas_loop_cc(bw_costas, 2**bits_per_sym) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(constellation) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(bits_per_sym) self.analog_probe_avg_mag_sqrd_x_0 = analog.probe_avg_mag_sqrd_c(th_probe, alpha_probe) 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.digital_diff_decoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0_0_0, 0)) self.connect((self, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.digital_costas_loop_cc_0_0_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self, 0)) self.connect((self, 0), (self.analog_probe_avg_mag_sqrd_x_0, 0))
def __init__(self, principal_gui, options): gr.hier_block2.__init__(self, "bpsk_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature #Enter the parameters of modulation self._samples_per_symbol = options.samples_per_symbol self.verbose = options.verbose self._gray_code =_def_gray_code if self._samples_per_symbol < 2: raise TypeError, "samples_per_symbol must be >= 2, is %r" % (self._samples_per_symbol,) arity = pow(2,self.bits_per_symbol()) # Automatic gain control #self.agc = gr.agc2_cc(0.6e-1, 1e-3, 1, 1, 100) self.agc = analog.agc2_cc(1e-5, 1.0,1.0,1.0) #self.agc = gr.feedforward_agc_cc(16, 2.0) # RRC data filter ntaps = 11 * self._samples_per_symbol self.rrc_taps = filter.firdes.root_raised_cosine( 1.0, # gain self._samples_per_symbol, # sampling rate 1.0, # symbol rate 0.35, # excess bandwidth (roll-off factor) ntaps) self.rrc_filter=filter.interp_fir_filter_ccf(1, self.rrc_taps) self._costas = digital.costas_loop_cc(6.28/100.0, 2) self.gr_null_sink = blocks.null_sink(gr.sizeof_float*1) self.connect((self._costas, 1), (self.gr_null_sink, 0)) self._mm = digital.clock_recovery_mm_cc(self._samples_per_symbol, # Initial samples/symbol 1e-06, # Second order gain 0.5, # Initial symbol phase 0.001, # First order gain 0.0001) # Maximum timing offset if self.verbose: self._print_verbage() # Do differential decoding based on phase change of symbols #self.diffdec = gr.diff_phasor_cc() # Connect and Initialize base class self.connect(self, self.agc, self.rrc_filter, (self._costas,0), self._mm, self)
def test_003_sets(self): agc = analog.agc2_cc(1e-3, 1e-1, 1, 1) agc.set_attack_rate(1) agc.set_decay_rate(2) agc.set_reference(1.1) agc.set_gain(1.1) agc.set_max_gain(100) self.assertAlmostEqual(agc.attack_rate(), 1) self.assertAlmostEqual(agc.decay_rate(), 2) self.assertAlmostEqual(agc.reference(), 1.1) self.assertAlmostEqual(agc.gain(), 1.1) self.assertAlmostEqual(agc.max_gain(), 100)
def __init__(self, mode, audio_rate=0, **kwargs): if mode == 'LSB': lsb = True elif mode == 'USB': lsb = False else: raise ValueError('Not an SSB mode: %r' % (mode,)) demod_rate = audio_rate SimpleAudioDemodulator.__init__(self, mode=mode, audio_rate=audio_rate, demod_rate=demod_rate, band_filter=audio_rate / 2, # unused band_filter_transition=audio_rate / 2, # unused **kwargs) input_rate = self.input_rate half_bandwidth = self.half_bandwidth = 2800 / 2 if lsb: band_mid = -200 - half_bandwidth else: band_mid = 200 + half_bandwidth self.band_filter_low = band_mid - half_bandwidth self.band_filter_high = band_mid + half_bandwidth self.band_filter_width = half_bandwidth / 5 self.sharp_filter_block = grfilter.fir_filter_ccc( 1, firdes.complex_band_pass(1.0, demod_rate, self.band_filter_low, self.band_filter_high, self.band_filter_width, firdes.WIN_HAMMING)) self.agc_block = analog.agc2_cc(reference=0.25) self.ssb_demod_block = blocks.complex_to_real(1) self.connect( self, self.band_filter_block, self.sharp_filter_block, self.rf_squelch_block, self.agc_block, self.ssb_demod_block) self.connect(self.sharp_filter_block, self.rf_probe_block) self.connect_audio_output(self.ssb_demod_block, self.ssb_demod_block)
def __init__(self, input_samp_rate, output_samp_rate): gr.hier_block2.__init__( self, "Am Block", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_float*1), ) # Parameters self.input_samp_rate = input_samp_rate self.output_samp_rate = output_samp_rate self.internal_samp_rate = 50000 # Blocks self.xlating_fir_filter = filter.freq_xlating_fir_filter_ccf( int(input_samp_rate/self.internal_samp_rate), (filter.firdes.low_pass_2(1, input_samp_rate, 25e3, 10e3, 40)), 0, input_samp_rate) self.agc = analog.agc2_cc(1e-1, 1e-2, 1, 1) self.agc.set_max_gain(100) self.am_demodulator = analog.am_demod_cf( channel_rate=self.internal_samp_rate, audio_decim=1, audio_pass=5000, audio_stop=5500, ) self.rational_resampler = filter.rational_resampler_fff( interpolation=output_samp_rate, decimation=self.internal_samp_rate, taps=None, fractional_bw=None, ) # Connections self.connect( self, self.xlating_fir_filter, self.agc, self.am_demodulator, self.rational_resampler, self )
def __init__(self, mode, input_rate, context): channels = 2 audio_rate = 10000 gr.hier_block2.__init__( self, str('%s demodulator' % (mode,)), gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_float * channels)) self.__input_rate = input_rate self.__rec_freq_input = 0.0 self.__signal_type = SignalType(kind='STEREO', sample_rate=audio_rate) # Using agc2 rather than feedforward AGC for efficiency, because this runs at the RF rate rather than the audio rate. agc_block = analog.agc2_cc(reference=dB(-8)) agc_block.set_attack_rate(8e-3) agc_block.set_decay_rate(8e-3) agc_block.set_max_gain(dB(40)) self.connect( self, agc_block) channel_joiner = blocks.streams_to_vector(gr.sizeof_float, channels) self.connect(channel_joiner, self) for channel in xrange(0, channels): self.connect( agc_block, grfilter.fir_filter_ccc(1, design_sawtooth_filter(decreasing=channel == 0)), blocks.complex_to_mag(1), blocks.float_to_complex(), # So we can use the complex-input band filter. TODO eliminate this for efficiency MultistageChannelFilter( input_rate=input_rate, output_rate=audio_rate, cutoff_freq=5000, transition_width=5000), blocks.complex_to_real(), # assuming below 40Hz is not of interest grfilter.dc_blocker_ff(audio_rate // 40, False), (channel_joiner, channel))
def __init__(self, mode, input_rate, context): channels = 2 audio_rate = 10000 gr.hier_block2.__init__( self, str('%s demodulator' % (mode, )), gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_float * channels)) self.__input_rate = input_rate self.__rec_freq_input = 0.0 self.__signal_type = SignalType(kind='STEREO', sample_rate=audio_rate) # Using agc2 rather than feedforward AGC for efficiency, because this runs at the RF rate rather than the audio rate. agc_block = analog.agc2_cc(reference=dB(-8)) agc_block.set_attack_rate(8e-3) agc_block.set_decay_rate(8e-3) agc_block.set_max_gain(dB(40)) self.connect(self, agc_block) channel_joiner = blocks.streams_to_vector(gr.sizeof_float, channels) self.connect(channel_joiner, self) for channel in xrange(0, channels): self.connect( agc_block, grfilter.fir_filter_ccc( 1, design_sawtooth_filter(decreasing=channel == 0)), blocks.complex_to_mag(1), blocks.float_to_complex( ), # So we can use the complex-input band filter. TODO eliminate this for efficiency MultistageChannelFilter(input_rate=input_rate, output_rate=audio_rate, cutoff_freq=5000, transition_width=5000), blocks.complex_to_real(), # assuming below 40Hz is not of interest grfilter.dc_blocker_ff(audio_rate // 40, False), (channel_joiner, channel))
def __init__(self, constellation, differential=_def_differential, samples_per_symbol=_def_samples_per_symbol, pre_diff_code=True, excess_bw=_def_excess_bw, freq_bw=_def_freq_bw, timing_bw=_def_timing_bw, phase_bw=_def_phase_bw, verbose=_def_verbose, log=_def_log): gr.hier_block2.__init__( self, "generic_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_char)) # Output signature self._constellation = constellation self._samples_per_symbol = samples_per_symbol self._excess_bw = excess_bw self._phase_bw = phase_bw self._freq_bw = freq_bw self._timing_bw = timing_bw self._timing_max_dev = _def_timing_max_dev self._differential = differential if self._samples_per_symbol < 2: raise TypeError, ("sbp must be >= 2, is %d" % self._samples_per_symbol) # Only apply a predifferential coding if the constellation also supports it. self.pre_diff_code = pre_diff_code and self._constellation.apply_pre_diff_code( ) arity = pow(2, self.bits_per_symbol()) nfilts = 32 ntaps = 11 * int(self._samples_per_symbol * nfilts) # Automatic gain control self.agc = analog.agc2_cc(0.6e-1, 1e-3, 1, 1) # Frequency correction fll_ntaps = 55 self.freq_recov = digital.fll_band_edge_cc(self._samples_per_symbol, self._excess_bw, fll_ntaps, self._freq_bw) # symbol timing recovery with RRC data filter taps = filter.firdes.root_raised_cosine( nfilts, nfilts * self._samples_per_symbol, 1.0, self._excess_bw, ntaps) self.time_recov = digital.pfb_clock_sync_ccf(self._samples_per_symbol, self._timing_bw, taps, nfilts, nfilts // 2, self._timing_max_dev) fmin = -0.25 fmax = 0.25 self.receiver = digital.constellation_receiver_cb( self._constellation.base(), self._phase_bw, fmin, fmax) # Do differential decoding based on phase change of symbols if differential: self.diffdec = digital.diff_decoder_bb(arity) if self.pre_diff_code: self.symbol_mapper = digital.map_bb( mod_codes.invert_code(self._constellation.pre_diff_code())) # unpack the k bit vector into a stream of bits self.unpack = blocks.unpack_k_bits_bb(self.bits_per_symbol()) if verbose: self._print_verbage() if log: self._setup_logging() # Connect and Initialize base class self._blocks = [ self, self.agc, self.freq_recov, self.time_recov, self.receiver ] if differential: self._blocks.append(self.diffdec) if self.pre_diff_code: self._blocks.append(self.symbol_mapper) self._blocks += [self.unpack, self] self.connect(*self._blocks)
def __init__(self): gr.top_block.__init__(self, "Wwv X310 Corr 1") Qt.QWidget.__init__(self) self.setWindowTitle("Wwv X310 Corr 1") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "wwv_x310_corr_1") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.ts_str = ts_str = dt.strftime(dt.utcnow(), "%Y-%m-%dT%H:%M:%S.%fZ") self.y_min = y_min = -60 self.y_max = y_max = 0 self.variable_qtgui_label_0 = variable_qtgui_label_0 = ts_str self.samp_rate = samp_rate = 500e3 self.rx_freq = rx_freq = 4.51e6 self.nfft = nfft = 1024*32 self.lpf_cutoff = lpf_cutoff = 50e3 self.delay = delay = 0 self.decim = decim = 1 self.decay_rate = decay_rate = 20e-3 self.c_ms = c_ms = 299792458 ################################################## # Blocks ################################################## self.main_tab = Qt.QTabWidget() self.main_tab_widget_0 = Qt.QWidget() self.main_tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.main_tab_widget_0) self.main_tab_grid_layout_0 = Qt.QGridLayout() self.main_tab_layout_0.addLayout(self.main_tab_grid_layout_0) self.main_tab.addTab(self.main_tab_widget_0, 'Main') self.main_tab_widget_1 = Qt.QWidget() self.main_tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.main_tab_widget_1) self.main_tab_grid_layout_1 = Qt.QGridLayout() self.main_tab_layout_1.addLayout(self.main_tab_grid_layout_1) self.main_tab.addTab(self.main_tab_widget_1, 'Corr') self.top_grid_layout.addWidget(self.main_tab, 1, 0, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._y_min_tool_bar = Qt.QToolBar(self) self._y_min_tool_bar.addWidget(Qt.QLabel('FREQ'+": ")) self._y_min_line_edit = Qt.QLineEdit(str(self.y_min)) self._y_min_tool_bar.addWidget(self._y_min_line_edit) self._y_min_line_edit.returnPressed.connect( lambda: self.set_y_min(eng_notation.str_to_num(str(self._y_min_line_edit.text().toAscii())))) self.main_tab_grid_layout_0.addWidget(self._y_min_tool_bar, 8, 4, 1, 1) for r in range(8, 9): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(4, 5): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self._y_max_tool_bar = Qt.QToolBar(self) self._y_max_tool_bar.addWidget(Qt.QLabel('FREQ'+": ")) self._y_max_line_edit = Qt.QLineEdit(str(self.y_max)) self._y_max_tool_bar.addWidget(self._y_max_line_edit) self._y_max_line_edit.returnPressed.connect( lambda: self.set_y_max(eng_notation.str_to_num(str(self._y_max_line_edit.text().toAscii())))) self.main_tab_grid_layout_0.addWidget(self._y_max_tool_bar, 8, 5, 1, 1) for r in range(8, 9): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(5, 6): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel('SAMP_RATE'+": ")) self._samp_rate_line_edit = Qt.QLineEdit(str(self.samp_rate)) self._samp_rate_tool_bar.addWidget(self._samp_rate_line_edit) self._samp_rate_line_edit.returnPressed.connect( lambda: self.set_samp_rate(eng_notation.str_to_num(str(self._samp_rate_line_edit.text().toAscii())))) self.main_tab_grid_layout_0.addWidget(self._samp_rate_tool_bar, 8, 0, 1, 1) for r in range(8, 9): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self._rx_freq_tool_bar = Qt.QToolBar(self) self._rx_freq_tool_bar.addWidget(Qt.QLabel('FREQ'+": ")) self._rx_freq_line_edit = Qt.QLineEdit(str(self.rx_freq)) self._rx_freq_tool_bar.addWidget(self._rx_freq_line_edit) self._rx_freq_line_edit.returnPressed.connect( lambda: self.set_rx_freq(eng_notation.str_to_num(str(self._rx_freq_line_edit.text().toAscii())))) self.main_tab_grid_layout_0.addWidget(self._rx_freq_tool_bar, 8, 1, 1, 1) for r in range(8, 9): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(1, 2): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self._lpf_cutoff_tool_bar = Qt.QToolBar(self) self._lpf_cutoff_tool_bar.addWidget(Qt.QLabel("lpf_cutoff"+": ")) self._lpf_cutoff_line_edit = Qt.QLineEdit(str(self.lpf_cutoff)) self._lpf_cutoff_tool_bar.addWidget(self._lpf_cutoff_line_edit) self._lpf_cutoff_line_edit.returnPressed.connect( lambda: self.set_lpf_cutoff(eng_notation.str_to_num(str(self._lpf_cutoff_line_edit.text().toAscii())))) self.main_tab_grid_layout_0.addWidget(self._lpf_cutoff_tool_bar, 8, 3, 1, 1) for r in range(8, 9): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(3, 4): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self._delay_tool_bar = Qt.QToolBar(self) self._delay_tool_bar.addWidget(Qt.QLabel('corr_delay'+": ")) self._delay_line_edit = Qt.QLineEdit(str(self.delay)) self._delay_tool_bar.addWidget(self._delay_line_edit) self._delay_line_edit.returnPressed.connect( lambda: self.set_delay(eng_notation.str_to_num(str(self._delay_line_edit.text().toAscii())))) self.main_tab_grid_layout_1.addWidget(self._delay_tool_bar, 8, 0, 1, 1) for r in range(8, 9): self.main_tab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.main_tab_grid_layout_1.setColumnStretch(c, 1) self._decay_rate_options = (100e-6, 65e-3, 20e-3, ) self._decay_rate_labels = ('Fast', 'Medium', 'Slow', ) self._decay_rate_group_box = Qt.QGroupBox("decay_rate") self._decay_rate_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._decay_rate_button_group = variable_chooser_button_group() self._decay_rate_group_box.setLayout(self._decay_rate_box) for i, label in enumerate(self._decay_rate_labels): radio_button = Qt.QRadioButton(label) self._decay_rate_box.addWidget(radio_button) self._decay_rate_button_group.addButton(radio_button, i) self._decay_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(self._decay_rate_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._decay_rate_options.index(i))) self._decay_rate_callback(self.decay_rate) self._decay_rate_button_group.buttonClicked[int].connect( lambda i: self.set_decay_rate(self._decay_rate_options[i])) self.main_tab_grid_layout_0.addWidget(self._decay_rate_group_box, 8, 2, 1, 1) for r in range(8, 9): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(2, 3): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_formatter = None else: self._variable_qtgui_label_0_formatter = lambda x: str(x) self._variable_qtgui_label_0_tool_bar.addWidget(Qt.QLabel('Start Time [UTC]'+": ")) self._variable_qtgui_label_0_label = Qt.QLabel(str(self._variable_qtgui_label_0_formatter(self.variable_qtgui_label_0))) self._variable_qtgui_label_0_tool_bar.addWidget(self._variable_qtgui_label_0_label) self.main_tab_grid_layout_0.addWidget(self._variable_qtgui_label_0_tool_bar, 8, 6, 1, 2) for r in range(8, 9): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(6, 8): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self.uhd_usrp_source_1 = uhd.usrp_source( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_1.set_clock_source('gpsdo', 0) self.uhd_usrp_source_1.set_time_source('gpsdo', 0) self.uhd_usrp_source_1.set_subdev_spec('A:AB B:AB', 0) self.uhd_usrp_source_1.set_samp_rate(samp_rate) self.uhd_usrp_source_1.set_time_unknown_pps(uhd.time_spec()) self.uhd_usrp_source_1.set_center_freq(uhd.tune_request(rx_freq), 0) self.uhd_usrp_source_1.set_gain(0, 0) self.uhd_usrp_source_1.set_antenna('A', 0) self.uhd_usrp_source_1.set_auto_dc_offset(True, 0) self.uhd_usrp_source_1.set_auto_iq_balance(True, 0) self.uhd_usrp_source_1.set_center_freq(uhd.tune_request(rx_freq), 1) self.uhd_usrp_source_1.set_gain(0, 1) self.uhd_usrp_source_1.set_antenna('A', 1) self.uhd_usrp_source_1.set_auto_dc_offset(True, 1) self.uhd_usrp_source_1.set_auto_iq_balance(True, 1) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0_0 = qtgui.waterfall_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc samp_rate / decim, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0_0.enable_grid(False) self.qtgui_waterfall_sink_x_0_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0_0.set_intensity_range(-140, -40) self._qtgui_waterfall_sink_x_0_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_0_win, 4, 4, 4, 4) for r in range(4, 8): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(4, 8): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc samp_rate / decim, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, -40) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_win, 4, 0, 4, 4) for r in range(4, 8): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 4): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 10, #size samp_rate/decim, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.010) self.qtgui_time_sink_x_0_0.set_y_axis(-20, 20) self.qtgui_time_sink_x_0_0.set_y_label('Range Delta [km]', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_0_win, 4, 0, 2, 4) for r in range(4, 6): self.main_tab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 4): self.main_tab_grid_layout_1.setColumnStretch(c, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( nfft, #size samp_rate/decim, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Correlation', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_win, 0, 4, 4, 4) for r in range(0, 4): self.main_tab_grid_layout_1.setRowStretch(r, 1) for c in range(4, 8): self.main_tab_grid_layout_1.setColumnStretch(c, 1) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 3 ) self.qtgui_number_sink_0.set_update_time(0.010) self.qtgui_number_sink_0.set_title("") labels = ['Delay', '', 'Range Delta', '', '', '', '', '', '', ''] units = ['[usec]', '', '[km]', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(3): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(True) self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_1.addWidget(self._qtgui_number_sink_0_win, 6, 0, 1, 2) for r in range(6, 7): self.main_tab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 2): self.main_tab_grid_layout_1.setColumnStretch(c, 1) self.qtgui_histogram_sink_x_0_0 = qtgui.histogram_sink_f( 20, 1000, 0, 100e4, "", 1 ) self.qtgui_histogram_sink_x_0_0.set_update_time(0.010) self.qtgui_histogram_sink_x_0_0.enable_autoscale(True) self.qtgui_histogram_sink_x_0_0.enable_accumulate(True) self.qtgui_histogram_sink_x_0_0.enable_grid(False) self.qtgui_histogram_sink_x_0_0.enable_axis_labels(True) if not True: self.qtgui_histogram_sink_x_0_0.disable_legend() labels = ['Correlation Magnitude', 'Corr Mag', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_histogram_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_histogram_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_histogram_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_histogram_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_histogram_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_histogram_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_histogram_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_histogram_sink_x_0_0_win = sip.wrapinstance(self.qtgui_histogram_sink_x_0_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_1.addWidget(self._qtgui_histogram_sink_x_0_0_win, 0, 0, 4, 4) for r in range(0, 4): self.main_tab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 4): self.main_tab_grid_layout_1.setColumnStretch(c, 1) self.qtgui_histogram_sink_x_0 = qtgui.histogram_sink_f( 20, 2000, -25*1/(samp_rate/decim) *c_ms / 1000.0, 25*1/(samp_rate/decim) *c_ms / 1000.0, "", 1 ) self.qtgui_histogram_sink_x_0.set_update_time(0.010) self.qtgui_histogram_sink_x_0.enable_autoscale(True) self.qtgui_histogram_sink_x_0.enable_accumulate(True) self.qtgui_histogram_sink_x_0.enable_grid(False) self.qtgui_histogram_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_histogram_sink_x_0.disable_legend() labels = ['Range Delta [km]', 'Corr Mag', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_histogram_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_histogram_sink_x_0.set_line_label(i, labels[i]) self.qtgui_histogram_sink_x_0.set_line_width(i, widths[i]) self.qtgui_histogram_sink_x_0.set_line_color(i, colors[i]) self.qtgui_histogram_sink_x_0.set_line_style(i, styles[i]) self.qtgui_histogram_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_histogram_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_histogram_sink_x_0_win = sip.wrapinstance(self.qtgui_histogram_sink_x_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_1.addWidget(self._qtgui_histogram_sink_x_0_win, 4, 4, 2, 4) for r in range(4, 6): self.main_tab_grid_layout_1.setRowStretch(r, 1) for c in range(4, 8): self.main_tab_grid_layout_1.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc samp_rate /decim, #bw "E/W Dipole", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.010) self.qtgui_freq_sink_x_0_0.set_y_axis(y_min, y_max) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(True) self.qtgui_freq_sink_x_0_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_0_win, 0, 4, 4, 4) for r in range(0, 4): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(4, 8): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc samp_rate / decim, #bw "N/S Dipole", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.010) self.qtgui_freq_sink_x_0.set_y_axis(y_min, y_max) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 4, 4) for r in range(0, 4): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 4): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self.low_pass_filter_1 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate/decim, lpf_cutoff, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate/decim, lpf_cutoff, 1e3, firdes.WIN_HAMMING, 6.76)) self.fft_vxx_2 = fft.fft_vcc(nfft, True, (window.blackmanharris(nfft)), True, 4) self.fft_vxx_1 = fft.fft_vcc(nfft, False, (window.blackmanharris(nfft)), False, 4) self.fft_vxx_0 = fft.fft_vcc(nfft, False, (window.blackmanharris(nfft)), False, 4) self.blocks_vector_to_stream_1 = blocks.vector_to_stream(gr.sizeof_float*1, nfft) self.blocks_stream_to_vector_1 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, nfft) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, nfft) self.blocks_short_to_float_0 = blocks.short_to_float(1, 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_short*1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((1/(samp_rate/decim) *c_ms / 1000.0, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((1/(samp_rate/decim) * 1e6, )) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(nfft) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(10, .1, 4000, 1) self.blocks_max_xx_0 = blocks.max_ff(nfft,1) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, int(delay)) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(nfft) self.blocks_argmax_xx_0 = blocks.argmax_fs(nfft) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-nfft/2.0, )) self.analog_agc2_xx_0_0 = analog.agc2_cc(decay_rate, decay_rate, 1.0, .5) self.analog_agc2_xx_0_0.set_max_gain(65536) self.analog_agc2_xx_0 = analog.agc2_cc(decay_rate, decay_rate, 1.0, .5) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.analog_agc2_xx_0_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_argmax_xx_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_argmax_xx_0, 0), (self.blocks_short_to_float_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_argmax_xx_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_max_xx_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_vector_to_stream_1, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_stream_to_vector_1, 0)) self.connect((self.blocks_max_xx_0, 0), (self.qtgui_histogram_sink_x_0_0, 0)) self.connect((self.blocks_max_xx_0, 0), (self.qtgui_number_sink_0, 1)) self.connect((self.blocks_max_xx_0, 0), (self.qtgui_time_sink_x_0_0, 1)) self.connect((self.blocks_moving_average_xx_0, 0), (self.qtgui_histogram_sink_x_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.qtgui_number_sink_0, 2)) self.connect((self.blocks_moving_average_xx_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.fft_vxx_2, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_stream_to_vector_1, 0), (self.fft_vxx_1, 0)) self.connect((self.blocks_vector_to_stream_1, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.fft_vxx_1, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.fft_vxx_2, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.low_pass_filter_1, 0), (self.blocks_delay_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.qtgui_freq_sink_x_0_0, 1)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_waterfall_sink_x_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.uhd_usrp_source_1, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.uhd_usrp_source_1, 1), (self.analog_agc2_xx_0_0, 0))
def __init__(self, mode='VOR', zero_point=59, **kwargs): self.channel_rate = channel_rate = 40000 internal_audio_rate = 20000 # TODO over spec'd self.zero_point = zero_point transition = 5000 SimpleAudioDemodulator.__init__(self, mode=mode, audio_rate=internal_audio_rate, demod_rate=channel_rate, band_filter=fm_subcarrier * 1.25 + fm_deviation + transition / 2, band_filter_transition=transition, **kwargs) self.dir_rate = dir_rate = 10 if internal_audio_rate % dir_rate != 0: raise ValueError( 'Audio rate %s is not a multiple of direction-finding rate %s' % (internal_audio_rate, dir_rate)) self.dir_scale = dir_scale = internal_audio_rate // dir_rate self.audio_scale = audio_scale = channel_rate // internal_audio_rate self.zeroer = blocks.add_const_vff((zero_point * (math.pi / 180), )) self.dir_vector_filter = grfilter.fir_filter_ccf( 1, firdes.low_pass(1, dir_rate, 1, 2, firdes.WIN_HAMMING, 6.76)) self.am_channel_filter_block = grfilter.fir_filter_ccf( 1, firdes.low_pass(1, channel_rate, 5000, 5000, firdes.WIN_HAMMING, 6.76)) self.goertzel_fm = fft.goertzel_fc(channel_rate, dir_scale * audio_scale, 30) self.goertzel_am = fft.goertzel_fc(internal_audio_rate, dir_scale, 30) self.fm_channel_filter_block = grfilter.freq_xlating_fir_filter_ccc( 1, (firdes.low_pass(1.0, channel_rate, fm_subcarrier / 2, fm_subcarrier / 2, firdes.WIN_HAMMING)), fm_subcarrier, channel_rate) self.multiply_conjugate_block = blocks.multiply_conjugate_cc(1) self.complex_to_arg_block = blocks.complex_to_arg(1) self.am_agc_block = analog.feedforward_agc_cc(1024, 1.0) self.am_demod_block = analog.am_demod_cf( channel_rate=channel_rate, audio_decim=audio_scale, audio_pass=5000, audio_stop=5500, ) self.fm_demod_block = analog.quadrature_demod_cf(1) self.phase_agc_fm = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.phase_agc_am = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.probe = blocks.probe_signal_f() self.audio_filter_block = grfilter.fir_filter_fff( 1, design_lofi_audio_filter(internal_audio_rate, False)) ################################################## # Connections ################################################## # Input self.connect(self, self.band_filter_block) # AM chain self.connect(self.band_filter_block, self.am_channel_filter_block, self.am_agc_block, self.am_demod_block) # AM audio self.connect( self.am_demod_block, blocks.multiply_const_ff(1.0 / audio_modulation_index * 0.5), self.audio_filter_block) self.connect_audio_output(self.audio_filter_block) # AM phase self.connect(self.am_demod_block, self.goertzel_am, self.phase_agc_am, (self.multiply_conjugate_block, 0)) # FM phase self.connect(self.band_filter_block, self.fm_channel_filter_block, self.fm_demod_block, self.goertzel_fm, self.phase_agc_fm, (self.multiply_conjugate_block, 1)) # Phase comparison and output self.connect( self.multiply_conjugate_block, self.dir_vector_filter, self.complex_to_arg_block, blocks.multiply_const_ff(-1), # opposite angle conventions self.zeroer, self.probe)
def __init__(self, fm_subcarrier=9960, zero_point=-5): grc_wxgui.top_block_gui.__init__(self, title="VOR Receiver") ################################################## # Parameters ################################################## self.fm_subcarrier = fm_subcarrier self.zero_point = zero_point ################################################## # Variables ################################################## self.rf_rate = rf_rate = 1000000 self.dir_rate = dir_rate = 10 self.channel_rate = channel_rate = 40000 self.audio_rate = audio_rate = 10000 self.vor_freq = vor_freq = 113.9e6 self.volume = volume = 0 self.rf_scale = rf_scale = int(rf_rate/channel_rate) + rf_rate % channel_rate self.offset = offset = fm_subcarrier + 4000 self.dir_scale = dir_scale = int(audio_rate/dir_rate) + audio_rate % dir_rate self.channel = channel = 113.9e6 self.audio_scale = audio_scale = int(channel_rate/audio_rate) + channel_rate % audio_rate ################################################## # Blocks ################################################## _volume_sizer = wx.BoxSizer(wx.VERTICAL) self._volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, label='volume', converter=forms.float_converter(), proportion=0, ) self._volume_slider = forms.slider( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, minimum=-10, maximum=10, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_volume_sizer) self._channel_text_box = forms.text_box( parent=self.GetWin(), value=self.channel, callback=self.set_channel, label="Channel (Hz)", converter=forms.float_converter(), ) self.Add(self._channel_text_box) self.zeroer = blocks.add_const_vff((zero_point*(math.pi/180), )) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit="deg", minval=-180, maxval=180, factor=180/math.acos(-1), decimal_places=2, ref_level=0, sample_rate=dir_rate, number_rate=dir_rate, average=True, avg_alpha=.25, label="Direction", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=channel, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=channel_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.25, title="Channel", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self._vor_freq_text_box = forms.text_box( parent=self.GetWin(), value=self.vor_freq, callback=self.set_vor_freq, label='vor_freq', converter=forms.float_converter(), ) self.Add(self._vor_freq_text_box) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=40, decimation=1, taps=None, fractional_bw=None, ) self.low_pass_filter_1 = filter.fir_filter_ccf(1, firdes.low_pass( 1, dir_rate, 1, 2, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, channel_rate, 10000, 4000, firdes.WIN_HAMMING, 6.76)) self.goertzel_fc_0_0 = fft.goertzel_fc(channel_rate, dir_scale*audio_scale, 30) self.goertzel_fc_0 = fft.goertzel_fc(audio_rate, dir_scale, 30) self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(1, (firdes.low_pass(1.0, channel_rate, 500, 100, firdes.WIN_HAMMING)), fm_subcarrier, channel_rate) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(rf_scale, (firdes.low_pass(1.0, rf_rate, channel_rate, channel_rate/2, firdes.WIN_HAMMING)), 900, rf_rate) self.dc_blocker_xx_0 = filter.dc_blocker_ff(128, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, 1e6) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((10**(volume/10), )) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/home/john/apps/aviation_rx/woodside_vor25.dat", True) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, int(channel_rate/30*0.0)) self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) self.audio_sink_0 = audio.sink(audio_rate, "", True) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=40e3, audio_decim=4, audio_pass=5000, audio_stop=5500, ) self.analog_agc2_xx_1 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_1.set_max_gain(65536) self.analog_agc2_xx_0_1_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_1_0.set_max_gain(100) self.analog_agc2_xx_0_1 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_1.set_max_gain(100) ################################################## # Connections ################################################## self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_delay_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.goertzel_fc_0_0, 0)) self.connect((self.goertzel_fc_0, 0), (self.analog_agc2_xx_0_1, 0)) self.connect((self.goertzel_fc_0_0, 0), (self.analog_agc2_xx_0_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_delay_0, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0)) self.connect((self.blocks_complex_to_arg_0, 0), (self.zeroer, 0)) self.connect((self.zeroer, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.analog_agc2_xx_0_1, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.analog_agc2_xx_0_1_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.blocks_multiply_conjugate_cc_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.analog_am_demod_cf_0, 0), (self.goertzel_fc_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.dc_blocker_xx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.analog_agc2_xx_1, 0)) self.connect((self.analog_agc2_xx_1, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
def __init__(self, mode='433', input_rate=0, context=None): assert input_rate > 0 assert context is not None gr.hier_block2.__init__( self, type(self).__name__, gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(0, 0, 0)) # The input bandwidth chosen is not primarily determined by the bandwidth of the input signals, but by the frequency error of the transmitters. Therefore it is not too critical, and we can choose the exact rate to make the filtering easy. if input_rate <= upper_preferred_demod_rate: # Skip having a filter at all. self.__band_filter = None demod_rate = input_rate else: # TODO: This gunk is very similar to the stuff that MultistageChannelFilter does. See if we can share some code. lower_rate = input_rate lower_rate_prev = None while lower_rate > upper_preferred_demod_rate and lower_rate != lower_rate_prev: lower_rate_prev = lower_rate if lower_rate % 5 == 0 and lower_rate > upper_preferred_demod_rate * 3: lower_rate /= 5 elif lower_rate % 2 == 0: lower_rate /= 2 else: # non-integer ratio lower_rate = upper_preferred_demod_rate break demod_rate = lower_rate self.__band_filter = MultistageChannelFilter( input_rate=input_rate, output_rate=demod_rate, cutoff_freq=demod_rate * 0.4, transition_width=demod_rate * 0.2) # Subprocess # using /usr/bin/env because twisted spawnProcess doesn't support path search # pylint: disable=no-member process = the_reactor.spawnProcess( RTL433ProcessProtocol(context.output_message), '/usr/bin/env', env=None, # inherit environment args=[ 'env', 'rtl_433', '-F', 'json', '-r', '-', # read from stdin '-m', '3', # complex float input '-s', str(demod_rate), ], childFDs={ 0: 'w', 1: 'r', 2: 2 }) sink = make_sink_to_process_stdin(process, itemsize=gr.sizeof_gr_complex) agc = analog.agc2_cc(reference=dB(-4)) agc.set_attack_rate(200 / demod_rate) agc.set_decay_rate(200 / demod_rate) if self.__band_filter: self.connect( self, self.__band_filter, agc) else: self.connect( self, agc) self.connect(agc, sink)
def __init__(self, n_filts=32, bits_per_sym=2, alpha_probe=0.1, th_probe=0, constellation=digital.constellation_calcdist([-1-1j, 1-1j, 1+1j, -1+1j], [], 4, 1).base(), samp_per_sym=5, bw_costas=2*math.pi/100, bw_clock_sync=2*math.pi/100, bw_fll=2*math.pi/100, len_sym_srrc=11, alfa=0.45): grc_wxgui.top_block_gui.__init__(self, title="Test Hier Rx Usrp") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Parameters ################################################## self.n_filts = n_filts self.bits_per_sym = bits_per_sym self.alpha_probe = alpha_probe self.th_probe = th_probe self.constellation = constellation self.samp_per_sym = samp_per_sym self.bw_costas = bw_costas self.bw_clock_sync = bw_clock_sync self.bw_fll = bw_fll self.len_sym_srrc = len_sym_srrc self.alfa = alfa ################################################## # Variables ################################################## self.filtro_srrc = filtro_srrc = firdes.root_raised_cosine(n_filts,samp_per_sym*n_filts,1.0,alfa,samp_per_sym*len_sym_srrc*n_filts) ################################################## # Blocks ################################################## self.wxgui_scopesink2_0 = scopesink2.scope_sink_c( self.GetWin(), title="Scope Plot", sample_rate=250000/samp_per_sym, v_scale=0.3, v_offset=0, t_scale=0.3, ac_couple=False, xy_mode=True, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(50000*samp_per_sym) self.uhd_usrp_source_0.set_center_freq(850000000, 0) self.uhd_usrp_source_0.set_gain(18, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(samp_per_sym, bw_clock_sync, (filtro_srrc), n_filts, 16, 5, 1) self.digital_mpsk_snr_est_cc_0 = digital.mpsk_snr_est_cc(2, 1000, 0.1) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(samp_per_sym, alfa, len_sym_srrc*samp_per_sym, bw_fll) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2**bits_per_sym) self.digital_costas_loop_cc_0_0_0 = digital.costas_loop_cc(bw_costas, 2**bits_per_sym) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(constellation) self.blocks_vector_sink_x_0 = blocks.vector_sink_b(1) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(bits_per_sym) self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_gr_complex*1, "/home/belza/pruebasUSRP/file_rx_sym", False) self.blocks_file_sink_0_0.set_unbuffered(True) self.analog_agc2_xx_0 = analog.agc2_cc(0.6e-1, 1e-3, 2, 15) self.analog_agc2_xx_0.set_max_gain(15) ################################################## # Connections ################################################## self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_vector_sink_x_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0_0_0, 0)) self.connect((self.digital_costas_loop_cc_0_0_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.digital_costas_loop_cc_0_0_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.digital_costas_loop_cc_0_0_0, 0), (self.digital_mpsk_snr_est_cc_0, 0)) self.connect((self.digital_mpsk_snr_est_cc_0, 0), (self.digital_constellation_decoder_cb_0, 0))
def __init__(self): gr.hier_block2.__init__( self, "Hier Tx Ch Rx", gr.io_signature(1, 1, gr.sizeof_char*1), gr.io_signature(1, 1, gr.sizeof_char*1), ) ################################################## # Variables ################################################## self.samp_per_sym = samp_per_sym = 3 self.n_filts = n_filts = 32 self.len_sym_srrc = len_sym_srrc = 7 self.alfa = alfa = 0.35 self.pulso = pulso = firdes.root_raised_cosine(samp_per_sym,samp_per_sym,1.0,alfa,samp_per_sym*len_sym_srrc) self.gain = gain = 15 self.frec = frec = 850e3 self.filtro_srrc = filtro_srrc = firdes.root_raised_cosine(n_filts,samp_per_sym*n_filts,1.0,alfa,samp_per_sym*len_sym_srrc*n_filts) self.bits_per_sym = bits_per_sym = 2 ################################################## # Blocks ################################################## self.pfb_interpolator_ccf_0 = pfb.interpolator_ccf( samp_per_sym, (pulso), 100) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(samp_per_sym, 2*math.pi/100, (filtro_srrc), n_filts, 16, 5, 1) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(samp_per_sym, alfa, len_sym_srrc*samp_per_sym, math.pi/1600) self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2**bits_per_sym) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2**bits_per_sym) self.digital_costas_loop_cc_0_0_0 = digital.costas_loop_cc(2*math.pi/100, 2**bits_per_sym) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( digital.constellation_calcdist([-1-1j, 1-1j, 1+1j, -1+1j], [], 4, 1).base()) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(([-1-1j,1-1j, 1+1j, -1+1j]), 1) self.channels_channel_model_0 = channels.channel_model( noise_voltage=0.0, frequency_offset=0.0, epsilon=1.00, taps=(1+0.5j, ), noise_seed=0, block_tags=False ) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(bits_per_sym) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(bits_per_sym, gr.GR_MSB_FIRST) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((0.4, )) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder( samples_per_symbol=samp_per_sym, bits_per_symbol=bits_per_sym, preamble="", access_code="", pad_for_usrp=True, ), payload_length=1, ) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(grc_blks2.packet_decoder( access_code="", threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload), ), ) self.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.pfb_interpolator_ccf_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.digital_diff_encoder_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.pfb_interpolator_ccf_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_diff_encoder_bb_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.blks2_packet_decoder_0, 0), (self, 0)) self.connect((self, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0_0_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0_0_0, 0))
def test_005(self): ''' Test the complex AGC loop (attack and decay rate inputs) ''' tb = self.tb expected_result = \ ((100.000244140625 + 7.2191943445432116e-07j), (0.80881959199905396 + 0.58764183521270752j), (0.30894950032234192 + 0.95084899663925171j), (-0.30895623564720154 + 0.95086973905563354j), (-0.80887287855148315 + 0.58768033981323242j), (-0.99984413385391235 + 5.850709250410091e-09j), (-0.80889981985092163 - 0.58770018815994263j), (-0.30897706747055054 - 0.95093393325805664j), (0.30898112058639526 - 0.95094609260559082j), (0.80893135070800781 - 0.58772283792495728j), (0.99990922212600708 - 8.7766354184282136e-09j), (0.80894720554351807 + 0.58773452043533325j), (0.30899339914321899 + 0.95098406076431274j), (-0.30899572372436523 + 0.95099133253097534j), (-0.80896598100662231 + 0.58774799108505249j), (-0.99994778633117676 + 1.4628290578855285e-08j), (-0.80897533893585205 - 0.58775502443313599j), (-0.30900305509567261 - 0.95101380348205566j), (0.30900448560714722 - 0.95101797580718994j), (0.80898630619049072 - 0.58776277303695679j), (0.99997037649154663 - 1.7554345532744264e-08j), (0.80899184942245483 + 0.58776694536209106j), (0.30900871753692627 + 0.95103120803833008j), (-0.30900952219963074 + 0.95103377103805542j), (-0.8089984655380249 + 0.58777159452438354j), (-0.99998390674591064 + 2.3406109050938539e-08j), (-0.809001624584198 - 0.58777409791946411j), (-0.30901208519935608 - 0.95104163885116577j), (0.30901262164115906 - 0.95104306936264038j), (0.80900543928146362 - 0.587776780128479j), (0.99999171495437622 - 2.6332081404234486e-08j), (0.80900734663009644 + 0.58777821063995361j), (0.30901408195495605 + 0.95104765892028809j), (-0.30901429057121277 + 0.95104855298995972j), (-0.80900967121124268 + 0.58777981996536255j), (-0.99999648332595825 + 3.2183805842578295e-08j), (-0.80901080369949341 - 0.58778077363967896j), (-0.30901527404785156 - 0.95105135440826416j), (0.30901545286178589 - 0.95105189085006714j), (0.80901217460632324 - 0.58778166770935059j), (0.99999916553497314 - 3.5109700036173308e-08j), (0.809012770652771 + 0.58778214454650879j), (0.30901595950126648 + 0.9510534405708313j), (-0.30901598930358887 + 0.95105385780334473j), (-0.80901366472244263 + 0.58778274059295654j), (-1.0000008344650269 + 4.0961388947380328e-08j), (-0.8090139627456665 - 0.58778303861618042j), (-0.30901634693145752 - 0.95105475187301636j), (0.30901640653610229 - 0.95105493068695068j), (0.80901449918746948 - 0.5877833366394043j)) sampling_freq = 100 src1 = analog.sig_source_c(sampling_freq, analog.GR_SIN_WAVE, sampling_freq * 0.10, 100) dst1 = blocks.vector_sink_c() head = blocks.head(gr.sizeof_gr_complex, int(5 * sampling_freq * 0.10)) agc = analog.agc2_cc(1e-2, 1e-3, 1, 1) tb.connect(src1, head) tb.connect(head, agc) tb.connect(agc, dst1) tb.run() dst_data = dst1.data() self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 4)
def __init__(self): gr.top_block.__init__(self, "Spectrum And Gain Analyzer") Qt.QWidget.__init__(self) self.setWindowTitle("Spectrum And Gain Analyzer") 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", "spectrum_and_gain_analyzer") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(1000000) self.uhd_usrp_source_0.set_center_freq(1500000000, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1 ) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ["", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 1000000, #bw "QT GUI Plot", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_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) if complex == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(50000.0) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.analog_agc2_xx_0, 1), (self.qtgui_number_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Mpsk Stage3") Qt.QWidget.__init__(self) self.setWindowTitle("Mpsk Stage3") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "mpsk_stage3") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 8 self.payload = payload = range(256) self.nfilts = nfilts = 32 self.timing_loop_bw = timing_loop_bw = 6.28/100.0 self.taps = taps = [1.0 + 0.0j, ] self.samp_rate = samp_rate = 250e3 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 45*nfilts) self.qpsk_const = qpsk_const = digital.constellation_rect(([-1, +1]), ([0, 1]), 1, 2, 1, 1, 1).base() self.payload_str = payload_str = ''.join(map(lambda x: "{0:08b}".format(x), payload)) self.gain = gain = 50 self.freq = freq = 2.3e9 self.excess_bw = excess_bw = 0.35 self.delay = delay = 32 self.decim = decim = 1 self.arity = arity = 2 self.access_code_str = access_code_str = "1111100110101" self.access_code = access_code = [31, 53] ################################################## # Blocks ################################################## self._delay_layout = Qt.QVBoxLayout() self._delay_tool_bar = Qt.QToolBar(self) self._delay_layout.addWidget(self._delay_tool_bar) self._delay_tool_bar.addWidget(Qt.QLabel("delay"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._delay_counter = qwt_counter_pyslot() self._delay_counter.setRange(0, 100, 1) self._delay_counter.setNumButtons(2) self._delay_counter.setValue(self.delay) self._delay_tool_bar.addWidget(self._delay_counter) self._delay_counter.valueChanged.connect(self.set_delay) self._delay_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._delay_slider.setRange(0, 100, 1) self._delay_slider.setValue(self.delay) self._delay_slider.setMinimumWidth(200) self._delay_slider.valueChanged.connect(self.set_delay) self._delay_layout.addWidget(self._delay_slider) self.top_layout.addLayout(self._delay_layout) self.west_stream_trigged_pdu_0 = west.stream_trigged_pdu("start_payload", 2048) self.west_ber_pdu_0 = west.ber_pdu(payload_str) self._timing_loop_bw_layout = Qt.QVBoxLayout() self._timing_loop_bw_label = Qt.QLabel("Time: BW") self._timing_loop_bw_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._timing_loop_bw_slider.setRange(0.0, 0.2, 0.005) self._timing_loop_bw_slider.setValue(self.timing_loop_bw) self._timing_loop_bw_slider.setMinimumWidth(200) self._timing_loop_bw_slider.valueChanged.connect(self.set_timing_loop_bw) self._timing_loop_bw_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_label) self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_slider) self.top_grid_layout.addLayout(self._timing_loop_bw_layout, 3,1,1,1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_const_sink_x_1_0 = qtgui.const_sink_c( 1024, #size "Equalizer", #name 1 #number of inputs ) self.qtgui_const_sink_x_1_0.set_update_time(0.10) self.qtgui_const_sink_x_1_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_1_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1_0.enable_autoscale(False) self.qtgui_const_sink_x_1_0.enable_grid(False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_1_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_0_win = sip.wrapinstance(self.qtgui_const_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_1_0_win) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( 1024, #size "Clock Sync Output", #name 1 #number of inputs ) self.qtgui_const_sink_x_1.set_update_time(0.10) self.qtgui_const_sink_x_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1.enable_autoscale(False) self.qtgui_const_sink_x_1.enable_grid(False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_win = sip.wrapinstance(self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_1_win) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 2048, #size "Costas Loop Output", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win, 0,1,1,1) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( 1, taps=(rrc_taps[:-1]), flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self._gain_layout = Qt.QVBoxLayout() self._gain_tool_bar = Qt.QToolBar(self) self._gain_layout.addWidget(self._gain_tool_bar) self._gain_tool_bar.addWidget(Qt.QLabel("RF gain"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._gain_counter = qwt_counter_pyslot() self._gain_counter.setRange(0, 90, 1) self._gain_counter.setNumButtons(2) self._gain_counter.setValue(self.gain) self._gain_tool_bar.addWidget(self._gain_counter) self._gain_counter.valueChanged.connect(self.set_gain) self._gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._gain_slider.setRange(0, 90, 1) self._gain_slider.setValue(self.gain) self._gain_slider.setMinimumWidth(200) self._gain_slider.valueChanged.connect(self.set_gain) self._gain_layout.addWidget(self._gain_slider) self.top_layout.addLayout(self._gain_layout) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(.015, 2) self.digital_correlate_access_code_bb_0 = digital.correlate_access_code_bb(access_code_str, 1) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk_const, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False, ) (self.digital_constellation_modulator_0).set_processor_affinity([2]) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(qpsk_const) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(16, 1, 0.15/100., 1) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc(sps*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.005) self.blocks_vector_source_x_0_0 = blocks.vector_source_b([135, 201]*5000 + access_code + payload*100000, False, 1, []) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8) 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_multiply_const_vxx_0 = blocks.multiply_const_vcc((.0001, )) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_char*1, 1) self.blocks_delay_0 = blocks.delay(gr.sizeof_char*1, int(delay)) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(analog.GR_GAUSSIAN, 0.3, 0, 8192) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-1, 1.0, 1) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_cma_equalizer_cc_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.qtgui_const_sink_x_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.digital_correlate_access_code_bb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_correlate_access_code_bb_0, 0), (self.west_stream_trigged_pdu_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.digital_correlate_access_code_bb_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.digital_diff_decoder_bb_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.west_stream_trigged_pdu_0, "pdus", self.west_ber_pdu_0, "pdus")
def __init__(self, samp_rate=10000): gr.hier_block2.__init__( self, "Sync Radio Hier Grc", gr.io_signaturev(2, 2, [gr.sizeof_char*1, gr.sizeof_gr_complex*1]), gr.io_signaturev(2, 2, [gr.sizeof_char*1, gr.sizeof_gr_complex*1]), ) ################################################## # Parameters ################################################## self.samp_rate = samp_rate ################################################## # Variables ################################################## self.sync_word2 = sync_word2 = [0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,(1+0j),(-1+0j),(-1+0j),(-1+0j),(1+0j),(-1+0j),(1+0j),(-1+0j),(-1+0j),(-1+0j),(-1+0j),(-1+0j),(-1+0j),(-1+0j),(-1+0j),(1+0j),0j,(1+0j),(-1+0j),(1+0j),(1+0j),(1+0j),(-1+0j),(1+0j),(1+0j),(1+0j),(-1+0j),(1+0j),(1+0j),(1+0j),(1+0j),(-1+0j),0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j] self.sync_word1 = sync_word1 = [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.42,0.0,-1.42,0.0,1.42,0.0,1.42,0.0,1.42,0.0,1.42,0.0,-1.42,0.0,1.42,0.0,1.42,0.0,-1.42,0.0,1.42,0.0,1.42,0.0,1.42,0.0,-1.42,0.0,1.42,0.0,1.42,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0] self.pilot_symbols = pilot_symbols = ((1, -1,),) self.pilot_carriers = pilot_carriers = ((-13, 12,),) self.payload_mod = payload_mod = digital.constellation_qpsk() self.packet_length_tag_key = packet_length_tag_key = "packet_len" self.occupied_carriers = occupied_carriers = ([-16, -15, -14, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15],) self.length_tag_key = length_tag_key = "frame_len" self.header_mod = header_mod = digital.constellation_bpsk() self.fft_len = fft_len = (len(sync_word1)+len(sync_word2))/2 self.rolloff = rolloff = 0 self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe(fft_len, payload_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 1) self.len_ocup_carr = len_ocup_carr = len(occupied_carriers[0]) self.header_formatter = header_formatter = digital.packet_header_ofdm(occupied_carriers, n_syms=1, len_tag_key=packet_length_tag_key, frame_len_tag_key=length_tag_key, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=payload_mod.bits_per_symbol(), scramble_header=True) self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe(fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols) self.forward_OOB = forward_OOB = [0.005277622700213007, 0.03443705907448985, 0.1214101788557494, 0.29179662246081545, 0.52428014905364, 0.7350677973792328, 0.8210395030022875, 0.7350677973792348, 0.5242801490536404, 0.291796622460816, 0.1214101788557501, 0.03443705907448997, 0.005277622700213012] self.feedback_OOB = feedback_OOB = [1.0, -1.0455317889337852, 3.9201525346250072, -3.9114761684448958, 6.54266144224035, -5.737287389902878, 5.820328302284336, -4.134700802700442, 2.7949972248757664, -1.4584448495689168, 0.6358650797085171, -0.19847981428665007, 0.04200458351675313] self.cp_len = cp_len = fft_len/4 self.active_carriers = active_carriers = len(occupied_carriers[0])+4 ################################################## # Blocks ################################################## self.iir_filter_xxx_1 = filter.iir_filter_ccd((forward_OOB), (feedback_OOB), False) self.fft_vxx_txpath = fft.fft_vcc(fft_len, False, (()), True, 1) self.fft_vxx_2_rxpath = fft.fft_vcc(fft_len, True, (), True, 1) self.fft_vxx_1_rxpath = fft.fft_vcc(fft_len, True, (()), True, 1) self.digital_packet_headerparser_b_rxpath = digital.packet_headerparser_b(header_formatter.base()) self.digital_packet_headergenerator_bb_txpath = digital.packet_headergenerator_bb(header_formatter.formatter(), "packet_len") self.digital_ofdm_sync_sc_cfb_rxpath = digital.ofdm_sync_sc_cfb(fft_len, fft_len/4, False) self.digital_ofdm_serializer_vcc_payload_rxpath = digital.ofdm_serializer_vcc(fft_len, occupied_carriers, length_tag_key, packet_length_tag_key, 1, "", True) self.digital_ofdm_serializer_vcc_header_rxpath = digital.ofdm_serializer_vcc(fft_len, occupied_carriers, length_tag_key, "", 0, "", True) self.digital_ofdm_frame_equalizer_vcvc_2_rxpath = digital.ofdm_frame_equalizer_vcvc(payload_equalizer.base(), cp_len, length_tag_key, True, 0) self.digital_ofdm_frame_equalizer_vcvc_1_rxpath = digital.ofdm_frame_equalizer_vcvc(header_equalizer.base(), cp_len, length_tag_key, True, 1) self.digital_ofdm_cyclic_prefixer_txpath = digital.ofdm_cyclic_prefixer(fft_len, fft_len+cp_len, rolloff, packet_length_tag_key) (self.digital_ofdm_cyclic_prefixer_txpath).set_min_output_buffer(24000) self.digital_ofdm_chanest_vcvc_rxpath = digital.ofdm_chanest_vcvc((sync_word1), (sync_word2), 1, 0, 3, False) self.digital_ofdm_carrier_allocator_cvc_txpath = digital.ofdm_carrier_allocator_cvc(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (sync_word1, sync_word2), packet_length_tag_key) (self.digital_ofdm_carrier_allocator_cvc_txpath).set_min_output_buffer(16000) self.digital_header_payload_demux_rxpath = digital.header_payload_demux( 3, fft_len, cp_len, length_tag_key, "", True, gr.sizeof_gr_complex, "rx_time", samp_rate, (), ) #self.digital_crc32_bb_txpath = digital.crc32_bb(False, packet_length_tag_key) #self.digital_crc32_bb_rxpath = digital.crc32_bb(True, packet_length_tag_key) self.digital_constellation_decoder_cb_1_rxpath = digital.constellation_decoder_cb(payload_mod.base()) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(header_mod.base()) self.digital_chunks_to_symbols_x_txpath = digital.chunks_to_symbols_bc((payload_mod.points()), 1) self.digital_chunks_to_symbols_txpath = digital.chunks_to_symbols_bc((header_mod.points()), 1) self.blocks_tagged_stream_mux_txpath = blocks.tagged_stream_mux(gr.sizeof_gr_complex*1, packet_length_tag_key, 0) (self.blocks_tagged_stream_mux_txpath).set_min_output_buffer(16000) self.blocks_tag_gate_txpath = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_repack_bits_bb_txpath = blocks.repack_bits_bb(8, payload_mod.bits_per_symbol(), packet_length_tag_key, False) self.blocks_repack_bits_bb_rxpath = blocks.repack_bits_bb(payload_mod.bits_per_symbol(), 8, packet_length_tag_key, True) self.blocks_multiply_xx_rxpath = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((.01, )) self.blocks_delay_rxpath = blocks.delay(gr.sizeof_gr_complex*1, fft_len+fft_len/4) self.analog_frequency_modulator_fc_rxpath = analog.frequency_modulator_fc(-2.0/fft_len) 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.digital_ofdm_sync_sc_cfb_rxpath, 0), (self.analog_frequency_modulator_fc_rxpath, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.digital_ofdm_sync_sc_cfb_rxpath, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.blocks_delay_rxpath, 0)) self.connect((self.digital_packet_headergenerator_bb_txpath, 0), (self.digital_chunks_to_symbols_txpath, 0)) self.connect((self.blocks_repack_bits_bb_txpath, 0), (self.digital_chunks_to_symbols_x_txpath, 0)) self.connect((self.digital_chunks_to_symbols_txpath, 0), (self.blocks_tagged_stream_mux_txpath, 0)) self.connect((self.digital_chunks_to_symbols_x_txpath, 0), (self.blocks_tagged_stream_mux_txpath, 1)) self.connect((self.digital_ofdm_cyclic_prefixer_txpath, 0), (self.blocks_tag_gate_txpath, 0)) self.connect((self.fft_vxx_txpath, 0), (self.digital_ofdm_cyclic_prefixer_txpath, 0)) self.connect((self.blocks_tagged_stream_mux_txpath, 0), (self.digital_ofdm_carrier_allocator_cvc_txpath, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_txpath, 0), (self.fft_vxx_txpath, 0)) self.connect((self.digital_header_payload_demux_rxpath, 0), (self.fft_vxx_1_rxpath, 0)) self.connect((self.fft_vxx_1_rxpath, 0), (self.digital_ofdm_chanest_vcvc_rxpath, 0)) self.connect((self.digital_ofdm_frame_equalizer_vcvc_1_rxpath, 0), (self.digital_ofdm_serializer_vcc_header_rxpath, 0)) self.connect((self.digital_ofdm_chanest_vcvc_rxpath, 0), (self.digital_ofdm_frame_equalizer_vcvc_1_rxpath, 0)) self.connect((self.digital_header_payload_demux_rxpath, 1), (self.fft_vxx_2_rxpath, 0)) self.connect((self.digital_ofdm_frame_equalizer_vcvc_2_rxpath, 0), (self.digital_ofdm_serializer_vcc_payload_rxpath, 0)) self.connect((self.fft_vxx_2_rxpath, 0), (self.digital_ofdm_frame_equalizer_vcvc_2_rxpath, 0)) self.connect((self.digital_ofdm_serializer_vcc_payload_rxpath, 0), (self.digital_constellation_decoder_cb_1_rxpath, 0)) self.connect((self.digital_constellation_decoder_cb_1_rxpath, 0), (self.blocks_repack_bits_bb_rxpath, 0)) self.connect((self.digital_ofdm_serializer_vcc_header_rxpath, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.analog_frequency_modulator_fc_rxpath, 0), (self.blocks_multiply_xx_rxpath, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_rxpath, 1), (self.digital_header_payload_demux_rxpath, 1)) self.connect((self.blocks_multiply_xx_rxpath, 0), (self.digital_header_payload_demux_rxpath, 0)) self.connect((self.blocks_delay_rxpath, 0), (self.blocks_multiply_xx_rxpath, 1)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_packet_headerparser_b_rxpath, 0)) self.connect((self, 1), (self.analog_agc2_xx_0, 0)) self.connect((self.blocks_tag_gate_txpath, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.iir_filter_xxx_1, 0), (self, 1)) ''' self.connect((self, 0), (self.digital_crc32_bb_txpath, 0)) self.connect((self.digital_crc32_bb_txpath, 0), (self.blocks_repack_bits_bb_txpath, 0)) self.connect((self.digital_crc32_bb_txpath, 0), (self.digital_packet_headergenerator_bb_txpath, 0)) ''' self.connect((self, 0), (self.blocks_repack_bits_bb_txpath, 0)) self.connect((self, 0), (self.digital_packet_headergenerator_bb_txpath, 0)) ''' self.connect((self.blocks_repack_bits_bb_rxpath, 0), (self.digital_crc32_bb_rxpath, 0)) self.connect((self.digital_crc32_bb_rxpath, 0), (self, 0)) ''' self.connect((self.blocks_repack_bits_bb_rxpath, 0), (self, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.iir_filter_xxx_1, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.digital_packet_headerparser_b_rxpath, "header_data", self.digital_header_payload_demux_rxpath, "header_data")
def __init__(self): gr.top_block.__init__(self, "Receiver NC-OFDM") ################################################## # Variables ################################################## self.shseq_len = shseq_len = 40 self.pn_symbols = pn_symbols = (1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1) self.lgseq_len = lgseq_len = 320 self.fft_len = fft_len = 64 self.dataseq_len = dataseq_len = 64 self.shseq_rep = shseq_rep = 8 self.shseq = shseq = pn_symbols[0:shseq_len] self.samp_rate = samp_rate = 1000000 self.pilot_symbols = pilot_symbols = ((1, 1, 1, -1,),) self.pilot_carriers = pilot_carriers = ((-21, -7, 7, 21,),) self.packet_len = packet_len = 3*len(range(-26, -21)+ range(-20,-7) + range(8, 21) + range(22, 27),) self.occupied_carriers = occupied_carriers = (range(-26, -21)+ range(-20,-7) + range(8, 21) + range(22, 27),) self.lgseq = lgseq = pn_symbols[shseq_len:shseq_len+lgseq_len] self.length_tag_name = length_tag_name = "packet_len" self.fileprefix = fileprefix = "/root/" self.data_len = data_len = dataseq_len*20 self.cp_len = cp_len = fft_len/4 self.cen_freq = cen_freq = 1500000000 self.ShThreshold = ShThreshold = 10 self.ShRepThreshold = ShRepThreshold = 3.5 self.LgThreshold = LgThreshold = 60 ################################################## # Blocks ################################################## self.uhd_usrp_source = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source.set_samp_rate(samp_rate) self.uhd_usrp_source.set_center_freq(cen_freq, 0) self.uhd_usrp_source.set_gain(10, 0) self.null_sink_shortpncorr_out = blocks.null_sink(gr.sizeof_gr_complex*1) self.null_sink_longpncorrv2_out = blocks.null_sink(gr.sizeof_gr_complex*1) self.null_sink_longpncorrv2_flag = blocks.null_sink(gr.sizeof_int*1) self.null_sink_longpncorrv2_corr = blocks.null_sink(gr.sizeof_gr_complex*1) self.ncofdm_ShortPNdetector = ncofdm.ShortPNdetector(fft_len, cp_len, shseq_rep, shseq_len, 1) self.ncofdm_ShortPNcorr = ncofdm.ShortPNcorr(fft_len, cp_len, shseq_rep, shseq_len, (shseq)) self.ncofdm_LongPNcorrV2 = ncofdm.LongPNcorrV2(fft_len, cp_len, lgseq_len, (lgseq), 60, shseq_len*shseq_rep+lgseq_len+data_len+10) self.ncofdm_FreqOffCalc = ncofdm.FreqOffCalc(fft_len, fft_len/4, shseq_len, shseq_rep) self.file_sink_short = blocks.file_sink(gr.sizeof_gr_complex*1, fileprefix+"short.dat", False) self.file_sink_short.set_unbuffered(False) self.file_sink_rxshth = blocks.file_sink(gr.sizeof_float*1, fileprefix+"rxshth.dat", False) self.file_sink_rxshth.set_unbuffered(False) self.file_sink_org = blocks.file_sink(gr.sizeof_gr_complex*1, fileprefix+"org.dat", False) self.file_sink_org.set_unbuffered(False) self.file_sink_long = blocks.file_sink(gr.sizeof_gr_complex*1, fileprefix+"long.dat", False) self.file_sink_long.set_unbuffered(False) self.file_sink_lgth = blocks.file_sink(gr.sizeof_float*1, fileprefix+"lgth.dat", False) self.file_sink_lgth.set_unbuffered(False) self.file_sink_gain = blocks.file_sink(gr.sizeof_float*1, fileprefix+"gain.dat", False) self.file_sink_gain.set_unbuffered(False) self.file_sink_freqoff = blocks.file_sink(gr.sizeof_float*1, fileprefix+"freqoff.dat", False) self.file_sink_freqoff.set_unbuffered(False) self.file_sink_corr = blocks.file_sink(gr.sizeof_int*1, fileprefix+"corr.dat", False) self.file_sink_corr.set_unbuffered(False) self.blocks_threshold_ff = blocks.threshold_ff(ShRepThreshold, ShRepThreshold, 0) self.blocks_moving_average = blocks.moving_average_ff(100, 0.01, 4000) self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex*1, 10000) self.blocks_float_to_int = blocks.float_to_int(1, 1) self.blocks_float_to_complex_lgpn_input = blocks.float_to_complex(1) self.blocks_delay_shpn_lgpn = blocks.delay(gr.sizeof_float*1, 2) self.blocks_delay_shpn_freqoff = blocks.delay(gr.sizeof_int*1, 1) self.blocks_delay_freqoff_lgpn = blocks.delay(gr.sizeof_float*1, 2) self.blocks_complex_to_real_lgth = blocks.complex_to_real(1) self.blocks_complex_to_mag_org = blocks.complex_to_mag(1) self.blocks_complex_to_mag = blocks.complex_to_mag(1) self.analog_agc = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc.set_max_gain(50000.0) ################################################## # Connections ################################################## self.connect((self.analog_agc, 0), (self.blocks_complex_to_mag_org, 0)) self.connect((self.analog_agc, 1), (self.file_sink_gain, 0)) self.connect((self.analog_agc, 0), (self.file_sink_org, 0)) self.connect((self.analog_agc, 0), (self.ncofdm_LongPNcorrV2, 0)) self.connect((self.analog_agc, 0), (self.ncofdm_ShortPNcorr, 0)) self.connect((self.blocks_complex_to_mag, 0), (self.ncofdm_ShortPNdetector, 0)) self.connect((self.blocks_complex_to_mag_org, 0), (self.blocks_moving_average, 0)) self.connect((self.blocks_complex_to_real_lgth, 0), (self.file_sink_lgth, 0)) self.connect((self.blocks_delay_freqoff_lgpn, 0), (self.blocks_float_to_complex_lgpn_input, 0)) self.connect((self.blocks_delay_freqoff_lgpn, 0), (self.file_sink_freqoff, 0)) self.connect((self.blocks_delay_shpn_freqoff, 0), (self.ncofdm_FreqOffCalc, 1)) self.connect((self.blocks_delay_shpn_lgpn, 0), (self.blocks_float_to_complex_lgpn_input, 1)) self.connect((self.blocks_float_to_complex_lgpn_input, 0), (self.ncofdm_LongPNcorrV2, 1)) self.connect((self.blocks_float_to_int, 0), (self.blocks_delay_shpn_freqoff, 0)) self.connect((self.blocks_head_0, 0), (self.analog_agc, 0)) self.connect((self.blocks_moving_average, 0), (self.ncofdm_LongPNcorrV2, 2)) self.connect((self.blocks_threshold_ff, 0), (self.blocks_delay_shpn_lgpn, 0)) self.connect((self.blocks_threshold_ff, 0), (self.blocks_float_to_int, 0)) self.connect((self.ncofdm_FreqOffCalc, 0), (self.blocks_delay_freqoff_lgpn, 0)) self.connect((self.ncofdm_LongPNcorrV2, 0), (self.blocks_complex_to_real_lgth, 0)) self.connect((self.ncofdm_LongPNcorrV2, 2), (self.file_sink_corr, 0)) self.connect((self.ncofdm_LongPNcorrV2, 1), (self.file_sink_long, 0)) self.connect((self.ncofdm_LongPNcorrV2, 1), (self.null_sink_longpncorrv2_corr, 0)) self.connect((self.ncofdm_LongPNcorrV2, 2), (self.null_sink_longpncorrv2_flag, 0)) self.connect((self.ncofdm_LongPNcorrV2, 0), (self.null_sink_longpncorrv2_out, 0)) self.connect((self.ncofdm_ShortPNcorr, 1), (self.blocks_complex_to_mag, 0)) self.connect((self.ncofdm_ShortPNcorr, 1), (self.file_sink_short, 0)) self.connect((self.ncofdm_ShortPNcorr, 1), (self.ncofdm_FreqOffCalc, 0)) self.connect((self.ncofdm_ShortPNcorr, 0), (self.null_sink_shortpncorr_out, 0)) self.connect((self.ncofdm_ShortPNdetector, 0), (self.blocks_threshold_ff, 0)) self.connect((self.ncofdm_ShortPNdetector, 1), (self.file_sink_rxshth, 0)) self.connect((self.uhd_usrp_source, 0), (self.blocks_head_0, 0))
def __init__(self, antenna=satnogs.not_set_antenna, bb_gain=satnogs.not_set_rx_bb_gain, cw_offset=1500, decoded_data_file_path='/tmp/.satnogs/data/data', dev_args=satnogs.not_set_dev_args, doppler_correction_per_sec=20, enable_iq_dump=0, file_path='test.ogg', if_gain=satnogs.not_set_rx_if_gain, iq_file_path='/tmp/iq.dat', lo_offset=100e3, ppm=0, rf_gain=satnogs.not_set_rx_rf_gain, rigctl_port=4532, rx_freq=100e6, rx_sdr_device='usrpb200', waterfall_file_path='/tmp/waterfall.dat'): gr.top_block.__init__(self, "BPSK Generic Demodulation") ################################################## # Parameters ################################################## self.antenna = antenna self.bb_gain = bb_gain self.cw_offset = cw_offset self.decoded_data_file_path = decoded_data_file_path self.dev_args = dev_args self.doppler_correction_per_sec = doppler_correction_per_sec self.enable_iq_dump = enable_iq_dump self.file_path = file_path self.if_gain = if_gain self.iq_file_path = iq_file_path self.lo_offset = lo_offset self.ppm = ppm self.rf_gain = rf_gain self.rigctl_port = rigctl_port self.rx_freq = rx_freq self.rx_sdr_device = rx_sdr_device self.waterfall_file_path = waterfall_file_path ################################################## # Variables ################################################## self.samp_rate_rx = samp_rate_rx = satnogs.hw_rx_settings[rx_sdr_device]['samp_rate'] self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(1, samp_rate_rx, 125000, 25000, firdes.WIN_HAMMING, 6.76) self.taps = taps = firdes.low_pass(12.0, samp_rate_rx, 100e3, 60000, firdes.WIN_HAMMING, 6.76) self.filter_rate = filter_rate = 250000 self.deviation = deviation = 5000 self.audio_samp_rate = audio_samp_rate = 48000 ################################################## # Blocks ################################################## self.satnogs_waterfall_sink_0 = satnogs.waterfall_sink(audio_samp_rate, 0.0, 10, 1024, waterfall_file_path, 1) self.satnogs_tcp_rigctl_msg_source_0 = satnogs.tcp_rigctl_msg_source("127.0.0.1", rigctl_port, False, 1000/doppler_correction_per_sec, 1500) self.satnogs_ogg_encoder_0 = satnogs.ogg_encoder(file_path, audio_samp_rate, 1.0) self.satnogs_iq_sink_0 = satnogs.iq_sink(32767, iq_file_path, False, enable_iq_dump) self.satnogs_coarse_doppler_correction_cc_0 = satnogs.coarse_doppler_correction_cc(rx_freq, samp_rate_rx) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + satnogs.handle_rx_dev_args(rx_sdr_device, dev_args) ) self.osmosdr_source_0.set_sample_rate(samp_rate_rx) self.osmosdr_source_0.set_center_freq(rx_freq - lo_offset, 0) self.osmosdr_source_0.set_freq_corr(ppm, 0) self.osmosdr_source_0.set_dc_offset_mode(2, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(satnogs.handle_rx_rf_gain(rx_sdr_device, rf_gain), 0) self.osmosdr_source_0.set_if_gain(satnogs.handle_rx_if_gain(rx_sdr_device, if_gain), 0) self.osmosdr_source_0.set_bb_gain(satnogs.handle_rx_bb_gain(rx_sdr_device, bb_gain), 0) self.osmosdr_source_0.set_antenna(satnogs.handle_rx_antenna(rx_sdr_device, antenna), 0) self.osmosdr_source_0.set_bandwidth(samp_rate_rx, 0) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, audio_samp_rate, 2000, 1000, firdes.WIN_HAMMING, 6.76)) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(int(samp_rate_rx/filter_rate), (xlate_filter_taps), lo_offset, samp_rate_rx) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blks2_rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=24, decimation=125, taps=None, fractional_bw=None, ) self.analog_sig_source_x_0 = analog.sig_source_c(audio_samp_rate, analog.GR_COS_WAVE, cw_offset, 1, 0) self.analog_agc2_xx_0_0 = analog.agc2_cc(0.01, 0.001, 0.015, 0.0) self.analog_agc2_xx_0_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect((self.satnogs_tcp_rigctl_msg_source_0, 'freq'), (self.satnogs_coarse_doppler_correction_cc_0, 'freq')) self.connect((self.analog_agc2_xx_0_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.low_pass_filter_0, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.satnogs_iq_sink_0, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.satnogs_waterfall_sink_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.satnogs_ogg_encoder_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_agc2_xx_0_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.satnogs_coarse_doppler_correction_cc_0, 0)) self.connect((self.satnogs_coarse_doppler_correction_cc_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Uhd Hf Am") Qt.QWidget.__init__(self) self.setWindowTitle("Uhd Hf Am") 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", "uhd_hf_am") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2.5e6 self.rx_freq = rx_freq = 1.0e6 self.fine_freq = fine_freq = 0 self.coarse_freq = coarse_freq = 0 self.volume = volume = 1 self.usb_lsb = usb_lsb = -1 self.ssb_am = ssb_am = 0 self.selection = selection = ((1, 0, 0), (0, 1, 0), (0, 0, 1)) self.pll_lbw = pll_lbw = 200 self.pll_freq = pll_freq = 100 self.lpf_cutoff = lpf_cutoff = 2e3 self.interp = interp = 48 self.freq_label = freq_label = rx_freq + fine_freq + coarse_freq self.decim = decim = samp_rate / 1e3 self.decay_rate = decay_rate = 100e-6 self.audio_ref = audio_ref = 1 self.audio_max_gain = audio_max_gain = 1 self.audio_gain = audio_gain = 1 self.audio_decay = audio_decay = 100 self.audio_attack = audio_attack = 1000 ################################################## # Blocks ################################################## self._volume_range = Range(0, 100, .1, 1, 200) self._volume_win = RangeWidget(self._volume_range, self.set_volume, "volume", "counter_slider", float) self.top_grid_layout.addWidget(self._volume_win, 7, 0, 1, 4) for r in range(7, 8): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self._usb_lsb_options = ( -1, 1, ) self._usb_lsb_labels = ( 'USB', 'LSB', ) self._usb_lsb_group_box = Qt.QGroupBox("usb_lsb") self._usb_lsb_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._usb_lsb_button_group = variable_chooser_button_group() self._usb_lsb_group_box.setLayout(self._usb_lsb_box) for i, label in enumerate(self._usb_lsb_labels): radio_button = Qt.QRadioButton(label) self._usb_lsb_box.addWidget(radio_button) self._usb_lsb_button_group.addButton(radio_button, i) self._usb_lsb_callback = lambda i: Qt.QMetaObject.invokeMethod( self._usb_lsb_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._usb_lsb_options.index(i))) self._usb_lsb_callback(self.usb_lsb) self._usb_lsb_button_group.buttonClicked[int].connect( lambda i: self.set_usb_lsb(self._usb_lsb_options[i])) self.top_grid_layout.addWidget(self._usb_lsb_group_box, 5, 5, 1, 1) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(5, 6): self.top_grid_layout.setColumnStretch(c, 1) self._ssb_am_options = ( 0, 1, 2, ) self._ssb_am_labels = ( 'SSB', 'AM', 'AM*', ) self._ssb_am_group_box = Qt.QGroupBox("ssb_am") self._ssb_am_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._ssb_am_button_group = variable_chooser_button_group() self._ssb_am_group_box.setLayout(self._ssb_am_box) for i, label in enumerate(self._ssb_am_labels): radio_button = Qt.QRadioButton(label) self._ssb_am_box.addWidget(radio_button) self._ssb_am_button_group.addButton(radio_button, i) self._ssb_am_callback = lambda i: Qt.QMetaObject.invokeMethod( self._ssb_am_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._ssb_am_options.index(i))) self._ssb_am_callback(self.ssb_am) self._ssb_am_button_group.buttonClicked[int].connect( lambda i: self.set_ssb_am(self._ssb_am_options[i])) self.top_grid_layout.addWidget(self._ssb_am_group_box, 4, 4, 1, 1) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 5): self.top_grid_layout.setColumnStretch(c, 1) self._rx_freq_range = Range(.2e6, 100e6, 100e3, 1.0e6, 200) self._rx_freq_win = RangeWidget(self._rx_freq_range, self.set_rx_freq, "rx_freq", "counter_slider", float) self.top_grid_layout.addWidget(self._rx_freq_win, 4, 0, 1, 4) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self._pll_lbw_tool_bar = Qt.QToolBar(self) self._pll_lbw_tool_bar.addWidget(Qt.QLabel("pll_lbw" + ": ")) self._pll_lbw_line_edit = Qt.QLineEdit(str(self.pll_lbw)) self._pll_lbw_tool_bar.addWidget(self._pll_lbw_line_edit) self._pll_lbw_line_edit.returnPressed.connect(lambda: self.set_pll_lbw( eng_notation.str_to_num( str(self._pll_lbw_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._pll_lbw_tool_bar, 9, 7, 1, 1) for r in range(9, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(7, 8): self.top_grid_layout.setColumnStretch(c, 1) self._pll_freq_tool_bar = Qt.QToolBar(self) self._pll_freq_tool_bar.addWidget(Qt.QLabel("pll_freq" + ": ")) self._pll_freq_line_edit = Qt.QLineEdit(str(self.pll_freq)) self._pll_freq_tool_bar.addWidget(self._pll_freq_line_edit) self._pll_freq_line_edit.returnPressed.connect( lambda: self.set_pll_freq( eng_notation.str_to_num( str(self._pll_freq_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._pll_freq_tool_bar, 9, 6, 1, 1) for r in range(9, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 7): self.top_grid_layout.setColumnStretch(c, 1) self._lpf_cutoff_options = ( 2e3, 3e3, 4e3, 8e3, ) self._lpf_cutoff_labels = ( str(self._lpf_cutoff_options[0]), str(self._lpf_cutoff_options[1]), str(self._lpf_cutoff_options[2]), str(self._lpf_cutoff_options[3]), ) self._lpf_cutoff_tool_bar = Qt.QToolBar(self) self._lpf_cutoff_tool_bar.addWidget(Qt.QLabel("lpf_cutoff" + ": ")) self._lpf_cutoff_combo_box = Qt.QComboBox() self._lpf_cutoff_tool_bar.addWidget(self._lpf_cutoff_combo_box) for label in self._lpf_cutoff_labels: self._lpf_cutoff_combo_box.addItem(label) self._lpf_cutoff_callback = lambda i: Qt.QMetaObject.invokeMethod( self._lpf_cutoff_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._lpf_cutoff_options.index(i))) self._lpf_cutoff_callback(self.lpf_cutoff) self._lpf_cutoff_combo_box.currentIndexChanged.connect( lambda i: self.set_lpf_cutoff(self._lpf_cutoff_options[i])) self.top_grid_layout.addWidget(self._lpf_cutoff_tool_bar, 4, 5, 1, 1) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(5, 6): self.top_grid_layout.setColumnStretch(c, 1) self._fine_freq_range = Range(-1e3, 1e3, 1, 0, 200) self._fine_freq_win = RangeWidget(self._fine_freq_range, self.set_fine_freq, "fine_freq", "counter_slider", float) self.top_grid_layout.addWidget(self._fine_freq_win, 6, 0, 1, 4) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self._decay_rate_options = ( 100e-6, 65e-3, 20e-3, ) self._decay_rate_labels = ( 'Fast', 'Medium', 'Slow', ) self._decay_rate_group_box = Qt.QGroupBox("decay_rate") self._decay_rate_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._decay_rate_button_group = variable_chooser_button_group() self._decay_rate_group_box.setLayout(self._decay_rate_box) for i, label in enumerate(self._decay_rate_labels): radio_button = Qt.QRadioButton(label) self._decay_rate_box.addWidget(radio_button) self._decay_rate_button_group.addButton(radio_button, i) self._decay_rate_callback = lambda i: Qt.QMetaObject.invokeMethod( self._decay_rate_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._decay_rate_options.index(i))) self._decay_rate_callback(self.decay_rate) self._decay_rate_button_group.buttonClicked[int].connect( lambda i: self.set_decay_rate(self._decay_rate_options[i])) self.top_grid_layout.addWidget(self._decay_rate_group_box, 4, 6, 1, 1) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 7): self.top_grid_layout.setColumnStretch(c, 1) self._coarse_freq_range = Range(-100e3, 100e3, 1, 0, 200) self._coarse_freq_win = RangeWidget(self._coarse_freq_range, self.set_coarse_freq, "coarse_freq", "counter_slider", float) self.top_grid_layout.addWidget(self._coarse_freq_win, 5, 0, 1, 4) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self._audio_ref_tool_bar = Qt.QToolBar(self) self._audio_ref_tool_bar.addWidget(Qt.QLabel("audio_ref" + ": ")) self._audio_ref_line_edit = Qt.QLineEdit(str(self.audio_ref)) self._audio_ref_tool_bar.addWidget(self._audio_ref_line_edit) self._audio_ref_line_edit.returnPressed.connect( lambda: self.set_audio_ref( eng_notation.str_to_num( str(self._audio_ref_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._audio_ref_tool_bar, 9, 3, 1, 1) for r in range(9, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self._audio_max_gain_tool_bar = Qt.QToolBar(self) self._audio_max_gain_tool_bar.addWidget( Qt.QLabel("audio_max_gain" + ": ")) self._audio_max_gain_line_edit = Qt.QLineEdit(str(self.audio_max_gain)) self._audio_max_gain_tool_bar.addWidget(self._audio_max_gain_line_edit) self._audio_max_gain_line_edit.returnPressed.connect( lambda: self.set_audio_max_gain( eng_notation.str_to_num( str(self._audio_max_gain_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._audio_max_gain_tool_bar, 9, 5, 1, 1) for r in range(9, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(5, 6): self.top_grid_layout.setColumnStretch(c, 1) self._audio_gain_tool_bar = Qt.QToolBar(self) self._audio_gain_tool_bar.addWidget(Qt.QLabel("audio_gain" + ": ")) 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, 9, 4, 1, 1) for r in range(9, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 5): self.top_grid_layout.setColumnStretch(c, 1) self._audio_decay_tool_bar = Qt.QToolBar(self) self._audio_decay_tool_bar.addWidget(Qt.QLabel("audio_decay" + ": ")) self._audio_decay_line_edit = Qt.QLineEdit(str(self.audio_decay)) self._audio_decay_tool_bar.addWidget(self._audio_decay_line_edit) self._audio_decay_line_edit.returnPressed.connect( lambda: self.set_audio_decay( eng_notation.str_to_num( str(self._audio_decay_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._audio_decay_tool_bar, 9, 2, 1, 1) for r in range(9, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self._audio_attack_tool_bar = Qt.QToolBar(self) self._audio_attack_tool_bar.addWidget(Qt.QLabel("audio_attack" + ": ")) self._audio_attack_line_edit = Qt.QLineEdit(str(self.audio_attack)) self._audio_attack_tool_bar.addWidget(self._audio_attack_line_edit) self._audio_attack_line_edit.returnPressed.connect( lambda: self.set_audio_attack( eng_notation.str_to_num( str(self._audio_attack_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._audio_attack_tool_bar, 9, 1, 1, 1) for r in range(9, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.uhd_usrp_source_1 = uhd.usrp_source( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_1.set_clock_source('external', 0) self.uhd_usrp_source_1.set_time_source('external', 0) self.uhd_usrp_source_1.set_subdev_spec('A:AB', 0) self.uhd_usrp_source_1.set_samp_rate(samp_rate) self.uhd_usrp_source_1.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_1.set_center_freq(uhd.tune_request(rx_freq, ), 0) self.uhd_usrp_source_1.set_gain(0, 0) self.uhd_usrp_source_1.set_auto_dc_offset(True, 0) self.uhd_usrp_source_1.set_auto_iq_balance(True, 0) self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=1, decimation=4, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=200, decimation=int(samp_rate / 1e3), taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=interp, decimation=int(decim), taps=None, fractional_bw=None, ) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate / decim * interp / 3, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 8, 0, 1, 4) for r in range(8, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0.set_update_time(0.010) self.qtgui_number_sink_0.set_title('') labels = ["RSSI", '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("blue", "red"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, 0) self.qtgui_number_sink_0.set_max(i, 50) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 5, 6, 1, 1) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 7): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim * interp / 3, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.0010) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(True) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ['', 'processed', '', '', '', '', '', '', '', ''] 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_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 6, 4, 3, 2) for r in range(6, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim * interp, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.010) self.qtgui_freq_sink_x_0.set_y_axis(-120, -10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not 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 = ['pre-d', 'processed', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 4, 4, 4) for r in range(0, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.low_pass_filter_0_1 = filter.interp_fir_filter_fff( 1, firdes.low_pass(1, samp_rate / decim * interp / 3, 1.5e3, 100, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 3, firdes.low_pass(1, samp_rate / decim * interp, lpf_cutoff, 100, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.interp_fir_filter_fff( 1, firdes.low_pass(1, samp_rate / decim * interp / 3, 1.5e3, 100, firdes.WIN_HAMMING, 6.76)) self._freq_label_tool_bar = Qt.QToolBar(self) if None: self._freq_label_formatter = None else: self._freq_label_formatter = lambda x: eng_notation.num_to_str(x) self._freq_label_tool_bar.addWidget(Qt.QLabel('Tuned Freq' + ": ")) self._freq_label_label = Qt.QLabel( str(self._freq_label_formatter(self.freq_label))) self._freq_label_tool_bar.addWidget(self._freq_label_label) self.top_grid_layout.addWidget(self._freq_label_tool_bar, 5, 4, 1, 1) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 5): self.top_grid_layout.setColumnStretch(c, 1) self.fosphor_qt_sink_c_0 = fosphor.qt_sink_c() self.fosphor_qt_sink_c_0.set_fft_window(window.WIN_BLACKMAN_hARRIS) self.fosphor_qt_sink_c_0.set_frequency_range( rx_freq, samp_rate / int(samp_rate / 1e3) * 200) self._fosphor_qt_sink_c_0_win = sip.wrapinstance( self.fosphor_qt_sink_c_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._fosphor_qt_sink_c_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.blocks_multiply_xx_1_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_matrix_xx_0_0_0 = blocks.multiply_matrix_cc( (selection[ssb_am], ), gr.TPP_ALL_TO_ALL) self.blocks_multiply_matrix_xx_0 = blocks.multiply_matrix_ff( (selection[ssb_am], ), gr.TPP_ALL_TO_ALL) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff( (100000, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff( (usb_lsb, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (volume, )) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( 1000, 1 / 1000.0, 4000, 1) self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.audio_sink_0 = audio.sink(16000, '', True) self.analog_sig_source_x_0_0_0 = analog.sig_source_f( samp_rate / decim * interp / 3, analog.GR_SIN_WAVE, 1.5e3, 1, 0) self.analog_sig_source_x_0_0 = analog.sig_source_f( samp_rate / decim * interp / 3, analog.GR_COS_WAVE, 1.5e3, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -1 * (fine_freq + coarse_freq), 1, 0) self.analog_pll_carriertracking_cc_0 = analog.pll_carriertracking_cc( math.pi / pll_lbw, math.pi / pll_freq, -math.pi / pll_freq) self.analog_agc2_xx_0_0 = analog.agc2_ff(audio_attack, audio_decay, audio_ref, audio_gain) self.analog_agc2_xx_0_0.set_max_gain(audio_max_gain) self.analog_agc2_xx_0 = analog.agc2_cc(0.1, decay_rate, .3, 1000) self.analog_agc2_xx_0.set_max_gain(65000) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.analog_agc2_xx_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.analog_pll_carriertracking_cc_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.analog_pll_carriertracking_cc_0, 0), (self.blocks_multiply_matrix_xx_0_0_0, 2)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.analog_sig_source_x_0_0_0, 0), (self.blocks_multiply_xx_1_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_matrix_xx_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.low_pass_filter_0_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_matrix_xx_0, 2)) self.connect((self.blocks_complex_to_real_0_0, 0), (self.blocks_multiply_matrix_xx_0, 1)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_multiply_matrix_xx_0, 0), (self.analog_agc2_xx_0_0, 0)) self.connect((self.blocks_multiply_matrix_xx_0_0_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.blocks_multiply_matrix_xx_0_0_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_1_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.analog_pll_carriertracking_cc_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_complex_to_real_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_multiply_matrix_xx_0_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_multiply_matrix_xx_0_0_0, 1)) self.connect((self.low_pass_filter_0_1, 0), (self.blocks_multiply_xx_1_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.fosphor_qt_sink_c_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.uhd_usrp_source_1, 0), (self.analog_agc2_xx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Fm Channelizer") Qt.QWidget.__init__(self) self.setWindowTitle("Fm Channelizer") 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", "fm_channelizer") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.synth_channels = synth_channels = 6 self.channels = channels = 10 self.ch_rate = ch_rate = 100e3 self.samp_rate = samp_rate = ch_rate * channels self.gain = gain = 20 self.fm_quad_rate = fm_quad_rate = ch_rate * synth_channels self.ch_tb = ch_tb = 20e3 self.ch_bw = ch_bw = ch_rate / 2 self.audio_rate = audio_rate = 60e3 self.atten = atten = 80 self.volume = volume = 0.1 self.tun_gain = tun_gain = gain self.pfb_taps = pfb_taps = firdes.low_pass_2(1, samp_rate, ch_bw, ch_tb, atten, firdes.WIN_BLACKMAN_HARRIS) self.pfb_synth_taps = pfb_synth_taps = firdes.low_pass_2( channels / 2, synth_channels * ch_rate, ch_bw, ch_tb, atten, firdes.WIN_BLACKMAN_HARRIS ) self.freq_corr = freq_corr = 0 self.fm_audio_decim = fm_audio_decim = int(fm_quad_rate / audio_rate) * 2 self.channel = channel = 0 self.center_freq = center_freq = 101.1e6 + 0e3 self.address = address = "" ################################################## # Blocks ################################################## self._volume_layout = Qt.QVBoxLayout() self._volume_tool_bar = Qt.QToolBar(self) self._volume_layout.addWidget(self._volume_tool_bar) self._volume_tool_bar.addWidget(Qt.QLabel("Volume" + ": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot("double") def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._volume_counter = qwt_counter_pyslot() self._volume_counter.setRange(0, 10, 0.1) self._volume_counter.setNumButtons(2) self._volume_counter.setValue(self.volume) self._volume_tool_bar.addWidget(self._volume_counter) self._volume_counter.valueChanged.connect(self.set_volume) self._volume_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._volume_slider.setRange(0, 10, 0.1) self._volume_slider.setValue(self.volume) self._volume_slider.setMinimumWidth(200) self._volume_slider.valueChanged.connect(self.set_volume) self._volume_layout.addWidget(self._volume_slider) self.top_grid_layout.addLayout(self._volume_layout, 3, 0, 1, 1) self._tun_gain_layout = Qt.QVBoxLayout() self._tun_gain_tool_bar = Qt.QToolBar(self) self._tun_gain_layout.addWidget(self._tun_gain_tool_bar) self._tun_gain_tool_bar.addWidget(Qt.QLabel("Gain (dB)" + ": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot("double") def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._tun_gain_counter = qwt_counter_pyslot() self._tun_gain_counter.setRange(0, 70, 1) self._tun_gain_counter.setNumButtons(2) self._tun_gain_counter.setValue(self.tun_gain) self._tun_gain_tool_bar.addWidget(self._tun_gain_counter) self._tun_gain_counter.valueChanged.connect(self.set_tun_gain) self._tun_gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._tun_gain_slider.setRange(0, 70, 1) self._tun_gain_slider.setValue(self.tun_gain) self._tun_gain_slider.setMinimumWidth(200) self._tun_gain_slider.valueChanged.connect(self.set_tun_gain) self._tun_gain_layout.addWidget(self._tun_gain_slider) self.top_grid_layout.addLayout(self._tun_gain_layout, 2, 1, 1, 1) self._freq_corr_layout = Qt.QVBoxLayout() self._freq_corr_tool_bar = Qt.QToolBar(self) self._freq_corr_layout.addWidget(self._freq_corr_tool_bar) self._freq_corr_tool_bar.addWidget(Qt.QLabel("Frequency Correction" + ": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot("double") def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._freq_corr_counter = qwt_counter_pyslot() self._freq_corr_counter.setRange(-40e3, 40e3, 100) self._freq_corr_counter.setNumButtons(2) self._freq_corr_counter.setValue(self.freq_corr) self._freq_corr_tool_bar.addWidget(self._freq_corr_counter) self._freq_corr_counter.valueChanged.connect(self.set_freq_corr) self._freq_corr_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._freq_corr_slider.setRange(-40e3, 40e3, 100) self._freq_corr_slider.setValue(self.freq_corr) self._freq_corr_slider.setMinimumWidth(200) self._freq_corr_slider.valueChanged.connect(self.set_freq_corr) self._freq_corr_layout.addWidget(self._freq_corr_slider) self.top_grid_layout.addLayout(self._freq_corr_layout, 3, 1, 1, 1) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join((address, "")), uhd.stream_args(cpu_format="fc32", channels=range(1)) ) self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(center_freq + freq_corr, 0) self.uhd_usrp_source_0.set_gain(tun_gain, 0) self.uhd_usrp_source_0.set_antenna("RX2", 0) self.qtgui_freq_sink_x_0_0_0 = qtgui.freq_sink_c( 1024, # size firdes.WIN_FLATTOP, # wintype 0, # fc ch_rate * synth_channels, # bw "QT GUI Plot", # name 1, # number of inputs ) self.qtgui_freq_sink_x_0_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0_0.set_fft_average(1.0) if complex == type(float()): self.qtgui_freq_sink_x_0_0_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_0_win, 1, 1, 1, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, # size firdes.WIN_BLACKMAN_hARRIS, # wintype 0, # fc samp_rate, # bw "QT GUI Plot", # name 1, # number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_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) if complex == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 1, 2) self.pfb_synthesizer_ccf_0 = filter.pfb_synthesizer_ccf(synth_channels, (pfb_synth_taps), True) self.pfb_synthesizer_ccf_0.set_channel_map(([10, 11, 0, 1, 2, 3])) self.pfb_synthesizer_ccf_0.declare_sample_delay(0) self.pfb_channelizer_ccf_0 = pfb.channelizer_ccf(channels, (pfb_taps), 2.0, atten) self.pfb_channelizer_ccf_0.set_channel_map(()) self.pfb_channelizer_ccf_0.declare_sample_delay(0) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_fff( 44.1e3 / (fm_quad_rate / fm_audio_decim), taps=None, flt_size=32 ) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.fir_filter_xxx_0 = filter.fir_filter_ccc( 2, (firdes.low_pass_2(1, ch_rate * synth_channels, 250e3, 300e3, 40, firdes.WIN_BLACKMAN_HARRIS)) ) self.fir_filter_xxx_0.declare_sample_delay(0) self._channel_layout = Qt.QVBoxLayout() self._channel_tool_bar = Qt.QToolBar(self) self._channel_layout.addWidget(self._channel_tool_bar) self._channel_tool_bar.addWidget(Qt.QLabel("Output Channel" + ": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot("double") def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._channel_counter = qwt_counter_pyslot() self._channel_counter.setRange(0, channels - 1, 1) self._channel_counter.setNumButtons(2) self._channel_counter.setValue(self.channel) self._channel_tool_bar.addWidget(self._channel_counter) self._channel_counter.valueChanged.connect(self.set_channel) self._channel_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._channel_slider.setRange(0, channels - 1, 1) self._channel_slider.setValue(self.channel) self._channel_slider.setMinimumWidth(200) self._channel_slider.valueChanged.connect(self.set_channel) self._channel_layout.addWidget(self._channel_slider) self.top_grid_layout.addLayout(self._channel_layout, 2, 0, 1, 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_multiply_const_vxx = blocks.multiply_const_vff((volume,)) self.audio_sink = audio.sink(44100, "", True) self.analog_wfm_rcv = analog.wfm_rcv(quad_rate=fm_quad_rate, audio_decimation=fm_audio_decim) 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.pfb_channelizer_ccf_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.analog_wfm_rcv, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_const_vxx, 0), (self.audio_sink, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.analog_wfm_rcv, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0_0_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx, 0)) self.connect((self.pfb_channelizer_ccf_0, 6), (self.blocks_null_sink_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 7), (self.blocks_null_sink_0, 1)) self.connect((self.pfb_channelizer_ccf_0, 8), (self.blocks_null_sink_0, 2)) self.connect((self.pfb_channelizer_ccf_0, 9), (self.blocks_null_sink_0, 3)) self.connect((self.pfb_channelizer_ccf_0, 0), (self.pfb_synthesizer_ccf_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 1), (self.pfb_synthesizer_ccf_0, 1)) self.connect((self.pfb_channelizer_ccf_0, 2), (self.pfb_synthesizer_ccf_0, 2)) self.connect((self.pfb_channelizer_ccf_0, 3), (self.pfb_synthesizer_ccf_0, 3)) self.connect((self.pfb_channelizer_ccf_0, 4), (self.pfb_synthesizer_ccf_0, 4)) self.connect((self.pfb_channelizer_ccf_0, 5), (self.pfb_synthesizer_ccf_0, 5)) self.connect((self.pfb_synthesizer_ccf_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.analog_agc2_xx_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="air band receiver") ################################################## # Variables ################################################## self.sql = sql = option.squelch self.samp_rate = samp_rate = 2.4e6 self.rfgain = rfgain = option.gain self.frq_corr = frq_corr = option.correct self.device_arg = device_arg = "rtl_tcp={0}:{1}".format(option.host, option.port) self.base_freq = base_freq = option.freq ################################################## # Blocks ################################################## self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + device_arg ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(base_freq, 0) self.osmosdr_source_0.set_freq_corr(frq_corr, 0) self.osmosdr_source_0.set_dc_offset_mode(2, 0) self.osmosdr_source_0.set_iq_balance_mode(2, 0) self.osmosdr_source_0.set_gain_mode(True, 0) self.osmosdr_source_0.set_gain(rfgain, 0) self.osmosdr_source_0.set_if_gain(0, 0) self.osmosdr_source_0.set_bb_gain(0, 0) self.osmosdr_source_0.set_antenna('RX', 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(50, (firdes.low_pass_2(1,samp_rate,25e3,10e3,40)), 0, samp_rate) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short*1, option.desthost, option.destport, 1472, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0.5, )) self.blocks_float_to_short_0 = blocks.float_to_short(1, 32767) self.audio_sink_0 = audio.sink(48000, '', True) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(sql, 1e-4, 0, False) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=48e3, audio_decim=1, audio_pass=5000, audio_stop=5500, ) self.analog_agc2_xx_0 = analog.agc2_cc(1e-3, 1e-5, 1.0, 0) self.analog_agc2_xx_0.set_max_gain(5) # dc_blocker not use # self.dc_blocker_xx_0 = filter.dc_blocker_ff(32,True) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.blocks_float_to_short_0, 0), (self.blocks_udp_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_throttle_0, 0)) # bypass dc blocker # self.connect((self.analog_am_demod_cf_0, 0), (self.dc_blocker_xx_0, 0)) # self.connect((self.dc_blocker_xx_0, 0), (self.blocks_float_to_short_0, 0)) # self.connect((self.dc_blocker_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.blocks_float_to_short_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self, constellation, differential=_def_differential, samples_per_symbol=_def_samples_per_symbol, pre_diff_code=True, excess_bw=_def_excess_bw, freq_bw=_def_freq_bw, timing_bw=_def_timing_bw, phase_bw=_def_phase_bw, verbose=_def_verbose, log=_def_log): gr.hier_block2.__init__(self, "generic_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_char)) # Output signature self._constellation = constellation self._samples_per_symbol = samples_per_symbol self._excess_bw = excess_bw self._phase_bw = phase_bw self._freq_bw = freq_bw self._timing_bw = timing_bw self._timing_max_dev= _def_timing_max_dev self._differential = differential if self._samples_per_symbol < 2: raise TypeError, ("sbp must be >= 2, is %d" % self._samples_per_symbol) # Only apply a predifferential coding if the constellation also supports it. self.pre_diff_code = pre_diff_code and self._constellation.apply_pre_diff_code() arity = pow(2,self.bits_per_symbol()) nfilts = 32 ntaps = 11 * int(self._samples_per_symbol*nfilts) # Automatic gain control self.agc = analog.agc2_cc(0.6e-1, 1e-3, 1, 1, 100) # Frequency correction fll_ntaps = 55 self.freq_recov = digital.fll_band_edge_cc(self._samples_per_symbol, self._excess_bw, fll_ntaps, self._freq_bw) # symbol timing recovery with RRC data filter taps = filter.firdes.root_raised_cosine(nfilts, nfilts*self._samples_per_symbol, 1.0, self._excess_bw, ntaps) self.time_recov = digital.pfb_clock_sync_ccf(self._samples_per_symbol, self._timing_bw, taps, nfilts, nfilts//2, self._timing_max_dev) fmin = -0.25 fmax = 0.25 self.receiver = digital.constellation_receiver_cb( self._constellation.base(), self._phase_bw, fmin, fmax) # Do differential decoding based on phase change of symbols if differential: self.diffdec = digital.diff_decoder_bb(arity) if self.pre_diff_code: self.symbol_mapper = digital.map_bb( mod_codes.invert_code(self._constellation.pre_diff_code())) # unpack the k bit vector into a stream of bits self.unpack = blocks.unpack_k_bits_bb(self.bits_per_symbol()) if verbose: self._print_verbage() if log: self._setup_logging() # Connect and Initialize base class self._blocks = [self, self.agc, self.freq_recov, self.time_recov, self.receiver] if differential: self._blocks.append(self.diffdec) if self.pre_diff_code: self._blocks.append(self.symbol_mapper) self._blocks += [self.unpack, self] self.connect(*self._blocks)
def __init__(self, mode='433', input_rate=0, context=None): assert input_rate > 0 assert context is not None gr.hier_block2.__init__(self, type(self).__name__, gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(0, 0, 0)) # The input bandwidth chosen is not primarily determined by the bandwidth of the input signals, but by the frequency error of the transmitters. Therefore it is not too critical, and we can choose the exact rate to make the filtering easy. if input_rate <= upper_preferred_demod_rate: # Skip having a filter at all. self.__band_filter = None demod_rate = input_rate else: # TODO: This gunk is very similar to the stuff that MultistageChannelFilter does. See if we can share some code. lower_rate = input_rate lower_rate_prev = None while lower_rate > upper_preferred_demod_rate and lower_rate != lower_rate_prev: lower_rate_prev = lower_rate if lower_rate % 5 == 0 and lower_rate > upper_preferred_demod_rate * 3: lower_rate /= 5 elif lower_rate % 2 == 0: lower_rate /= 2 else: # non-integer ratio lower_rate = upper_preferred_demod_rate break demod_rate = lower_rate self.__band_filter = MultistageChannelFilter( input_rate=input_rate, output_rate=demod_rate, cutoff_freq=demod_rate * 0.4, transition_width=demod_rate * 0.2) # Subprocess # using /usr/bin/env because twisted spawnProcess doesn't support path search # pylint: disable=no-member process = the_reactor.spawnProcess( RTL433ProcessProtocol(context.output_message), '/usr/bin/env', env=None, # inherit environment args=[ 'env', 'rtl_433', '-F', 'json', '-r', '-', # read from stdin '-m', '3', # complex float input '-s', str(demod_rate), ], childFDs={ 0: 'w', 1: 'r', 2: 2 }) sink = make_sink_to_process_stdin(process, itemsize=gr.sizeof_gr_complex) agc = analog.agc2_cc(reference=dB(-4)) agc.set_attack_rate(200 / demod_rate) agc.set_decay_rate(200 / demod_rate) if self.__band_filter: self.connect(self, self.__band_filter, agc) else: self.connect(self, agc) self.connect(agc, sink)
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.data_rate_V2 = data_rate_V2 = 510*2 self.version_chooser = version_chooser = data_rate_V2 self.freq_range = freq_range = 433.995 self.audio_rate = audio_rate = 48000 self.trans = trans = 1.2e3 self.samp_rate = samp_rate = 2400000 self.samp_per_sym = samp_per_sym = audio_rate/version_chooser self.gain = gain = 390 self.freq_offset = freq_offset = 100e3 self.freq = freq = (0*433.886e6+0*433.877e6+0*433.995e6)+freq_range*1e6+100e3 self.data_rate_V1 = data_rate_V1 = 680 self.data_rate = data_rate = version_chooser self.channel_trans = channel_trans = 2000 self.channel_spacing = channel_spacing = 25e3 ################################################## # 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, "Frequency") 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, "Signal") 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, "Datarate") self.top_layout.addWidget(self.tab) self._gain_layout = Qt.QVBoxLayout() self._gain_tool_bar = Qt.QToolBar(self) self._gain_layout.addWidget(self._gain_tool_bar) self._gain_tool_bar.addWidget(Qt.QLabel("Decoder_Gain"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._gain_counter = qwt_counter_pyslot() self._gain_counter.setRange(0, 1000, 1) self._gain_counter.setNumButtons(2) self._gain_counter.setValue(self.gain) self._gain_tool_bar.addWidget(self._gain_counter) self._gain_counter.valueChanged.connect(self.set_gain) self._gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._gain_slider.setRange(0, 1000, 1) self._gain_slider.setValue(self.gain) self._gain_slider.setMinimumWidth(1000) self._gain_slider.valueChanged.connect(self.set_gain) self._gain_layout.addWidget(self._gain_slider) self.tab_layout_1.addLayout(self._gain_layout) self._version_chooser_options = [data_rate_V1, data_rate_V2] self._version_chooser_labels = ["V1","V2"] self._version_chooser_tool_bar = Qt.QToolBar(self) self._version_chooser_tool_bar.addWidget(Qt.QLabel("Oregon Scientific Version"+": ")) self._version_chooser_combo_box = Qt.QComboBox() self._version_chooser_tool_bar.addWidget(self._version_chooser_combo_box) for label in self._version_chooser_labels: self._version_chooser_combo_box.addItem(label) self._version_chooser_callback = lambda i: Qt.QMetaObject.invokeMethod(self._version_chooser_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._version_chooser_options.index(i))) self._version_chooser_callback(self.version_chooser) self._version_chooser_combo_box.currentIndexChanged.connect( lambda i: self.set_version_chooser(self._version_chooser_options[i])) self.tab_grid_layout_2.addWidget(self._version_chooser_tool_bar, 0,0) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #fc samp_rate, #bw "", #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) 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.tab_grid_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_win, 2,0) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype freq-freq_offset, #fc samp_rate/50, #bw "", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0/10) self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_layout_1.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(True) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1 ) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ["", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_1.addWidget(self._qtgui_number_sink_0_win, 0,0) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #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.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(1.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_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) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(True, 0) self.osmosdr_source_0.set_gain(10, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna("TX/RX", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(50, (firdes.low_pass(1, samp_rate, channel_spacing,channel_trans, firdes.WIN_BLACKMAN, 6.76)), -freq_offset, samp_rate) self._freq_range_layout = Qt.QVBoxLayout() self._freq_range_tool_bar = Qt.QToolBar(self) self._freq_range_layout.addWidget(self._freq_range_tool_bar) self._freq_range_tool_bar.addWidget(Qt.QLabel("Frequency"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._freq_range_counter = qwt_counter_pyslot() self._freq_range_counter.setRange(433, 434, 0.005) self._freq_range_counter.setNumButtons(2) self._freq_range_counter.setValue(self.freq_range) self._freq_range_tool_bar.addWidget(self._freq_range_counter) self._freq_range_counter.valueChanged.connect(self.set_freq_range) self._freq_range_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._freq_range_slider.setRange(433, 434, 0.005) self._freq_range_slider.setValue(self.freq_range) self._freq_range_slider.setMinimumWidth(1) self._freq_range_slider.valueChanged.connect(self.set_freq_range) self._freq_range_layout.addWidget(self._freq_range_slider) self.tab_grid_layout_0.addLayout(self._freq_range_layout, 1,0) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(samp_per_sym*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_1 = digital.binary_slicer_fb() self._data_rate_tool_bar = Qt.QToolBar(self) self._data_rate_tool_bar.addWidget(Qt.QLabel("Datarate"+": ")) self._data_rate_line_edit = Qt.QLineEdit(str(self.data_rate)) self._data_rate_tool_bar.addWidget(self._data_rate_line_edit) self._data_rate_line_edit.returnPressed.connect( lambda: self.set_data_rate(int(self._data_rate_line_edit.text().toAscii()))) self.tab_grid_layout_2.addWidget(self._data_rate_tool_bar, 1,0) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/tmp/fifo", False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_add_const_vxx_0 = blocks.add_const_vff((gain*1e-3, )) self.band_pass_filter_0 = filter.fir_filter_ccc(1, firdes.complex_band_pass( 1, samp_rate/50, -2500, 2500, trans, firdes.WIN_HAMMING, 6.76)) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=samp_rate/50, audio_decim=1, audio_pass=0*500+1*2500, audio_stop=5000, ) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1, 0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.digital_binary_slicer_fb_1, 0), (self.blocks_file_sink_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_1, 0)) self.connect((self.osmosdr_source_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self) _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.base_freq = base_freq = 121250000 self.t = 0 self.volume_min = 0.001 self.volume = volume = self.volume_min self.volume_max = 0.6 self.squelch = squelch = -26 self.samp_rate = samp_rate = 2400000 self.freq_corr = freq_corr = 31 self.freq = freq = base_freq self.frq_choices = [ 121250000, 121500000, 122200000, 123450000, 124175000, 124925000, 125450000, 130875000, 132700000, 134225000, 134925000, 136050000, 136575000, 169000000 ] # EPSD Port 122700000 EP Przelotowa 124500000 Air-To-Air 2 136975000 #self.frq_choices = [134225000] self.frq_labels = [ 'EPSC TWR', 'EP EMRG', 'EPSD Kwadrat', 'Air-To-Air', 'Mueritz EDWW Radar', 'B FIR Warszawa', 'EPWW Radar 2', 'EPWW Radar 3', 'EPWW Radar 4', 'D FIR Warszawa', 'EPWW Radar', 'Mark EDWW Radar', 'E FIR Warszawa', 'Lotnicze Pogotowie Ratunkowe' ] #self.frq_labels = ['D FIR Warszawa'] self.j = 0 ################################################## # Blocks ################################################## self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "") self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(freq_corr, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(49.6, 0) self.rtlsdr_source_0.set_if_gain(1, 0) self.rtlsdr_source_0.set_bb_gain(1, 0) self.rtlsdr_source_0.set_antenna("RX", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.signal_probe = blocks.probe_signal_c() #self.signal_probe = analog.probe_avg_mag_sqrd_c(0, 1) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 50, (firdes.low_pass_2(1, samp_rate, 25e3, 10e3, 40)), 0, samp_rate) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (volume, )) self.audio_sink_0 = audio.sink(48000, "hw:0,1", True) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc( squelch, 0.1, 0, False) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=48000, audio_decim=1, audio_pass=5000, audio_stop=5500, ) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 0.1e-4, 1.0, 0) self.analog_agc2_xx_0.set_max_gain(5) ################################################## # Connections ################################################## self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.signal_probe, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_agc2_xx_0, 0))
def __init__( self, pilot_carriers=((-40, -14, 13, 39),), pilot_symbols=((1, 1, 1, -1),), occupied_carriers=( [ -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, ], ), samp_rate=10000, payload_mod="qpsk", sync_word1=[ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.42, 0.0, -1.42, 0.0, -1.42, 0.0, 1.42, 0.0, 1.42, 0.0, -1.42, 0.0, -1.42, 0.0, -1.42, 0.0, 1.42, 0.0, -1.42, 0.0, 1.42, 0.0, 1.42, 0.0, 1.42, 0.0, 1.42, 0.0, 1.42, 0.0, -1.42, 0.0, -1.42, 0.0, -1.42, 0.0, -1.42, 0.0, -1.42, 0.0, 1.42, 0.0, -1.42, 0.0, -1.42, 0.0, 1.42, 0.0, -1.42, 0.0, 1.42, 0.0, -1.42, 0.0, 1.42, 0.0, -1.42, 0.0, 1.42, 0.0, 1.42, 0.0, 1.42, 0.0, -1.42, 0.0, 1.42, 0.0, 1.42, 0.0, 1.42, 0.0, -1.42, 0.0, 1.42, 0.0, 1.42, 0.0, 1.42, 0.0, 1.42, 0.0, -1.42, 0.0, 1.42, 0.0, -1.42, 0.0, -1.42, 0.0, -1.42, 0.0, 1.42, 0.0, -1.42, 0.0, 1.42, 0.0, -1.42, 0.0, -1.42, 0.0, -1.42, 0.0, -1.42, 0.0, -1.42, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, ], sync_word2=[ 0j, 0j, 0j, 0j, 0j, 0j, 0j, 0j, 0j, 0j, (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), 0j, (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), 0j, 0j, 0j, 0j, 0j, 0j, 0j, 0j, 0j, 0j, ], scramble_mode=0, crc_mode=0, clipper_mode=0, filter_mode=1, clipping_factor=10, ): gr.hier_block2.__init__( self, "Ofdm Radio Hier", gr.io_signaturev(2, 2, [gr.sizeof_char * 1, gr.sizeof_gr_complex * 1]), gr.io_signaturev(2, 2, [gr.sizeof_char * 1, gr.sizeof_gr_complex * 1]), ) ################################################## # Parameters ################################################## self.pilot_carriers = pilot_carriers self.pilot_symbols = pilot_symbols self.occupied_carriers = occupied_carriers self.samp_rate = samp_rate self.sync_word1 = sync_word1 self.sync_word2 = sync_word2 self.scramble_mode = scramble_mode self.crc_mode = crc_mode self.clipping_factor = clipping_factor self.clipper_mode = clipper_mode self.filter_mode = filter_mode if payload_mod == "qpsk": self.payload_mod = payload_mod = digital.constellation_qpsk() elif payload_mod == "qam16": self.payload_mod = payload_mod = digital.qam.qam_constellation(16, True, "none", False) elif payload_mod == "bpsk": self.payload_mod = payload_mod = digital.constellation_bpsk() ################################################## # Variables ################################################## self.packet_length_tag_key = packet_length_tag_key = "packet_len" self.length_tag_key = length_tag_key = "frame_len" self.header_mod = header_mod = digital.constellation_bpsk() self.fft_len = fft_len = (len(sync_word1) + len(sync_word2)) / 2 self.scramble_seed = scramble_seed = 0x7F self.rolloff = rolloff = 0 self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe( fft_len, payload_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 1 ) self.len_ocup_carr = len_ocup_carr = len(occupied_carriers[0]) self.header_formatter = header_formatter = digital.packet_header_ofdm( occupied_carriers, n_syms=1, len_tag_key=packet_length_tag_key, frame_len_tag_key=length_tag_key, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=payload_mod.bits_per_symbol(), scramble_header=True, ) self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe( fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols ) self.forward_OOB = forward_OOB = [ 0.40789374966665903, 3.2351160543115207, 11.253435139165413, 22.423991613997735, 27.99555756436666, 22.423991613997735, 11.253435139165425, 3.235116054311531, 0.40789374966666014, ] self.feedback_OOB = feedback_OOB = [ 1.0, 6.170110168740749, 16.888669609673336, 26.73762881119027, 26.75444043101795, 17.322358010203928, 7.091659316015212, 1.682084643429639, 0.17795354282083842, ] self.cp_len_0 = cp_len_0 = fft_len / 4 self.cp_len = cp_len = fft_len / 4 self.active_carriers = active_carriers = len(occupied_carriers[0]) + 4 ################################################## # Blocks ################################################## self.ofdm_tools_clipper_0 = ofdm_tools.clipper_cc(clipping_factor) self.iir_filter_xxx_1 = filter.iir_filter_ccd((forward_OOB), (feedback_OOB), False) self.fft_vxx_txpath = fft.fft_vcc(fft_len, False, (()), True, 1) self.fft_vxx_2_rxpath = fft.fft_vcc(fft_len, True, (), True, 1) self.fft_vxx_1_rxpath = fft.fft_vcc(fft_len, True, (()), True, 1) self.digital_packet_headerparser_b_rxpath = digital.packet_headerparser_b(header_formatter.base()) self.digital_packet_headergenerator_bb_txpath = digital.packet_headergenerator_bb( header_formatter.formatter(), "packet_len" ) self.digital_ofdm_sync_sc_cfb_rxpath = digital.ofdm_sync_sc_cfb(fft_len, fft_len / 4, False) self.digital_ofdm_serializer_vcc_payload_rxpath = digital.ofdm_serializer_vcc( fft_len, occupied_carriers, length_tag_key, packet_length_tag_key, 1, "", True ) self.digital_ofdm_serializer_vcc_header_rxpath = digital.ofdm_serializer_vcc( fft_len, occupied_carriers, length_tag_key, "", 0, "", True ) self.digital_ofdm_frame_equalizer_vcvc_2_rxpath = digital.ofdm_frame_equalizer_vcvc( payload_equalizer.base(), cp_len, length_tag_key, True, 0 ) self.digital_ofdm_frame_equalizer_vcvc_1_rxpath = digital.ofdm_frame_equalizer_vcvc( header_equalizer.base(), cp_len, length_tag_key, True, 1 ) self.digital_ofdm_cyclic_prefixer_txpath = digital.ofdm_cyclic_prefixer( fft_len, fft_len + cp_len, rolloff, packet_length_tag_key ) (self.digital_ofdm_cyclic_prefixer_txpath).set_min_output_buffer(24000) self.digital_ofdm_chanest_vcvc_rxpath = digital.ofdm_chanest_vcvc((sync_word1), (sync_word2), 1, 0, 3, False) self.digital_ofdm_carrier_allocator_cvc_txpath = digital.ofdm_carrier_allocator_cvc( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (sync_word1, sync_word2), packet_length_tag_key ) (self.digital_ofdm_carrier_allocator_cvc_txpath).set_min_output_buffer(16000) self.digital_header_payload_demux_rxpath = digital.header_payload_demux( 3, fft_len, cp_len, length_tag_key, "", True, gr.sizeof_gr_complex, "rx_time", samp_rate, () ) self.digital_crc32_bb_txpath = digital.crc32_bb(False, packet_length_tag_key) self.digital_crc32_bb_rxpath = digital.crc32_bb(True, packet_length_tag_key) self.digital_constellation_decoder_cb_1_rxpath = digital.constellation_decoder_cb(payload_mod.base()) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(header_mod.base()) self.digital_chunks_to_symbols_x_txpath = digital.chunks_to_symbols_bc((payload_mod.points()), 1) self.digital_chunks_to_symbols_txpath = digital.chunks_to_symbols_bc((header_mod.points()), 1) self.digital_additive_scrambler_bb_txpath_0 = digital.additive_scrambler_bb( 0x8A, 0x7F, 7, 0, bits_per_byte=8, reset_tag_key=self.packet_length_tag_key ) self.digital_additive_scrambler_bb_rxpath_0 = digital.additive_scrambler_bb( 0x8A, 0x7F, 7, 0, bits_per_byte=8, reset_tag_key=self.packet_length_tag_key ) self.blocks_tagged_stream_mux_txpath = blocks.tagged_stream_mux( gr.sizeof_gr_complex * 1, packet_length_tag_key, 0 ) (self.blocks_tagged_stream_mux_txpath).set_min_output_buffer(16000) self.blocks_tag_gate_txpath = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_repack_bits_bb_txpath = blocks.repack_bits_bb( 8, payload_mod.bits_per_symbol(), packet_length_tag_key, False ) self.blocks_repack_bits_bb_rxpath = blocks.repack_bits_bb( payload_mod.bits_per_symbol(), 8, packet_length_tag_key, True ) self.blocks_multiply_xx_rxpath = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.01,)) self.blocks_delay_rxpath = blocks.delay(gr.sizeof_gr_complex * 1, fft_len + fft_len / 4) self.blks2_selector_0_2 = grc_blks2.selector( item_size=gr.sizeof_gr_complex * 1, num_inputs=2, num_outputs=1, input_index=clipper_mode, output_index=0 ) self.blks2_selector_0_1 = grc_blks2.selector( item_size=gr.sizeof_char * 1, num_inputs=2, num_outputs=1, input_index=scramble_mode, output_index=0 ) self.blks2_selector_0_0_0 = grc_blks2.selector( item_size=gr.sizeof_char * 1, num_inputs=2, num_outputs=1, input_index=scramble_mode, output_index=0 ) self.blks2_selector_0_0 = grc_blks2.selector( item_size=gr.sizeof_char * 1, num_inputs=2, num_outputs=1, input_index=crc_mode, output_index=0 ) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_char * 1, num_inputs=2, num_outputs=1, input_index=crc_mode, output_index=0 ) self.blks2_selector_0_2_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex * 1, num_inputs=2, num_outputs=1, input_index=filter_mode, output_index=0 ) self.analog_frequency_modulator_fc_rxpath = analog.frequency_modulator_fc(-2.0 / fft_len) 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.digital_ofdm_sync_sc_cfb_rxpath, 0), (self.analog_frequency_modulator_fc_rxpath, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.digital_ofdm_sync_sc_cfb_rxpath, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.blocks_delay_rxpath, 0)) self.connect((self.digital_packet_headergenerator_bb_txpath, 0), (self.digital_chunks_to_symbols_txpath, 0)) self.connect((self.blocks_repack_bits_bb_txpath, 0), (self.digital_chunks_to_symbols_x_txpath, 0)) self.connect((self.digital_chunks_to_symbols_txpath, 0), (self.blocks_tagged_stream_mux_txpath, 0)) self.connect((self.digital_chunks_to_symbols_x_txpath, 0), (self.blocks_tagged_stream_mux_txpath, 1)) self.connect((self.digital_ofdm_cyclic_prefixer_txpath, 0), (self.blocks_tag_gate_txpath, 0)) self.connect((self.fft_vxx_txpath, 0), (self.digital_ofdm_cyclic_prefixer_txpath, 0)) self.connect((self.blocks_tagged_stream_mux_txpath, 0), (self.digital_ofdm_carrier_allocator_cvc_txpath, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_txpath, 0), (self.fft_vxx_txpath, 0)) self.connect((self.digital_header_payload_demux_rxpath, 0), (self.fft_vxx_1_rxpath, 0)) self.connect((self.fft_vxx_1_rxpath, 0), (self.digital_ofdm_chanest_vcvc_rxpath, 0)) self.connect( (self.digital_ofdm_frame_equalizer_vcvc_1_rxpath, 0), (self.digital_ofdm_serializer_vcc_header_rxpath, 0) ) self.connect((self.digital_ofdm_chanest_vcvc_rxpath, 0), (self.digital_ofdm_frame_equalizer_vcvc_1_rxpath, 0)) self.connect((self.digital_header_payload_demux_rxpath, 1), (self.fft_vxx_2_rxpath, 0)) self.connect( (self.digital_ofdm_frame_equalizer_vcvc_2_rxpath, 0), (self.digital_ofdm_serializer_vcc_payload_rxpath, 0) ) self.connect((self.fft_vxx_2_rxpath, 0), (self.digital_ofdm_frame_equalizer_vcvc_2_rxpath, 0)) self.connect( (self.digital_ofdm_serializer_vcc_payload_rxpath, 0), (self.digital_constellation_decoder_cb_1_rxpath, 0) ) self.connect((self.digital_constellation_decoder_cb_1_rxpath, 0), (self.blocks_repack_bits_bb_rxpath, 0)) self.connect((self.digital_ofdm_serializer_vcc_header_rxpath, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.analog_frequency_modulator_fc_rxpath, 0), (self.blocks_multiply_xx_rxpath, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_rxpath, 1), (self.digital_header_payload_demux_rxpath, 1)) self.connect((self.blocks_multiply_xx_rxpath, 0), (self.digital_header_payload_demux_rxpath, 0)) self.connect((self.blocks_delay_rxpath, 0), (self.blocks_multiply_xx_rxpath, 1)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_packet_headerparser_b_rxpath, 0)) self.connect((self, 0), (self.digital_crc32_bb_txpath, 0)) self.connect((self, 1), (self.analog_agc2_xx_0, 0)) self.connect((self.blocks_tag_gate_txpath, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self, 0), (self.blks2_selector_0, 0)) self.connect((self.digital_crc32_bb_txpath, 0), (self.blks2_selector_0, 1)) self.connect((self.blks2_selector_0_1, 0), (self.blocks_repack_bits_bb_txpath, 0)) self.connect((self.blks2_selector_0, 0), (self.digital_packet_headergenerator_bb_txpath, 0)) self.connect((self.blks2_selector_0, 0), (self.digital_additive_scrambler_bb_txpath_0, 0)) self.connect((self.digital_additive_scrambler_bb_txpath_0, 0), (self.blks2_selector_0_1, 1)) self.connect((self.blks2_selector_0, 0), (self.blks2_selector_0_1, 0)) self.connect((self.digital_crc32_bb_rxpath, 0), (self.blks2_selector_0_0, 1)) self.connect((self.digital_additive_scrambler_bb_rxpath_0, 0), (self.blks2_selector_0_0_0, 1)) self.connect((self.blocks_repack_bits_bb_rxpath, 0), (self.digital_additive_scrambler_bb_rxpath_0, 0)) self.connect((self.blocks_repack_bits_bb_rxpath, 0), (self.blks2_selector_0_0_0, 0)) self.connect((self.blks2_selector_0_0_0, 0), (self.digital_crc32_bb_rxpath, 0)) self.connect((self.blks2_selector_0_0_0, 0), (self.blks2_selector_0_0, 0)) self.connect((self.blks2_selector_0_0, 0), (self, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.ofdm_tools_clipper_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blks2_selector_0_2, 0)) self.connect(self.blks2_selector_0_2, self.iir_filter_xxx_1) self.connect(self.blks2_selector_0_2, (self.blks2_selector_0_2_0, 0)) self.connect(self.iir_filter_xxx_1, (self.blks2_selector_0_2_0, 1)) self.connect(self.blks2_selector_0_2_0, (self, 1)) self.connect((self.ofdm_tools_clipper_0, 0), (self.blks2_selector_0_2, 1)) ################################################## # Asynch Message Connections ################################################## self.msg_connect( self.digital_packet_headerparser_b_rxpath, "header_data", self.digital_header_payload_demux_rxpath, "header_data", )
def __init__(self, meta_rate=10): gr.top_block.__init__(self, "Fox1D Playback") Qt.QWidget.__init__(self) self.setWindowTitle("Fox1D Playback") 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", "fox1d_playback") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.meta_rate = meta_rate ################################################## # Variables ################################################## self.samp_rate = samp_rate = 250e3 self.decim = decim = 5 self.baud = baud = 9600 self.xlate_taps_old = xlate_taps_old = firdes.low_pass( 1.0, samp_rate, samp_rate / 2, 1000, firdes.WIN_HAMMING, 6.76) self.xlate_taps = xlate_taps = firdes.low_pass(1.0, samp_rate, 15e3, 1000, firdes.WIN_HAMMING, 6.76) self.volume = volume = 0.01 self.throttle_factor = throttle_factor = 1 self.samps_per_symb = samps_per_symb = samp_rate / decim / baud self.rf_lpf_cutoff = rf_lpf_cutoff = 8e3 self.fsk_deviation_hz = fsk_deviation_hz = 4000 self.fll_loop_bw_fine = fll_loop_bw_fine = 0.0001 self.fll_loop_bw = fll_loop_bw = math.pi / 200 self.audio_lpf_cutoff = audio_lpf_cutoff = 7e3 ################################################## # Blocks ################################################## self._volume_tool_bar = Qt.QToolBar(self) self._volume_tool_bar.addWidget(Qt.QLabel("volume" + ": ")) self._volume_line_edit = Qt.QLineEdit(str(self.volume)) self._volume_tool_bar.addWidget(self._volume_line_edit) self._volume_line_edit.returnPressed.connect(lambda: self.set_volume( eng_notation.str_to_num( str(self._volume_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._volume_tool_bar, 7, 4, 1, 2) for r in range(7, 8): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self._throttle_factor_tool_bar = Qt.QToolBar(self) self._throttle_factor_tool_bar.addWidget( Qt.QLabel("throttle_factor" + ": ")) self._throttle_factor_line_edit = Qt.QLineEdit( str(self.throttle_factor)) self._throttle_factor_tool_bar.addWidget( self._throttle_factor_line_edit) self._throttle_factor_line_edit.returnPressed.connect( lambda: self.set_throttle_factor( eng_notation.str_to_num( str(self._throttle_factor_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._throttle_factor_tool_bar, 6, 4, 1, 2) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self._rf_lpf_cutoff_tool_bar = Qt.QToolBar(self) self._rf_lpf_cutoff_tool_bar.addWidget( Qt.QLabel("rf_lpf_cutoff" + ": ")) self._rf_lpf_cutoff_line_edit = Qt.QLineEdit(str(self.rf_lpf_cutoff)) self._rf_lpf_cutoff_tool_bar.addWidget(self._rf_lpf_cutoff_line_edit) self._rf_lpf_cutoff_line_edit.returnPressed.connect( lambda: self.set_rf_lpf_cutoff( eng_notation.str_to_num( str(self._rf_lpf_cutoff_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._rf_lpf_cutoff_tool_bar, 6, 0, 1, 2) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._fll_loop_bw_fine_tool_bar = Qt.QToolBar(self) self._fll_loop_bw_fine_tool_bar.addWidget( Qt.QLabel("fll_loop_bw_fine" + ": ")) self._fll_loop_bw_fine_line_edit = Qt.QLineEdit( str(self.fll_loop_bw_fine)) self._fll_loop_bw_fine_tool_bar.addWidget( self._fll_loop_bw_fine_line_edit) self._fll_loop_bw_fine_line_edit.returnPressed.connect( lambda: self.set_fll_loop_bw_fine( eng_notation.str_to_num( str(self._fll_loop_bw_fine_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._fll_loop_bw_fine_tool_bar, 7, 2, 1, 2) for r in range(7, 8): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 4): self.top_grid_layout.setColumnStretch(c, 1) self._fll_loop_bw_tool_bar = Qt.QToolBar(self) self._fll_loop_bw_tool_bar.addWidget(Qt.QLabel("fll_loop_bw" + ": ")) self._fll_loop_bw_line_edit = Qt.QLineEdit(str(self.fll_loop_bw)) self._fll_loop_bw_tool_bar.addWidget(self._fll_loop_bw_line_edit) self._fll_loop_bw_line_edit.returnPressed.connect( lambda: self.set_fll_loop_bw( eng_notation.str_to_num( str(self._fll_loop_bw_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._fll_loop_bw_tool_bar, 6, 2, 1, 2) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 4): self.top_grid_layout.setColumnStretch(c, 1) self._audio_lpf_cutoff_tool_bar = Qt.QToolBar(self) self._audio_lpf_cutoff_tool_bar.addWidget( Qt.QLabel("audio_lpf_cutoff" + ": ")) self._audio_lpf_cutoff_line_edit = Qt.QLineEdit( str(self.audio_lpf_cutoff)) self._audio_lpf_cutoff_tool_bar.addWidget( self._audio_lpf_cutoff_line_edit) self._audio_lpf_cutoff_line_edit.returnPressed.connect( lambda: self.set_audio_lpf_cutoff( eng_notation.str_to_num( str(self._audio_lpf_cutoff_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._audio_lpf_cutoff_tool_bar, 7, 0, 1, 2) for r in range(7, 8): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=1, decimation=4, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=1, decimation=4, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=48, decimation=50, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0_0 = qtgui.waterfall_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim, #bw "corrected", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0_0.enable_grid(False) self.qtgui_waterfall_sink_x_0_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0_0.set_intensity_range(-80, 0) self._qtgui_waterfall_sink_x_0_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_0_win, 2, 4, 2, 4) for r in range(2, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim, #bw "Pre-D", #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(-80, 0) 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, 0, 4, 2, 4) for r in range(0, 2): 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( 1024, #size samp_rate / decim / 50 * 48, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 8, 0, 1, 8) for r in range(8, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_number_sink_0_0_0_0_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1) self.qtgui_number_sink_0_0_0_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0_0_0_0.set_title("") labels = ['SNR', '', '', '', '', '', '', '', '', ''] units = ['dB', '', '', '', '', '', '', '', '', ''] colors = [("blue", "red"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_0_0_0_0.set_min(i, 0) self.qtgui_number_sink_0_0_0_0_0.set_max(i, 30) self.qtgui_number_sink_0_0_0_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_0_0_0.set_label( i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_0_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0_0_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0_0_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_0_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_0_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_0_0_win, 6, 6, 1, 1) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 7): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_number_sink_0_0_0_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1) self.qtgui_number_sink_0_0_0_0.set_update_time(0.010) self.qtgui_number_sink_0_0_0_0.set_title("") labels = ['Freq Offset', 'Phase', 'Error', '', '', '', '', '', '', ''] units = ['Hz', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_0_0_0.set_min(i, -32767) self.qtgui_number_sink_0_0_0_0.set_max(i, 32767) self.qtgui_number_sink_0_0_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_0_0.set_label( i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_0_win, 6, 7, 1, 1) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(7, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim, #bw "Pre-D", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.010) self.qtgui_freq_sink_x_0.set_y_axis(-60, 0) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not 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 = ['pre-d', 'corr', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_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_0_0_0 = filter.fir_filter_fff( 1, firdes.low_pass(1, samp_rate / decim / 50 * 48, audio_lpf_cutoff, 2e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate / decim, rf_lpf_cutoff, 2e3, firdes.WIN_HAMMING, 6.76)) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( decim, (xlate_taps), 0, samp_rate) self.digital_fll_band_edge_cc_0_0 = digital.fll_band_edge_cc( samps_per_symb, .5, 1024, fll_loop_bw_fine) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc( samps_per_symb, .5, 1024, fll_loop_bw) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate * throttle_factor, True) self.blocks_tagged_stream_to_pdu_0_0 = blocks.tagged_stream_to_pdu( blocks.float_t, 'snr') self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.float_t, 'rfo') self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream( gr.sizeof_float, 1, 1, "snr") self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_float, 1, 1, "rfo") self.blocks_socket_pdu_0_0 = blocks.socket_pdu("TCP_SERVER", '0.0.0.0', '52002', 10000, False) self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", '0.0.0.0', '52001', 10000, False) self.blocks_null_sink_0_1 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_null_sink_0_0_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_nlog10_ff_0_1 = blocks.nlog10_ff(10, 1, 0) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff( (-1 * samp_rate / decim / (2 * math.pi), )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (volume, )) self.blocks_moving_average_xx_0_0_1 = blocks.moving_average_ff( 10000, 0.0001, 4000, 1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( 100000, 0.00001, 4000, 1) self.blocks_keep_one_in_n_0_0 = blocks.keep_one_in_n( gr.sizeof_float * 1, int(samp_rate * meta_rate)) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_float * 1, int(samp_rate / 4 * meta_rate)) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, '/home/zleffke/captures/fox1d/20180913/FOX-1D_USRP_20180913_151002.518249_UTC_250k.fc32', False) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared( 1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, samp_rate / 2, 1, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf( samp_rate / (2 * math.pi * fsk_deviation_hz / 8.0)) 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.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.blocks_socket_pdu_0, 'pdus')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0, 'pdus'), (self.blocks_socket_pdu_0_0, 'pdus')) self.connect((self.analog_agc2_xx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.low_pass_filter_0_0_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_divide_xx_0, 0), (self.blocks_nlog10_ff_0_1, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_stream_to_tagged_stream_0_0, 0)) self.connect((self.blocks_keep_one_in_n_0_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_keep_one_in_n_0_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.qtgui_number_sink_0_0_0_0, 0)) self.connect((self.blocks_moving_average_xx_0_0_1, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_moving_average_xx_0_0_1, 0), (self.qtgui_number_sink_0_0_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.blocks_nlog10_ff_0_1, 0), (self.blocks_moving_average_xx_0_0_1, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_0, 0), (self.blocks_tagged_stream_to_pdu_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 1), (self.blocks_add_xx_0, 1)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 2), (self.blocks_null_sink_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 3), (self.blocks_null_sink_0_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.digital_fll_band_edge_cc_0_0, 1), (self.blocks_add_xx_0, 0)) self.connect((self.digital_fll_band_edge_cc_0_0, 3), (self.blocks_null_sink_0_0_0, 0)) self.connect((self.digital_fll_band_edge_cc_0_0, 2), (self.blocks_null_sink_0_1, 0)) self.connect((self.digital_fll_band_edge_cc_0_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.digital_fll_band_edge_cc_0_0, 0), (self.qtgui_waterfall_sink_x_0_0, 0)) self.connect((self.digital_fll_band_edge_cc_0_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.digital_fll_band_edge_cc_0_0, 0)) self.connect((self.low_pass_filter_0_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_complex_to_mag_squared_0_0, 0))
def __init__(self, freq=1000): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Parameters ################################################## self.freq = freq ################################################## # Variables ################################################## self.samp_rate = samp_rate = 48000 ################################################## # Blocks ################################################## self.rational_resampler_xxx_1 = filter.rational_resampler_fff( interpolation=16, decimation=5, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=10, decimation=5, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) 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 "float" == "float" or "float" == "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, -60) 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) self.qtgui_histogram_sink_x_0 = qtgui.histogram_sink_f( 1024, 100, -1, 1, "", 1) self.qtgui_histogram_sink_x_0.set_update_time(0.10) self.qtgui_histogram_sink_x_0.enable_autoscale(True) self.qtgui_histogram_sink_x_0.enable_accumulate(False) self.qtgui_histogram_sink_x_0.enable_grid(False) self.qtgui_histogram_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_histogram_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_histogram_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_histogram_sink_x_0.set_line_label(i, labels[i]) self.qtgui_histogram_sink_x_0.set_line_width(i, widths[i]) self.qtgui_histogram_sink_x_0.set_line_color(i, colors[i]) self.qtgui_histogram_sink_x_0.set_line_style(i, styles[i]) self.qtgui_histogram_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_histogram_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_histogram_sink_x_0_win = sip.wrapinstance( self.qtgui_histogram_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_histogram_sink_x_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(True) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "float" == "float" or "float" == "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.low_pass_filter_0 = filter.fir_filter_ccf( 5, firdes.low_pass(1, samp_rate, 2500, 1, firdes.WIN_HAMMING, 6.76)) self.blocks_wavfile_source_0 = blocks.wavfile_source( '/home/andreas/gits/rf-receiver/Software/gnuradio/ssb.wav', True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((500, )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.audio_sink_0 = audio.sink(samp_rate, '', True) self.analog_sig_source_x_0_0 = analog.sig_source_f( samp_rate, analog.GR_SIN_WAVE, 1200, 0.5, 0) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 1200, 0.5, 0) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 651e3, 0.1, 1.0) self.analog_agc2_xx_0.set_max_gain(1) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_histogram_sink_x_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_wavfile_source_0, 1), (self.blocks_float_to_complex_0, 1)) self.connect((self.low_pass_filter_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.audio_sink_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Airband") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.volume = volume = 500e-3 self.samp_rate = samp_rate = 2.4e6 self.offset_freq1 = offset_freq1 = -300e3 self.freq_corr = freq_corr = 0 self.base_freq = base_freq = 27.315e6 ################################################## # Blocks ################################################## _volume_sizer = wx.BoxSizer(wx.VERTICAL) self._volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, label="Volume", converter=forms.float_converter(), proportion=0, ) self._volume_slider = forms.slider( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_volume_sizer) _freq_corr_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_corr_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_corr_sizer, value=self.freq_corr, callback=self.set_freq_corr, label="Freq correction (ppm)", converter=forms.int_converter(), proportion=0, ) self._freq_corr_slider = forms.slider( parent=self.GetWin(), sizer=_freq_corr_sizer, value=self.freq_corr, callback=self.set_freq_corr, minimum=-127, maximum=127, num_steps=254, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_freq_corr_sizer) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=5, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(base_freq, 0) self.rtlsdr_source_0.set_freq_corr(freq_corr, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(1, 0) self.rtlsdr_source_0.set_gain(49.6, 0) self.rtlsdr_source_0.set_if_gain(1, 0) self.rtlsdr_source_0.set_bb_gain(1, 0) self.rtlsdr_source_0.set_antenna("RX", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self._offset_freq1_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.offset_freq1, callback=self.set_offset_freq1, label="Frequency select", choices=[-800e3,-550e3, -300e3,300e3,500e3], labels=["TWR1 118.6M","TWR2 118.85M", "APP1 119.1M","APP2 119.7M","APP3 119.9M"], style=wx.RA_VERTICAL, ) self.Add(self._offset_freq1_chooser) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(50, (firdes.low_pass_2(1,samp_rate,25e3,10e3,40)), base_freq, samp_rate) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((volume, )) self.audio_sink_0 = audio.sink(48000, "pulse", True) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=48e3, audio_decim=1, audio_pass=5000, audio_stop=5500, ) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-5, 1, 0) self.analog_agc2_xx_0.set_max_gain(5) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0))
def __init__(self): gr.top_block.__init__(self, "APRS S-Gate") Qt.QWidget.__init__(self) self.setWindowTitle("APRS S-Gate") 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", "aprs_satgate") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.freq = freq = 145.825e6 self.variable_qtgui_label_0 = variable_qtgui_label_0 = int(freq) self.samp_rate = samp_rate = 2.4e6 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(4, 48000, 1200, 0.35, 16*48000/1200) self.rfgain = rfgain = 35 self.audio_mute = audio_mute = True self.afgain = afgain = -7 ################################################## # Blocks ################################################## self._rfgain_range = Range(0, 49, 1, 35, 200) self._rfgain_win = RangeWidget(self._rfgain_range, self.set_rfgain, 'RF Gain (dB)', "counter_slider", float) self.top_grid_layout.addWidget(self._rfgain_win, 3,0,1,1) self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_formatter = None else: self._variable_qtgui_label_0_formatter = lambda x: x self._variable_qtgui_label_0_tool_bar.addWidget(Qt.QLabel('Freq (Hz)'+": ")) self._variable_qtgui_label_0_label = Qt.QLabel(str(self._variable_qtgui_label_0_formatter(self.variable_qtgui_label_0))) self._variable_qtgui_label_0_tool_bar.addWidget(self._variable_qtgui_label_0_label) self.top_grid_layout.addWidget(self._variable_qtgui_label_0_tool_bar, 4,0,1,1) self.show_text_2 = display.show_text() self._show_text_2_win = sip.wrapinstance(self.show_text_2.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._show_text_2_win, 2,2,2,1) self.show_text_0 = display.show_text() self._show_text_0_win = sip.wrapinstance(self.show_text_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._show_text_0_win, 2,0,1,2) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 192e3, #bw "", #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) self.qtgui_waterfall_sink_x_0.enable_axis_labels(False) if not False: 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(-105, -20) 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, 0,2,1,1) self.qtgui_time_sink_x_2 = qtgui.time_sink_f( 2048, #size 1200, #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(-4, 4) self.qtgui_time_sink_x_2.set_y_label('Amplitude', "") self.qtgui_time_sink_x_2.enable_tags(-1, True) self.qtgui_time_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_2.enable_autoscale(False) self.qtgui_time_sink_x_2.enable_grid(True) self.qtgui_time_sink_x_2.enable_axis_labels(False) self.qtgui_time_sink_x_2.enable_control_panel(False) if not False: self.qtgui_time_sink_x_2.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [2, 2, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "blue", "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 = [0.7, 0.7, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_2.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_2.set_line_label(i, labels[i]) self.qtgui_time_sink_x_2.set_line_width(i, widths[i]) self.qtgui_time_sink_x_2.set_line_color(i, colors[i]) self.qtgui_time_sink_x_2.set_line_style(i, styles[i]) self.qtgui_time_sink_x_2.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_2.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_2_win = sip.wrapinstance(self.qtgui_time_sink_x_2.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_2_win, 1,0,1,3) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 144.39e6, #fc 192e3, #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(-120, -10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0.enable_axis_labels(False) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [2, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["red", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [0.8, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0,0,1,2) self.igate_aprs_pkt_gen_0 = igate.aprs_pkt_gen(120, 'YD1SDL-10', 'APGRC', 'WIDE2-2', 240, 3, '!0745.80S/11022.51E` Temporary / Experimental APRS I/S-Gate') self.igate_aprs_is_sink_0 = igate.aprs_is_sink('rotate.aprs.net', 14580, 'YD1SDL-10', 24505) self.igate_aprs_demod_0 = igate.aprs_demod(48000) self.gpredict_doppler_0 = gpredict.doppler(self.set_freq, "localhost", 4532, True) self.fft_filter_xxx_3 = filter.fft_filter_fff(1, (firdes.band_pass(0.5,48e3,1e3,2400,1e2,firdes.WIN_HAMMING)), 1) self.fft_filter_xxx_3.declare_sample_delay(0) self.fft_filter_xxx_2 = filter.fft_filter_fff(2, (firdes.band_pass(0.25,48e3,400,2500,500,firdes.WIN_BLACKMAN)), 1) self.fft_filter_xxx_2.declare_sample_delay(0) self.fft_filter_xxx_1 = filter.fft_filter_fff(1, (rrc_taps), 1) self.fft_filter_xxx_1.declare_sample_delay(0) self.fft_filter_xxx_0 = filter.fft_filter_ccc(1, (firdes.low_pass(1,48e3,1e3,1e2,firdes.WIN_BLACKMAN)), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_fff(48000 / 1200, 6.28 / 1000, (rrc_taps), 39, 20, 1.5, 1) self.blocks_wavfile_sink_0 = blocks.wavfile_sink('IO86-wav-dump.wav', 1, 24000, 16) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_rotator_cc_0 = blocks.rotator_cc(-1700 / 48e3 * 2 * math.pi) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, 10) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(int(10e3*math.pi), 1.0/(10e3*math.pi), 4000) self.blocks_float_to_complex_0_0 = blocks.float_to_complex(1) _audio_mute_check_box = Qt.QCheckBox('Audio Mute') self._audio_mute_choices = {True: True, False: False} self._audio_mute_choices_inv = dict((v,k) for k,v in self._audio_mute_choices.iteritems()) self._audio_mute_callback = lambda i: Qt.QMetaObject.invokeMethod(_audio_mute_check_box, "setChecked", Qt.Q_ARG("bool", self._audio_mute_choices_inv[i])) self._audio_mute_callback(self.audio_mute) _audio_mute_check_box.stateChanged.connect(lambda i: self.set_audio_mute(self._audio_mute_choices[bool(i)])) self.top_grid_layout.addWidget(_audio_mute_check_box, 4,1,1,1) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(48e3 / (2*math.pi*1200/8.0)) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-1, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) self.afsk_aprs2inet_1 = afsk.aprs2inet(12000, 4) self.afsk_afsk1200_0 = afsk.afsk1200(48000,4) self._afgain_range = Range(-20, -1, 0.1, -7, 200) self._afgain_win = RangeWidget(self._afgain_range, self.set_afgain, 'AF Gain (dB)', "counter_slider", float) self.top_grid_layout.addWidget(self._afgain_win, 3,1,1,1) self.RTL_APRS_RX_0 = RTL_APRS_RX( device_ppm=58, freq=freq, rf_gain=rfgain, samp_rate=samp_rate, ) ################################################## # Connections ################################################## self.msg_connect((self.igate_aprs_demod_0, 'out'), (self.igate_aprs_is_sink_0, 'in')) self.msg_connect((self.igate_aprs_pkt_gen_0, 'out'), (self.igate_aprs_is_sink_0, 'in')) self.connect((self.RTL_APRS_RX_0, 1), (self.fft_filter_xxx_2, 0)) self.connect((self.RTL_APRS_RX_0, 1), (self.fft_filter_xxx_3, 0)) self.connect((self.RTL_APRS_RX_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.RTL_APRS_RX_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.afsk_afsk1200_0, 0), (self.show_text_2, 0)) self.connect((self.afsk_aprs2inet_1, 0), (self.show_text_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_float_to_complex_0_0, 0), (self.blocks_rotator_cc_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_repeat_0, 0), (self.afsk_aprs2inet_1, 0)) self.connect((self.blocks_rotator_cc_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.fft_filter_xxx_1, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_time_sink_x_2, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.fft_filter_xxx_1, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.fft_filter_xxx_2, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.fft_filter_xxx_3, 0), (self.afsk_afsk1200_0, 0)) self.connect((self.fft_filter_xxx_3, 0), (self.blocks_float_to_complex_0_0, 0)) self.connect((self.fft_filter_xxx_3, 0), (self.igate_aprs_demod_0, 0))
def __init__(self): gr.top_block.__init__(self, "Nexrad Playback Sigmf") Qt.QWidget.__init__(self) self.setWindowTitle("Nexrad Playback Sigmf") 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", "nexrad_playback_sigmf") 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.tune = tune = 1e6 self.trig_lvl = trig_lvl = 30 self.throttle_rate = throttle_rate = 0.5 self.thresh_lo = thresh_lo = 10000 self.thresh_hi = thresh_hi = 10000 self.samp_rate = samp_rate = 15e6 self.lpf_trans = lpf_trans = 500e3 self.lpf_cutoff = lpf_cutoff = .45e6 self.look_ahead = look_ahead = 10 self.decim = decim = 1 self.alpha_0 = alpha_0 = 1 self.alpha = alpha = 0.01 ################################################## # Blocks ################################################## self._tune_tool_bar = Qt.QToolBar(self) self._tune_tool_bar.addWidget(Qt.QLabel('tune' + ": ")) self._tune_line_edit = Qt.QLineEdit(str(self.tune)) self._tune_tool_bar.addWidget(self._tune_line_edit) self._tune_line_edit.returnPressed.connect(lambda: self.set_tune( eng_notation.str_to_num(str(self._tune_line_edit.text())))) self.top_grid_layout.addWidget(self._tune_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._trig_lvl_tool_bar = Qt.QToolBar(self) self._trig_lvl_tool_bar.addWidget(Qt.QLabel('trig_lvl' + ": ")) self._trig_lvl_line_edit = Qt.QLineEdit(str(self.trig_lvl)) self._trig_lvl_tool_bar.addWidget(self._trig_lvl_line_edit) self._trig_lvl_line_edit.returnPressed.connect( lambda: self.set_trig_lvl( eng_notation.str_to_num(str(self._trig_lvl_line_edit.text())))) self.top_grid_layout.addWidget(self._trig_lvl_tool_bar, 3, 4, 1, 1) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 5): self.top_grid_layout.setColumnStretch(c, 1) 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())))) self.top_grid_layout.addWidget(self._throttle_rate_tool_bar, 3, 5, 1, 1) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(5, 6): self.top_grid_layout.setColumnStretch(c, 1) self._thresh_lo_tool_bar = Qt.QToolBar(self) self._thresh_lo_tool_bar.addWidget(Qt.QLabel('thresh_lo' + ": ")) self._thresh_lo_line_edit = Qt.QLineEdit(str(self.thresh_lo)) self._thresh_lo_tool_bar.addWidget(self._thresh_lo_line_edit) self._thresh_lo_line_edit.returnPressed.connect( lambda: self.set_thresh_lo( eng_notation.str_to_num(str(self._thresh_lo_line_edit.text())) )) self.top_grid_layout.addWidget(self._thresh_lo_tool_bar, 0, 7, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(7, 8): self.top_grid_layout.setColumnStretch(c, 1) self._thresh_hi_tool_bar = Qt.QToolBar(self) self._thresh_hi_tool_bar.addWidget(Qt.QLabel('thresh_hi' + ": ")) self._thresh_hi_line_edit = Qt.QLineEdit(str(self.thresh_hi)) self._thresh_hi_tool_bar.addWidget(self._thresh_hi_line_edit) self._thresh_hi_line_edit.returnPressed.connect( lambda: self.set_thresh_hi( eng_notation.str_to_num(str(self._thresh_hi_line_edit.text())) )) self.top_grid_layout.addWidget(self._thresh_hi_tool_bar, 0, 6, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 7): self.top_grid_layout.setColumnStretch(c, 1) self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel('samp_rate' + ": ")) self._samp_rate_line_edit = Qt.QLineEdit(str(self.samp_rate)) self._samp_rate_tool_bar.addWidget(self._samp_rate_line_edit) self._samp_rate_line_edit.returnPressed.connect( lambda: self.set_samp_rate( eng_notation.str_to_num(str(self._samp_rate_line_edit.text())) )) self.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._lpf_trans_tool_bar = Qt.QToolBar(self) self._lpf_trans_tool_bar.addWidget(Qt.QLabel('lpf_trans' + ": ")) self._lpf_trans_line_edit = Qt.QLineEdit(str(self.lpf_trans)) self._lpf_trans_tool_bar.addWidget(self._lpf_trans_line_edit) self._lpf_trans_line_edit.returnPressed.connect( lambda: self.set_lpf_trans( eng_notation.str_to_num(str(self._lpf_trans_line_edit.text())) )) self.top_grid_layout.addWidget(self._lpf_trans_tool_bar, 2, 5, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(5, 6): self.top_grid_layout.setColumnStretch(c, 1) self._lpf_cutoff_tool_bar = Qt.QToolBar(self) self._lpf_cutoff_tool_bar.addWidget(Qt.QLabel('lpf_cutoff' + ": ")) self._lpf_cutoff_line_edit = Qt.QLineEdit(str(self.lpf_cutoff)) self._lpf_cutoff_tool_bar.addWidget(self._lpf_cutoff_line_edit) self._lpf_cutoff_line_edit.returnPressed.connect( lambda: self.set_lpf_cutoff( eng_notation.str_to_num(str(self._lpf_cutoff_line_edit.text())) )) self.top_grid_layout.addWidget(self._lpf_cutoff_tool_bar, 2, 4, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 5): self.top_grid_layout.setColumnStretch(c, 1) self._alpha_0_tool_bar = Qt.QToolBar(self) self._alpha_0_tool_bar.addWidget(Qt.QLabel('alpha_0' + ": ")) self._alpha_0_line_edit = Qt.QLineEdit(str(self.alpha_0)) self._alpha_0_tool_bar.addWidget(self._alpha_0_line_edit) self._alpha_0_line_edit.returnPressed.connect(lambda: self.set_alpha_0( eng_notation.str_to_num(str(self._alpha_0_line_edit.text())))) self.top_grid_layout.addWidget(self._alpha_0_tool_bar, 2, 6, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 7): self.top_grid_layout.setColumnStretch(c, 1) self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff( alpha_0, 1) self.sigmf_source_0 = gr_sigmf.source( '/captures/20191214/NEXRAD_2019-12-14T23:24:46Z.sigmf-data', "ci16" + ("_le" if sys.byteorder == "little" else "_be"), True) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 1024 * 16 * 100, #size samp_rate / decim, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(0, 2) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, .5, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(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, 7, 4, 1, 4) for r in range(7, 8): 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( 1024 * 16 * 100, #size samp_rate / decim, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(0, 50) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, trig_lvl, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) 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] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(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, 4, 4, 3, 4) for r in range(4, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.low_pass_filter_0 = filter.fir_filter_ccf( decim, firdes.low_pass(1, samp_rate, lpf_cutoff, lpf_trans, firdes.WIN_HAMMING, 6.76)) self._look_ahead_tool_bar = Qt.QToolBar(self) self._look_ahead_tool_bar.addWidget(Qt.QLabel('look_ahead' + ": ")) self._look_ahead_line_edit = Qt.QLineEdit(str(self.look_ahead)) self._look_ahead_tool_bar.addWidget(self._look_ahead_line_edit) self._look_ahead_line_edit.returnPressed.connect( lambda: self.set_look_ahead( int(str(self._look_ahead_line_edit.text())))) self.top_grid_layout.addWidget(self._look_ahead_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.fosphor_qt_sink_c_0 = fosphor.qt_sink_c() self.fosphor_qt_sink_c_0.set_fft_window(window.WIN_BLACKMAN_hARRIS) self.fosphor_qt_sink_c_0.set_frequency_range(0, samp_rate / decim) self._fosphor_qt_sink_c_0_win = sip.wrapinstance( self.fosphor_qt_sink_c_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._fosphor_qt_sink_c_0_win, 0, 0, 8, 4) for r in range(0, 8): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_short * 2, samp_rate * throttle_rate, True) self.blocks_threshold_ff_0 = blocks.threshold_ff( thresh_hi, thresh_lo, 0) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_xx_0 = blocks.multiply_const_cc( 1.0 / 65536.0, 1) self.blocks_interleaved_short_to_complex_0 = blocks.interleaved_short_to_complex( True, False) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, tune, 1, 0, 0) 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) self._alpha_tool_bar = Qt.QToolBar(self) self._alpha_tool_bar.addWidget(Qt.QLabel('alpha' + ": ")) self._alpha_line_edit = Qt.QLineEdit(str(self.alpha)) self._alpha_tool_bar.addWidget(self._alpha_line_edit) self._alpha_line_edit.returnPressed.connect(lambda: self.set_alpha( eng_notation.str_to_num(str(self._alpha_line_edit.text())))) self.top_grid_layout.addWidget(self._alpha_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) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.single_pole_iir_filter_xx_0, 0)) self.connect((self.blocks_interleaved_short_to_complex_0, 0), (self.blocks_multiply_const_xx_0, 0)) self.connect((self.blocks_multiply_const_xx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_interleaved_short_to_complex_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.fosphor_qt_sink_c_0, 0)) self.connect((self.sigmf_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_threshold_ff_0, 0))
def __init__(self): gr.top_block.__init__(self, "Lms6 To Wav") Qt.QWidget.__init__(self) self.setWindowTitle("Lms6 To Wav") 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", "lms6_to_wav") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 50e3 self.decim = decim = 1 self.baud = baud = 4800 self.xlate_taps = xlate_taps = firdes.low_pass(1.0, samp_rate, samp_rate / 2, 1000, firdes.WIN_HAMMING, 6.76) self.samps_per_symb = samps_per_symb = samp_rate / decim * 24 / 25 / baud self.offset = offset = .5e3 self.fsk_deviation_hz = fsk_deviation_hz = 4000 self.delay = delay = 0 ################################################## # Blocks ################################################## self._offset_tool_bar = Qt.QToolBar(self) self._offset_tool_bar.addWidget(Qt.QLabel('OFFSET' + ": ")) self._offset_line_edit = Qt.QLineEdit(str(self.offset)) self._offset_tool_bar.addWidget(self._offset_line_edit) self._offset_line_edit.returnPressed.connect(lambda: self.set_offset( eng_notation.str_to_num( str(self._offset_line_edit.text().toAscii())))) self.top_layout.addWidget(self._offset_tool_bar) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=24, decimation=25, taps=None, fractional_bw=None, ) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.010) self.qtgui_freq_sink_x_0.set_y_axis(-80, 0) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 3, 3) self.low_pass_filter_0 = filter.fir_filter_ccf( decim, firdes.low_pass(1, samp_rate, 6e3, 2e3, firdes.WIN_HAMMING, 6.76)) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 1, (xlate_taps), offset, samp_rate) self._delay_range = Range(0, 1000, 1, 0, 200) self._delay_win = RangeWidget(self._delay_range, self.set_delay, "delay", "counter_slider", float) self.top_layout.addWidget(self._delay_win) self.blocks_wavfile_sink_0 = blocks.wavfile_sink( '/home/zleffke/captures/radiosonde/lms6_1.wav', 1, 48000, 8) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, '/home/zleffke/captures/radiosonde/BBNWS_LMS6_USRP_20171203_010607.352482_UTC_50k.fc32', False) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=int(samp_rate / decim * 24 / 25), quad_rate=int(samp_rate / decim * 24 / 25), tau=75e-6, max_dev=5e3, ) 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.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.analog_nbfm_rx_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_nbfm_rx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Inmarsat Playback") Qt.QWidget.__init__(self) self.setWindowTitle("Inmarsat Playback") 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", "inmarsat_playback") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 250e3 self.interp = interp = 48 self.decim = decim = 250 self.baud = baud = 1200 self.samp_per_sym = samp_per_sym = (samp_rate / decim * interp) / baud self.alpha = alpha = 0.5 self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass( 1, samp_rate, samp_rate / 2, 1000, firdes.WIN_HAMMING, 6.76) self.rrc_filter_taps = rrc_filter_taps = firdes.root_raised_cosine( 32, 1.0, 1.0 / (samp_per_sym * 32), alpha, int(samp_per_sym * 32)) self.loop_bw = loop_bw = 300 self.freq_correct = freq_correct = -28.7e3 self.delay = delay = 0 self.cutoff = cutoff = 4800 self.cols = cols = 54 ################################################## # Blocks ################################################## self._freq_correct_tool_bar = Qt.QToolBar(self) self._freq_correct_tool_bar.addWidget(Qt.QLabel("freq_correct" + ": ")) self._freq_correct_line_edit = Qt.QLineEdit(str(self.freq_correct)) self._freq_correct_tool_bar.addWidget(self._freq_correct_line_edit) self._freq_correct_line_edit.returnPressed.connect( lambda: self.set_freq_correct( eng_notation.str_to_num( str(self._freq_correct_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._freq_correct_tool_bar, 12, 0, 1, 2) 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, 12, 2, 1, 2) self._cutoff_tool_bar = Qt.QToolBar(self) self._cutoff_tool_bar.addWidget(Qt.QLabel("cutoff" + ": ")) self._cutoff_line_edit = Qt.QLineEdit(str(self.cutoff)) self._cutoff_tool_bar.addWidget(self._cutoff_line_edit) self._cutoff_line_edit.returnPressed.connect(lambda: self.set_cutoff( eng_notation.str_to_num( str(self._cutoff_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._cutoff_tool_bar, 13, 0, 1, 2) self._cols_range = Range(1, 500, 1, 54, 200) self._cols_win = RangeWidget(self._cols_range, self.set_cols, "cols", "counter_slider", float) self.top_grid_layout.addWidget(self._cols_win, 12, 4, 1, 4) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=interp, decimation=decim, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=1, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim * interp, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0_0.set_update_time(0.01) self.qtgui_waterfall_sink_x_0_0.enable_grid(True) self.qtgui_waterfall_sink_x_0_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0_0.set_intensity_range(-60, -10) self._qtgui_waterfall_sink_x_0_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_0_win, 4, 4, 4, 4) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.01) self.qtgui_waterfall_sink_x_0.enable_grid(True) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-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) self.qtgui_time_raster_sink_x_0 = qtgui.time_raster_sink_b( samp_rate, 20, cols, ([]), ([]), "", 1, ) self.qtgui_time_raster_sink_x_0.set_update_time(0.10) self.qtgui_time_raster_sink_x_0.set_intensity_range(-1, 1) self.qtgui_time_raster_sink_x_0.enable_grid(False) self.qtgui_time_raster_sink_x_0.enable_axis_labels(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_time_raster_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_raster_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_raster_sink_x_0.set_color_map(i, colors[i]) self.qtgui_time_raster_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_raster_sink_x_0_win = sip.wrapinstance( self.qtgui_time_raster_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_raster_sink_x_0_win, 8, 4, 4, 4) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_f( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim * interp, #bw "baud", #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(1.0) 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 "float" == "float" or "float" == "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.top_layout.addWidget(self._qtgui_freq_sink_x_1_win) self.qtgui_freq_sink_x_0_0_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim * interp, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0_0.set_update_time(0.01) self.qtgui_freq_sink_x_0_0_0.set_y_axis(-60, -10) self.qtgui_freq_sink_x_0_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0_0.enable_grid(True) self.qtgui_freq_sink_x_0_0_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0_0.set_plot_pos_half(not True) labels = ['', 'corrected', '', '', '', '', '', '', '', ''] 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_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_0_win, 0, 4, 4, 4) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "pre-d", #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(-100, -20) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['pre-d', 'corrected', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 4, 4) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 8, 0, 1, 4) self.mapper_demapper_soft_0 = mapper.demapper_soft( mapper.BPSK, ([0, 1])) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate / decim * interp, cutoff, 1000, firdes.WIN_HAMMING, 6.76)) self.freq_xlating_fir_filter_xxx_0_1 = filter.freq_xlating_fir_filter_ccc( 1, (xlate_filter_taps), freq_correct, samp_rate) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 1, (xlate_filter_taps), 0, samp_rate) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( math.pi * 2 / loop_bw, 2, False) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc( samp_per_sym * (1 + 0.0), 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, '/home/zleffke/github/eclipse2017/waveforms/playback/GS1_4F3_20170821_151602.312844_UTC_250k.fc32', True) self.blocks_delay_1 = blocks.delay(gr.sizeof_char * 1, delay) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1) self.blocks_conjugate_cc_0 = blocks.conjugate_cc() self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.analog_agc2_xx_0 = analog.agc2_cc(1e-4, 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.rational_resampler_xxx_0_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_delay_0, 0), (self.blocks_conjugate_cc_0, 0)) self.connect((self.blocks_delay_1, 0), (self.qtgui_time_raster_sink_x_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.mapper_demapper_soft_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.blocks_delay_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_delay_1, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.freq_xlating_fir_filter_xxx_0_1, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0_1, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.mapper_demapper_soft_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_waterfall_sink_x_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.qtgui_freq_sink_x_0_0_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="air band receiver") _icon_path = "C:\Program Files\GNURadio-3.7\share\icons\hicolor\scalable/apps\gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.volume = volume = 1 self.sql = sql = 0 self.samp_rate = samp_rate = 2.4e6 self.rfgain = rfgain = 50 self.frq_corr = frq_corr = 30 self.base_freq = base_freq = 120.5e6 ################################################## # Blocks ################################################## _volume_sizer = wx.BoxSizer(wx.VERTICAL) self._volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, label='Volume', converter=forms.float_converter(), proportion=0, ) self._volume_slider = forms.slider( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_volume_sizer) _sql_sizer = wx.BoxSizer(wx.VERTICAL) self._sql_text_box = forms.text_box( parent=self.GetWin(), sizer=_sql_sizer, value=self.sql, callback=self.set_sql, label='Squelch', converter=forms.float_converter(), proportion=0, ) self._sql_slider = forms.slider( parent=self.GetWin(), sizer=_sql_sizer, value=self.sql, callback=self.set_sql, minimum=-100, maximum=100, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_sql_sizer) _rfgain_sizer = wx.BoxSizer(wx.VERTICAL) self._rfgain_text_box = forms.text_box( parent=self.GetWin(), sizer=_rfgain_sizer, value=self.rfgain, callback=self.set_rfgain, label='RF_Gain', converter=forms.float_converter(), proportion=0, ) self._rfgain_slider = forms.slider( parent=self.GetWin(), sizer=_rfgain_sizer, value=self.rfgain, callback=self.set_rfgain, minimum=0, maximum=50, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_rfgain_sizer) _frq_corr_sizer = wx.BoxSizer(wx.VERTICAL) self._frq_corr_text_box = forms.text_box( parent=self.GetWin(), sizer=_frq_corr_sizer, value=self.frq_corr, callback=self.set_frq_corr, label='freq_correction(ppm)', converter=forms.float_converter(), proportion=0, ) self._frq_corr_slider = forms.slider( parent=self.GetWin(), sizer=_frq_corr_sizer, value=self.frq_corr, callback=self.set_frq_corr, minimum=-127, maximum=127, num_steps=254, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_frq_corr_sizer) self.wxgui_fftsink2_0_0_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate / 50, fft_size=512, fft_rate=5, average=False, avg_alpha=None, title='FFT Plot', peak_hold=False, ) self.Add(self.wxgui_fftsink2_0_0_0.win) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + 'rtl_tcp=192.168.10.109:1235') self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(base_freq, 0) self.osmosdr_source_0.set_freq_corr(frq_corr, 0) self.osmosdr_source_0.set_dc_offset_mode(2, 0) self.osmosdr_source_0.set_iq_balance_mode(2, 0) self.osmosdr_source_0.set_gain_mode(True, 0) self.osmosdr_source_0.set_gain(rfgain, 0) self.osmosdr_source_0.set_if_gain(0, 0) self.osmosdr_source_0.set_bb_gain(0, 0) self.osmosdr_source_0.set_antenna('RX', 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 50, (firdes.low_pass_2(1, samp_rate, 25e3, 10e3, 40)), 0, samp_rate) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short * 1, '192.168.10.30', 8082, 1472, True) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (volume, )) self.blocks_float_to_short_0 = blocks.float_to_short(1, 32767) self.audio_sink_0 = audio.sink(48000, '', True) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc( sql, 1e-4, 0, False) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=48e3, audio_decim=1, audio_pass=5000, audio_stop=5500, ) self.analog_agc2_xx_0 = analog.agc2_cc(1e-3, 1e-5, 1.0, 0) self.analog_agc2_xx_0.set_max_gain(5) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.wxgui_fftsink2_0_0_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.blocks_float_to_short_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.blocks_float_to_short_0, 0), (self.blocks_udp_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Lang Tx") ################################################## # Variables ################################################## self.PTT = PTT = False self.Mode = Mode = 0 self.MicGain = MicGain = 5.0 self.KEY = KEY = False self.Filt_Low = Filt_Low = 300 self.Filt_High = Filt_High = 3000 self.FMMIC = FMMIC = 50 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=11, decimation=1, taps=None, fractional_bw=None, ) self.pluto_sink_0 = iio.pluto_sink('ip:pluto.local', 1000000000, 528000, 2000000, 0x800, False, 0, '', True) self.blocks_mute_xx_0_0 = blocks.mute_cc(bool(not PTT)) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_4 = blocks.multiply_const_vcc( ((Mode < 4) or (Mode == 5), )) self.blocks_multiply_const_vxx_3 = blocks.multiply_const_vcc( (Mode == 4, )) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff( (FMMIC / 10.0, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( ((MicGain / 10.0) * (not (Mode == 2)) * (not (Mode == 3)), )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_add_xx_2 = blocks.add_vcc(1) self.blocks_add_const_vxx_0 = blocks.add_const_vcc( ((0.5 * int(Mode == 5)) + (int(Mode == 2) * KEY) + (int(Mode == 3) * KEY), )) self.band_pass_filter_1 = filter.fir_filter_fff( 1, firdes.band_pass(1, 48000, 200, 3000, 100, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0_0 = filter.fir_filter_ccc( 1, firdes.complex_band_pass(1, 48000, Filt_Low, Filt_High, 100, firdes.WIN_HAMMING, 6.76)) self.audio_source_0 = audio.source(48000, "hw:CARD=Device,DEV=0", False) self.analog_sig_source_x_0 = analog.sig_source_c( 48000, analog.GR_COS_WAVE, 0, 1, 0) self.analog_nbfm_tx_0 = analog.nbfm_tx( audio_rate=48000, quad_rate=48000, tau=75e-6, max_dev=3000, fh=-1, ) self.analog_const_source_x_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 0) self.analog_agc2_xx_1 = analog.agc2_cc(1e-1, 1e-1, 1.3 - (0.65 * (int(Mode == 5))), 1.0) self.analog_agc2_xx_1.set_max_gain(10) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_1, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.analog_nbfm_tx_0, 0), (self.blocks_multiply_const_vxx_3, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.audio_source_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.audio_source_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.blocks_multiply_const_vxx_4, 0)) self.connect((self.band_pass_filter_1, 0), (self.analog_nbfm_tx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_add_xx_2, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.band_pass_filter_1, 0)) self.connect((self.blocks_multiply_const_vxx_3, 0), (self.blocks_add_xx_2, 0)) self.connect((self.blocks_multiply_const_vxx_4, 0), (self.blocks_add_xx_2, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.analog_agc2_xx_1, 0)) self.connect((self.blocks_mute_xx_0_0, 0), (self.pluto_sink_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_mute_xx_0_0, 0))
def __init__(self, mode, audio_rate=0, **kwargs): if mode == 'LSB': lsb = True cw = False elif mode == 'USB': lsb = False cw = False elif mode == 'CW': lsb = False cw = True else: raise ValueError('Not an SSB mode: %r' % (mode,)) demod_rate = audio_rate SimpleAudioDemodulator.__init__(self, mode=mode, audio_rate=audio_rate, demod_rate=demod_rate, band_filter=audio_rate / 2, # note narrower filter applied later band_filter_transition=audio_rate / 2, **kwargs) input_rate = self.input_rate if cw: self.__offset = 1500 half_bandwidth = self.half_bandwidth = 500 self.band_filter_width = 120 band_mid = 0 agc_reference = 0.1 else: self.__offset = 0 half_bandwidth = self.half_bandwidth = 2800 / 2 self.band_filter_width = half_bandwidth / 5 if lsb: band_mid = -200 - half_bandwidth else: band_mid = 200 + half_bandwidth agc_reference = 0.25 self.band_filter_low = band_mid - half_bandwidth self.band_filter_high = band_mid + half_bandwidth self.sharp_filter_block = grfilter.fir_filter_ccc( 1, firdes.complex_band_pass(1.0, demod_rate, self.band_filter_low + self.__offset, self.band_filter_high + self.__offset, self.band_filter_width, firdes.WIN_HAMMING)) self.agc_block = analog.agc2_cc(reference=agc_reference) self.ssb_demod_block = blocks.complex_to_real(1) self.connect( self, self.band_filter_block, self.sharp_filter_block, self.rf_squelch_block, self.agc_block, self.ssb_demod_block) self.connect(self.sharp_filter_block, self.rf_probe_block) self.connect_audio_output(self.ssb_demod_block, self.ssb_demod_block)
def __init__(self): gr.top_block.__init__(self, "Adsb Sigmf Playback") Qt.QWidget.__init__(self) self.setWindowTitle("Adsb Sigmf Playback") 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", "adsb_sigmf_playback") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.threshold = threshold = 10 self.samp_rate = samp_rate = 2e6 self.fine_tune = fine_tune = 0 ################################################## # Blocks ################################################## self._threshold_tool_bar = Qt.QToolBar(self) self._threshold_tool_bar.addWidget(Qt.QLabel('Detection Threshold'+": ")) self._threshold_line_edit = Qt.QLineEdit(str(self.threshold)) self._threshold_tool_bar.addWidget(self._threshold_line_edit) self._threshold_line_edit.returnPressed.connect( lambda: self.set_threshold(eng_notation.str_to_num(str(self._threshold_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._threshold_tool_bar, 5, 4, 1, 2) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self._fine_tune_range = Range(-100000, 100000, 1, 0, 200) self._fine_tune_win = RangeWidget(self._fine_tune_range, self.set_fine_tune, "fine_tune", "counter_slider", float) self.top_grid_layout.addWidget(self._fine_tune_win, 4, 4, 1, 4) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.sigmf_source_0 = gr_sigmf.source('/home/zleffke/captures/nsat/20190420/discone_test_1/017_ADSB_Multiple_2019-04-20T17:36:43.sigmf-data', "cf32" + ("_le" if sys.byteorder == "little" else "_be"), True) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=10, taps=None, fractional_bw=None, ) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( int(samp_rate*8*150e-6), #size int(samp_rate*8), #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(1.0/100.0) self.qtgui_time_sink_x_0.set_y_axis(0, 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_TAG, qtgui.TRIG_SLOPE_POS, 0, 1.25e-6, 0, "burst") 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 False: 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 = [0, -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, 4, 0, 2, 4) for r in range(4, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate/10, #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, -40) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(True) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 4, 4, 4) for r in range(0, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.fosphor_qt_sink_c_0 = fosphor.qt_sink_c() self.fosphor_qt_sink_c_0.set_fft_window(window.WIN_BLACKMAN_hARRIS) self.fosphor_qt_sink_c_0.set_frequency_range(0, samp_rate) self._fosphor_qt_sink_c_0_win = sip.wrapinstance(self.fosphor_qt_sink_c_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._fosphor_qt_sink_c_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.blocks_throttle_1 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_message_debug_0_0 = blocks.message_debug() self.blocks_message_debug_0 = blocks.message_debug() self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, fine_tune, 1, 0) self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, threshold) 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) self.adsb_framer_1 = adsb.framer(samp_rate, threshold) self.adsb_demod_0 = adsb.demod(samp_rate) self.adsb_decoder_0 = adsb.decoder("All Messages", "None", "None") ################################################## # Connections ################################################## self.msg_connect((self.adsb_decoder_0, 'decoded'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.adsb_demod_0, 'demodulated'), (self.adsb_decoder_0, 'demodulated')) self.msg_connect((self.sigmf_source_0, 'meta'), (self.blocks_message_debug_0_0, 'print')) self.connect((self.adsb_demod_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.adsb_framer_1, 0), (self.adsb_demod_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.fosphor_qt_sink_c_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.analog_const_source_x_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.adsb_framer_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_throttle_1, 0)) self.connect((self.blocks_throttle_1, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.sigmf_source_0, 0), (self.blocks_multiply_xx_0, 1))
def __init__(self, antenna="", baudrate=9600.0, bb_freq=0.0, bw=0.0, dc_removal="False", decoded_data_file_path="/tmp/.satnogs/data/data", dev_args="", doppler_correction_per_sec=20, enable_iq_dump=0, excess_bw=0.5, file_path="test.wav", framing="ax25", gain=0.0, gain_mode="Overall", iq_file_path="/tmp/iq.dat", lo_offset=100e3, max_cfo=2000.0, other_settings="", ppm=0, rigctl_port=4532, rx_freq=100e6, samp_rate_rx=0.0, soapy_rx_device="driver=invalid", stream_args="", tune_args="", udp_IP="127.0.0.1", udp_port=16887, waterfall_file_path="/tmp/waterfall.dat"): gr.top_block.__init__(self, "satnogs_bpsk UDP") ################################################## # Parameters ################################################## self.antenna = antenna self.baudrate = baudrate self.bb_freq = bb_freq self.bw = bw self.dc_removal = dc_removal self.decoded_data_file_path = decoded_data_file_path self.dev_args = dev_args self.doppler_correction_per_sec = doppler_correction_per_sec self.enable_iq_dump = enable_iq_dump self.excess_bw = excess_bw self.file_path = file_path self.framing = framing self.gain = gain self.gain_mode = gain_mode self.iq_file_path = iq_file_path self.lo_offset = lo_offset self.max_cfo = max_cfo self.other_settings = other_settings self.ppm = ppm self.rigctl_port = rigctl_port self.rx_freq = rx_freq self.samp_rate_rx = samp_rate_rx self.soapy_rx_device = soapy_rx_device self.stream_args = stream_args self.tune_args = tune_args self.udp_IP = udp_IP self.udp_port = udp_port self.waterfall_file_path = waterfall_file_path ################################################## # Variables ################################################## self.variable_ax25_decoder_0 = variable_ax25_decoder_0 = satnogs.ax25_decoder_make( 'GND', 0, True, True, True, 1024) self.sps = sps = 4 self.nfilts = nfilts = 32 self.audio_samp_rate = audio_samp_rate = 48000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), excess_bw, 11 * sps * nfilts) self.if_freq = if_freq = 12000 self.decimation = decimation = satnogs.find_decimation( baudrate, 2, audio_samp_rate, sps) self.bpsk_constellation = bpsk_constellation = digital.constellation_bpsk( ).base() self.available_framings = available_framings = { 'ax25': variable_ax25_decoder_0 } ################################################## # Blocks ################################################## self.soapy_source_0 = None # Make sure that the gain mode is valid if (gain_mode not in ['Overall', 'Specific', 'Settings Field']): raise ValueError( "Wrong gain mode on channel 0. Allowed gain modes: " "['Overall', 'Specific', 'Settings Field']") dev = soapy_rx_device # Stream arguments for every activated stream tune_args = [tune_args] settings = [other_settings] # Setup the device arguments dev_args = dev_args self.soapy_source_0 = soapy.source(1, dev, dev_args, stream_args, tune_args, settings, samp_rate_rx, "fc32") self.soapy_source_0.set_dc_removal( 0, bool(distutils.util.strtobool(dc_removal))) # Set up DC offset. If set to (0, 0) internally the source block # will handle the case if no DC offset correction is supported self.soapy_source_0.set_dc_offset(0, 0) # Setup IQ Balance. If set to (0, 0) internally the source block # will handle the case if no IQ balance correction is supported self.soapy_source_0.set_iq_balance(0, 0) self.soapy_source_0.set_agc(0, False) # generic frequency setting should be specified first self.soapy_source_0.set_frequency(0, rx_freq - lo_offset) self.soapy_source_0.set_frequency(0, "BB", bb_freq) # Setup Frequency correction. If set to 0 internally the source block # will handle the case if no frequency correction is supported self.soapy_source_0.set_frequency_correction(0, ppm) self.soapy_source_0.set_antenna(0, antenna) self.soapy_source_0.set_bandwidth(0, bw) if (gain_mode != 'Settings Field'): # pass is needed, in case the template does not evaluare anything pass self.soapy_source_0.set_gain(0, gain) self.satnogs_waterfall_sink_0_0 = satnogs.waterfall_sink( baudrate * decimation, rx_freq, 10, 1024, waterfall_file_path, 1) self.satnogs_udp_msg_sink_0_0 = satnogs.udp_msg_sink( udp_IP, udp_port, 1500) self.satnogs_tcp_rigctl_msg_source_0 = satnogs.tcp_rigctl_msg_source( "127.0.0.1", rigctl_port, False, int(1000.0 / doppler_correction_per_sec) + 1, 1500) self.satnogs_ogg_encoder_0 = satnogs.ogg_encoder( file_path, audio_samp_rate, 1.0) self.satnogs_json_converter_0 = satnogs.json_converter() self.satnogs_iq_sink_0_0 = satnogs.iq_sink(16768, iq_file_path, False, enable_iq_dump) self.satnogs_frame_file_sink_0_1_0 = satnogs.frame_file_sink( decoded_data_file_path, 0) self.satnogs_frame_decoder_0_0 = satnogs.frame_decoder( available_framings[framing], 1 * 1) self.satnogs_doppler_compensation_0 = satnogs.doppler_compensation( samp_rate_rx, rx_freq, lo_offset, baudrate * decimation, 1, 0) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( audio_samp_rate / (baudrate * decimation), taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, audio_samp_rate, 0.42 * audio_samp_rate / 2.0, 0.05 * audio_samp_rate, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( decimation // sps, firdes.low_pass( 1, baudrate * decimation, baudrate / 2 + excess_bw * baudrate / 2 + abs(max_cfo), baudrate / 10.0, firdes.WIN_HAMMING, 6.76)) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, 2.0 * math.pi / 100.0, rrc_taps, nfilts, nfilts / 2, 1.5, 1) self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb( bpsk_constellation, 2.0 * math.pi / 100.0, -0.25, 0.25) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short * 1, udp_IP, 7355, 1472, True) self.blocks_rotator_cc_0_0 = blocks.rotator_cc( 2.0 * math.pi * (if_freq / audio_samp_rate)) self.blocks_float_to_short_0 = blocks.float_to_short(1, 32767) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.analog_agc2_xx_0_0 = analog.agc2_cc(0.01, 0.001, 0.015, 1.0) self.analog_agc2_xx_0_0.set_max_gain(65536) self.analog_agc2_xx_0 = analog.agc2_cc(1e-3, 1e-3, 0.5, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect((self.satnogs_frame_decoder_0_0, 'out'), (self.satnogs_json_converter_0, 'in')) self.msg_connect((self.satnogs_json_converter_0, 'out'), (self.satnogs_frame_file_sink_0_1_0, 'frame')) self.msg_connect((self.satnogs_json_converter_0, 'out'), (self.satnogs_udp_msg_sink_0_0, 'in')) self.msg_connect((self.satnogs_tcp_rigctl_msg_source_0, 'freq'), (self.satnogs_doppler_compensation_0, 'doppler')) self.connect((self.analog_agc2_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.analog_agc2_xx_0_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_float_to_short_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.satnogs_ogg_encoder_0, 0)) self.connect((self.blocks_float_to_short_0, 0), (self.blocks_udp_sink_0, 0)) self.connect((self.blocks_rotator_cc_0_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.satnogs_frame_decoder_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_constellation_receiver_cb_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_rotator_cc_0_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.analog_agc2_xx_0_0, 0)) self.connect((self.satnogs_doppler_compensation_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.satnogs_doppler_compensation_0, 0), (self.satnogs_iq_sink_0_0, 0)) self.connect((self.satnogs_doppler_compensation_0, 0), (self.satnogs_waterfall_sink_0_0, 0)) self.connect((self.soapy_source_0, 0), (self.satnogs_doppler_compensation_0, 0))
def __init__(self, ip='127.0.0.1', iq_file='./rocksat_125kbd_500ksps_date_comment.dat', meta_rate=.1, port='52001', record_iq=0, record_rfo=0, record_snr=0, rfo_file='./rocksat_rfo_date_comment.meta', snr_file='./rocksat_snr_date_comment.meta'): gr.top_block.__init__(self, "VTGS Rocksat Receiver") Qt.QWidget.__init__(self) self.setWindowTitle("VTGS Rocksat Receiver") 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", "vtgs_rx_1") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.ip = ip self.iq_file = iq_file self.meta_rate = meta_rate self.port = port self.record_iq = record_iq self.record_rfo = record_rfo self.record_snr = record_snr self.rfo_file = rfo_file self.snr_file = snr_file ################################################## # Variables ################################################## self.samp_rate = samp_rate = 250e3 self.baud = baud = 125e3 / 2 self.samps_per_symb = samps_per_symb = int(samp_rate / baud) self.rx_freq = rx_freq = 2395e6 self.alpha = alpha = 0.5 self.tuned_center = tuned_center = 'baud_0' self.rx_offset = rx_offset = 250e3 self.rx_gain = rx_gain = 10 self.rrc_filter_taps = rrc_filter_taps = firdes.root_raised_cosine( 32, 1.0, 1.0 / (samps_per_symb * 32), alpha, samps_per_symb * 32) self.noise = noise = 0 self.mult = mult = (samp_rate) / 2 / 3.141593 self.lpf_taps = lpf_taps = firdes.low_pass(1.0, samp_rate, samp_rate / 2, 1000, firdes.WIN_HAMMING, 6.76) self.lo = lo = 1833e6 self.khz_offset = khz_offset = 0 self.center_freq_lbl = center_freq_lbl = rx_freq / 1e6 ################################################## # Blocks ################################################## self._noise_range = Range(0, 1, 0.00001, 0, 200) self._noise_win = RangeWidget(self._noise_range, self.set_noise, "noise", "counter_slider", float) self.top_layout.addWidget(self._noise_win) self._khz_offset_range = Range(-150, 150, 1, 0, 200) self._khz_offset_win = RangeWidget(self._khz_offset_range, self.set_khz_offset, 'Offset [kHz]', "counter_slider", float) self.top_grid_layout.addWidget(self._khz_offset_win, 7, 8, 1, 4) self.vtgs_mult_descrambler_0 = vtgs.mult_descrambler(17, 0x3FFFF) self.vtgs_ao40_decoder_0_0 = vtgs.ao40_decoder() self._tuned_center_tool_bar = Qt.QToolBar(self) if None: self._tuned_center_formatter = None else: self._tuned_center_formatter = lambda x: x self._tuned_center_tool_bar.addWidget( Qt.QLabel(' Tuned Center [MHz]' + ": ")) self._tuned_center_label = Qt.QLabel( str(self._tuned_center_formatter(self.tuned_center))) self._tuned_center_tool_bar.addWidget(self._tuned_center_label) self.top_grid_layout.addWidget(self._tuned_center_tool_bar, 1, 8, 1, 2) self._rx_gain_range = Range(0, 86, 1, 10, 200) self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, 'RX Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._rx_gain_win, 6, 8, 1, 4) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw '', #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0.enable_grid(True) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not False: 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 = ['pre-d', 'post', '', '', '', '', '', '', '', ''] colors = [0, 1, 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, -20) 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, 8, 0, 8, 8) self.qtgui_number_sink_1 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_1.set_update_time(0.10) self.qtgui_number_sink_1.set_title("") labels = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_1.set_min(i, -1) self.qtgui_number_sink_1.set_max(i, 1) self.qtgui_number_sink_1.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_1.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_1.set_label(i, labels[i]) self.qtgui_number_sink_1.set_unit(i, units[i]) self.qtgui_number_sink_1.set_factor(i, factor[i]) self.qtgui_number_sink_1.enable_autoscale(False) self._qtgui_number_sink_1_win = sip.wrapinstance( self.qtgui_number_sink_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_1_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024 * 4, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.0010) self.qtgui_freq_sink_x_0.set_y_axis(-120, -20) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['pre-d', 'post', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 8, 8) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-1, 1) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(True) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 8, 8, 8, 4) self.mapper_demapper_soft_0 = mapper.demapper_soft( mapper.BPSK, ([0, 1])) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, (baud * (1 + alpha)) / 2, 1000, firdes.WIN_HAMMING, 6.76)) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 1, (lpf_taps), khz_offset * 1000, samp_rate) self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_ccf( samps_per_symb, math.pi * 2 / 100, (rrc_filter_taps), 32, 16, 1.5, 1) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc( math.pi * 2 / 100, 2, False) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( math.pi * 2 / 100, 2, False) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self._center_freq_lbl_tool_bar = Qt.QToolBar(self) if None: self._center_freq_lbl_formatter = None else: self._center_freq_lbl_formatter = lambda x: x self._center_freq_lbl_tool_bar.addWidget( Qt.QLabel('Center Frequency [MHz]' + ": ")) self._center_freq_lbl_label = Qt.QLabel( str(self._center_freq_lbl_formatter(self.center_freq_lbl))) self._center_freq_lbl_tool_bar.addWidget(self._center_freq_lbl_label) self.top_grid_layout.addWidget(self._center_freq_lbl_tool_bar, 0, 8, 1, 2) self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", ip, port, 1024, False) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((mult, )) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_gr_complex * 1, addr='127.0.0.1', port=5000, server=True, ) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, noise, 0) self.analog_agc2_xx_0_0 = analog.agc2_cc(1e-3, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect((self.vtgs_ao40_decoder_0_0, 'valid_frames'), (self.blocks_socket_pdu_0, 'pdus')) self.connect((self.analog_agc2_xx_0_0, 0), (self.digital_costas_loop_cc_0_0, 0)) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blks2_tcp_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.analog_agc2_xx_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_number_sink_1, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.mapper_demapper_soft_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 1), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.vtgs_mult_descrambler_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.digital_pfb_clock_sync_xxx_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.mapper_demapper_soft_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.vtgs_mult_descrambler_0, 0), (self.vtgs_ao40_decoder_0_0, 0))
def __init__(self, fsk_dev=10000, lpf_cutoff=10e3, lpf_trans=1e3): gr.top_block.__init__(self, "Afsk Test") Qt.QWidget.__init__(self) self.setWindowTitle("Afsk Test") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "afsk_test") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.fsk_dev = fsk_dev self.lpf_cutoff = lpf_cutoff self.lpf_trans = lpf_trans ################################################## # Variables ################################################## self.samp_rate = samp_rate = 48000 self.baud = baud = 1200 self.samps_per_symb = samps_per_symb = int(samp_rate/baud) self.noise_amp = noise_amp = 0.3 self.mult = mult = (samp_rate)/2/3.141593 self.decim = decim = 2 self.bb_gain = bb_gain = .75 self.alpha = alpha = 0.5 ################################################## # Blocks ################################################## self._noise_amp_range = Range(0, 1, 0.005, 0.3, 200) self._noise_amp_win = RangeWidget(self._noise_amp_range, self.set_noise_amp, "noise_amp", "counter_slider", float) self.top_grid_layout.addWidget(self._noise_amp_win, 6,0,1,4) self._bb_gain_range = Range(0, 1, .01, .75, 200) self._bb_gain_win = RangeWidget(self._bb_gain_range, self.set_bb_gain, 'bb_gain', "counter_slider", float) self.top_grid_layout.addWidget(self._bb_gain_win, 5,0,1,4) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) 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 "float" == "float" or "float" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not False) 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_layout.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 8192, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) self.qtgui_time_sink_x_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 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(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, 4,4,3,4) self.qtgui_freq_sink_x_1_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate/decim, #bw "RX Spectrum", #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(-80, 10) self.qtgui_freq_sink_x_1_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1_0.enable_autoscale(False) self.qtgui_freq_sink_x_1_0.enable_grid(True) self.qtgui_freq_sink_x_1_0.set_fft_average(1.0) self.qtgui_freq_sink_x_1_0.enable_axis_labels(True) self.qtgui_freq_sink_x_1_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_1_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_0_win, 0,4,4,4) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "TX Spectrum", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(True) self.qtgui_freq_sink_x_1.enable_grid(True) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not False: 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.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 0,0,4,4) self.pyqt_text_output_0 = pyqt.text_output() self._pyqt_text_output_0_win = self.pyqt_text_output_0; self.top_layout.addWidget(self._pyqt_text_output_0_win) self.pyqt_text_input_0 = pyqt.text_input() self._pyqt_text_input_0_win = self.pyqt_text_input_0; self.top_grid_layout.addWidget(self._pyqt_text_input_0_win, 4,0,1,4) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate/decim, lpf_cutoff, lpf_trans, firdes.WIN_HAMMING, 6.76)) self.kiss_nrzi_encode_0 = kiss.nrzi_encode() self.kiss_hdlc_framer_0 = kiss.hdlc_framer(preamble_bytes=64, postamble_bytes=16) self.kiss_hdlc_deframer_0 = kiss.hdlc_deframer(check_fcs=True, max_length=300) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=samps_per_symb, sensitivity=0.06, bt=1, verbose=False, log=False, ) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0, 16) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(samps_per_symb*(1+0.0)/decim, 0.25*0.175*0.175, 0.25, 0.175, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_tag_gate_0.set_single_key("packet_len") self.blocks_socket_pdu_0_2 = blocks.socket_pdu("UDP_SERVER", '0.0.0.0', '52002', 1024, False) self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len') self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((bb_gain, )) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_add_xx_1 = blocks.add_vcc(1) self.audio_sink_0 = audio.sink(samp_rate, '', True) self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1700, 1, 0) self.analog_quadrature_demod_cf_1 = analog.quadrature_demod_cf((samp_rate/decim)/(2*math.pi*fsk_dev/8.0)) self.analog_nbfm_tx_0 = analog.nbfm_tx( audio_rate=samp_rate, quad_rate=samp_rate, tau=75e-6, max_dev=5e3, fh=-1.0, ) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(analog.GR_GAUSSIAN, noise_amp, 0, 8192) 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.msg_connect((self.blocks_socket_pdu_0_2, 'pdus'), (self.kiss_hdlc_framer_0, 'in')) self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.blocks_socket_pdu_0_2, 'pdus')) self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.pyqt_text_output_0, 'pdus')) self.msg_connect((self.kiss_hdlc_framer_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus')) self.msg_connect((self.pyqt_text_input_0, 'pdus'), (self.kiss_hdlc_framer_0, 'in')) self.connect((self.analog_agc2_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.analog_nbfm_tx_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.analog_quadrature_demod_cf_1, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.analog_quadrature_demod_cf_1, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_add_xx_1, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.analog_nbfm_tx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.kiss_nrzi_encode_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.kiss_hdlc_deframer_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.kiss_nrzi_encode_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_1_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0, 0))
def __init__(self): gr.top_block.__init__(self, "Sigmf Adsb Playback") Qt.QWidget.__init__(self) self.setWindowTitle("Sigmf Adsb Playback") 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", "sigmf_adsb_playback") 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.threshold = threshold = 10 self.samp_rate = samp_rate = 10e6 self.rx_gain = rx_gain = 50 self.lpf_cutoff = lpf_cutoff = 1.5e6 self.freq = freq = 1090e6 ################################################## # Blocks ################################################## self._threshold_tool_bar = Qt.QToolBar(self) self._threshold_tool_bar.addWidget(Qt.QLabel('Detection Threshold' + ": ")) self._threshold_line_edit = Qt.QLineEdit(str(self.threshold)) self._threshold_tool_bar.addWidget(self._threshold_line_edit) self._threshold_line_edit.returnPressed.connect( lambda: self.set_threshold(eng_notation.str_to_num(str(self._threshold_line_edit.text())))) self.top_grid_layout.addWidget(self._threshold_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._lpf_cutoff_tool_bar = Qt.QToolBar(self) self._lpf_cutoff_tool_bar.addWidget(Qt.QLabel('lpf_cutoff' + ": ")) self._lpf_cutoff_line_edit = Qt.QLineEdit(str(self.lpf_cutoff)) self._lpf_cutoff_tool_bar.addWidget(self._lpf_cutoff_line_edit) self._lpf_cutoff_line_edit.returnPressed.connect( lambda: self.set_lpf_cutoff(eng_notation.str_to_num(str(self._lpf_cutoff_line_edit.text())))) self.top_grid_layout.addWidget(self._lpf_cutoff_tool_bar, 1, 6, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 8): self.top_grid_layout.setColumnStretch(c, 1) self.sigmf_source_0 = gr_sigmf.source('/captures/20191211/ADSB_2019-12-11T22:34:43Z.sigmf-data', "cf32" + ("_le" if sys.byteorder == "little" else "_be"), False) self._rx_gain_range = Range(1, 76, 1, 50, 200) self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, 'rx_gain', "counter_slider", float) self.top_grid_layout.addWidget(self._rx_gain_win, 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.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=4, decimation=10, taps=None, fractional_bw=None) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( int(samp_rate*1*150e-6), #size int(samp_rate*1), #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(1.0/100.0) self.qtgui_time_sink_x_0.set_y_axis(0, 100) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0, 1.25e-6, 0, "burst") 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) 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', 'dark blue'] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [0, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 2, 4, 1, 4) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass( 1, samp_rate/10*4, lpf_cutoff, 10e3, firdes.WIN_HAMMING, 6.76)) self.fosphor_qt_sink_c_1 = fosphor.qt_sink_c() self.fosphor_qt_sink_c_1.set_fft_window(window.WIN_BLACKMAN_hARRIS) self.fosphor_qt_sink_c_1.set_frequency_range(0, samp_rate/10*4) self._fosphor_qt_sink_c_1_win = sip.wrapinstance(self.fosphor_qt_sink_c_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._fosphor_qt_sink_c_1_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.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate ,True) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, 'packet_len') self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(gr.sizeof_char*1, 'packet_len', 1.0/8) self.blocks_socket_pdu_0 = blocks.socket_pdu('TCP_SERVER', '127.0.0.1', '52001', 10000, False) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len') self.blocks_message_debug_0 = blocks.message_debug() self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, threshold) self.analog_agc2_xx_0 = analog.agc2_cc(1e-6, 1e-3, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) self.adsb_framer_1 = adsb.framer(samp_rate, threshold) self.adsb_demod_0 = adsb.demod(samp_rate) self.adsb_decoder_0 = adsb.decoder("All Messages", "None", "None") ################################################## # Connections ################################################## self.msg_connect((self.adsb_decoder_0, 'decoded'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.adsb_demod_0, 'demodulated'), (self.adsb_decoder_0, 'demodulated')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.blocks_message_debug_0, 'print')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.blocks_socket_pdu_0, 'pdus')) self.connect((self.adsb_demod_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.adsb_framer_1, 0), (self.adsb_demod_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.analog_const_source_x_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.adsb_framer_1, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.fosphor_qt_sink_c_1, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.sigmf_source_0, 0), (self.blocks_throttle_0, 0))
def __init__(self): gr.top_block.__init__(self, "SSB Receiver") Qt.QWidget.__init__(self) self.setWindowTitle("SSB Receiver") 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", "ssb_receiver") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.ssb_width = ssb_width = 3000 self.freq_offset = freq_offset = 51500 self.center_freq = center_freq = 50300000 self.station_freq = station_freq = center_freq + freq_offset + ssb_width / 2 self.samp_rate = samp_rate = 256000 self.resamp_factor = resamp_factor = 8 ################################################## # Blocks ################################################## self._freq_offset_range = Range(50000, 60000, 100, 51500, 200) self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, 'Frequency offset', "counter_slider", float) self.top_grid_layout.addWidget(self._freq_offset_win) self._station_freq_tool_bar = Qt.QToolBar(self) if None: self._station_freq_formatter = None else: self._station_freq_formatter = lambda x: str(x) self._station_freq_tool_bar.addWidget( Qt.QLabel('Station frequency' + ": ")) self._station_freq_label = Qt.QLabel( str(self._station_freq_formatter(self.station_freq))) self._station_freq_tool_bar.addWidget(self._station_freq_label) self.top_grid_layout.addWidget(self._station_freq_tool_bar) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=3, decimation=2, taps=None, fractional_bw=None, ) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype center_freq + freq_offset, #fc samp_rate / resamp_factor, #bw 'FIR Filter', #name False, #plotfreq True, #plotwaterfall False, #plottime False, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0 / 100) self._qtgui_sink_x_0_win = sip.wrapinstance( self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(True) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype center_freq, #fc samp_rate, #bw 'Signal spectrum', #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-50, 50) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not 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.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( resamp_factor, (firdes.low_pass(1, samp_rate, ssb_width / 2, 100)), freq_offset, samp_rate) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_multiply_xx_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0.15, )) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, 'D:\\ssb_lsb_256k_complex2.dat', True) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.audio_sink_0 = audio.sink(48000, '', True) self.analog_sig_source_x_0_0 = analog.sig_source_f( samp_rate / resamp_factor, analog.GR_SIN_WAVE, 1500, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate / resamp_factor, analog.GR_COS_WAVE, 1500, 1, 0) self.analog_agc2_xx_0 = analog.agc2_cc(0.3, 0.00001, 0.2, 1) self.analog_agc2_xx_0.set_max_gain(1) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.blocks_add_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_1, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self, ip='127.0.0.1', iq_file='./rocksat_125kbd_500ksps_date_comment.dat', meta_rate=.1, port='52001', pre_bits=[ 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0 ], record_iq=0, record_rfo=0, record_snr=0, rfo_file='./rocksat_rfo_date_comment.meta', snr_file='./rocksat_snr_date_comment.meta'): gr.top_block.__init__(self, "MGS Rocksat Receiver v1.0") Qt.QWidget.__init__(self) self.setWindowTitle("MGS Rocksat Receiver v1.0") 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", "mgs_rx_hdlc_1") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.ip = ip self.iq_file = iq_file self.meta_rate = meta_rate self.port = port self.pre_bits = pre_bits self.record_iq = record_iq self.record_rfo = record_rfo self.record_snr = record_snr self.rfo_file = rfo_file self.snr_file = snr_file ################################################## # Variables ################################################## self.samp_rate = samp_rate = 500e3 self.baud = baud = 125e3 self.samps_per_symb = samps_per_symb = int(samp_rate / baud) self.rx_offset = rx_offset = 250e3 self.rx_gain = rx_gain = 25 self.rx_freq = rx_freq = 2395e6 self.mult = mult = (samp_rate) / 2 / 3.141593 self.lpf_taps = lpf_taps = firdes.low_pass(1.0, samp_rate, samp_rate / 2, 1000, firdes.WIN_HAMMING, 6.76) self.lo = lo = 1833e6 self.khz_offset = khz_offset = 0 self.alpha = alpha = 0.5 ################################################## # Blocks ################################################## self._rx_gain_range = Range(0, 86, 1, 25, 200) self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, 'RX Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._rx_gain_win, 0, 8, 1, 4) self._khz_offset_range = Range(-150, 150, 1, 0, 200) self._khz_offset_win = RangeWidget(self._khz_offset_range, self.set_khz_offset, 'Offset [kHz]', "counter_slider", float) self.top_grid_layout.addWidget(self._khz_offset_win, 1, 8, 1, 4) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq( uhd.tune_request(rx_freq, rx_offset), 0) self.uhd_usrp_source_0.set_gain(rx_gain, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw '', #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0.enable_grid(True) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not False: 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 = ['pre-d', 'post', '', '', '', '', '', '', '', ''] colors = [0, 1, 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.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 8, 0, 8, 8) 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 = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024 * 4, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.0010) self.qtgui_freq_sink_x_0.set_y_axis(-120, -20) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['pre-d', 'post', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 8, 8) self.pyqt_trim_tail_0 = pyqt.trim_tail(20) self.pyqt_time_plot_1_0_0 = pyqt.time_plot('Soft Bits') self._pyqt_time_plot_1_0_0_win = self.pyqt_time_plot_1_0_0 self.top_grid_layout.addWidget(self._pyqt_time_plot_1_0_0_win, 4, 8, 1, 4) self.pyqt_time_plot_1_0 = pyqt.time_plot('Hard Bits') self._pyqt_time_plot_1_0_win = self.pyqt_time_plot_1_0 self.top_grid_layout.addWidget(self._pyqt_time_plot_1_0_win, 5, 8, 1, 4) self.pyqt_text_output_0 = pyqt.text_output() self._pyqt_text_output_0_win = self.pyqt_text_output_0 self.top_grid_layout.addWidget(self._pyqt_text_output_0_win, 6, 8, 4, 4) self.pyqt_skip_head_0 = pyqt.skip_head(100) self.pyqt_head_0 = pyqt.head(1024) self.pyqt_cpower_plot_0_0 = pyqt.cpower_plot('Burst Post Length-D') self._pyqt_cpower_plot_0_0_win = self.pyqt_cpower_plot_0_0 self.top_grid_layout.addWidget(self._pyqt_cpower_plot_0_0_win, 2, 8, 1, 4) self.pyqt_const_plot_0_0 = pyqt.const_plot(label='Symbols') self._pyqt_const_plot_0_0_win = self.pyqt_const_plot_0_0 self.top_grid_layout.addWidget(self._pyqt_const_plot_0_0_win, 3, 8, 1, 4) self.mapper_demapper_soft_0 = mapper.demapper_soft( mapper.BPSK, ([0, 1])) self.mapper_demapper_msg_0_0 = mapper.demapper_msg( mapper.BPSK, ([0, 1])) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, (baud * (1 + alpha)) / 2, 1000, firdes.WIN_HAMMING, 6.76)) self.kiss_nrzi_decode_0 = kiss.nrzi_decode() self.kiss_hdlc_deframer_0 = kiss.hdlc_deframer(check_fcs=True, max_length=1024) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 1, (lpf_taps), khz_offset * 1000, samp_rate) self.es_trigger_edge_f_0 = es.trigger_edge_f(-1, 256 * 16, 100, gr.sizeof_gr_complex, 500) self.es_sink_0 = es.sink(1 * [gr.sizeof_gr_complex], 4, 128, 0, 2, 0) self.es_handler_pdu_0 = es.es_make_handler_pdu( es.es_handler_print.TYPE_C32) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc( math.pi * 2 / 100, 2, False) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( math.pi * 2 / 100, 2, False) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc( samps_per_symb * (1 + 0.0), 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.burst_slicer_0 = burst.slicer() self.burst_preamble_correlator_0 = burst.preamble_correlator( 4, 0.5, (pre_bits)) self.burst_length_detect_c_0 = burst.length_detect_c() (self.burst_length_detect_c_0).set_min_output_buffer(20800) self.burst_correlator_filter_0 = burst.correlator_filter( 100, 1e-4, -10) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", ip, port, 1024, False) self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream( blocks.complex_t, 'pl2') self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((10, )) self.blocks_message_debug_0 = blocks.message_debug() self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.analog_agc2_xx_0_0 = analog.agc2_cc(1e-3, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect((self.burst_length_detect_c_0, 'cpdus'), (self.mapper_demapper_msg_0_0, 'cpdus')) self.msg_connect((self.burst_length_detect_c_0, 'cpdus'), (self.pyqt_const_plot_0_0, 'cpdus')) self.msg_connect((self.burst_length_detect_c_0, 'cpdus'), (self.pyqt_cpower_plot_0_0, 'cpdus')) self.msg_connect((self.burst_length_detect_c_0, 'cpdus'), (self.pyqt_trim_tail_0, 'pdus')) self.msg_connect((self.burst_slicer_0, 'pdus'), (self.pyqt_time_plot_1_0, 'pdus')) self.msg_connect((self.es_handler_pdu_0, 'pdus_out'), (self.burst_length_detect_c_0, 'cpdus')) self.msg_connect((self.es_trigger_edge_f_0, 'edge_event'), (self.es_handler_pdu_0, 'handle_event')) self.msg_connect((self.es_trigger_edge_f_0, 'which_stream'), (self.es_sink_0, 'schedule_event')) self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.blocks_socket_pdu_0, 'pdus')) self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.pyqt_text_output_0, 'pdus')) self.msg_connect((self.mapper_demapper_msg_0_0, 'fpdus'), (self.burst_slicer_0, 'fpdus')) self.msg_connect((self.mapper_demapper_msg_0_0, 'fpdus'), (self.pyqt_time_plot_1_0_0, 'pdus')) self.msg_connect((self.pyqt_head_0, 'pdus'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus')) self.msg_connect((self.pyqt_skip_head_0, 'pdus'), (self.pyqt_head_0, 'pdus')) self.msg_connect((self.pyqt_trim_tail_0, 'pdus'), (self.pyqt_skip_head_0, 'pdus')) self.connect((self.analog_agc2_xx_0_0, 0), (self.digital_costas_loop_cc_0_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.burst_correlator_filter_0, 0), (self.es_trigger_edge_f_0, 0)) self.connect((self.burst_preamble_correlator_0, 0), (self.burst_correlator_filter_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.burst_preamble_correlator_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.es_trigger_edge_f_0, 1)) self.connect((self.digital_costas_loop_cc_0, 0), (self.mapper_demapper_soft_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.kiss_nrzi_decode_0, 0)) self.connect((self.es_trigger_edge_f_0, 0), (self.es_sink_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_agc2_xx_0_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.kiss_nrzi_decode_0, 0), (self.kiss_hdlc_deframer_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.mapper_demapper_soft_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
def __init__(self, rx_freq=401.5e6, rx_offset=250e3): gr.top_block.__init__(self, "VCC Simple Downlink Receiver") Qt.QWidget.__init__(self) self.setWindowTitle("VCC Simple Downlink Receiver") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "fsk_rx_uhd") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.rx_freq = rx_freq self.rx_offset = rx_offset ################################################## # Variables ################################################## self.samp_rate = samp_rate = 250000 self.interp = interp = 24 self.decim = decim = 25 * 5 self.baud = baud = 9600 self.samps_per_symb = samps_per_symb = (samp_rate / decim * interp) / baud self.rx_gain = rx_gain = 0 self.rx_correct = rx_correct = -300 self.lpf_trans = lpf_trans = 1e3 self.lpf_cutoff = lpf_cutoff = 12.5e3 self.fsk_dev = fsk_dev = 10000 ################################################## # Blocks ################################################## self._rx_gain_range = Range(0, 86, 1, 0, 200) self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, 'RX Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._rx_gain_win, 4, 0, 1, 4) self._rx_correct_range = Range(-10000, 10000, 1, -300, 200) self._rx_correct_win = RangeWidget(self._rx_correct_range, self.set_rx_correct, "rx_correct", "counter_slider", float) self.top_grid_layout.addWidget(self._rx_correct_win, 5, 0, 1, 4) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq( uhd.tune_request(rx_freq + rx_correct, rx_offset), 0) self.uhd_usrp_source_0.set_gain(rx_gain, 0) self.uhd_usrp_source_0.set_antenna('TX/RX', 0) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=interp, decimation=decim, taps=None, fractional_bw=None, ) self.qtgui_freq_sink_x_1_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim * interp, #bw "RX Spectrum", #name 2 #number of inputs ) self.qtgui_freq_sink_x_1_0.set_update_time(0.010) self.qtgui_freq_sink_x_1_0.set_y_axis(-150, 0) self.qtgui_freq_sink_x_1_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1_0.enable_autoscale(False) self.qtgui_freq_sink_x_1_0.enable_grid(True) self.qtgui_freq_sink_x_1_0.set_fft_average(1.0) self.qtgui_freq_sink_x_1_0.enable_axis_labels(True) self.qtgui_freq_sink_x_1_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_1_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_0_win, 0, 0, 4, 4) self.pyqt_text_output_0 = pyqt.text_output() self._pyqt_text_output_0_win = self.pyqt_text_output_0 self.top_grid_layout.addWidget(self._pyqt_text_output_0_win, 6, 0, 2, 4) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate / decim * interp, lpf_cutoff, lpf_trans, firdes.WIN_HAMMING, 6.76)) self.kiss_pdu_to_kiss_0 = kiss.pdu_to_kiss() self.kiss_nrzi_decode_0 = kiss.nrzi_decode() self.kiss_hdlc_deframer_0 = kiss.hdlc_deframer(check_fcs=True, max_length=300) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0, 16) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff( samps_per_symb * (1 + 0.0), 0.25 * 0.175 * 0.175, 0.25, 0.175, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_socket_pdu_0_2_0 = blocks.socket_pdu( "TCP_SERVER", '0.0.0.0', '8001', 1024, False) self.analog_quadrature_demod_cf_1 = analog.quadrature_demod_cf( (samp_rate / decim * interp) / (2 * math.pi * fsk_dev / 8.0)) 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.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.kiss_pdu_to_kiss_0, 'in')) self.msg_connect((self.kiss_pdu_to_kiss_0, 'out'), (self.blocks_socket_pdu_0_2_0, 'pdus')) self.msg_connect((self.kiss_pdu_to_kiss_0, 'out'), (self.pyqt_text_output_0, 'pdus')) self.connect((self.analog_agc2_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.analog_quadrature_demod_cf_1, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.kiss_nrzi_decode_0, 0)) self.connect((self.kiss_nrzi_decode_0, 0), (self.kiss_hdlc_deframer_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_1_0, 1)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_1_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.rational_resampler_xxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Psk Rx") Qt.QWidget.__init__(self) self.setWindowTitle("Psk Rx") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "psk_rx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 2 self.samp_rate = samp_rate = 1e6 self.my_constellation = my_constellation = digital.constellation_calcdist(([-1,1]), ([0, 1]), 2, 1).base() self.freq = freq = 2.4e9 ################################################## # Blocks ################################################## self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #fc samp_rate, #bw "", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0/10) self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(False) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_0_win) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(10, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 6.28/100.0, (filter.firdes.root_raised_cosine(32,32*sps,1.0,0.35,11*32*sps)), 32, 16, 1.5, 1) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(sps, 0.35, 55, 6.28/100.0) self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2) self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb(my_constellation, 6.28/100.0, -0.25, 0.25) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(1) self.blocks_null_sink_0_1 = blocks.null_sink(gr.sizeof_float*1) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, "/home/ubuntu/recv.b", False) self.blocks_file_sink_0.set_unbuffered(False) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_c(grc_blks2.packet_decoder( access_code="", threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload), ), ) self.analog_agc2_xx_0 = analog.agc2_cc(0.06, 0.001, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 2), (self.blocks_null_sink_0_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 3), (self.blocks_null_sink_0_1, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.digital_diff_encoder_bb_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 4), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_diff_encoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_constellation_receiver_cb_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.qtgui_sink_x_0, 0))
def __init__(self, file_path, min_freq, max_freq, min_volume, max_volume, default_samp_rate,default_resamp_factor, cutoff_freq): grc_wxgui.top_block_gui.__init__(self, title="Am Receive") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) # Variables self.volume = volume = 0.05 self.samp_rate = samp_rate = default_samp_rate self.resamp_factor = resamp_factor = default_resamp_factor self.freq = freq = 0 # Blocks # Volume Slider _volume_sizer = wx.BoxSizer(wx.VERTICAL) self._volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, label='volume', converter=forms.float_converter(), proportion=0, ) self._volume_slider = forms.slider( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, minimum=min_volume, maximum=max_volume, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_volume_sizer) # Frequency Slider _freq_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, label='freq', converter=forms.float_converter(), proportion=0, ) self._freq_slider = forms.slider( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, minimum=min_freq, maximum=max_freq, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freq_sizer) # Source GUI self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="Source FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) # Sink GUI self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title="Scope Plot", sample_rate=samp_rate/resamp_factor, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) # Sampler before sink self.rational_resampler_xxx_1 = filter.rational_resampler_fff( interpolation=1, decimation=4, taps=None, fractional_bw=None, ) # Sampler after source self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=48000/((samp_rate/resamp_factor)/resamp_factor), decimation=resamp_factor, taps=None, fractional_bw=None, ) # Low Pass Filter self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate/resamp_factor, cutoff_freq, 100, firdes.WIN_HAMMING, 6.76)) # Mulitply Source with Cosine Wave self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) # Multiply volume with constant (Slider) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((volume, )) # File Source self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, file_path, True) # Complex to Magnitude Converter self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) # Audio Sink self.audio_sink_0 = audio.sink(48000, "", True) # Wave generator self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, freq, 1, 0) # Automatic Volume Adjustment self.analog_agc2_xx_0 = analog.agc2_cc(6.25e-4, 1e-5, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) # Connections self.connect((self.analog_agc2_xx_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.audio_sink_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.wxgui_scopesink2_0, 0))
def __init__(self): gr.top_block.__init__(self, "superdarn_playback_sigmf") Qt.QWidget.__init__(self) self.setWindowTitle("superdarn_playback_sigmf") 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", "superdarn_playback_sigmf") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.trig_lvl = trig_lvl = 0 self.throttle_rate = throttle_rate = 1 self.samp_rate = samp_rate = 250e3 self.decim = decim = 5 self.cutoff = cutoff = 5e3 self.coarse_freq = coarse_freq = 0 ################################################## # Blocks ################################################## self._trig_lvl_tool_bar = Qt.QToolBar(self) self._trig_lvl_tool_bar.addWidget(Qt.QLabel("trig_lvl"+": ")) self._trig_lvl_line_edit = Qt.QLineEdit(str(self.trig_lvl)) self._trig_lvl_tool_bar.addWidget(self._trig_lvl_line_edit) self._trig_lvl_line_edit.returnPressed.connect( lambda: self.set_trig_lvl(eng_notation.str_to_num(str(self._trig_lvl_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._trig_lvl_tool_bar, 7, 6, 1, 2) for r in range(7, 8): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 8): self.top_grid_layout.setColumnStretch(c, 1) 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, 4, 6, 1, 2) for r in range(4, 5): 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, 4, 4, 1, 2) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self._cutoff_tool_bar = Qt.QToolBar(self) self._cutoff_tool_bar.addWidget(Qt.QLabel("cutoff"+": ")) self._cutoff_line_edit = Qt.QLineEdit(str(self.cutoff)) self._cutoff_tool_bar.addWidget(self._cutoff_line_edit) self._cutoff_line_edit.returnPressed.connect( lambda: self.set_cutoff(eng_notation.str_to_num(str(self._cutoff_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._cutoff_tool_bar, 6, 4, 1, 2) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self._coarse_freq_range = Range(-125e3, 125e3, 1, 0, 200) self._coarse_freq_win = RangeWidget(self._coarse_freq_range, self.set_coarse_freq, "coarse_freq", "counter_slider", float) self.top_grid_layout.addWidget(self._coarse_freq_win, 5, 4, 1, 4) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.sigmf_source_0 = gr_sigmf.source('/captures/20200731/SUPERDARN_2020-08-01T03:43:13Z.sigmf-data', "cf32" + ("_le" if sys.byteorder == "little" else "_be"), True) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0.enable_grid(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 = qtgui.time_sink_f( 1024, #size samp_rate/decim/decim, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.010) self.qtgui_time_sink_x_0.set_y_axis(-30, 20) 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, trig_lvl, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not False: 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, 2, 4, 2, 4) for r in range(2, 4): 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_0_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate/decim, #bw "", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.010) self.qtgui_freq_sink_x_0_0.set_y_axis(-80, 10) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 0, 4, 2, 4) for r in range(0, 2): 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_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.010) self.qtgui_freq_sink_x_0.set_y_axis(-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 False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 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_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate/decim, cutoff, 1e3, firdes.WIN_HAMMING, 6.76)) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate*throttle_rate,True) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -1*coarse_freq, 1, 0) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-1, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_0_0, 1)) self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.sigmf_source_0, 0), (self.blocks_throttle_0, 0))
def __init__(self, mode, **kwargs): if mode == 'LSB': lsb = True cw = False elif mode == 'USB': lsb = False cw = False elif mode == 'CW': lsb = False cw = True else: raise ValueError('Not an SSB mode: %r' % (mode,)) demod_rate = 8000 # round number close to SSB bandwidth * 2 SimpleAudioDemodulator.__init__(self, mode=mode, audio_rate=demod_rate, demod_rate=demod_rate, band_filter=demod_rate / 2, # note narrower filter applied later band_filter_transition=demod_rate / 2, **kwargs) if cw: self.__offset = 1500 # CW beat frequency half_bandwidth = self.half_bandwidth = 500 band_filter_width = 120 band_mid = 0 agc_reference = dB(-10) agc_rate = 1e-1 else: self.__offset = 0 half_bandwidth = self.half_bandwidth = 2800 / 2 # standard SSB bandwidth band_filter_width = half_bandwidth / 5 if lsb: band_mid = -200 - half_bandwidth else: band_mid = 200 + half_bandwidth agc_reference = dB(-8) agc_rate = 8e-1 band_filter_low = band_mid - half_bandwidth band_filter_high = band_mid + half_bandwidth sharp_filter_block = grfilter.fir_filter_ccc( 1, firdes.complex_band_pass(1.0, demod_rate, band_filter_low + self.__offset, band_filter_high + self.__offset, band_filter_width, firdes.WIN_HAMMING)) self.__filter_shape = BandShape.bandpass_transition( low=band_filter_low, high=band_filter_high, transition=band_filter_width, markers={}) self.agc_block = analog.agc2_cc(reference=agc_reference) self.agc_block.set_attack_rate(agc_rate) self.agc_block.set_decay_rate(agc_rate) self.agc_block.set_max_gain(dB(_ssb_max_agc)) ssb_demod_block = blocks.complex_to_real(1) self.connect( self, self.band_filter_block, sharp_filter_block, # TODO: We would like to have a squelch which does not interfere with the AGC, but this is impossible without combining the squelch and AGC self.rf_squelch_block, self.agc_block, ssb_demod_block) self.connect(sharp_filter_block, self.rf_probe_block) self.connect_audio_output(ssb_demod_block)
def __init__(self): gr.top_block.__init__(self, "Uhd Ais 3") Qt.QWidget.__init__(self) self.setWindowTitle("Uhd Ais 3") 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", "uhd_ais_3") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 250e3 self.decim = decim = 5 self.baud = baud = 9600 self.samp_per_sym = samp_per_sym = (samp_rate / decim / 50 * 48) / baud self.rx_gain = rx_gain = 45 self.fsk_deviation = fsk_deviation = 10e3 self.freq = freq = 162e6 ################################################## # Blocks ################################################## self._rx_gain_tool_bar = Qt.QToolBar(self) self._rx_gain_tool_bar.addWidget(Qt.QLabel("rx_gain" + ": ")) self._rx_gain_line_edit = Qt.QLineEdit(str(self.rx_gain)) self._rx_gain_tool_bar.addWidget(self._rx_gain_line_edit) self._rx_gain_line_edit.returnPressed.connect(lambda: self.set_rx_gain( eng_notation.str_to_num( str(self._rx_gain_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._rx_gain_tool_bar, 8, 0, 1, 2) self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff( interpolation=48, decimation=50, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=48, decimation=50, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "AIS-B", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0_0.enable_grid(True) self.qtgui_waterfall_sink_x_0_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0_0.set_intensity_range(-60, 10) self._qtgui_waterfall_sink_x_0_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_0_win, 2, 4, 2, 4) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "AIS-A", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0.enable_grid(True) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-60, 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, 0, 4, 2, 4) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim, #bw "AIS", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.01) self.qtgui_freq_sink_x_0.set_y_axis(-60, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not 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 = [ "green", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 4, 4) self.pyqt_text_output_0_0 = pyqt.text_output() self._pyqt_text_output_0_0_win = self.pyqt_text_output_0_0 self.top_grid_layout.addWidget(self._pyqt_text_output_0_0_win, 4, 0, 4, 4) self.pyqt_text_output_0 = pyqt.text_output() self._pyqt_text_output_0_win = self.pyqt_text_output_0 self.top_grid_layout.addWidget(self._pyqt_text_output_0_win, 4, 4, 4, 4) self.low_pass_filter_0_0 = filter.fir_filter_ccf( decim, firdes.low_pass(1, samp_rate, 7e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( decim, firdes.low_pass(1, samp_rate, 7e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.digital_hdlc_deframer_bp_0_0 = digital.hdlc_deframer_bp(11, 1000) self.digital_hdlc_deframer_bp_0 = digital.hdlc_deframer_bp(11, 1000) self.digital_diff_decoder_bb_0_0 = digital.diff_decoder_bb(2) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_clock_recovery_mm_xx_0_0 = digital.clock_recovery_mm_ff( samp_per_sym * (1 + 0.0), 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff( samp_per_sym * (1 + 0.0), 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_0_0 = digital.binary_slicer_fb() self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate * 4, True) self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", '', '52001', 10000, False) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_message_debug_0_1 = blocks.message_debug() self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, '/home/zleffke/workspace/captures/ais/ais_20161218_250k_2.32fc', True) self.analog_sig_source_x_1 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 25e3 + 400, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -25e3 + 400, 1, 0) self.analog_quadrature_demod_cf_0_0 = analog.quadrature_demod_cf( (samp_rate / decim) / (2 * math.pi * fsk_deviation / 8.0)) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf( (samp_rate / decim) / (2 * math.pi * fsk_deviation / 8.0)) self.analog_agc2_xx_0_0 = analog.agc2_cc(1e-3, 1e-1, 1.0, 1.0) self.analog_agc2_xx_0_0.set_max_gain(65536) self.analog_agc2_xx_0 = analog.agc2_cc(1e-3, 1e-1, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) self.ais_pdu_to_nmea_0_0 = ais.pdu_to_nmea('B') self.ais_pdu_to_nmea_0 = ais.pdu_to_nmea('A') self.ais_invert_0_0 = ais.invert() self.ais_invert_0 = ais.invert() ################################################## # Connections ################################################## self.msg_connect((self.ais_pdu_to_nmea_0, 'out'), (self.blocks_message_debug_0_1, 'print')) self.msg_connect((self.ais_pdu_to_nmea_0, 'out'), (self.blocks_message_debug_0_1, 'print_pdu')) self.msg_connect((self.ais_pdu_to_nmea_0, 'out'), (self.blocks_socket_pdu_0, 'pdus')) self.msg_connect((self.ais_pdu_to_nmea_0, 'out'), (self.pyqt_text_output_0_0, 'pdus')) self.msg_connect((self.ais_pdu_to_nmea_0_0, 'out'), (self.blocks_message_debug_0_1, 'print')) self.msg_connect((self.ais_pdu_to_nmea_0_0, 'out'), (self.blocks_message_debug_0_1, 'print_pdu')) self.msg_connect((self.ais_pdu_to_nmea_0_0, 'out'), (self.blocks_socket_pdu_0, 'pdus')) self.msg_connect((self.ais_pdu_to_nmea_0_0, 'out'), (self.pyqt_text_output_0, 'pdus')) self.msg_connect((self.digital_hdlc_deframer_bp_0, 'out'), (self.ais_pdu_to_nmea_0, 'to_nmea')) self.msg_connect((self.digital_hdlc_deframer_bp_0_0, 'out'), (self.ais_pdu_to_nmea_0_0, 'to_nmea')) self.connect((self.ais_invert_0, 0), (self.digital_hdlc_deframer_bp_0, 0)) self.connect((self.ais_invert_0_0, 0), (self.digital_hdlc_deframer_bp_0_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.analog_quadrature_demod_cf_0_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.analog_agc2_xx_0_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.analog_agc2_xx_0_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.analog_agc2_xx_0_0, 0), (self.qtgui_waterfall_sink_x_0_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.analog_quadrature_demod_cf_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_binary_slicer_fb_0_0, 0), (self.digital_diff_decoder_bb_0_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0_0, 0), (self.digital_binary_slicer_fb_0_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.ais_invert_0, 0)) self.connect((self.digital_diff_decoder_bb_0_0, 0), (self.ais_invert_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.analog_agc2_xx_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.digital_clock_recovery_mm_xx_0_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Airband") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.volume = volume = 500e-3 self.samp_rate = samp_rate = 2.4e6 self.offset_freq = offset_freq = 119e6 self.freq_corr = freq_corr = 65 self.freq = freq = 591.28e6 self.base_freq = base_freq = 560e6 ################################################## # Blocks ################################################## _volume_sizer = wx.BoxSizer(wx.VERTICAL) self._volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, label="Volume", converter=forms.float_converter(), proportion=0, ) self._volume_slider = forms.slider( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_volume_sizer) self._offset_freq_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.offset_freq, callback=self.set_offset_freq, label="Frequency select", choices=[119e6,120.5e6,123.85e6,126.55e6,128.65e6,132.225e6,560e6], labels=["bradley 119M","worc tow 120.5M", "worc ground 123.85M","worc atais126.55M","worc clrnc 128.65M","logan twr 132.225M","560AM"], style=wx.RA_VERTICAL, ) self.Add(self._offset_freq_chooser) _freq_corr_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_corr_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_corr_sizer, value=self.freq_corr, callback=self.set_freq_corr, label="Freq correction (ppm)", converter=forms.int_converter(), proportion=0, ) self._freq_corr_slider = forms.slider( parent=self.GetWin(), sizer=_freq_corr_sizer, value=self.freq_corr, callback=self.set_freq_corr, minimum=-127, maximum=127, num_steps=254, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_freq_corr_sizer) self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_time_now(osmosdr.time_spec_t(time.time()), osmosdr.ALL_MBOARDS) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(offset_freq, 0) self.rtlsdr_source_0.set_freq_corr(freq_corr, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(49.6, 0) self.rtlsdr_source_0.set_if_gain(1, 0) self.rtlsdr_source_0.set_bb_gain(1, 0) self.rtlsdr_source_0.set_antenna("RX", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=48, decimation=48, taps=None, fractional_bw=None, ) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(50, (firdes.low_pass_2(1,samp_rate,25e3,10e3,40)), 0, samp_rate) _freq_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, label="freq", converter=forms.float_converter(), proportion=0, ) self._freq_slider = forms.slider( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, minimum=500e6, maximum=1200e6, num_steps=700, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freq_sizer) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((volume, )) self.audio_sink_0 = audio.sink(48000, "pulse", True) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=48e3, audio_decim=1, audio_pass=5000, audio_stop=5500, ) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-5, 1, 0) self.analog_agc2_xx_0.set_max_gain(5) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
def __init__(self, antenna="TX/RX", vor_freq_1=111e6, com_freq_1=135.275e6, vor_freq_2=111e6, rx_gain=30, gain=20): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Parameters ################################################## self.antenna = antenna self.vor_freq_1 = vor_freq_1 self.com_freq_1 = com_freq_1 self.vor_freq_2 = vor_freq_2 self.rx_gain = rx_gain self.gain = gain ################################################## # Variables ################################################## self.obs_decimation = obs_decimation = 25 self.ils_decimation = ils_decimation = 50 self.am_sample_rate = am_sample_rate = 12.5e3 self.vor_samp_rate = vor_samp_rate = 250e3 self.vor_freq_entry_2 = vor_freq_entry_2 = vor_freq_2 self.vor_freq_entry_1 = vor_freq_entry_1 = vor_freq_1 self.vor_center_freq_0 = vor_center_freq_0 = (117.95e6 - 108.00e6) / 2 + 117.95e6 self.vor_center_freq = vor_center_freq = (117.95e6 - 108.00e6) / 2 + 117.95e6 self.squelch_slider = squelch_slider = -110 self.rxgain = rxgain = 15 self.phase_correction = phase_correction = 5 self.obs_sample_rate = obs_sample_rate = am_sample_rate / obs_decimation self.ils_sample_rate = ils_sample_rate = am_sample_rate / ils_decimation self.gain_slider = gain_slider = gain self.com_freq_entry_1 = com_freq_entry_1 = com_freq_1 self.band_center_freq = band_center_freq = (136.975e6 - 108.0e6) / 2 + 108.0e6 self.audio_select = audio_select = 0 self.audio_sample_rate = audio_sample_rate = 48e3 self.am_decimation = am_decimation = 1 ################################################## # Blocks ################################################## self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "RF Analyzer") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Channel FFT") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Demod Audio FFT") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Ref and Phase Scope") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Manipulated Ref and Phase") self.Add(self.notebook_0) self._vor_freq_entry_1_text_box = forms.text_box( parent=self.notebook_0.GetPage(0).GetWin(), value=self.vor_freq_entry_1, callback=self.set_vor_freq_entry_1, label='vor_freq_entry_1', converter=forms.float_converter(), ) self.notebook_0.GetPage(0).Add(self._vor_freq_entry_1_text_box) _gain_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_slider_text_box = forms.text_box( parent=self.notebook_0.GetPage(0).GetWin(), sizer=_gain_slider_sizer, value=self.gain_slider, callback=self.set_gain_slider, label='gain_slider', converter=forms.float_converter(), proportion=0, ) self._gain_slider_slider = forms.slider( parent=self.notebook_0.GetPage(0).GetWin(), sizer=_gain_slider_sizer, value=self.gain_slider, callback=self.set_gain_slider, minimum=0, maximum=30, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.notebook_0.GetPage(0).Add(_gain_slider_sizer) self._com_freq_entry_1_text_box = forms.text_box( parent=self.notebook_0.GetPage(0).GetWin(), value=self.com_freq_entry_1, callback=self.set_com_freq_entry_1, label='com_freq_entry_1', converter=forms.float_converter(), ) self.notebook_0.GetPage(0).Add(self._com_freq_entry_1_text_box) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.notebook_0.GetPage(1).GetWin(), title="Scope Plot", sample_rate=10e3, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=2, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.notebook_0.GetPage(1).Add(self.wxgui_scopesink2_0.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit="Units", minval=-100, maxval=100, factor=1.0, decimal_places=10, ref_level=0, sample_rate=10, number_rate=15, average=False, avg_alpha=None, label="Number Plot", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.notebook_0.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=12.5e3, fft_size=1024, fft_rate=5, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_0.win) self._vor_freq_entry_2_text_box = forms.text_box( parent=self.notebook_0.GetPage(0).GetWin(), value=self.vor_freq_entry_2, callback=self.set_vor_freq_entry_2, label='vor_freq_entry_2', converter=forms.float_converter(), ) self.notebook_0.GetPage(0).Add(self._vor_freq_entry_2_text_box) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_0.set_subdev_spec("A:0 A:0", 0) self.uhd_usrp_source_0.set_samp_rate(vor_samp_rate) self.uhd_usrp_source_0.set_center_freq( uhd.tune_request(com_freq_entry_1, rf_freq=band_center_freq, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_source_0.set_gain(gain_slider, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.uhd_usrp_source_0.set_center_freq( uhd.tune_request(vor_freq_entry_1, rf_freq=band_center_freq, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 1) self.uhd_usrp_source_0.set_gain(gain_slider, 1) self.uhd_usrp_source_0.set_antenna("TX/RX", 1) self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(250e3) self.uhd_usrp_sink_0.set_center_freq( uhd.tune_request(com_freq_entry_1, 20e6), 0) self.uhd_usrp_sink_0.set_gain(15, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) _squelch_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._squelch_slider_text_box = forms.text_box( parent=self.notebook_0.GetPage(0).GetWin(), sizer=_squelch_slider_sizer, value=self.squelch_slider, callback=self.set_squelch_slider, label='squelch_slider', converter=forms.float_converter(), proportion=0, ) self._squelch_slider_slider = forms.slider( parent=self.notebook_0.GetPage(0).GetWin(), sizer=_squelch_slider_sizer, value=self.squelch_slider, callback=self.set_squelch_slider, minimum=-110, maximum=0, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.notebook_0.GetPage(0).Add(_squelch_slider_sizer) self.squelch = analog.pwr_squelch_cc(squelch_slider, 0.01, 20, True) self.rational_resampler_xxx_2 = filter.rational_resampler_fff( interpolation=250, decimation=48, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_1 = filter.rational_resampler_fff( interpolation=480, decimation=125, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=4, decimation=5, taps=None, fractional_bw=None, ) self.openavionics_joystick_interface_0 = openavionics.joystick_interface( ) self.openavionics_audio_ptt_0 = openavionics.audio_ptt() self.null_sink_0_0_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.null_sink_0_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.multiply_xx_0_0_0 = blocks.multiply_vcc(1) self.multiply_xx_0_0 = blocks.multiply_vff(1) self.low_pass_filter_3 = filter.fir_filter_ccf( 1, firdes.low_pass(1, 10e3, 1, 2, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_2_0_0 = filter.fir_filter_ccf( 5, firdes.low_pass(1, 40e3, 2e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_2_0 = filter.fir_filter_ccf( 5, firdes.low_pass(1, 40e3, 2e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_2 = filter.fir_filter_ccf( 5, firdes.low_pass(1, vor_samp_rate, 15e3, 5e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_1 = filter.interp_fir_filter_fff( 1, firdes.low_pass(1, 12.5e3, 3e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( int(250e3 / 12.5e3), firdes.low_pass(1, vor_samp_rate, 10e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.goertzel_fc_0_0 = fft.goertzel_fc(10000, 1000, 30) self.goertzel_fc_0 = fft.goertzel_fc(40000, 4000, 30) self.float_to_complex_0_0 = blocks.float_to_complex(1) self.const_source_x_0_0_0 = analog.sig_source_c( 0, analog.GR_CONST_WAVE, 0, 0, 0.450) self.const_source_x_0_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0.550) self.const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0.450) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-87.2665e-3, )) self.band_pass_filter_0_0 = filter.fir_filter_fff( 4, firdes.band_pass(1, 40e3, 20, 40, 20, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0 = filter.fir_filter_fff( 1, firdes.band_pass(1, 10e3, 20, 40, 20, firdes.WIN_HAMMING, 6.76)) self.audio_source_0 = audio.source(48000, "", True) self.audio_sink_0 = audio.sink(int(audio_sample_rate), "", True) self._audio_select_chooser = forms.drop_down( parent=self.GetWin(), value=self.audio_select, callback=self.set_audio_select, label='audio_select', choices=[0, 1], labels=['AM Voice', 'VOR Subcarrier'], ) self.Add(self._audio_select_chooser) self.analog_sig_source_x_0 = analog.sig_source_c( 40e3, analog.GR_COS_WAVE, -9.96e3, 1, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=40e3, audio_decim=4, audio_pass=5000, audio_stop=5500, ) self.analog_agc2_xx_0_1_0 = analog.agc2_ff(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_1_0.set_max_gain(100) self.analog_agc2_xx_0_1 = analog.agc2_ff(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_1.set_max_gain(100) self.analog_agc2_xx_0_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_0.set_max_gain(100) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(100) self.am_demod_cf_0 = analog.am_demod_cf( channel_rate=am_sample_rate, audio_decim=am_decimation, audio_pass=3e3, audio_stop=4e3, ) self.agc2_xx_0 = analog.agc2_cc(1, 1, 0.75, 1.0) self.agc2_xx_0.set_max_gain(0.0) self.add_xx_0_0 = blocks.add_vff(1) ################################################## # Connections ################################################## self.connect((self.agc2_xx_0, 0), (self.am_demod_cf_0, 0)) self.connect((self.am_demod_cf_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.agc2_xx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.multiply_xx_0_0, 0), (self.add_xx_0_0, 0)) self.connect((self.const_source_x_0, 0), (self.multiply_xx_0_0, 1)) self.connect((self.const_source_x_0_0, 0), (self.add_xx_0_0, 1)) self.connect((self.multiply_xx_0_0_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.add_xx_0_0, 0), (self.float_to_complex_0_0, 0)) self.connect((self.add_xx_0_0, 0), (self.float_to_complex_0_0, 1)) self.connect((self.float_to_complex_0_0, 0), (self.multiply_xx_0_0_0, 0)) self.connect((self.const_source_x_0_0_0, 0), (self.multiply_xx_0_0_0, 1)) self.connect((self.uhd_usrp_source_0, 0), (self.null_sink_0_0_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.audio_sink_0, 0)) self.connect((self.analog_agc2_xx_0_1_0, 0), (self.wxgui_scopesink2_0, 1)) self.connect((self.analog_agc2_xx_0_1, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.analog_agc2_xx_0_1, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.analog_agc2_xx_0_1_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.goertzel_fc_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.low_pass_filter_3, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.low_pass_filter_3, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.analog_agc2_xx_0_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.goertzel_fc_0_0, 0), (self.analog_agc2_xx_0_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.goertzel_fc_0_0, 0)) self.connect((self.goertzel_fc_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.low_pass_filter_2_0_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_2_0_0, 0)) self.connect((self.low_pass_filter_2_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_2_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.null_sink_0_0, 0)) self.connect((self.low_pass_filter_2, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.audio_source_0, 0), (self.openavionics_audio_ptt_0, 0)) self.connect((self.openavionics_audio_ptt_0, 0), (self.rational_resampler_xxx_2, 0)) self.connect((self.rational_resampler_xxx_2, 0), (self.multiply_xx_0_0, 0)) self.connect((self.squelch, 0), (self.agc2_xx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.squelch, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_2, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.openavionics_joystick_interface_0, "out", self.openavionics_audio_ptt_0, "in2")
def __init__(self, mode='VOR', zero_point=59, **kwargs): self.channel_rate = channel_rate = 40000 internal_audio_rate = 20000 # TODO over spec'd self.zero_point = zero_point transition = 5000 SimpleAudioDemodulator.__init__(self, mode=mode, audio_rate=internal_audio_rate, demod_rate=channel_rate, band_filter=fm_subcarrier * 1.25 + fm_deviation + transition / 2, band_filter_transition=transition, **kwargs) self.dir_rate = dir_rate = 10 if internal_audio_rate % dir_rate != 0: raise ValueError('Audio rate %s is not a multiple of direction-finding rate %s' % (internal_audio_rate, dir_rate)) self.dir_scale = dir_scale = internal_audio_rate // dir_rate self.audio_scale = audio_scale = channel_rate // internal_audio_rate self.zeroer = blocks.add_const_vff((zero_point * (math.pi / 180), )) self.dir_vector_filter = grfilter.fir_filter_ccf(1, firdes.low_pass( 1, dir_rate, 1, 2, firdes.WIN_HAMMING, 6.76)) self.am_channel_filter_block = grfilter.fir_filter_ccf(1, firdes.low_pass( 1, channel_rate, 5000, 5000, firdes.WIN_HAMMING, 6.76)) self.goertzel_fm = fft.goertzel_fc(channel_rate, dir_scale * audio_scale, 30) self.goertzel_am = fft.goertzel_fc(internal_audio_rate, dir_scale, 30) self.fm_channel_filter_block = grfilter.freq_xlating_fir_filter_ccc(1, (firdes.low_pass(1.0, channel_rate, fm_subcarrier / 2, fm_subcarrier / 2, firdes.WIN_HAMMING)), fm_subcarrier, channel_rate) self.multiply_conjugate_block = blocks.multiply_conjugate_cc(1) self.complex_to_arg_block = blocks.complex_to_arg(1) self.am_agc_block = analog.feedforward_agc_cc(1024, 1.0) self.am_demod_block = analog.am_demod_cf( channel_rate=channel_rate, audio_decim=audio_scale, audio_pass=5000, audio_stop=5500, ) self.fm_demod_block = analog.quadrature_demod_cf(1) self.phase_agc_fm = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.phase_agc_am = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.probe = blocks.probe_signal_f() self.audio_filter_block = grfilter.fir_filter_fff(1, design_lofi_audio_filter(internal_audio_rate, False)) ################################################## # Connections ################################################## # Input self.connect( self, self.band_filter_block) # AM chain self.connect( self.band_filter_block, self.am_channel_filter_block, self.am_agc_block, self.am_demod_block) # AM audio self.connect( self.am_demod_block, blocks.multiply_const_ff(1.0 / audio_modulation_index * 0.5), self.audio_filter_block) self.connect_audio_output(self.audio_filter_block) # AM phase self.connect( self.am_demod_block, self.goertzel_am, self.phase_agc_am, (self.multiply_conjugate_block, 0)) # FM phase self.connect( self.band_filter_block, self.fm_channel_filter_block, self.fm_demod_block, self.goertzel_fm, self.phase_agc_fm, (self.multiply_conjugate_block, 1)) # Phase comparison and output self.connect( self.multiply_conjugate_block, self.dir_vector_filter, self.complex_to_arg_block, blocks.multiply_const_ff(-1), # opposite angle conventions self.zeroer, self.probe)
def __init__(self, antenna=satnogs.not_set_antenna, baudrate=9600.0, bb_gain=satnogs.not_set_rx_bb_gain, decoded_data_file_path='/tmp/.satnogs/data/data', dev_args=satnogs.not_set_dev_args, doppler_correction_per_sec=1000, enable_iq_dump=0, excess_bw=0.35, file_path='test.wav', if_gain=satnogs.not_set_rx_if_gain, iq_file_path='/tmp/iq.dat', lo_offset=100e3, max_cfo=1000.0, ppm=0, rf_gain=satnogs.not_set_rx_rf_gain, rigctl_port=4532, rx_freq=100e6, rx_sdr_device='usrpb200', samp_rate_rx=satnogs.not_set_samp_rate_rx, udp_IP='127.0.0.1', udp_port=16887, waterfall_file_path='/tmp/waterfall.dat'): gr.top_block.__init__(self, "satnogs_bpsk_ax25") ################################################## # Parameters ################################################## self.antenna = antenna self.baudrate = baudrate self.bb_gain = bb_gain self.decoded_data_file_path = decoded_data_file_path self.dev_args = dev_args self.doppler_correction_per_sec = doppler_correction_per_sec self.enable_iq_dump = enable_iq_dump self.excess_bw = excess_bw self.file_path = file_path self.if_gain = if_gain self.iq_file_path = iq_file_path self.lo_offset = lo_offset self.max_cfo = max_cfo self.ppm = ppm self.rf_gain = rf_gain self.rigctl_port = rigctl_port self.rx_freq = rx_freq self.rx_sdr_device = rx_sdr_device self.samp_rate_rx = samp_rate_rx self.udp_IP = udp_IP self.udp_port = udp_port self.waterfall_file_path = waterfall_file_path ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), excess_bw, 11 * sps * nfilts) self.bpsk_constellation = bpsk_constellation = digital.constellation_bpsk( ).base() self.audio_samp_rate = audio_samp_rate = 48000 ################################################## # Blocks ################################################## self.satnogs_waterfall_sink_0 = satnogs.waterfall_sink( audio_samp_rate, 0.0, 10, 1024, waterfall_file_path, 1) self.satnogs_udp_msg_sink_0_0 = satnogs.udp_msg_sink( udp_IP, udp_port, 1500) self.satnogs_tcp_rigctl_msg_source_0 = satnogs.tcp_rigctl_msg_source( "127.0.0.1", rigctl_port, False, 1000, 1500) self.satnogs_ogg_encoder_0 = satnogs.ogg_encoder( file_path, audio_samp_rate, 1.0) self.satnogs_iq_sink_0 = satnogs.iq_sink(16768, iq_file_path, False, enable_iq_dump) self.satnogs_frame_file_sink_0_1_0 = satnogs.frame_file_sink( decoded_data_file_path, 0) self.satnogs_coarse_doppler_correction_cc_0 = satnogs.coarse_doppler_correction_cc( rx_freq, satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx)) self.satnogs_ax25_decoder_bm_0_0 = satnogs.ax25_decoder_bm( 'GND', 0, True, False, 1024) self.satnogs_ax25_decoder_bm_0 = satnogs.ax25_decoder_bm( 'GND', 0, True, True, 1024) self.pfb_arb_resampler_xxx_0_0 = pfb.arb_resampler_ccf( (1.0 * sps * baudrate) / satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx), taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0_0.declare_sample_delay(0) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( audio_samp_rate / satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx), taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + satnogs.handle_rx_dev_args(rx_sdr_device, dev_args)) self.osmosdr_source_0.set_sample_rate( satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx)) self.osmosdr_source_0.set_center_freq(rx_freq - lo_offset, 0) self.osmosdr_source_0.set_freq_corr(ppm, 0) self.osmosdr_source_0.set_dc_offset_mode(2, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain( satnogs.handle_rx_rf_gain(rx_sdr_device, rf_gain), 0) self.osmosdr_source_0.set_if_gain( satnogs.handle_rx_if_gain(rx_sdr_device, if_gain), 0) self.osmosdr_source_0.set_bb_gain( satnogs.handle_rx_bb_gain(rx_sdr_device, bb_gain), 0) self.osmosdr_source_0.set_antenna( satnogs.handle_rx_antenna(rx_sdr_device, antenna), 0) self.osmosdr_source_0.set_bandwidth( satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx), 0) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, audio_samp_rate, ((1.0 + excess_bw) * baudrate / 2.0) + min(baudrate, abs(max_cfo)), baudrate / 10.0, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, sps * baudrate, ((1.0 + excess_bw) * baudrate / 2.0) + min(baudrate, abs(max_cfo)), baudrate / 10.0, firdes.WIN_HAMMING, 6.76)) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, 2.0 * math.pi / 100.0, (rrc_taps), nfilts, nfilts / 2, 1.5, 1) self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc( 2.0 * math.pi / 100.0, 2, True) self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb( bpsk_constellation, 2.0 * math.pi / 100.0, -0.25, 0.25) self.blocks_rotator_cc_0_0 = blocks.rotator_cc( 2.0 * math.pi * (1200.0 / audio_samp_rate)) self.blocks_rotator_cc_0 = blocks.rotator_cc( -2.0 * math.pi * (lo_offset / satnogs.handle_samp_rate_rx(rx_sdr_device, samp_rate_rx))) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.analog_agc2_xx_0_0 = analog.agc2_cc(0.01, 0.001, 0.015, 1.0) self.analog_agc2_xx_0_0.set_max_gain(65536) self.analog_agc2_xx_0 = analog.agc2_cc(1e-3, 1e-3, 0.5, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect((self.satnogs_ax25_decoder_bm_0, 'pdu'), (self.satnogs_frame_file_sink_0_1_0, 'frame')) self.msg_connect((self.satnogs_ax25_decoder_bm_0, 'pdu'), (self.satnogs_udp_msg_sink_0_0, 'in')) self.msg_connect((self.satnogs_ax25_decoder_bm_0_0, 'pdu'), (self.satnogs_frame_file_sink_0_1_0, 'frame')) self.msg_connect((self.satnogs_ax25_decoder_bm_0_0, 'pdu'), (self.satnogs_udp_msg_sink_0_0, 'in')) self.msg_connect((self.satnogs_tcp_rigctl_msg_source_0, 'freq'), (self.satnogs_coarse_doppler_correction_cc_0, 'freq')) self.connect((self.analog_agc2_xx_0, 0), (self.pfb_arb_resampler_xxx_0_0, 0)) self.connect((self.analog_agc2_xx_0_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.satnogs_ogg_encoder_0, 0)) self.connect((self.blocks_rotator_cc_0, 0), (self.satnogs_coarse_doppler_correction_cc_0, 0)) self.connect((self.blocks_rotator_cc_0_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.satnogs_ax25_decoder_bm_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.satnogs_ax25_decoder_bm_0_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_constellation_receiver_cb_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.digital_costas_loop_cc_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_rotator_cc_0_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_rotator_cc_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.analog_agc2_xx_0_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.satnogs_iq_sink_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.satnogs_waterfall_sink_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.satnogs_coarse_doppler_correction_cc_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.satnogs_coarse_doppler_correction_cc_0, 0), (self.pfb_arb_resampler_xxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "vor_record_sigmf") Qt.QWidget.__init__(self) self.setWindowTitle("vor_record_sigmf") 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") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.throttle_rate = throttle_rate = 1 self.samp_rate = samp_rate = 250e3 self.fine = fine = 0 self.decim = decim = 5 self.audio_gain_30hz = audio_gain_30hz = 1 self.alpha = alpha = .02 ################################################## # 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._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.sigmf_source_0 = gr_sigmf.source( '/captures/20191216/VOR_2019-12-16T18:51:17Z.sigmf-data', "cf32" + ("_le" if sys.byteorder == "little" else "_be"), False) self.rational_resampler_xxx_2 = filter.rational_resampler_fff( interpolation=66, decimation=1, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_1 = filter.rational_resampler_fff( interpolation=66, decimation=1, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0_0_0 = filter.rational_resampler_ccc( interpolation=24, decimation=25, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 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( 1024, #size samp_rate / decim / 25 * 24, #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(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_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 = ['', '', '', '', '', '', '', '', '', ''] 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, 6, 4, 2, 4) for r in range(6, 8): 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 samp_rate / decim / 25 * 24, #samp_rate "30 Hz Variable", #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, 0, "") 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 = ['', '', '', '', '', '', '', '', '', ''] 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, 4, 4, 2, 4) for r in range(4, 6): 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 = qtgui.freq_sink_f( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim / 25 * 24, #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(1.0) 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 "float" == "float" or "float" == "msg_float": self.qtgui_freq_sink_x_1.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.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.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_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_0_0 = filter.fir_filter_fff( 1, firdes.low_pass(10, samp_rate / decim / 25 * 24, 1e3, 500, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_fff( 1, firdes.low_pass(1, 48e3, 1, 1, firdes.WIN_HAMMING, 6.76)) self.dc_blocker_xx_0_0 = filter.dc_blocker_ff(1024, True) self.dc_blocker_xx_0 = filter.dc_blocker_ff(1024, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate * throttle_rate, True) self.blocks_multiply_xx_3 = blocks.multiply_vff(1) self.blocks_multiply_xx_2 = blocks.multiply_vff(1) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_integrate_xx_2 = blocks.integrate_ff(66, 1) self.blocks_integrate_xx_0 = blocks.integrate_ff(66, 1) self.blocks_float_to_complex_2 = blocks.float_to_complex(1) self.blocks_float_to_complex_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_divide_xx_0_0 = blocks.divide_ff(1) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_delay_1 = blocks.delay(gr.sizeof_float * 1, 0) self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, 0) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) self.band_pass_filter_0_0 = filter.fir_filter_fff( 1, firdes.band_pass(1, samp_rate / decim / 25 * 24, 25, 35, 5, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0 = filter.fir_filter_fff( 1, firdes.band_pass(1, samp_rate / decim / 25 * 24, 25, 35, 5, firdes.WIN_HAMMING, 6.76)) self._audio_gain_30hz_tool_bar = Qt.QToolBar(self) self._audio_gain_30hz_tool_bar.addWidget(Qt.QLabel('vol30' + ": ")) self._audio_gain_30hz_line_edit = Qt.QLineEdit( str(self.audio_gain_30hz)) self._audio_gain_30hz_tool_bar.addWidget( self._audio_gain_30hz_line_edit) self._audio_gain_30hz_line_edit.returnPressed.connect( lambda: self.set_audio_gain_30hz( eng_notation.str_to_num( str(self._audio_gain_30hz_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._audio_gain_30hz_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( samp_rate, analog.GR_COS_WAVE, 9960, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -1 * fine, 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=samp_rate / decim / 25 * 24, audio_decim=1, deviation=1e3, audio_pass=100, audio_stop=200, gain=1.0, tau=75e-6, ) self.analog_const_source_x_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 0) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=48e3, audio_decim=1, audio_pass=12000, audio_stop=13000, ) 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) self._alpha_tool_bar = Qt.QToolBar(self) self._alpha_tool_bar.addWidget(Qt.QLabel('alpha' + ": ")) self._alpha_line_edit = Qt.QLineEdit(str(self.alpha)) self._alpha_tool_bar.addWidget(self._alpha_line_edit) self._alpha_line_edit.returnPressed.connect(lambda: self.set_alpha( eng_notation.str_to_num(str(self._alpha_line_edit.text().toAscii()) ))) self.top_grid_layout.addWidget(self._alpha_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) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1)) 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_0, 0), (self.blocks_multiply_xx_0, 1)) 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), (self.low_pass_filter_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_divide_xx_0_0, 1)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_3, 0)) self.connect((self.blocks_delay_1, 0), (self.blocks_multiply_xx_2, 1)) self.connect((self.blocks_divide_xx_0, 0), (self.blocks_float_to_complex_2, 0)) self.connect((self.blocks_divide_xx_0_0, 0), (self.blocks_float_to_complex_2, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.blocks_float_to_complex_1, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.blocks_float_to_complex_2, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.blocks_integrate_xx_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.blocks_integrate_xx_2, 0), (self.rational_resampler_xxx_2, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.analog_fm_demod_cf_0, 0)) self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_integrate_xx_0, 0)) self.connect((self.blocks_multiply_xx_3, 0), (self.blocks_integrate_xx_2, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.blocks_delay_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.blocks_multiply_xx_2, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.dc_blocker_xx_0_0, 0), (self.blocks_delay_1, 0)) self.connect((self.dc_blocker_xx_0_0, 0), (self.blocks_multiply_xx_3, 1)) self.connect((self.dc_blocker_xx_0_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_pll_carriertracking_cc_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_float_to_complex_1, 0)) self.connect((self.rational_resampler_xxx_2, 0), (self.blocks_divide_xx_0_0, 0)) self.connect((self.rational_resampler_xxx_2, 0), (self.blocks_float_to_complex_1, 1)) self.connect((self.sigmf_source_0, 0), (self.blocks_throttle_0, 0))
def test_005(self): ''' Test the complex AGC loop (attack and decay rate inputs) ''' tb = self.tb expected_result = \ ((100.000244140625+7.2191943445432116e-07j), (0.80881959199905396+0.58764183521270752j), (0.30894950032234192+0.95084899663925171j), (-0.30895623564720154+0.95086973905563354j), (-0.80887287855148315+0.58768033981323242j), (-0.99984413385391235+5.850709250410091e-09j), (-0.80889981985092163-0.58770018815994263j), (-0.30897706747055054-0.95093393325805664j), (0.30898112058639526-0.95094609260559082j), (0.80893135070800781-0.58772283792495728j), (0.99990922212600708-8.7766354184282136e-09j), (0.80894720554351807+0.58773452043533325j), (0.30899339914321899+0.95098406076431274j), (-0.30899572372436523+0.95099133253097534j), (-0.80896598100662231+0.58774799108505249j), (-0.99994778633117676+1.4628290578855285e-08j), (-0.80897533893585205-0.58775502443313599j), (-0.30900305509567261-0.95101380348205566j), (0.30900448560714722-0.95101797580718994j), (0.80898630619049072-0.58776277303695679j), (0.99997037649154663-1.7554345532744264e-08j), (0.80899184942245483+0.58776694536209106j), (0.30900871753692627+0.95103120803833008j), (-0.30900952219963074+0.95103377103805542j), (-0.8089984655380249+0.58777159452438354j), (-0.99998390674591064+2.3406109050938539e-08j), (-0.809001624584198-0.58777409791946411j), (-0.30901208519935608-0.95104163885116577j), (0.30901262164115906-0.95104306936264038j), (0.80900543928146362-0.587776780128479j), (0.99999171495437622-2.6332081404234486e-08j), (0.80900734663009644+0.58777821063995361j), (0.30901408195495605+0.95104765892028809j), (-0.30901429057121277+0.95104855298995972j), (-0.80900967121124268+0.58777981996536255j), (-0.99999648332595825+3.2183805842578295e-08j), (-0.80901080369949341-0.58778077363967896j), (-0.30901527404785156-0.95105135440826416j), (0.30901545286178589-0.95105189085006714j), (0.80901217460632324-0.58778166770935059j), (0.99999916553497314-3.5109700036173308e-08j), (0.809012770652771+0.58778214454650879j), (0.30901595950126648+0.9510534405708313j), (-0.30901598930358887+0.95105385780334473j), (-0.80901366472244263+0.58778274059295654j), (-1.0000008344650269+4.0961388947380328e-08j), (-0.8090139627456665-0.58778303861618042j), (-0.30901634693145752-0.95105475187301636j), (0.30901640653610229-0.95105493068695068j), (0.80901449918746948-0.5877833366394043j)) sampling_freq = 100 src1 = analog.sig_source_c(sampling_freq, analog.GR_SIN_WAVE, sampling_freq * 0.10, 100) dst1 = blocks.vector_sink_c() head = blocks.head(gr.sizeof_gr_complex, int(5*sampling_freq * 0.10)) agc = analog.agc2_cc(1e-2, 1e-3, 1, 1) tb.connect(src1, head) tb.connect(head, agc) tb.connect(agc, dst1) tb.run() dst_data = dst1.data() self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 4)
def __init__(self,samples_per_symbol,demod_type,rx_callback,SNR,equal="HLS_LS"): gr.hier_block2.__init__(self, "receive_path", gr.io_signature(1,1,gr.sizeof_gr_complex), gr.io_signature(0,0,0)) self.samples_per_symbol = samples_per_symbol self.demod_type = demod_type if(self.demod_type == "bpsk"): self.bits = 1 else: self.bits = 2 self.block_size = 128 self.cp_size = 32 self.db_num = 4 self.eb_num = 1 sw_decim = 1 self.chbw_factor = 1.0 self.excess_bw = 0.35 self.timing_bw = 2*math.pi/100 self.timing_max_dev = 1.5 self.thresh = 0.5 self.k = 50 self.equal_method = equal # MMSE or LS chan_coeffs = filter.firdes.low_pass(1.0, # gain sw_decim * self.samples_per_symbol, #sampling rate self.chbw_factor, # midpoint of trans. band 0.5, # width of trans. band filter.firdes.WIN_HANN) # filter type self.channel_filter = filter.fft_filter_ccc(sw_decim, chan_coeffs) self.agc = analog.agc2_cc(0.6e-1, 1e-3, 1, 1) #pulse shaping nfilts = 32 ntaps = nfilts*11*int(self.samples_per_symbol) taps = filter.firdes.root_raised_cosine(nfilts, nfilts*self.samples_per_symbol, 1.0, self.excess_bw, ntaps) self.time_recov = digital.pfb_clock_sync_ccf(self.samples_per_symbol,self.timing_bw, taps, nfilts, nfilts//2, self.timing_max_dev) self.time_sync = timing_sync(self.block_size,self.cp_size,self.thresh,self.k) #### for perfect timing synchromization #self.time_sync = scfde.simulation_perfect_timing_cb(self.block_size,self.cp_size,6) self.block_acq = scfde.block_acquization_cbcb(block_size=self.block_size,cp_size=self.cp_size, eb_num=self.eb_num,db_num=self.db_num) self.freq_sync = scfde.frequency_sync_cbcb(block_size=self.block_size,cp_size=self.cp_size) self.fde = scfde.frequency_domain_equalize_cbcc(block_size=self.block_size, cp_size=self.cp_size, eb_num=self.eb_num, equal_method=self.equal_method, SNR=SNR) self.demod = scfde.demod_mapper_cbb(demod_type=self.demod_type,data_size=self.block_size) self.pack = scfde.pack_k_bits_bbbb(self.bits) self.rcvd_pktq = gr.msg_queue() self.sink = scfde.message_acquization_bb(self.rcvd_pktq,frame_size=self.block_size/8*self.bits) self.watcher = queue_watcher_thread(self.rcvd_pktq,rx_callback) self.connect(self,self.channel_filter,self.agc,self.time_recov) self.connect(self.time_recov,self.time_sync) self.connect(self.time_recov,(self.block_acq,0)) #self.connect(self,self.time_sync) #self.connect(self,(self.block_acq,0)) self.connect(self.time_sync,(self.block_acq,1)) self.connect((self.block_acq,0),(self.freq_sync,0)) self.connect((self.block_acq,1),(self.freq_sync,1)) self.connect((self.freq_sync,0),(self.fde,0)) self.connect((self.freq_sync,1),(self.fde,1)) self.connect((self.fde,0),self.demod) self.connect((self.demod,0),(self.pack,0)) self.connect((self.demod,1),(self.pack,1)) self.connect((self.pack,0),(self.sink,0)) self.connect((self.pack,1),(self.sink,1)) self.write_data()