def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 44100 self.center1 = center1 = 0 ################################################## # Blocks ################################################## self._center1_range = Range(-20000, 20000, 100, 0, 200) self._center1_win = RangeWidget(self._center1_range, self.set_center1, "center1", "counter_slider", float) self.top_layout.addWidget(self._center1_win) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_fcf(1, (1, ), center1, samp_rate) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc(1, (1, ), center1, samp_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_complex_to_float_0_0 = blocks.complex_to_float(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.audio_source_0 = audio.source(samp_rate, "", True) self.audio_sink_0 = audio.sink(samp_rate, "", True) self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.audio_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.audio_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_complex_to_float_0_0, 0), (self.audio_sink_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.blocks_complex_to_float_0_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_complex_to_float_0, 0))
def test_fft_filter_ccf_002(self): self.generate_ccf_source() decim = 4 lo = sig_source_c(self.fs, -self.fc, 1, len(self.src_data)) despun = mix(lo, self.src_data) expected_data = fir_filter(despun, self.taps, decim) src = blocks.vector_source_c(self.src_data) op = filter.freq_xlating_fft_filter_ccc(decim, self.taps, self.fc, self.fs) dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() self.assert_fft_ok(expected_data, result_data)
def __init__(self, decim, center_freq, sample_rate, baud_rate, alpha=0.35): gr.hier_block2.__init__( self, "tone_detector_cf", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_float), ) self.center_freq = center_freq self.sample_rate = sample_rate self.baud_rate = baud_rate self.alpha = alpha self._filter = freq_xlating_fft_filter_ccc(int(decim), self._taps(), float(center_freq), float(sample_rate)) self._mag = blocks.complex_to_mag_squared() self.connect(self, self._filter, self._mag, self)
def __init__(self, seq1, seq2, factor, lookahead, alpha, freqs): """ Description: frequency timing estimator class does frequency/timing acquisition from scratch.It uses a bank of parallel correlators at each specified frequency. It then takes the max abs value of all these and passes it through a peak detector to find timing. Args: seq1: sequence1 of kronecker filter, which is the given training sequence. seq2: sequence2 of kronecker filter, which is the pulse for each training symbol. factor: the rise and fall factors in peak detector, which is the factor determining when a peak has started and ended. In the peak detector, an average of the signal is calculated. When the value of the signal goes over factor*average, we start looking for a peak. When the value of the signal goes below factor*average, we stop looking for a peak. alpha: the smoothing factor of a moving average filter used in the peak detector taking values in (0,1). freqs: the vector of normalized center frequencies for each matched filter. Note that for a training sequence of length Nt, each matched filter can recover a sequence with normalized frequency offset ~ 1/(2Nt). """ gr.hier_block2.__init__(self, "freq_timing_estimator", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signaturev(3, 3, [gr.sizeof_char*1, gr.sizeof_float*1, gr.sizeof_float*1]), ) ################################################## # Parameters ################################################## self.seq1 = seq1 self.seq2 = seq2 self.factor = factor self.lookahead = lookahead self.alpha = alpha self.freqs = freqs self.n = n = len(freqs) self.on = 1 ################################################## # Blocks ################################################## self._filter=[0]*self.n self._c2mag2=[0]*self.n for i in range(self.n): #self._filter[i]= cdma.kronecker_filter(seq1,seq2,1,self.freqs[i]) #self._filter[i]= filter.freq_xlating_fir_filter_ccc(1, numpy.kron(seq1,seq2), self.freqs[i], 1) self._filter[i]= filter.freq_xlating_fft_filter_ccc(1, numpy.kron(seq1,seq2), self.freqs[i], 1) self._c2mag2[i] = blocks.complex_to_mag_squared(1) self.blocks_max = blocks.max_ff(1) self.blocks_peak_detector = cdma.switched_peak_detector_fb(self.factor, self.factor, self.lookahead, self.alpha, self.on) self.blocks_argmax = blocks.argmax_fs(1) self.blocks_null_sink = blocks.null_sink(gr.sizeof_short*1) self.digital_chunks_to_symbols = digital.chunks_to_symbols_sf((freqs), 1) self.blocks_sample_and_hold = blocks.sample_and_hold_ff() ################################################## # Connections ################################################## for i in range(self.n): self.connect((self, 0), (self._filter[i], 0)) self.connect((self._filter[i], 0), (self._c2mag2[i], 0)) self.connect((self._c2mag2[i], 0), (self.blocks_max, i)) self.connect((self._c2mag2[i], 0), (self.blocks_argmax, i)) self.connect((self.blocks_max, 0), (self.blocks_peak_detector, 0)) self.connect((self.blocks_peak_detector, 0), (self, 0)) self.connect((self.blocks_argmax, 0), (self.blocks_null_sink, 0)) self.connect((self.blocks_argmax, 1), (self.digital_chunks_to_symbols, 0)) self.connect((self.digital_chunks_to_symbols, 0), (self.blocks_sample_and_hold, 0)) self.connect((self.blocks_peak_detector, 0), (self.blocks_sample_and_hold, 1)) self.connect((self.blocks_sample_and_hold, 0), (self, 1)) self.connect((self.blocks_max, 0), (self, 2))
def __init__(self): gr.top_block.__init__(self, "Tetra Rx Multi") options = self.get_options() ################################################## # Variables ################################################## self.srate_rx = srate_rx = options.sample_rate self.channels = srate_rx / 25000 self.srate_channel = 36000 self.afc_period = 5 self.afc_gain = 1. self.afc_channel = options.auto_tune or -1 self.afc_ppm_step = 100 self.debug = options.debug self.last_pwr = -100000 self.sig_det_period = 10 self.sig_det_bw = sig_det_bw = options.sig_detection_bw or srate_rx if self.sig_det_bw <= 1.: self.sig_det_bw *= srate_rx self.sig_det_threshold = options.sig_detection_threshold self.sig_det_channels = [] for ch in range(self.channels): if ch >= self.channels / 2: ch_ = (self.channels - ch - 1) else: ch_ = ch if (float(ch_) / self.channels * 2) <= (self.sig_det_bw / srate_rx): self.sig_det_channels.append(ch) ################################################## # RPC server ################################################## self.xmlrpc_server = SimpleXMLRPCServer.SimpleXMLRPCServer( ("localhost", options.listen_port), allow_none=True) self.xmlrpc_server.register_instance(self) threading.Thread(target=self.xmlrpc_server.serve_forever).start() ################################################## # Rx Blocks and connections ################################################## self.src = osmosdr.source( args=options.args ) self.src.set_sample_rate(srate_rx) self.src.set_center_freq(options.frequency, 0) self.src.set_freq_corr(options.ppm, 0) self.src.set_dc_offset_mode(0, 0) self.src.set_iq_balance_mode(0, 0) if options.gain is not None: self.src.set_gain_mode(False, 0) self.src.set_gain(36, 0) else: self.src.set_gain_mode(True, 0) out_type, dst_path = options.output.split("://", 1) if out_type == "udp": dst_ip, dst_port = dst_path.split(':', 1) self.freq_xlating = freq_xlating_fft_filter_ccc(1, (1, ), 0, srate_rx) self.channelizer = pfb.channelizer_ccf( self.channels, (firdes.root_raised_cosine(1, srate_rx, 18000, 0.35, 1024)), 36./25., 100) self.squelch = [] self.digital_mpsk_receiver_cc = [] self.diff_phasor = [] self.complex_to_arg = [] self.multiply_const = [] self.add_const = [] self.float_to_uchar = [] self.map_bits = [] self.unpack_k_bits = [] self.blocks_sink = [] for ch in range(0, self.channels): squelch = analog.pwr_squelch_cc(0, 0.001, 0, True) mpsk = digital.mpsk_receiver_cc( 4, math.pi/4, math.pi/100.0, -0.5, 0.5, 0.25, 0.001, 2, 0.001, 0.001) diff_phasor = digital.diff_phasor_cc() complex_to_arg = blocks.complex_to_arg(1) multiply_const = blocks.multiply_const_vff((2./math.pi, )) add_const = blocks.add_const_vff((1.5, )) float_to_uchar = blocks.float_to_uchar() map_bits = digital.map_bb(([3, 2, 0, 1, 3])) unpack_k_bits = blocks.unpack_k_bits_bb(2) brmchannels = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,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,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71] #brmchannels = [11,4,3,64,45,47,53,8,68,6,56,49,17,54,65,5,71,22,48,7,50] # itds kancl #brmchannels = [23,13,40,69,59,7,42,54,5,14,4,56,45,46,67,55,66,44,71,49,31,57,0,65,70] # doma - dole brmchannels = [23,13,59,40,69,7,49,60,42,70,4,50,66,67,3,14,57,33,46,22,68,32,39,24,6,12,43,58,48,17,5,56,65,29,54,30,16,52,53,41,47,2,34,44,8] # doma - strecha #brmchannels = [67, 7, 23, 70] # doma - strecha - SDS brmchannels = [67, 7, 23, 70,9,71,64,63,62,61,55,51,45,38,37,36,35,31,28,27,26,25,21,20,19,18,15,11,10,1,0] # doma - strecha - komplement if out_type == 'udp': sink = blocks.udp_sink(gr.sizeof_gr_char, dst_ip, int(dst_port)+ch, 1472, True) elif out_type == 'file': sink = blocks.file_sink(gr.sizeof_char, dst_path % ch, False) sink.set_unbuffered(True) else: raise ValueError("Invalid output URL '%s'" % options.output) if ch in brmchannels: self.connect((self.channelizer, ch), #(squelch, 0), (mpsk, 0), (diff_phasor, 0), (complex_to_arg, 0), (multiply_const, 0), (add_const, 0), (float_to_uchar, 0), (map_bits, 0), (unpack_k_bits, 0), (sink, 0)) self.squelch.append(squelch) self.digital_mpsk_receiver_cc.append(mpsk) self.diff_phasor.append(diff_phasor) self.complex_to_arg.append(complex_to_arg) self.multiply_const.append(multiply_const) self.add_const.append(add_const) self.float_to_uchar.append(float_to_uchar) self.map_bits.append(map_bits) self.unpack_k_bits.append(unpack_k_bits) self.blocks_sink.append(sink) self.connect( (self.src, 0), (self.freq_xlating, 0), (self.channelizer, 0)) ################################################## # signal strenght identification ################################################## self.pwr_probes = [] for ch in range(self.channels): pwr_probe = analog.probe_avg_mag_sqrd_c(0, 1./self.srate_channel) self.pwr_probes.append(pwr_probe) self.connect((self.channelizer, ch), (pwr_probe, 0)) def _sig_det_probe(): while True: pwr = [self.pwr_probes[ch].level() for ch in range(self.channels) if ch in self.sig_det_channels] pwr = [10 * math.log10(p) for p in pwr if p > 0.] if not pwr: continue pwr = min(pwr) + self.sig_det_threshold print "power threshold target %f"%pwr if abs(pwr - self.last_pwr) > (self.sig_det_threshold / 2): for s in self.squelch: s.set_threshold(pwr) self.last_pwr = pwr time.sleep(self.sig_det_period) if self.sig_det_threshold is not None: self._sig_det_probe_thread = threading.Thread(target=_sig_det_probe) self._sig_det_probe_thread.daemon = True self._sig_det_probe_thread.start() ################################################## # AFC blocks and connections ################################################## self.afc_selector = grc_blks2.selector( item_size=gr.sizeof_gr_complex, num_inputs=self.channels, num_outputs=1, input_index=0, output_index=0, ) self.afc_demod = analog.quadrature_demod_cf(self.srate_channel/(2*math.pi)) samp_afc = self.srate_channel*self.afc_period / 2 self.afc_avg = blocks.moving_average_ff(samp_afc, 1./samp_afc*self.afc_gain) self.afc_probe = blocks.probe_signal_f() def _afc_probe(): while True: time.sleep(self.afc_period) if self.afc_channel == -1: continue err = self.afc_probe.level() if abs(err) < self.afc_ppm_step: continue freq = self.freq_xlating.center_freq + err * self.afc_gain print "err: %f\tfreq: %f" % (err, freq, ) self.freq_xlating.set_center_freq(freq) self.afc_channel = 23 self._afc_err_thread = threading.Thread(target=_afc_probe) self._afc_err_thread.daemon = True self._afc_err_thread.start() for ch in range(self.channels): self.connect((self.channelizer, ch), (self.afc_selector, ch)) self.connect( (self.afc_selector, 0), (self.afc_demod, 0), (self.afc_avg, 0), (self.afc_probe, 0)) if self.afc_channel != -1: self.afc_selector.set_input_index(self.afc_channel)
def __init__(self): gr.top_block.__init__(self, "CP v0.4a") Qt.QWidget.__init__(self) self.setWindowTitle("CP v0.4a") 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", "cp04a") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.radio_freq = radio_freq = 100 self.samp_rate = samp_rate = 2.4e6 self.rf_gain = rf_gain = 10 self.freq = freq = radio_freq * 1000000 self.ch3_volume = ch3_volume = 1 self.ch3_squelch = ch3_squelch = -30 self.ch3_mute = ch3_mute = 1 self.ch3_modulation = ch3_modulation = 0 self.ch3_invert = ch3_invert = 1 self.ch3_freq = ch3_freq = radio_freq self.ch2_volume = ch2_volume = 1 self.ch2_squelch = ch2_squelch = -30 self.ch2_mute = ch2_mute = 1 self.ch2_modulation = ch2_modulation = 0 self.ch2_invert = ch2_invert = 1 self.ch2_freq = ch2_freq = radio_freq self.ch1_volume = ch1_volume = 1 self.ch1_squelch = ch1_squelch = -30 self.ch1_mute = ch1_mute = 1 self.ch1_modulation = ch1_modulation = 0 self.ch1_invert = ch1_invert = 1 self.ch1_freq = ch1_freq = radio_freq ################################################## # Blocks ################################################## self.settings = Qt.QTabWidget() self.settings_widget_0 = Qt.QWidget() self.settings_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.settings_widget_0) self.settings_grid_layout_0 = Qt.QGridLayout() self.settings_layout_0.addLayout(self.settings_grid_layout_0) self.settings.addTab(self.settings_widget_0, "Settings") self.top_grid_layout.addWidget(self.settings, 4, 3, 2, 3) self.tabs = Qt.QTabWidget() self.tabs_widget_0 = Qt.QWidget() self.tabs_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_0) self.tabs_grid_layout_0 = Qt.QGridLayout() self.tabs_layout_0.addLayout(self.tabs_grid_layout_0) self.tabs.addTab(self.tabs_widget_0, "Ch 1") self.tabs_widget_1 = Qt.QWidget() self.tabs_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_1) self.tabs_grid_layout_1 = Qt.QGridLayout() self.tabs_layout_1.addLayout(self.tabs_grid_layout_1) self.tabs.addTab(self.tabs_widget_1, "Ch 2") self.tabs_widget_2 = Qt.QWidget() self.tabs_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_2) self.tabs_grid_layout_2 = Qt.QGridLayout() self.tabs_layout_2.addLayout(self.tabs_grid_layout_2) self.tabs.addTab(self.tabs_widget_2, "Ch 3") self.top_grid_layout.addWidget(self.tabs, 4, 0, 2, 3) self._rf_gain_range = Range(0, 50, 1, 10, 100) self._rf_gain_win = RangeWidget(self._rf_gain_range, self.set_rf_gain, "RF Gain", "counter_slider", float) self.settings_grid_layout_0.addWidget(self._rf_gain_win, 1, 0, 1, 1) self._ch2_volume_range = Range(0, 10, 1, 1, 50) self._ch2_volume_win = RangeWidget(self._ch2_volume_range, self.set_ch2_volume, "Volume", "counter_slider", int) self.top_grid_layout.addWidget(self._ch2_volume_win, 1, 2, 1, 1) self._ch2_squelch_range = Range(-70, 0, 10, -30, 50) self._ch2_squelch_win = RangeWidget(self._ch2_squelch_range, self.set_ch2_squelch, "Squelch", "counter_slider", int) self.top_grid_layout.addWidget(self._ch2_squelch_win, 1, 3, 1, 1) _ch2_mute_check_box = Qt.QCheckBox("Mute") self._ch2_mute_choices = {True: 0, False: 1} self._ch2_mute_choices_inv = dict( (v, k) for k, v in self._ch2_mute_choices.iteritems()) self._ch2_mute_callback = lambda i: Qt.QMetaObject.invokeMethod( _ch2_mute_check_box, "setChecked", Qt.Q_ARG("bool", self._ch2_mute_choices_inv[i])) self._ch2_mute_callback(self.ch2_mute) _ch2_mute_check_box.stateChanged.connect( lambda i: self.set_ch2_mute(self._ch2_mute_choices[bool(i)])) self.top_grid_layout.addWidget(_ch2_mute_check_box, 1, 5, 1, 1) self._ch2_modulation_options = ( 0, 1, 2, ) self._ch2_modulation_labels = ( "DMR", "NBFM", "WBFM", ) self._ch2_modulation_tool_bar = Qt.QToolBar(self) self._ch2_modulation_tool_bar.addWidget(Qt.QLabel("Modulation" + ": ")) self._ch2_modulation_combo_box = Qt.QComboBox() self._ch2_modulation_tool_bar.addWidget(self._ch2_modulation_combo_box) for label in self._ch2_modulation_labels: self._ch2_modulation_combo_box.addItem(label) self._ch2_modulation_callback = lambda i: Qt.QMetaObject.invokeMethod( self._ch2_modulation_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._ch2_modulation_options.index(i))) self._ch2_modulation_callback(self.ch2_modulation) self._ch2_modulation_combo_box.currentIndexChanged.connect( lambda i: self.set_ch2_modulation(self._ch2_modulation_options[i])) self.top_grid_layout.addWidget(self._ch2_modulation_tool_bar, 1, 1, 1, 1) _ch2_invert_check_box = Qt.QCheckBox("Invert") self._ch2_invert_choices = {True: -1, False: 1} self._ch2_invert_choices_inv = dict( (v, k) for k, v in self._ch2_invert_choices.iteritems()) self._ch2_invert_callback = lambda i: Qt.QMetaObject.invokeMethod( _ch2_invert_check_box, "setChecked", Qt.Q_ARG("bool", self._ch2_invert_choices_inv[i])) self._ch2_invert_callback(self.ch2_invert) _ch2_invert_check_box.stateChanged.connect( lambda i: self.set_ch2_invert(self._ch2_invert_choices[bool(i)])) self.top_grid_layout.addWidget(_ch2_invert_check_box, 1, 4, 1, 1) self._ch2_freq_tool_bar = Qt.QToolBar(self) self._ch2_freq_tool_bar.addWidget(Qt.QLabel("Ch2 Freq (MHz)" + ": ")) self._ch2_freq_line_edit = Qt.QLineEdit(str(self.ch2_freq)) self._ch2_freq_tool_bar.addWidget(self._ch2_freq_line_edit) self._ch2_freq_line_edit.returnPressed.connect( lambda: self.set_ch2_freq( eng_notation.str_to_num( str(self._ch2_freq_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._ch2_freq_tool_bar, 1, 0, 1, 1) self._ch1_volume_range = Range(0, 10, 1, 1, 100) self._ch1_volume_win = RangeWidget(self._ch1_volume_range, self.set_ch1_volume, "Volume", "counter_slider", int) self.top_grid_layout.addWidget(self._ch1_volume_win, 0, 2, 1, 1) self._ch1_squelch_range = Range(-70, 0, 10, -30, 100) self._ch1_squelch_win = RangeWidget(self._ch1_squelch_range, self.set_ch1_squelch, "Squelch", "counter_slider", int) self.top_grid_layout.addWidget(self._ch1_squelch_win, 0, 3, 1, 1) _ch1_mute_check_box = Qt.QCheckBox("Mute") self._ch1_mute_choices = {True: 0, False: 1} self._ch1_mute_choices_inv = dict( (v, k) for k, v in self._ch1_mute_choices.iteritems()) self._ch1_mute_callback = lambda i: Qt.QMetaObject.invokeMethod( _ch1_mute_check_box, "setChecked", Qt.Q_ARG("bool", self._ch1_mute_choices_inv[i])) self._ch1_mute_callback(self.ch1_mute) _ch1_mute_check_box.stateChanged.connect( lambda i: self.set_ch1_mute(self._ch1_mute_choices[bool(i)])) self.top_grid_layout.addWidget(_ch1_mute_check_box, 0, 5, 1, 1) self._ch1_modulation_options = ( 0, 1, 2, ) self._ch1_modulation_labels = ( "DMR", "NBFM", "WBFM", ) self._ch1_modulation_tool_bar = Qt.QToolBar(self) self._ch1_modulation_tool_bar.addWidget(Qt.QLabel("Modulation" + ": ")) self._ch1_modulation_combo_box = Qt.QComboBox() self._ch1_modulation_tool_bar.addWidget(self._ch1_modulation_combo_box) for label in self._ch1_modulation_labels: self._ch1_modulation_combo_box.addItem(label) self._ch1_modulation_callback = lambda i: Qt.QMetaObject.invokeMethod( self._ch1_modulation_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._ch1_modulation_options.index(i))) self._ch1_modulation_callback(self.ch1_modulation) self._ch1_modulation_combo_box.currentIndexChanged.connect( lambda i: self.set_ch1_modulation(self._ch1_modulation_options[i])) self.top_grid_layout.addWidget(self._ch1_modulation_tool_bar, 0, 1, 1, 1) _ch1_invert_check_box = Qt.QCheckBox("Invert") self._ch1_invert_choices = {True: -1, False: 1} self._ch1_invert_choices_inv = dict( (v, k) for k, v in self._ch1_invert_choices.iteritems()) self._ch1_invert_callback = lambda i: Qt.QMetaObject.invokeMethod( _ch1_invert_check_box, "setChecked", Qt.Q_ARG("bool", self._ch1_invert_choices_inv[i])) self._ch1_invert_callback(self.ch1_invert) _ch1_invert_check_box.stateChanged.connect( lambda i: self.set_ch1_invert(self._ch1_invert_choices[bool(i)])) self.top_grid_layout.addWidget(_ch1_invert_check_box, 0, 4, 1, 1) self._ch1_freq_tool_bar = Qt.QToolBar(self) self._ch1_freq_tool_bar.addWidget(Qt.QLabel("Ch1 Freq (MHz)" + ": ")) self._ch1_freq_line_edit = Qt.QLineEdit(str(self.ch1_freq)) self._ch1_freq_tool_bar.addWidget(self._ch1_freq_line_edit) self._ch1_freq_line_edit.returnPressed.connect( lambda: self.set_ch1_freq( eng_notation.str_to_num( str(self._ch1_freq_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._ch1_freq_tool_bar, 0, 0, 1, 1) self.wbfm_chain_0_0 = wbfm_chain() self.wbfm_chain_0 = wbfm_chain() 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(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(rf_gain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=400000, decimation=2400000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=400000, decimation=2400000, taps=None, fractional_bw=None, ) self._radio_freq_tool_bar = Qt.QToolBar(self) self._radio_freq_tool_bar.addWidget( Qt.QLabel("Radio Freq (MHz)" + ": ")) self._radio_freq_line_edit = Qt.QLineEdit(str(self.radio_freq)) self._radio_freq_tool_bar.addWidget(self._radio_freq_line_edit) self._radio_freq_line_edit.returnPressed.connect( lambda: self.set_radio_freq( eng_notation.str_to_num( str(self._radio_freq_line_edit.text().toAscii())))) self.settings_grid_layout_0.addWidget(self._radio_freq_tool_bar, 0, 0, 1, 1) 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) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if complex == type(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, 10, 0, 10, 6) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 512, #size firdes.WIN_BLACKMAN_hARRIS, #wintype (ch2_freq * 1000000), #fc 400000, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) 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(0.2) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0.disable_legend() if complex == type(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(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.tabs_grid_layout_1.addWidget(self._qtgui_freq_sink_x_0_0_win, 0, 0, 1, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 512, #size firdes.WIN_BLACKMAN_hARRIS, #wintype (ch1_freq * 1000000), #fc 400000, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() 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.tabs_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 1, 1) self.nbfm_chain_0_0 = nbfm_chain() self.nbfm_chain_0 = nbfm_chain() self.freq_xlating_fft_filter_ccc_0_0 = filter.freq_xlating_fft_filter_ccc( 1, (firdes.low_pass(1, samp_rate, 200000, 10000)), (ch2_freq * 1000000) - freq, samp_rate) self.freq_xlating_fft_filter_ccc_0_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0_0.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc( 1, (firdes.low_pass(1, samp_rate, 200000, 10000)), (ch1_freq * 1000000) - freq, samp_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) self.dsd_chain_0_0 = dsd_chain() self.dsd_chain_0 = dsd_chain() self._ch3_volume_range = Range(0, 10, 1, 1, 50) self._ch3_volume_win = RangeWidget(self._ch3_volume_range, self.set_ch3_volume, "Volume", "counter_slider", int) self.top_grid_layout.addWidget(self._ch3_volume_win, 2, 2, 1, 1) self._ch3_squelch_range = Range(-70, 0, 10, -30, 50) self._ch3_squelch_win = RangeWidget(self._ch3_squelch_range, self.set_ch3_squelch, "Squelch", "counter_slider", int) self.top_grid_layout.addWidget(self._ch3_squelch_win, 2, 3, 1, 1) _ch3_mute_check_box = Qt.QCheckBox("Mute") self._ch3_mute_choices = {True: 0, False: 1} self._ch3_mute_choices_inv = dict( (v, k) for k, v in self._ch3_mute_choices.iteritems()) self._ch3_mute_callback = lambda i: Qt.QMetaObject.invokeMethod( _ch3_mute_check_box, "setChecked", Qt.Q_ARG("bool", self._ch3_mute_choices_inv[i])) self._ch3_mute_callback(self.ch3_mute) _ch3_mute_check_box.stateChanged.connect( lambda i: self.set_ch3_mute(self._ch3_mute_choices[bool(i)])) self.top_grid_layout.addWidget(_ch3_mute_check_box, 2, 5, 1, 1) self._ch3_modulation_options = ( 0, 1, 2, ) self._ch3_modulation_labels = ( "DMR", "NBFM", "WBFM", ) self._ch3_modulation_tool_bar = Qt.QToolBar(self) self._ch3_modulation_tool_bar.addWidget(Qt.QLabel("Modulation" + ": ")) self._ch3_modulation_combo_box = Qt.QComboBox() self._ch3_modulation_tool_bar.addWidget(self._ch3_modulation_combo_box) for label in self._ch3_modulation_labels: self._ch3_modulation_combo_box.addItem(label) self._ch3_modulation_callback = lambda i: Qt.QMetaObject.invokeMethod( self._ch3_modulation_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._ch3_modulation_options.index(i))) self._ch3_modulation_callback(self.ch3_modulation) self._ch3_modulation_combo_box.currentIndexChanged.connect( lambda i: self.set_ch3_modulation(self._ch3_modulation_options[i])) self.top_grid_layout.addWidget(self._ch3_modulation_tool_bar, 2, 1, 1, 1) _ch3_invert_check_box = Qt.QCheckBox("Invert") self._ch3_invert_choices = {True: -1, False: 1} self._ch3_invert_choices_inv = dict( (v, k) for k, v in self._ch3_invert_choices.iteritems()) self._ch3_invert_callback = lambda i: Qt.QMetaObject.invokeMethod( _ch3_invert_check_box, "setChecked", Qt.Q_ARG("bool", self._ch3_invert_choices_inv[i])) self._ch3_invert_callback(self.ch3_invert) _ch3_invert_check_box.stateChanged.connect( lambda i: self.set_ch3_invert(self._ch3_invert_choices[bool(i)])) self.top_grid_layout.addWidget(_ch3_invert_check_box, 2, 4, 1, 1) self._ch3_freq_tool_bar = Qt.QToolBar(self) self._ch3_freq_tool_bar.addWidget(Qt.QLabel("Ch3 Freq (MHz)" + ": ")) self._ch3_freq_line_edit = Qt.QLineEdit(str(self.ch3_freq)) self._ch3_freq_tool_bar.addWidget(self._ch3_freq_line_edit) self._ch3_freq_line_edit.returnPressed.connect( lambda: self.set_ch3_freq( eng_notation.str_to_num( str(self._ch3_freq_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._ch3_freq_tool_bar, 2, 0, 1, 1) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff( (ch2_invert * ch2_mute, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff( (ch1_invert * ch1_mute, )) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff( (ch2_volume, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (ch1_volume, )) self.blks2_selector_0_1 = grc_blks2.selector( item_size=gr.sizeof_gr_complex * 1, num_inputs=1, num_outputs=3, input_index=0, output_index=ch2_modulation, ) self.blks2_selector_0_0_0 = grc_blks2.selector( item_size=gr.sizeof_float * 1, num_inputs=3, num_outputs=1, input_index=ch2_modulation, output_index=0, ) self.blks2_selector_0_0 = grc_blks2.selector( item_size=gr.sizeof_float * 1, num_inputs=3, num_outputs=1, input_index=ch1_modulation, output_index=0, ) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex * 1, num_inputs=1, num_outputs=3, input_index=0, output_index=ch1_modulation, ) self.audio_sink_0_0 = audio.sink(48000, "", True) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_pwr_squelch_xx_0_0_0 = analog.pwr_squelch_cc( ch2_squelch, 1e-4, 0, True) self.analog_pwr_squelch_xx_0_0 = analog.pwr_squelch_cc( ch1_squelch, 1e-4, 0, True) ################################################## # Connections ################################################## self.connect((self.analog_pwr_squelch_xx_0_0, 0), (self.blks2_selector_0, 0)) self.connect((self.analog_pwr_squelch_xx_0_0_0, 0), (self.blks2_selector_0_1, 0)) self.connect((self.blks2_selector_0, 0), (self.dsd_chain_0, 0)) self.connect((self.blks2_selector_0, 1), (self.nbfm_chain_0, 0)) self.connect((self.blks2_selector_0, 2), (self.wbfm_chain_0, 0)) self.connect((self.blks2_selector_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blks2_selector_0_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blks2_selector_0_1, 0), (self.dsd_chain_0_0, 0)) self.connect((self.blks2_selector_0_1, 1), (self.nbfm_chain_0_0, 0)) self.connect((self.blks2_selector_0_1, 2), (self.wbfm_chain_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.audio_sink_0_0, 0)) self.connect((self.dsd_chain_0, 0), (self.blks2_selector_0_0, 0)) self.connect((self.dsd_chain_0_0, 0), (self.blks2_selector_0_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.analog_pwr_squelch_xx_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.analog_pwr_squelch_xx_0_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.nbfm_chain_0, 0), (self.blks2_selector_0_0, 1)) self.connect((self.nbfm_chain_0_0, 0), (self.blks2_selector_0_0_0, 1)) 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.qtgui_freq_sink_x_0_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.wbfm_chain_0, 0), (self.blks2_selector_0_0, 2)) self.connect((self.wbfm_chain_0_0, 0), (self.blks2_selector_0_0_0, 2))
def __init__(self): gr.top_block.__init__(self, "NOAA Demo based on PFB Channelizer Demo") Qt.QWidget.__init__(self) self.setWindowTitle("NOAA Demo based on PFB Channelizer Demo") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "noaa_demo") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.noaa_num_chans = noaa_num_chans = 7 self.noaa_chan_width = noaa_chan_width = int(25e3) self.noaa_band_start = noaa_band_start = 162.4e6 self.oversampled_width = oversampled_width = noaa_chan_width * (noaa_num_chans + 1) self.noaa_fm_dev = noaa_fm_dev = int(5e3) self.noaa_band_center = noaa_band_center = noaa_band_start + (noaa_num_chans / 2 * noaa_chan_width) self.hardware_rate = hardware_rate = int(1e6) self.tuner_freq = tuner_freq = 162.3e6 self.target_freq = target_freq = noaa_band_center self.ppm = ppm = 0 self.pfb_taps = pfb_taps = firdes.low_pass(2.0, oversampled_width, noaa_fm_dev*2 ,1000, firdes.WIN_HAMMING, 6.76) self.lpf_taps = lpf_taps = firdes.low_pass(1.0, hardware_rate, oversampled_width / 2,noaa_chan_width, firdes.WIN_HAMMING, 6.76) self.channel_map = channel_map = range(0, noaa_num_chans) self.volume = volume = 0.15 self.tuner_offset = tuner_offset = target_freq - tuner_freq self.ppm_corr = ppm_corr = tuner_freq * (ppm/1e6) self.pfb_sizeof_taps = pfb_sizeof_taps = len(pfb_taps) self.noaa_band_width = noaa_band_width = noaa_chan_width * noaa_num_chans self.noaa_band_end = noaa_band_end = noaa_band_start + (noaa_num_chans * noaa_chan_width) self.lpf_sizeof_taps = lpf_sizeof_taps = len(lpf_taps) self.fftwidth = fftwidth = 512 self.fft_interval = fft_interval = 1.0/20 self.decimation = decimation = hardware_rate / oversampled_width self.channelizer_map = channelizer_map = 5,6,7,0,1,2,3 self.channel_names = channel_names = map(lambda x: "%.3fMHz" % (162.4 + (x*0.025)), channel_map) self.chan_num = chan_num = channel_map[6] ################################################## # Blocks ################################################## self._volume_layout = Qt.QVBoxLayout() self._volume_label = Qt.QLabel("volume") self._volume_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._volume_slider.setRange(0, 1, 0.05) self._volume_slider.setValue(self.volume) self._volume_slider.setMinimumWidth(50) self._volume_slider.valueChanged.connect(self.set_volume) self._volume_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._volume_layout.addWidget(self._volume_label) self._volume_layout.addWidget(self._volume_slider) self.top_grid_layout.addLayout(self._volume_layout, 0,1,1,1) self._chan_num_options = channel_map self._chan_num_labels = channel_names self._chan_num_tool_bar = Qt.QToolBar(self) self._chan_num_tool_bar.addWidget(Qt.QLabel("Channel"+": ")) self._chan_num_combo_box = Qt.QComboBox() self._chan_num_tool_bar.addWidget(self._chan_num_combo_box) for label in self._chan_num_labels: self._chan_num_combo_box.addItem(label) self._chan_num_callback = lambda i: Qt.QMetaObject.invokeMethod(self._chan_num_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._chan_num_options.index(i))) self._chan_num_callback(self.chan_num) self._chan_num_combo_box.currentIndexChanged.connect( lambda i: self.set_chan_num(self._chan_num_options[i])) self.top_grid_layout.addWidget(self._chan_num_tool_bar, 0,0,1,1) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_clock_source("external", 0) self.uhd_usrp_source_0.set_subdev_spec("A:0", 0) self.uhd_usrp_source_0.set_samp_rate(hardware_rate) self.uhd_usrp_source_0.set_center_freq(tuner_freq, 0) self.uhd_usrp_source_0.set_gain(30, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=48, decimation=25, taps=None, fractional_bw=None, ) self.qtgui_sink_x_0_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc hardware_rate, #bw "Radoi Samples", #name True, #plotfreq False, #plotwaterfall False, #plottime False, #plotconst ) self.qtgui_sink_x_0_0.set_update_time(1.0/10) self._qtgui_sink_x_0_0_win = sip.wrapinstance(self.qtgui_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_sink_x_0_0_win) self.qtgui_sink_x_0_0.enable_rf_freq(False) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc hardware_rate/decimation, #bw "Filtered Samples", #name True, #plotfreq False, #plotwaterfall False, #plottime False, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0/10) self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(False) self._ppm_layout = Qt.QVBoxLayout() self._ppm_label = Qt.QLabel("ppm") self._ppm_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._ppm_slider.setRange(-20, 20, 0.5) self._ppm_slider.setValue(self.ppm) self._ppm_slider.setMinimumWidth(50) self._ppm_slider.valueChanged.connect(self.set_ppm) self._ppm_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._ppm_layout.addWidget(self._ppm_label) self._ppm_layout.addWidget(self._ppm_slider) self.top_grid_layout.addLayout(self._ppm_layout, 0,2,1,1) self.pfb_channelizer_ccf_0 = pfb.channelizer_ccf( noaa_num_chans+1, (pfb_taps), 1, 1) self.pfb_channelizer_ccf_0.set_channel_map((channelizer_map)) self.pfb_channelizer_ccf_0.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc(int(decimation), (lpf_taps), tuner_offset + ppm_corr, hardware_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) self.blocks_multiply_const_vxx_0_7 = blocks.multiply_const_vcc((50, )) self.blocks_multiply_const_vxx_0_6_0 = blocks.multiply_const_vff((volume, )) self.blocks_multiply_const_vxx_0_6 = blocks.multiply_const_vcc((10, )) self.blocks_multiply_const_vxx_0_5_0 = blocks.multiply_const_vcc((1 if chan_num is 7 else 0, )) self.blocks_multiply_const_vxx_0_5 = blocks.multiply_const_vcc((1 if chan_num is 6 else 0, )) self.blocks_multiply_const_vxx_0_4 = blocks.multiply_const_vcc((1 if chan_num is 5 else 0, )) self.blocks_multiply_const_vxx_0_3 = blocks.multiply_const_vcc((1 if chan_num is 4 else 0, )) self.blocks_multiply_const_vxx_0_2 = blocks.multiply_const_vcc((1 if chan_num is 3 else 0, )) self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_vcc((1 if chan_num is 2 else 0, )) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((1 if chan_num is 1 else 0, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((1 if chan_num is 0 else 0, )) self.blocks_add_xx_0 = blocks.add_vcc(1) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=noaa_chan_width, quad_rate=noaa_chan_width, tau=75e-6, max_dev=noaa_fm_dev, ) ################################################## # Connections ################################################## self.connect((self.analog_nbfm_rx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_0_1, 0), (self.blocks_add_xx_0, 2)) self.connect((self.blocks_multiply_const_vxx_0_2, 0), (self.blocks_add_xx_0, 3)) self.connect((self.blocks_multiply_const_vxx_0_3, 0), (self.blocks_add_xx_0, 4)) self.connect((self.blocks_multiply_const_vxx_0_4, 0), (self.blocks_add_xx_0, 5)) self.connect((self.blocks_multiply_const_vxx_0_5, 0), (self.blocks_add_xx_0, 6)) self.connect((self.blocks_multiply_const_vxx_0_5_0, 0), (self.blocks_add_xx_0, 7)) self.connect((self.blocks_multiply_const_vxx_0_6, 0), (self.analog_nbfm_rx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_6_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_7, 0), (self.qtgui_sink_x_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0_6_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_const_vxx_0_7, 0)) self.connect((self.blocks_multiply_const_vxx_0_7, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.pfb_channelizer_ccf_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_const_vxx_0_6, 0)) self.connect((self.pfb_channelizer_ccf_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 1), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 2), (self.blocks_multiply_const_vxx_0_1, 0)) self.connect((self.pfb_channelizer_ccf_0, 3), (self.blocks_multiply_const_vxx_0_2, 0)) self.connect((self.pfb_channelizer_ccf_0, 4), (self.blocks_multiply_const_vxx_0_3, 0)) self.connect((self.pfb_channelizer_ccf_0, 5), (self.blocks_multiply_const_vxx_0_4, 0)) self.connect((self.pfb_channelizer_ccf_0, 6), (self.blocks_multiply_const_vxx_0_5, 0)) self.connect((self.pfb_channelizer_ccf_0, 7), (self.blocks_multiply_const_vxx_0_5_0, 0))
def __init__(self): gr.top_block.__init__(self, "Uhd Ais 1") Qt.QWidget.__init__(self) self.setWindowTitle("Uhd Ais 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", "uhd_ais_1") 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 self.filter_taps = filter_taps = firdes.low_pass( 1, samp_rate, samp_rate / 2, 50000, firdes.WIN_FLATTOP, 6.76) ################################################## # 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 = qtgui.waterfall_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim, #bw "", #name 2 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.01) 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(2): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-120, -40) 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, 0, 4, 4) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim, #bw "", #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(-120, -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(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "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, 4, 0, 4, 4) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate / decim, 12.5e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate / decim, 12.5e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.freq_xlating_fft_filter_ccc_0_0 = filter.freq_xlating_fft_filter_ccc( decim, (filter_taps), -25e3, samp_rate) self.freq_xlating_fft_filter_ccc_0_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0_0.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc( decim, (filter_taps), 25e3, samp_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) 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, True) self.blocks_message_debug_0_1 = blocks.message_debug() self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, '/home/leffke/sandbox/ais/captures/ais_20161216_250k_6.32fc', False) 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.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.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, '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_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.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fft_filter_ccc_0_0, 0)) 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.freq_xlating_fft_filter_ccc_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_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.qtgui_waterfall_sink_x_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.analog_quadrature_demod_cf_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_waterfall_sink_x_0, 1)) 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): gr.top_block.__init__(self, "OFDM PU Phy") Qt.QWidget.__init__(self) self.setWindowTitle("OFDM PU Phy") 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", "ofdm_trans") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 10e6 self.usrp_samp_rate = usrp_samp_rate = 10e6 self.taps = taps = filter.firdes.low_pass(1,samp_rate, 0.98e6,0.5e6) self.sync_word2 = sync_word2 = [0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 0, 0, 0, 0, 0] self.sync_word1 = sync_word1 = [0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0.] self.pilot_symbols = pilot_symbols = ((1, 1, 1, -1,),) self.pilot_carriers = pilot_carriers = ((-21, -7, 7, 21,),) self.packet_len = packet_len = 64 self.occupied_carriers = occupied_carriers = (range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27),) self.len_tag_key = len_tag_key = "packet_len" self.interp_factor = interp_factor = 5 self.fft_len = fft_len = 64 self.decim_factor = decim_factor = 1 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0_0_1_1 = filter.rational_resampler_ccc( interpolation=interp_factor, decimation=decim_factor, taps=(taps), fractional_bw=None, ) self.rational_resampler_xxx_0_0_1_0 = filter.rational_resampler_ccc( interpolation=interp_factor, decimation=decim_factor, taps=(taps), fractional_bw=None, ) self.rational_resampler_xxx_0_0_1 = filter.rational_resampler_ccc( interpolation=interp_factor, decimation=decim_factor, taps=(taps), fractional_bw=None, ) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=interp_factor, decimation=decim_factor, taps=(taps), fractional_bw=None, ) self.freq_xlating_fft_filter_ccc_0_2 = filter.freq_xlating_fft_filter_ccc(interp_factor, (filter.firdes.low_pass(1,usrp_samp_rate, samp_rate/2.0*.98, 0.5e6)), -3.75e6, usrp_samp_rate) self.freq_xlating_fft_filter_ccc_0_2.set_nthreads(4) self.freq_xlating_fft_filter_ccc_0_2.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0_1 = filter.freq_xlating_fft_filter_ccc(interp_factor, (filter.firdes.low_pass(1,usrp_samp_rate, samp_rate/2.0*0.98, 0.5e6)), 3.75e6, usrp_samp_rate) self.freq_xlating_fft_filter_ccc_0_1.set_nthreads(4) self.freq_xlating_fft_filter_ccc_0_1.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0_0 = filter.freq_xlating_fft_filter_ccc(interp_factor, (filter.firdes.low_pass(1,usrp_samp_rate, samp_rate/2.0*0.98, 0.5e6)), -1.25e6, usrp_samp_rate) self.freq_xlating_fft_filter_ccc_0_0.set_nthreads(4) self.freq_xlating_fft_filter_ccc_0_0.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc(interp_factor, (filter.firdes.low_pass(1,usrp_samp_rate, samp_rate/2.0*0.98, 0.5e6)), 1.25e6, usrp_samp_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(4) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len/4, packet_length_tag_key=len_tag_key, occupied_carriers=occupied_carriers, pilot_carriers=pilot_carriers, pilot_symbols=pilot_symbols, sync_word1=sync_word1, sync_word2=sync_word2, bps_header=1, bps_payload=2, rolloff=0, debug_log=False, scramble_bits=False ) self.digital_ofdm_rx_0_2 = digital.ofdm_rx( fft_len=fft_len, cp_len=fft_len/4, frame_length_tag_key='frame_'+"rx_len", packet_length_tag_key="rx_len", occupied_carriers=occupied_carriers, pilot_carriers=pilot_carriers, pilot_symbols=pilot_symbols, sync_word1=sync_word1, sync_word2=sync_word2, bps_header=1, bps_payload=2, debug_log=False, scramble_bits=False ) self.digital_ofdm_rx_0_1 = digital.ofdm_rx( fft_len=fft_len, cp_len=fft_len/4, frame_length_tag_key='frame_'+"rx_len", packet_length_tag_key="rx_len", occupied_carriers=occupied_carriers, pilot_carriers=pilot_carriers, pilot_symbols=pilot_symbols, sync_word1=sync_word1, sync_word2=sync_word2, bps_header=1, bps_payload=2, debug_log=False, scramble_bits=False ) self.digital_ofdm_rx_0_0 = digital.ofdm_rx( fft_len=fft_len, cp_len=fft_len/4, frame_length_tag_key='frame_'+"rx_len", packet_length_tag_key="rx_len", occupied_carriers=occupied_carriers, pilot_carriers=pilot_carriers, pilot_symbols=pilot_symbols, sync_word1=sync_word1, sync_word2=sync_word2, bps_header=1, bps_payload=2, debug_log=False, scramble_bits=False ) self.digital_ofdm_rx_0 = digital.ofdm_rx( fft_len=fft_len, cp_len=fft_len/4, frame_length_tag_key='frame_'+"rx_len", packet_length_tag_key="rx_len", occupied_carriers=occupied_carriers, pilot_carriers=pilot_carriers, pilot_symbols=pilot_symbols, sync_word1=sync_word1, sync_word2=sync_word2, bps_header=1, bps_payload=2, debug_log=False, scramble_bits=False ) self.dbconnect_pktrecv_0 = dbconnect.pktrecv("127.0.0.1", 5002, False) self.dbconnect_packet_controller_0 = dbconnect.packet_controller(samp_rate/interp_factor, (10000,), 5, 10, 2, 5, 5, 5, 6643, 60000, (10,20,30), (), False) self.dbconnect_cmd_pktgen_0 = dbconnect.cmd_pktgen("127.0.0.1", 5002, 64, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_tagged_stream_to_pdu_0_2 = blocks.tagged_stream_to_pdu(blocks.byte_t, "rx_len") self.blocks_tagged_stream_to_pdu_0_1 = blocks.tagged_stream_to_pdu(blocks.byte_t, "rx_len") self.blocks_tagged_stream_to_pdu_0_0_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, "rx_len") self.blocks_tagged_stream_to_pdu_0_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, "rx_len") self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.complex_t, "packet_len") self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len") self.blocks_multiply_xx_0_3 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_2 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.09, )) self.blocks_message_debug_0 = blocks.message_debug() self.blocks_add_xx_2 = blocks.add_vcc(1) self.analog_sig_source_x_0_3 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -3.75e6, 1, 0) self.analog_sig_source_x_0_2 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 3.75e6, 1, 0) self.analog_sig_source_x_0_1 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -1.25e6, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 1.25e6, 1, 0) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.dbconnect_packet_controller_0, 'in0')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0, 'pdus'), (self.dbconnect_pktrecv_0, 'in0')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0_0, 'pdus'), (self.dbconnect_pktrecv_0, 'in1')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0_1, 'pdus'), (self.dbconnect_pktrecv_0, 'in2')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0_2, 'pdus'), (self.dbconnect_pktrecv_0, 'in3')) self.msg_connect((self.dbconnect_cmd_pktgen_0, 'out0'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.dbconnect_packet_controller_0, 'cmd'), (self.blocks_message_debug_0, 'print')) self.msg_connect((self.dbconnect_packet_controller_0, 'gcmd'), (self.blocks_message_debug_0, 'print')) self.msg_connect((self.dbconnect_packet_controller_0, 'cmd'), (self.dbconnect_cmd_pktgen_0, 'cmd')) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_0_1, 0), (self.blocks_multiply_xx_0_1, 1)) self.connect((self.analog_sig_source_x_0_2, 0), (self.blocks_multiply_xx_0_2, 1)) self.connect((self.analog_sig_source_x_0_3, 0), (self.blocks_multiply_xx_0_3, 1)) self.connect((self.blocks_add_xx_2, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_2, 0)) self.connect((self.blocks_multiply_xx_0_1, 0), (self.blocks_add_xx_2, 1)) self.connect((self.blocks_multiply_xx_0_2, 0), (self.blocks_add_xx_2, 2)) self.connect((self.blocks_multiply_xx_0_3, 0), (self.blocks_add_xx_2, 3)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fft_filter_ccc_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fft_filter_ccc_0_1, 0)) self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fft_filter_ccc_0_2, 0)) self.connect((self.dbconnect_packet_controller_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.dbconnect_packet_controller_0, 1), (self.rational_resampler_xxx_0_0_1, 0)) self.connect((self.dbconnect_packet_controller_0, 2), (self.rational_resampler_xxx_0_0_1_0, 0)) self.connect((self.dbconnect_packet_controller_0, 3), (self.rational_resampler_xxx_0_0_1_1, 0)) self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_tagged_stream_to_pdu_0_0, 0)) self.connect((self.digital_ofdm_rx_0_0, 0), (self.blocks_tagged_stream_to_pdu_0_0_0, 0)) self.connect((self.digital_ofdm_rx_0_1, 0), (self.blocks_tagged_stream_to_pdu_0_1, 0)) self.connect((self.digital_ofdm_rx_0_2, 0), (self.blocks_tagged_stream_to_pdu_0_2, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.digital_ofdm_rx_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.digital_ofdm_rx_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_1, 0), (self.digital_ofdm_rx_0_1, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_2, 0), (self.digital_ofdm_rx_0_2, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.rational_resampler_xxx_0_0_1, 0), (self.blocks_multiply_xx_0_1, 0)) self.connect((self.rational_resampler_xxx_0_0_1_0, 0), (self.blocks_multiply_xx_0_2, 0)) self.connect((self.rational_resampler_xxx_0_0_1_1, 0), (self.blocks_multiply_xx_0_3, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__( self, title="Eshail-2 QO-100 Satellite recever.") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.tuner = tuner = -1300 self.filter_width = filter_width = 1.2e3 self.volume = volume = .8 self.variable_static_text_0 = variable_static_text_0 = int( (14.2e6 + tuner - (2 * filter_width)) / 1e3) self.variable_slider_RX_freq = variable_slider_RX_freq = 739.739e6 self.variable_slider_1 = variable_slider_1 = 0.01 self.variable_chooser_1 = variable_chooser_1 = 1 self.variable_chooser_0 = variable_chooser_0 = 0 self.samp_rate_0 = samp_rate_0 = 250000 self.samp_rate = samp_rate = 300000 self.gain = gain = 10000 self.decimate = decimate = 5 self.center_freq = center_freq = 14.2e6 self.agc_decay = agc_decay = 65e-6 self.agc_attack = agc_attack = .1 ################################################## # 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.GridAdd(_volume_sizer, 0, 0, 1, 4) _variable_slider_RX_freq_sizer = wx.BoxSizer(wx.VERTICAL) self._variable_slider_RX_freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_variable_slider_RX_freq_sizer, value=self.variable_slider_RX_freq, callback=self.set_variable_slider_RX_freq, label='RX Frequency', converter=forms.float_converter(), proportion=0, ) self._variable_slider_RX_freq_slider = forms.slider( parent=self.GetWin(), sizer=_variable_slider_RX_freq_sizer, value=self.variable_slider_RX_freq, callback=self.set_variable_slider_RX_freq, minimum=739.600e6, maximum=739.800e6, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_variable_slider_RX_freq_sizer) self._variable_chooser_1_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.variable_chooser_1, callback=self.set_variable_chooser_1, label='CW Filter', choices=[0, 1, 2, 3], labels=["900", "500", "200", "SSB"], style=wx.RA_HORIZONTAL, ) self.Add(self._variable_chooser_1_chooser) self._variable_chooser_0_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.variable_chooser_0, callback=self.set_variable_chooser_0, label='Modelation', choices=[0, 1], labels=["SSB", "AM"], style=wx.RA_HORIZONTAL, ) self.Add(self._variable_chooser_0_chooser) _tuner_sizer = wx.BoxSizer(wx.VERTICAL) self._tuner_text_box = forms.text_box( parent=self.GetWin(), sizer=_tuner_sizer, value=self.tuner, callback=self.set_tuner, label='Tune', converter=forms.float_converter(), proportion=0, ) self._tuner_slider = forms.slider( parent=self.GetWin(), sizer=_tuner_sizer, value=self.tuner, callback=self.set_tuner, minimum=-25e3, maximum=25e3, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_tuner_sizer) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label='gain', converter=forms.int_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=30000, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.GridAdd(_gain_sizer, 0, 5, 1, 4) _agc_decay_sizer = wx.BoxSizer(wx.VERTICAL) self._agc_decay_text_box = forms.text_box( parent=self.GetWin(), sizer=_agc_decay_sizer, value=self.agc_decay, callback=self.set_agc_decay, label='AGC Decay', converter=forms.float_converter(), proportion=0, ) self._agc_decay_slider = forms.slider( parent=self.GetWin(), sizer=_agc_decay_sizer, value=self.agc_decay, callback=self.set_agc_decay, minimum=10e-6, maximum=100e-6, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_agc_decay_sizer, 0, 32, 1, 10) _agc_attack_sizer = wx.BoxSizer(wx.VERTICAL) self._agc_attack_text_box = forms.text_box( parent=self.GetWin(), sizer=_agc_attack_sizer, value=self.agc_attack, callback=self.set_agc_attack, label='AGC Attack', converter=forms.float_converter(), proportion=0, ) self._agc_attack_slider = forms.slider( parent=self.GetWin(), sizer=_agc_attack_sizer, value=self.agc_attack, callback=self.set_agc_attack, minimum=1e-1, maximum=3e-1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_agc_attack_sizer, 0, 20, 1, 10) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.GetWin(), baseband_freq=variable_slider_RX_freq, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate / decimate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title='Spectrum', ) self.Add(self.wxgui_waterfallsink2_0.win) self.wxgui_fftsink2_1 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=variable_slider_RX_freq + tuner - filter_width, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate / 25, fft_size=1024, fft_rate=10, average=False, avg_alpha=None, title='Filtered Signal', peak_hold=False, ) self.Add(self.wxgui_fftsink2_1.win) self._variable_static_text_0_static_text = forms.static_text( parent=self.GetWin(), value=self.variable_static_text_0, callback=self.set_variable_static_text_0, label='Frequency', converter=forms.float_converter(), ) self.GridAdd(self._variable_static_text_0_static_text, 0, 9, 1, 10) _variable_slider_1_sizer = wx.BoxSizer(wx.VERTICAL) self._variable_slider_1_text_box = forms.text_box( parent=self.GetWin(), sizer=_variable_slider_1_sizer, value=self.variable_slider_1, callback=self.set_variable_slider_1, label='Audio gain', converter=forms.float_converter(), proportion=0, ) self._variable_slider_1_slider = forms.slider( parent=self.GetWin(), sizer=_variable_slider_1_sizer, value=self.variable_slider_1, callback=self.set_variable_slider_1, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_variable_slider_1_sizer) self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=1, decimation=decimate, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=16, decimation=10, taps=None, fractional_bw=None, ) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + ' rtl=0') self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(variable_slider_RX_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.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc( decimate, (firdes.low_pass(1, 50e3, filter_width - 200, 300)), tuner - filter_width, samp_rate / decimate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) 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_1 = blocks.multiply_const_vff( (volume, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((gain, )) (self.blocks_multiply_const_vxx_0).set_block_alias("RF Gain") self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.blks2_selector_0_0 = grc_blks2.selector( item_size=gr.sizeof_float * 1, num_inputs=2, num_outputs=1, input_index=variable_chooser_0, output_index=0, ) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex * 1, num_inputs=1, num_outputs=2, input_index=0, output_index=variable_chooser_0, ) self.band_pass_filter_2 = filter.fir_filter_fff( 1, firdes.band_pass(1, 12000, 600, 800, 50, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_1 = filter.fir_filter_fff( 1, firdes.band_pass(1, 12000, 450, 950, 100, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0 = filter.fir_filter_fff( 1, firdes.band_pass(1, 12000, 300, 1100, 100, firdes.WIN_HAMMING, 6.76)) self.audio_sink_0 = audio.sink(16000, '', True) self.analog_sig_source_x_1 = analog.sig_source_f( samp_rate / (decimate * decimate), analog.GR_COS_WAVE, filter_width, .5, 0) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate / (decimate * decimate), analog.GR_SIN_WAVE, filter_width, .5, 0) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=60000, audio_decim=16000, audio_pass=5000, audio_stop=5500, ) self.analog_agc2_xx_0 = analog.agc2_cc(agc_attack, agc_decay, .3, 1) self.analog_agc2_xx_0.set_max_gain(1) self.CW_selector_1 = grc_blks2.selector( item_size=gr.sizeof_float * 1, num_inputs=4, num_outputs=1, input_index=variable_chooser_1, output_index=0, ) self.CW_selector_0 = grc_blks2.selector( item_size=gr.sizeof_float * 1, num_inputs=1, num_outputs=4, input_index=0, output_index=variable_chooser_1, ) ################################################## # Connections ################################################## self.connect((self.CW_selector_0, 3), (self.CW_selector_1, 3)) self.connect((self.CW_selector_0, 2), (self.band_pass_filter_0, 0)) self.connect((self.CW_selector_0, 0), (self.band_pass_filter_1, 0)) self.connect((self.CW_selector_0, 1), (self.band_pass_filter_2, 0)) self.connect((self.CW_selector_1, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.blks2_selector_0_0, 1)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.band_pass_filter_0, 0), (self.CW_selector_1, 2)) self.connect((self.band_pass_filter_1, 0), (self.CW_selector_1, 0)) self.connect((self.band_pass_filter_2, 0), (self.CW_selector_1, 1)) self.connect((self.blks2_selector_0, 1), (self.analog_am_demod_cf_0, 0)) self.connect((self.blks2_selector_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.blks2_selector_0_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.CW_selector_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_multiply_const_vxx_0, 0), (self.blks2_selector_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blks2_selector_0_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.rational_resampler_xxx_1, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.wxgui_fftsink2_1, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Signal Hunter Faked") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2000000 self.xlate_decimation = xlate_decimation = 40 self.offset2 = offset2 = 0 self.offset = offset = samp_rate / 4 self.hunter_freq_0 = hunter_freq_0 = 0 self.gain = gain = 10 self.frequency = frequency = 930000000 self.filter_width = filter_width = 5120 self.fft_taps = fft_taps = filter.firdes.low_pass_2( 1, samp_rate, 2000, 1000, 0.1) ################################################## # Blocks ################################################## _offset2_sizer = wx.BoxSizer(wx.VERTICAL) self._offset2_text_box = forms.text_box( parent=self.GetWin(), sizer=_offset2_sizer, value=self.offset2, callback=self.set_offset2, label='offset2', converter=forms.int_converter(), proportion=0, ) self._offset2_slider = forms.slider( parent=self.GetWin(), sizer=_offset2_sizer, value=self.offset2, callback=self.set_offset2, minimum=-samp_rate / 2, maximum=samp_rate / 2, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_offset2_sizer) _offset_sizer = wx.BoxSizer(wx.VERTICAL) self._offset_text_box = forms.text_box( parent=self.GetWin(), sizer=_offset_sizer, value=self.offset, callback=self.set_offset, label='offset', converter=forms.int_converter(), proportion=0, ) self._offset_slider = forms.slider( parent=self.GetWin(), sizer=_offset_sizer, value=self.offset, callback=self.set_offset, minimum=-samp_rate / 2, maximum=samp_rate / 2, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_offset_sizer) _hunter_freq_0_sizer = wx.BoxSizer(wx.VERTICAL) self._hunter_freq_0_text_box = forms.text_box( parent=self.GetWin(), sizer=_hunter_freq_0_sizer, value=self.hunter_freq_0, callback=self.set_hunter_freq_0, label='hunter_freq_0', converter=forms.int_converter(), proportion=0, ) self._hunter_freq_0_slider = forms.slider( parent=self.GetWin(), sizer=_hunter_freq_0_sizer, value=self.hunter_freq_0, callback=self.set_hunter_freq_0, minimum=-100000, maximum=100000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_hunter_freq_0_sizer) _frequency_sizer = wx.BoxSizer(wx.VERTICAL) self._frequency_text_box = forms.text_box( parent=self.GetWin(), sizer=_frequency_sizer, value=self.frequency, callback=self.set_frequency, label='Frequency', converter=forms.int_converter(), proportion=0, ) self._frequency_slider = forms.slider( parent=self.GetWin(), sizer=_frequency_sizer, value=self.frequency, callback=self.set_frequency, minimum=80000000, maximum=1100000000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_frequency_sizer) self.zeromq_push_sink_1 = zeromq.push_sink(gr.sizeof_gr_complex, samp_rate, 'tcp://127.0.0.1:9001', 100, False, -1) self.zeromq_push_sink_0_0 = zeromq.push_sink(gr.sizeof_float, 1024, 'tcp://127.0.0.1:9000', 100, False, -1) self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer( ('localhost', 8080), allow_none=True) self.xmlrpc_server_0.register_instance(self) self.xmlrpc_server_0_thread = threading.Thread( target=self.xmlrpc_server_0.serve_forever) self.xmlrpc_server_0_thread.daemon = True self.xmlrpc_server_0_thread.start() self.wxgui_fftsink2_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 / xlate_decimation, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title='filtered_fft', peak_hold=False, ) self.Add(self.wxgui_fftsink2_0_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=frequency, 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='master_plot', peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label='gain', converter=forms.int_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=50, num_steps=50, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_gain_sizer) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc( xlate_decimation, (fft_taps), frequency + hunter_freq_0, samp_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) _filter_width_sizer = wx.BoxSizer(wx.VERTICAL) self._filter_width_text_box = forms.text_box( parent=self.GetWin(), sizer=_filter_width_sizer, value=self.filter_width, callback=self.set_filter_width, label='filter_width', converter=forms.int_converter(), proportion=0, ) self._filter_width_slider = forms.slider( parent=self.GetWin(), sizer=_filter_width_sizer, value=self.filter_width, callback=self.set_filter_width, minimum=2048, maximum=40960, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_filter_width_sizer) self.fft_vxx_0 = fft.fft_vcc(1024, True, (window.blackmanharris(1024)), True, 1) self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, 1024) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_stream_to_vector_2 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, samp_rate) self.blocks_stream_to_vector_1 = blocks.stream_to_vector( gr.sizeof_float * 1, 1024) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, 1024) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_sig_source_x_0_0 = analog.sig_source_c( samp_rate, analog.GR_SIN_WAVE, frequency + offset, 0.001, 0) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, frequency + offset2, 0.001, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_stream_to_vector_2, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_stream_to_vector_1, 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.zeromq_push_sink_0_0, 0)) self.connect((self.blocks_stream_to_vector_2, 0), (self.zeromq_push_sink_1, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.wxgui_fftsink2_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "NOAA Demo based on PFB Channelizer Demo") Qt.QWidget.__init__(self) self.setWindowTitle("NOAA Demo based on PFB Channelizer Demo") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "noaa_demo") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.noaa_num_chans = noaa_num_chans = 7 self.noaa_chan_width = noaa_chan_width = int(25e3) self.noaa_band_start = noaa_band_start = 162.4e6 self.oversampled_width = oversampled_width = noaa_chan_width * ( noaa_num_chans + 1) self.noaa_fm_dev = noaa_fm_dev = int(5e3) self.noaa_band_center = noaa_band_center = noaa_band_start + ( noaa_num_chans / 2 * noaa_chan_width) self.hardware_rate = hardware_rate = int(1e6) self.tuner_freq = tuner_freq = 162.3e6 self.target_freq = target_freq = noaa_band_center self.ppm = ppm = 0 self.pfb_taps = pfb_taps = firdes.low_pass(2.0, oversampled_width, noaa_fm_dev * 2, 1000, firdes.WIN_HAMMING, 6.76) self.lpf_taps = lpf_taps = firdes.low_pass(1.0, hardware_rate, oversampled_width / 2, noaa_chan_width, firdes.WIN_HAMMING, 6.76) self.channel_map = channel_map = range(0, noaa_num_chans) self.volume = volume = 0.15 self.tuner_offset = tuner_offset = target_freq - tuner_freq self.ppm_corr = ppm_corr = tuner_freq * (ppm / 1e6) self.pfb_sizeof_taps = pfb_sizeof_taps = len(pfb_taps) self.noaa_band_width = noaa_band_width = noaa_chan_width * noaa_num_chans self.noaa_band_end = noaa_band_end = noaa_band_start + ( noaa_num_chans * noaa_chan_width) self.lpf_sizeof_taps = lpf_sizeof_taps = len(lpf_taps) self.fftwidth = fftwidth = 512 self.fft_interval = fft_interval = 1.0 / 20 self.decimation = decimation = hardware_rate / oversampled_width self.channelizer_map = channelizer_map = 5, 6, 7, 0, 1, 2, 3 self.channel_names = channel_names = map( lambda x: "%.3fMHz" % (162.4 + (x * 0.025)), channel_map) self.chan_num = chan_num = channel_map[6] ################################################## # Blocks ################################################## self._volume_layout = Qt.QVBoxLayout() self._volume_label = Qt.QLabel("volume") self._volume_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._volume_slider.setRange(0, 1, 0.05) self._volume_slider.setValue(self.volume) self._volume_slider.setMinimumWidth(50) self._volume_slider.valueChanged.connect(self.set_volume) self._volume_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._volume_layout.addWidget(self._volume_label) self._volume_layout.addWidget(self._volume_slider) self.top_grid_layout.addLayout(self._volume_layout, 0, 1, 1, 1) self._chan_num_options = channel_map self._chan_num_labels = channel_names self._chan_num_tool_bar = Qt.QToolBar(self) self._chan_num_tool_bar.addWidget(Qt.QLabel("Channel" + ": ")) self._chan_num_combo_box = Qt.QComboBox() self._chan_num_tool_bar.addWidget(self._chan_num_combo_box) for label in self._chan_num_labels: self._chan_num_combo_box.addItem(label) self._chan_num_callback = lambda i: Qt.QMetaObject.invokeMethod( self._chan_num_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._chan_num_options.index(i))) self._chan_num_callback(self.chan_num) self._chan_num_combo_box.currentIndexChanged.connect( lambda i: self.set_chan_num(self._chan_num_options[i])) self.top_grid_layout.addWidget(self._chan_num_tool_bar, 0, 0, 1, 1) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_clock_source("external", 0) self.uhd_usrp_source_0.set_subdev_spec("A:0", 0) self.uhd_usrp_source_0.set_samp_rate(hardware_rate) self.uhd_usrp_source_0.set_center_freq(tuner_freq, 0) self.uhd_usrp_source_0.set_gain(30, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=48, decimation=25, taps=None, fractional_bw=None, ) self.qtgui_sink_x_0_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc hardware_rate, #bw "Radoi Samples", #name True, #plotfreq False, #plotwaterfall False, #plottime False, #plotconst ) self.qtgui_sink_x_0_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_0_win = sip.wrapinstance( self.qtgui_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_sink_x_0_0_win) self.qtgui_sink_x_0_0.enable_rf_freq(False) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc hardware_rate / decimation, #bw "Filtered Samples", #name True, #plotfreq False, #plotwaterfall False, #plottime False, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_win = sip.wrapinstance( self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(False) self._ppm_layout = Qt.QVBoxLayout() self._ppm_label = Qt.QLabel("ppm") self._ppm_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._ppm_slider.setRange(-20, 20, 0.5) self._ppm_slider.setValue(self.ppm) self._ppm_slider.setMinimumWidth(50) self._ppm_slider.valueChanged.connect(self.set_ppm) self._ppm_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._ppm_layout.addWidget(self._ppm_label) self._ppm_layout.addWidget(self._ppm_slider) self.top_grid_layout.addLayout(self._ppm_layout, 0, 2, 1, 1) self.pfb_channelizer_ccf_0 = pfb.channelizer_ccf( noaa_num_chans + 1, (pfb_taps), 1, 1) self.pfb_channelizer_ccf_0.set_channel_map((channelizer_map)) self.pfb_channelizer_ccf_0.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc( int(decimation), (lpf_taps), tuner_offset + ppm_corr, hardware_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) self.blocks_multiply_const_vxx_0_7 = blocks.multiply_const_vcc((50, )) self.blocks_multiply_const_vxx_0_6_0 = blocks.multiply_const_vff( (volume, )) self.blocks_multiply_const_vxx_0_6 = blocks.multiply_const_vcc((10, )) self.blocks_multiply_const_vxx_0_5_0 = blocks.multiply_const_vcc( (1 if chan_num is 7 else 0, )) self.blocks_multiply_const_vxx_0_5 = blocks.multiply_const_vcc( (1 if chan_num is 6 else 0, )) self.blocks_multiply_const_vxx_0_4 = blocks.multiply_const_vcc( (1 if chan_num is 5 else 0, )) self.blocks_multiply_const_vxx_0_3 = blocks.multiply_const_vcc( (1 if chan_num is 4 else 0, )) self.blocks_multiply_const_vxx_0_2 = blocks.multiply_const_vcc( (1 if chan_num is 3 else 0, )) self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_vcc( (1 if chan_num is 2 else 0, )) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc( (1 if chan_num is 1 else 0, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc( (1 if chan_num is 0 else 0, )) self.blocks_add_xx_0 = blocks.add_vcc(1) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=noaa_chan_width, quad_rate=noaa_chan_width, tau=75e-6, max_dev=noaa_fm_dev, ) ################################################## # Connections ################################################## self.connect((self.analog_nbfm_rx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_0_1, 0), (self.blocks_add_xx_0, 2)) self.connect((self.blocks_multiply_const_vxx_0_2, 0), (self.blocks_add_xx_0, 3)) self.connect((self.blocks_multiply_const_vxx_0_3, 0), (self.blocks_add_xx_0, 4)) self.connect((self.blocks_multiply_const_vxx_0_4, 0), (self.blocks_add_xx_0, 5)) self.connect((self.blocks_multiply_const_vxx_0_5, 0), (self.blocks_add_xx_0, 6)) self.connect((self.blocks_multiply_const_vxx_0_5_0, 0), (self.blocks_add_xx_0, 7)) self.connect((self.blocks_multiply_const_vxx_0_6, 0), (self.analog_nbfm_rx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_6_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_7, 0), (self.qtgui_sink_x_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0_6_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_const_vxx_0_7, 0)) self.connect((self.blocks_multiply_const_vxx_0_7, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.pfb_channelizer_ccf_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_const_vxx_0_6, 0)) self.connect((self.pfb_channelizer_ccf_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 1), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 2), (self.blocks_multiply_const_vxx_0_1, 0)) self.connect((self.pfb_channelizer_ccf_0, 3), (self.blocks_multiply_const_vxx_0_2, 0)) self.connect((self.pfb_channelizer_ccf_0, 4), (self.blocks_multiply_const_vxx_0_3, 0)) self.connect((self.pfb_channelizer_ccf_0, 5), (self.blocks_multiply_const_vxx_0_4, 0)) self.connect((self.pfb_channelizer_ccf_0, 6), (self.blocks_multiply_const_vxx_0_5, 0)) self.connect((self.pfb_channelizer_ccf_0, 7), (self.blocks_multiply_const_vxx_0_5_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Signal Hunter Faked") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2000000 self.xlate_decimation = xlate_decimation = 40 self.offset2 = offset2 = 0 self.offset = offset = samp_rate/4 self.hunter_freq_0 = hunter_freq_0 = 0 self.gain = gain = 10 self.frequency = frequency = 930000000 self.filter_width = filter_width = 5120 self.fft_taps = fft_taps = filter.firdes.low_pass_2(1, samp_rate, 2000, 1000, 0.1) ################################################## # Blocks ################################################## _offset2_sizer = wx.BoxSizer(wx.VERTICAL) self._offset2_text_box = forms.text_box( parent=self.GetWin(), sizer=_offset2_sizer, value=self.offset2, callback=self.set_offset2, label='offset2', converter=forms.int_converter(), proportion=0, ) self._offset2_slider = forms.slider( parent=self.GetWin(), sizer=_offset2_sizer, value=self.offset2, callback=self.set_offset2, minimum=-samp_rate/2, maximum=samp_rate/2, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_offset2_sizer) _offset_sizer = wx.BoxSizer(wx.VERTICAL) self._offset_text_box = forms.text_box( parent=self.GetWin(), sizer=_offset_sizer, value=self.offset, callback=self.set_offset, label='offset', converter=forms.int_converter(), proportion=0, ) self._offset_slider = forms.slider( parent=self.GetWin(), sizer=_offset_sizer, value=self.offset, callback=self.set_offset, minimum=-samp_rate/2, maximum=samp_rate/2, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_offset_sizer) _hunter_freq_0_sizer = wx.BoxSizer(wx.VERTICAL) self._hunter_freq_0_text_box = forms.text_box( parent=self.GetWin(), sizer=_hunter_freq_0_sizer, value=self.hunter_freq_0, callback=self.set_hunter_freq_0, label='hunter_freq_0', converter=forms.int_converter(), proportion=0, ) self._hunter_freq_0_slider = forms.slider( parent=self.GetWin(), sizer=_hunter_freq_0_sizer, value=self.hunter_freq_0, callback=self.set_hunter_freq_0, minimum=-100000, maximum=100000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_hunter_freq_0_sizer) _frequency_sizer = wx.BoxSizer(wx.VERTICAL) self._frequency_text_box = forms.text_box( parent=self.GetWin(), sizer=_frequency_sizer, value=self.frequency, callback=self.set_frequency, label='Frequency', converter=forms.int_converter(), proportion=0, ) self._frequency_slider = forms.slider( parent=self.GetWin(), sizer=_frequency_sizer, value=self.frequency, callback=self.set_frequency, minimum=80000000, maximum=1100000000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_frequency_sizer) self.zeromq_push_sink_1 = zeromq.push_sink(gr.sizeof_gr_complex, samp_rate, 'tcp://127.0.0.1:9001', 100, False, -1) self.zeromq_push_sink_0_0 = zeromq.push_sink(gr.sizeof_float, 1024, 'tcp://127.0.0.1:9000', 100, False, -1) self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(('localhost', 8080), allow_none=True) self.xmlrpc_server_0.register_instance(self) self.xmlrpc_server_0_thread = threading.Thread(target=self.xmlrpc_server_0.serve_forever) self.xmlrpc_server_0_thread.daemon = True self.xmlrpc_server_0_thread.start() self.wxgui_fftsink2_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/xlate_decimation, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title='filtered_fft', peak_hold=False, ) self.Add(self.wxgui_fftsink2_0_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=frequency, 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='master_plot', peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label='gain', converter=forms.int_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=50, num_steps=50, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_gain_sizer) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc(xlate_decimation, (fft_taps), frequency + hunter_freq_0, samp_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) _filter_width_sizer = wx.BoxSizer(wx.VERTICAL) self._filter_width_text_box = forms.text_box( parent=self.GetWin(), sizer=_filter_width_sizer, value=self.filter_width, callback=self.set_filter_width, label='filter_width', converter=forms.int_converter(), proportion=0, ) self._filter_width_slider = forms.slider( parent=self.GetWin(), sizer=_filter_width_sizer, value=self.filter_width, callback=self.set_filter_width, minimum=2048, maximum=40960, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_filter_width_sizer) self.fft_vxx_0 = fft.fft_vcc(1024, True, (window.blackmanharris(1024)), True, 1) self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, 1024) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_stream_to_vector_2 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, samp_rate) self.blocks_stream_to_vector_1 = blocks.stream_to_vector(gr.sizeof_float*1, 1024) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 1024) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate, analog.GR_SIN_WAVE, frequency+offset, 0.001, 0) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, frequency+offset2, 0.001, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_stream_to_vector_2, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_stream_to_vector_1, 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.zeromq_push_sink_0_0, 0)) self.connect((self.blocks_stream_to_vector_2, 0), (self.zeromq_push_sink_1, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.wxgui_fftsink2_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "NOAA Demo based on PFB Channelizer Demo") Qt.QWidget.__init__(self) self.setWindowTitle("NOAA Demo based on PFB Channelizer Demo") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "amplitude_loss_test") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.noaa_num_chans = noaa_num_chans = 7 self.noaa_chan_width = noaa_chan_width = int(25e3) self.noaa_band_start = noaa_band_start = 162.4e6 self.oversampled_width = oversampled_width = noaa_chan_width * (noaa_num_chans + 1) self.noaa_fm_dev = noaa_fm_dev = int(5e3) self.noaa_band_center = noaa_band_center = noaa_band_start + (noaa_num_chans / 2 * noaa_chan_width) self.hardware_rate = hardware_rate = int(1e6) self.tuner_freq = tuner_freq = 162.3e6 self.target_freq = target_freq = noaa_band_center self.ppm = ppm = 0 self.pfb_taps = pfb_taps = firdes.low_pass(2.0, oversampled_width, noaa_fm_dev*2 ,1000, firdes.WIN_HAMMING, 6.76) self.lpf_taps = lpf_taps = firdes.low_pass(1.0, hardware_rate, oversampled_width / 2,noaa_chan_width, firdes.WIN_HAMMING, 6.76) self.channel_map = channel_map = range(0, noaa_num_chans) self.volume = volume = 0 self.tuner_offset = tuner_offset = target_freq - tuner_freq self.ppm_corr = ppm_corr = tuner_freq * (ppm/1e6) self.pfb_sizeof_taps = pfb_sizeof_taps = len(pfb_taps) self.noaa_band_width = noaa_band_width = noaa_chan_width * noaa_num_chans self.noaa_band_end = noaa_band_end = noaa_band_start + (noaa_num_chans * noaa_chan_width) self.lpf_sizeof_taps = lpf_sizeof_taps = len(lpf_taps) self.fftwidth = fftwidth = 512 self.fft_interval = fft_interval = 1.0/20 self.decimation = decimation = hardware_rate / oversampled_width self.channelizer_map = channelizer_map = 5,6,7,0,1,2,3 self.channel_names = channel_names = map(lambda x: "%.3fMHz" % (162.4 + (x*0.025)), channel_map) self.chan_num = chan_num = 3 ################################################## # 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_clock_source("external", 0) self.uhd_usrp_source_0.set_subdev_spec("A:0", 0) self.uhd_usrp_source_0.set_samp_rate(hardware_rate) self.uhd_usrp_source_0.set_center_freq(tuner_freq, 0) self.uhd_usrp_source_0.set_gain(30, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.qtgui_sink_x_0_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc hardware_rate, #bw "Radio Samples", #name True, #plotfreq False, #plotwaterfall False, #plottime False, #plotconst ) self.qtgui_sink_x_0_0.set_update_time(1.0/10) self._qtgui_sink_x_0_0_win = sip.wrapinstance(self.qtgui_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_sink_x_0_0_win, 0,0,1,2) self.qtgui_sink_x_0_0.enable_rf_freq(False) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc hardware_rate/decimation, #bw "Filtered Samples", #name True, #plotfreq False, #plotwaterfall False, #plottime False, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0/10) self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_sink_x_0_win, 0,2,1,2) self.qtgui_sink_x_0.enable_rf_freq(False) self.pfb_channelizer_ccf_0 = pfb.channelizer_ccf( noaa_num_chans+1, (pfb_taps), 1, 1) self.pfb_channelizer_ccf_0.set_channel_map((channelizer_map)) self.pfb_channelizer_ccf_0.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc(int(decimation), (lpf_taps), tuner_offset + ppm_corr, hardware_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) self.blocks_null_sink_0_5 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_null_sink_0_4 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_null_sink_0_3 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_null_sink_0_2_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_null_sink_0_2 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_null_sink_0_1 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1) ################################################## # Connections ################################################## self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.pfb_channelizer_ccf_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 5), (self.blocks_null_sink_0_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 1), (self.blocks_null_sink_0_1, 0)) self.connect((self.pfb_channelizer_ccf_0, 2), (self.blocks_null_sink_0_2, 0)) self.connect((self.pfb_channelizer_ccf_0, 3), (self.blocks_null_sink_0_2_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 4), (self.blocks_null_sink_0_3, 0)) self.connect((self.pfb_channelizer_ccf_0, 6), (self.blocks_null_sink_0_4, 0)) self.connect((self.pfb_channelizer_ccf_0, 7), (self.blocks_null_sink_0_5, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_sink_x_0_0, 0))
def __init__(self, queue): grc_wxgui.top_block_gui.__init__(self, title="Pager 6Ch Decode") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2000000 self.xlate_decimation = xlate_decimation = 80 self.hunter_freq_5 = hunter_freq_5 = 0 self.hunter_freq_4 = hunter_freq_4 = 0 self.hunter_freq_3 = hunter_freq_3 = 0 self.hunter_freq_2 = hunter_freq_2 = 0 self.hunter_freq_1 = hunter_freq_1 = 0 self.hunter_freq_0 = hunter_freq_0 = 0 self.gain = gain = 10 self.frequency = frequency = 929000000 self.filter_width = filter_width = 5120 self.fft_taps = fft_taps = filter.firdes.low_pass_2( 1, samp_rate, 10000, 1000, 0.1) self.fft_n_elements = fft_n_elements = 2048 ################################################## # Blocks ################################################## _hunter_freq_5_sizer = wx.BoxSizer(wx.VERTICAL) self._hunter_freq_5_text_box = forms.text_box( parent=self.GetWin(), sizer=_hunter_freq_5_sizer, value=self.hunter_freq_5, callback=self.set_hunter_freq_5, label='hunter_freq_5', converter=forms.int_converter(), proportion=0, ) self._hunter_freq_5_slider = forms.slider( parent=self.GetWin(), sizer=_hunter_freq_5_sizer, value=self.hunter_freq_5, callback=self.set_hunter_freq_5, minimum=-5000000, maximum=5000000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_hunter_freq_5_sizer) _hunter_freq_4_sizer = wx.BoxSizer(wx.VERTICAL) self._hunter_freq_4_text_box = forms.text_box( parent=self.GetWin(), sizer=_hunter_freq_4_sizer, value=self.hunter_freq_4, callback=self.set_hunter_freq_4, label='hunter_freq_4', converter=forms.int_converter(), proportion=0, ) self._hunter_freq_4_slider = forms.slider( parent=self.GetWin(), sizer=_hunter_freq_4_sizer, value=self.hunter_freq_4, callback=self.set_hunter_freq_4, minimum=-5000000, maximum=5000000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_hunter_freq_4_sizer) _hunter_freq_3_sizer = wx.BoxSizer(wx.VERTICAL) self._hunter_freq_3_text_box = forms.text_box( parent=self.GetWin(), sizer=_hunter_freq_3_sizer, value=self.hunter_freq_3, callback=self.set_hunter_freq_3, label='hunter_freq_3', converter=forms.int_converter(), proportion=0, ) self._hunter_freq_3_slider = forms.slider( parent=self.GetWin(), sizer=_hunter_freq_3_sizer, value=self.hunter_freq_3, callback=self.set_hunter_freq_3, minimum=-5000000, maximum=5000000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_hunter_freq_3_sizer) _hunter_freq_2_sizer = wx.BoxSizer(wx.VERTICAL) self._hunter_freq_2_text_box = forms.text_box( parent=self.GetWin(), sizer=_hunter_freq_2_sizer, value=self.hunter_freq_2, callback=self.set_hunter_freq_2, label='hunter_freq_2', converter=forms.int_converter(), proportion=0, ) self._hunter_freq_2_slider = forms.slider( parent=self.GetWin(), sizer=_hunter_freq_2_sizer, value=self.hunter_freq_2, callback=self.set_hunter_freq_2, minimum=-5000000, maximum=5000000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_hunter_freq_2_sizer) _hunter_freq_1_sizer = wx.BoxSizer(wx.VERTICAL) self._hunter_freq_1_text_box = forms.text_box( parent=self.GetWin(), sizer=_hunter_freq_1_sizer, value=self.hunter_freq_1, callback=self.set_hunter_freq_1, label='hunter_freq_1', converter=forms.int_converter(), proportion=0, ) self._hunter_freq_1_slider = forms.slider( parent=self.GetWin(), sizer=_hunter_freq_1_sizer, value=self.hunter_freq_1, callback=self.set_hunter_freq_1, minimum=-5000000, maximum=5000000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_hunter_freq_1_sizer) _hunter_freq_0_sizer = wx.BoxSizer(wx.VERTICAL) self._hunter_freq_0_text_box = forms.text_box( parent=self.GetWin(), sizer=_hunter_freq_0_sizer, value=self.hunter_freq_0, callback=self.set_hunter_freq_0, label='hunter_freq_0', converter=forms.int_converter(), proportion=0, ) self._hunter_freq_0_slider = forms.slider( parent=self.GetWin(), sizer=_hunter_freq_0_sizer, value=self.hunter_freq_0, callback=self.set_hunter_freq_0, minimum=-5000000, maximum=5000000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_hunter_freq_0_sizer) _frequency_sizer = wx.BoxSizer(wx.VERTICAL) self._frequency_text_box = forms.text_box( parent=self.GetWin(), sizer=_frequency_sizer, value=self.frequency, callback=self.set_frequency, label='Frequency', converter=forms.int_converter(), proportion=0, ) self._frequency_slider = forms.slider( parent=self.GetWin(), sizer=_frequency_sizer, value=self.frequency, callback=self.set_frequency, minimum=80000000, maximum=1100000000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_frequency_sizer) self.zeromq_push_sink_0_0 = zeromq.push_sink(gr.sizeof_float, fft_n_elements, 'tcp://127.0.0.1:9000', 100, False, -1) self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer( ('localhost', 8080), allow_none=True) self.xmlrpc_server_0.register_instance(self) self.xmlrpc_server_0_thread = threading.Thread( target=self.xmlrpc_server_0.serve_forever) self.xmlrpc_server_0_thread.daemon = True self.xmlrpc_server_0_thread.start() self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=frequency, 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='master_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(frequency, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(40, 0) self.rtlsdr_source_0.set_if_gain(0, 0) self.rtlsdr_source_0.set_bb_gain(0, 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(samp_rate, 0) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label='gain', converter=forms.int_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=50, num_steps=50, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_gain_sizer) self.freq_xlating_fft_filter_ccc_0_0_3 = filter.freq_xlating_fft_filter_ccc( xlate_decimation, (fft_taps), frequency + hunter_freq_5, samp_rate) self.freq_xlating_fft_filter_ccc_0_0_3.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0_0_3.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0_0_2 = filter.freq_xlating_fft_filter_ccc( xlate_decimation, (fft_taps), frequency + hunter_freq_4, samp_rate) self.freq_xlating_fft_filter_ccc_0_0_2.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0_0_2.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0_0_1 = filter.freq_xlating_fft_filter_ccc( xlate_decimation, (fft_taps), frequency + hunter_freq_3, samp_rate) self.freq_xlating_fft_filter_ccc_0_0_1.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0_0_1.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0_0_0 = filter.freq_xlating_fft_filter_ccc( xlate_decimation, (fft_taps), frequency + hunter_freq_2, samp_rate) self.freq_xlating_fft_filter_ccc_0_0_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0_0_0.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0_0 = filter.freq_xlating_fft_filter_ccc( xlate_decimation, (fft_taps), frequency + hunter_freq_1, samp_rate) self.freq_xlating_fft_filter_ccc_0_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0_0.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc( xlate_decimation, (fft_taps), frequency + hunter_freq_0, samp_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) _filter_width_sizer = wx.BoxSizer(wx.VERTICAL) self._filter_width_text_box = forms.text_box( parent=self.GetWin(), sizer=_filter_width_sizer, value=self.filter_width, callback=self.set_filter_width, label='filter_width', converter=forms.int_converter(), proportion=0, ) self._filter_width_slider = forms.slider( parent=self.GetWin(), sizer=_filter_width_sizer, value=self.filter_width, callback=self.set_filter_width, minimum=2048, maximum=40960, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_filter_width_sizer) self.fft_vxx_0 = fft.fft_vcc(fft_n_elements, True, (window.blackmanharris(fft_n_elements)), True, 1) self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, fft_n_elements) self.blocks_stream_to_vector_1 = blocks.stream_to_vector( gr.sizeof_float * 1, fft_n_elements) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, fft_n_elements) self.blocks_null_sink_0_0_3 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_null_sink_0_0_2 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_null_sink_0_0_1 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_null_sink_0_0_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) # FLEX protocol demodulator self.flex0 = pager.flex_demod(queue, 0, False, False) # options.verbose, options.log self.flex1 = pager.flex_demod(queue, 0, False, False) # options.verbose, options.log self.flex2 = pager.flex_demod(queue, 0, False, False) # options.verbose, options.log self.flex3 = pager.flex_demod(queue, 0, False, False) # options.verbose, options.log self.flex4 = pager.flex_demod(queue, 0, False, False) # options.verbose, options.log self.flex5 = pager.flex_demod(queue, 0, False, False) # options.verbose, options.log ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_stream_to_vector_1, 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.zeromq_push_sink_0_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.flex0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.flex1, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0_0, 0), (self.flex2, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0_1, 0), (self.flex3, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0_2, 0), (self.flex4, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0_3, 0), (self.flex5, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0_1, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0_2, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0_3, 0)) self.connect((self.rtlsdr_source_0, 0), (self.wxgui_fftsink2_0, 0))
def __init__(self): gr.top_block.__init__(self, "Stanley Rx") Qt.QWidget.__init__(self) self.setWindowTitle("Stanley 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", "stanley_rx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.output_rate = output_rate = int(15e3) self.hackrf_rate = hackrf_rate = int(2e6) self.frequency = frequency = 433.858e6 self.dc_offset = dc_offset = 200e3 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=output_rate, decimation=hackrf_rate, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc output_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) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if float == type(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_layout.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size output_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "") self.osmosdr_source_0.set_sample_rate(hackrf_rate) self.osmosdr_source_0.set_center_freq(frequency + dc_offset, 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("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc( 1, (1, ), 0 - dc_offset, hackrf_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) self.blocks_wavfile_sink_0 = blocks.wavfile_sink( "/Users/adamcoddington/Desktop/output/1_offw.wav", 1, output_rate, 8) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.analog_agc_xx_0 = analog.agc_cc(1e-4, 1.0, 1.0) self.analog_agc_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_agc_xx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 16000000 self.channelizer_decimation = channelizer_decimation = 50 self.wspr_center_frequency_2 = wspr_center_frequency_2 = 10.1387e6 self.wspr_center_frequency_1 = wspr_center_frequency_1 = 7.0386e6 self.wspr_center_frequency_0 = wspr_center_frequency_0 = 14.0956e6 self.rs_interpolation = rs_interpolation = 3 self.rs_decimation = rs_decimation = 20 self.channelizer_samp_rate = channelizer_samp_rate = samp_rate/channelizer_decimation self.center_frequency = center_frequency = 8000000 self.wspr_deviation_2 = wspr_deviation_2 = wspr_center_frequency_2-center_frequency self.wspr_deviation_1 = wspr_deviation_1 = wspr_center_frequency_1-center_frequency self.wspr_deviation_0 = wspr_deviation_0 = wspr_center_frequency_0-center_frequency self.rs_samp_rate = rs_samp_rate = channelizer_samp_rate*rs_interpolation/rs_decimation self.rf_gain = rf_gain = 14 self.if_gain = if_gain = 16 self.bb_gain = bb_gain = 16 self.bandpass_transition = bandpass_transition = 2500 self.bandpass_low = bandpass_low = 200 self.bandpass_high = bandpass_high = 2500 ################################################## # Blocks ################################################## self._rf_gain_range = Range(0, 14, 14, 14, 200) self._rf_gain_win = RangeWidget(self._rf_gain_range, self.set_rf_gain, "rf_gain", "counter_slider", int) self.top_layout.addWidget(self._rf_gain_win) self._if_gain_range = Range(0, 40, 8, 16, 200) self._if_gain_win = RangeWidget(self._if_gain_range, self.set_if_gain, "if_gain", "counter_slider", int) self.top_layout.addWidget(self._if_gain_win) self._bb_gain_range = Range(0, 62, 2, 16, 200) self._bb_gain_win = RangeWidget(self._bb_gain_range, self.set_bb_gain, "bb_gain", "counter_slider", int) self.top_layout.addWidget(self._bb_gain_win) self.rational_resampler_xxx_0_0_0 = filter.rational_resampler_ccc( interpolation=rs_interpolation, decimation=rs_decimation, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=rs_interpolation, decimation=rs_decimation, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=rs_interpolation, decimation=rs_decimation, taps=None, fractional_bw=None, ) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + 'hackrf=0' ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(center_frequency, 0) self.osmosdr_source_0.set_freq_corr(0, 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(False, 0) self.osmosdr_source_0.set_gain(rf_gain, 0) self.osmosdr_source_0.set_if_gain(if_gain, 0) self.osmosdr_source_0.set_bb_gain(bb_gain, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.freq_xlating_fft_filter_ccc_0_0_0 = filter.freq_xlating_fft_filter_ccc(channelizer_decimation, (firdes.complex_band_pass(1,samp_rate,-samp_rate/channelizer_decimation/2,samp_rate/channelizer_decimation/2,samp_rate/channelizer_decimation/16)), wspr_deviation_2, samp_rate) self.freq_xlating_fft_filter_ccc_0_0_0.set_nthreads(2) self.freq_xlating_fft_filter_ccc_0_0_0.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0_0 = filter.freq_xlating_fft_filter_ccc(channelizer_decimation, (firdes.complex_band_pass(1,samp_rate,-samp_rate/channelizer_decimation/2,samp_rate/channelizer_decimation/2,samp_rate/channelizer_decimation/16)), wspr_deviation_1, samp_rate) self.freq_xlating_fft_filter_ccc_0_0.set_nthreads(2) self.freq_xlating_fft_filter_ccc_0_0.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc(channelizer_decimation, (firdes.complex_band_pass(1,samp_rate,-samp_rate/channelizer_decimation/2,samp_rate/channelizer_decimation/2,samp_rate/channelizer_decimation/16)), wspr_deviation_0, samp_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(2) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) self.blocks_complex_to_real_0_0_0 = blocks.complex_to_real(1) self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.band_pass_filter_0_0_0 = filter.fir_filter_ccf(1, firdes.band_pass( 1, rs_samp_rate, bandpass_low, bandpass_high, bandpass_transition, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0_0 = filter.fir_filter_ccf(1, firdes.band_pass( 1, rs_samp_rate, bandpass_low, bandpass_high, bandpass_transition, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0 = filter.fir_filter_ccf(1, firdes.band_pass( 1, rs_samp_rate, bandpass_low, bandpass_high, bandpass_transition, firdes.WIN_HAMMING, 6.76)) self.audio_sink_0_0_0 = audio.sink(rs_samp_rate, 'virtual_3', False) self.audio_sink_0_0 = audio.sink(rs_samp_rate, 'virtual_2', False) self.audio_sink_0 = audio.sink(rs_samp_rate, 'virtual_1', False) self.analog_agc2_xx_0_0_0 = analog.agc2_cc(0.25, 0.25, (3.0/2000.0), 1.0) self.analog_agc2_xx_0_0_0.set_max_gain(0) self.analog_agc2_xx_0_0 = analog.agc2_cc(0.25, 0.25, (3.0/2000.0), 1.0) self.analog_agc2_xx_0_0.set_max_gain(0) self.analog_agc2_xx_0 = analog.agc2_cc(0.25, 0.25, (3.0/2000.0), 1.0) self.analog_agc2_xx_0.set_max_gain(0) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.analog_agc2_xx_0_0, 0), (self.blocks_complex_to_real_0_0, 0)) self.connect((self.analog_agc2_xx_0_0_0, 0), (self.blocks_complex_to_real_0_0_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.analog_agc2_xx_0_0, 0)) self.connect((self.band_pass_filter_0_0_0, 0), (self.analog_agc2_xx_0_0_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_complex_to_real_0_0, 0), (self.audio_sink_0_0, 0)) self.connect((self.blocks_complex_to_real_0_0_0, 0), (self.audio_sink_0_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0_0, 0), (self.rational_resampler_xxx_0_0_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.band_pass_filter_0_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "ELEKTRO-L2/L3 TLM Demodulator") Qt.QWidget.__init__(self) self.setWindowTitle("ELEKTRO-L2/L3 TLM Demodulator") 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", "elektro_tlm") 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.file_rate = file_rate = 1024000 self.sym_rate = sym_rate = 5000.0 self.samp_rate = samp_rate = file_rate / 4 self.sps = sps = samp_rate / sym_rate self.offset = offset = 0 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=4, taps=None, fractional_bw=None) self.qtgui_time_raster_sink_x_0 = qtgui.time_raster_sink_b( samp_rate, 100, 1792, [], [], "", 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(False) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [2, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_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, 3, 0, 1, 2) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): 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, #bw "", #name 1) self.qtgui_freq_sink_x_0_0.set_update_time(0.01) self.qtgui_freq_sink_x_0_0.set_y_axis(-65, -15) 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.1) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) self.qtgui_freq_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(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, 0, 0, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): 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) self.qtgui_freq_sink_x_0.set_update_time(0.01) self.qtgui_freq_sink_x_0.set_y_axis(-65, 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.05) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) self.qtgui_freq_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(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, 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.qtgui_const_sink_x_0 = qtgui.const_sink_c( 256, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.01) self.qtgui_const_sink_x_0.set_y_axis(-0.5, 0.5) self.qtgui_const_sink_x_0.set_x_axis(-0.5, 0.5) 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(False) 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 range(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 1, 1, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 4.5e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 10e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc( 1, firdes.low_pass(1, samp_rate, samp_rate / (2 * 1), 1000), offset, samp_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(3e-3, 2, False) self.digital_clock_recovery_mm_xx_1 = digital.clock_recovery_mm_cc( sps * (1 + 0.0), 0.625e-3, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.dc_blocker_xx_0 = filter.dc_blocker_cc(32, True) self.blocks_wavfile_source_0 = blocks.wavfile_source('', True) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_gr_complex * 28, '127.0.0.1', 52001, 1472, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, file_rate, True) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_char * 1, 224) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_moving_average_xx_0 = blocks.moving_average_cc( 2, 0.5, 4000, 1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_SIN_WAVE, -5000, 1, 0, 0) self.analog_agc_xx_0_0_0 = analog.agc_cc(10e-3, 500e-3, 0.5) self.analog_agc_xx_0_0_0.set_max_gain(4e3) self.analog_agc_xx_0_0 = analog.agc_cc(10e-3, 500e-3, 0.5) self.analog_agc_xx_0_0.set_max_gain(4e3) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.analog_agc_xx_0_0_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.blocks_udp_sink_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.analog_agc_xx_0_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.dc_blocker_xx_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.qtgui_time_raster_sink_x_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_1, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_1, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_clock_recovery_mm_xx_1, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.analog_agc_xx_0_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.dc_blocker_xx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Vor Receive Realtime Clean") ################################################## # Variables ################################################## self.morse_vol = morse_vol = 10 self.samp_rate = samp_rate = 32000 self.rtl_gain = rtl_gain = 42 self.rtl_freq = rtl_freq = 112500e3 self.morse_gain = morse_gain = pow(10, morse_vol / 10) self.morse_amp_level = morse_amp_level = 0 self.PI = PI = 3.14159 ################################################## # Blocks ################################################## self.wxgui_scopesink2_1_0_0 = scopesink2.scope_sink_f( self.GetWin(), title='Morse', sample_rate=samp_rate / (1600), v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_STRIPCHART, y_axis_label='Amp', ) self.Add(self.wxgui_scopesink2_1_0_0.win) self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + '') self.rtlsdr_source_0.set_sample_rate(samp_rate * 64) self.rtlsdr_source_0.set_center_freq(rtl_freq, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(rtl_gain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.pfb_decimator_ccf_0 = pfb.decimator_ccf( 64, (firdes.low_pass(1, samp_rate * 64, 16e3, 200e3)), 0, 100, True, True) self.pfb_decimator_ccf_0.declare_sample_delay(0) _morse_vol_sizer = wx.BoxSizer(wx.VERTICAL) self._morse_vol_text_box = forms.text_box( parent=self.GetWin(), sizer=_morse_vol_sizer, value=self.morse_vol, callback=self.set_morse_vol, label='Morse Volume (dB):', converter=forms.float_converter(), proportion=0, ) self._morse_vol_slider = forms.slider( parent=self.GetWin(), sizer=_morse_vol_sizer, value=self.morse_vol, callback=self.set_morse_vol, minimum=-25, maximum=25, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_morse_vol_sizer) def _morse_amp_level_probe(): while True: val = self.morse_amp.level() try: self.set_morse_amp_level(val) except AttributeError: pass time.sleep(1.0 / (25)) _morse_amp_level_thread = threading.Thread( target=_morse_amp_level_probe) _morse_amp_level_thread.daemon = True _morse_amp_level_thread.start() self.hilbert_fc_0 = filter.hilbert_fc(64, firdes.WIN_HAMMING, 6.76) self.goertzel_fc_0_0 = fft.goertzel_fc(samp_rate, 3200, 30) self.goertzel_fc_0 = fft.goertzel_fc(samp_rate, 3200, 30) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc( 1, (firdes.low_pass(1, samp_rate, 480 * 2, 500 * 2)), 9960, samp_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) self.blocks_tcp_server_sink_0 = blocks.tcp_server_sink( gr.sizeof_gr_complex * 1, '0.0.0.0', 20000, True) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (morse_gain, )) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_integrate_xx_1 = blocks.integrate_ff(1600, 1) self.blocks_integrate_xx_0 = blocks.integrate_cc(8, 1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.band_pass_filter_0 = filter.fir_filter_fcc( 1, firdes.complex_band_pass(1, samp_rate, 1010, 1030, 100, firdes.WIN_HAMMING, 6.76)) self.audio_sink_0_0 = audio.sink(samp_rate, '', True) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=samp_rate, audio_decimation=1, ) self.analog_agc3_xx_0 = analog.agc3_cc(1e-3, 1e-4, 1.0, 1.0, 1) self.analog_agc3_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc3_xx_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.goertzel_fc_0_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.goertzel_fc_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.hilbert_fc_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_integrate_xx_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_integrate_xx_0, 0), (self.blocks_tcp_server_sink_0, 0)) self.connect((self.blocks_integrate_xx_1, 0), (self.wxgui_scopesink2_1_0_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_integrate_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.goertzel_fc_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.goertzel_fc_0_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.hilbert_fc_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.pfb_decimator_ccf_0, 0), (self.analog_agc3_xx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.pfb_decimator_ccf_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.audio_rate = audio_rate = int(48e3) self.rtl_rate = rtl_rate = int(240e3) self.out_intermediary_rate = out_intermediary_rate = audio_rate*4 self.out_gain = out_gain = .25 self.out_frequency_offset = out_frequency_offset = -50e3 self.out_frequency = out_frequency = 145.521e6 self.out_audio_inverted = out_audio_inverted = True self.in_frequency_offset = in_frequency_offset = 0 self.in_frequency = in_frequency = 145.551e6 self.in_final_gain = in_final_gain = 0.5 self.in_decimation_factor = in_decimation_factor = 8 self.in_audio_inverted = in_audio_inverted = True self.hackrf_rate = hackrf_rate = 2e6 self.dstar_bandwidth = dstar_bandwidth = 6.5e3 ################################################## # Blocks ################################################## self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(rtl_rate) self.rtlsdr_source_0.set_center_freq(in_frequency+in_frequency_offset, 0) self.rtlsdr_source_0.set_freq_corr(69, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(10, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.rational_resampler_xxx_3 = filter.rational_resampler_ccc( interpolation=int(hackrf_rate), decimation=out_intermediary_rate, taps=None, fractional_bw=None, ) self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "" ) self.osmosdr_sink_0.set_sample_rate(hackrf_rate) self.osmosdr_sink_0.set_center_freq(out_frequency-out_frequency_offset, 0) self.osmosdr_sink_0.set_freq_corr(4, 0) self.osmosdr_sink_0.set_gain(14, 0) self.osmosdr_sink_0.set_if_gain(0, 0) self.osmosdr_sink_0.set_bb_gain(0, 0) self.osmosdr_sink_0.set_antenna("0", 0) self.osmosdr_sink_0.set_bandwidth(100e3, 0) self.low_pass_filter_1 = filter.fir_filter_ccf(5, firdes.low_pass( 1, rtl_rate, dstar_bandwidth*2, 500, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_fff(1, firdes.low_pass( 1, audio_rate, dstar_bandwidth*2, 200, firdes.WIN_KAISER, 6.76)) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc(1, (1, ), 0-out_frequency_offset, out_intermediary_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) self.dc_blocker_xx_0 = filter.dc_blocker_ff(128, True) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff(((-1 if out_audio_inverted else 1)*out_gain, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((0-in_final_gain if in_audio_inverted else in_final_gain, )) self.audio_source_0 = audio.source(audio_rate, "hw:10,1", True) self.audio_sink_1 = audio.sink(audio_rate, "plughw:11,0", True) self.analog_pwr_squelch_xx_1 = analog.pwr_squelch_cc(-30, 1, 1, False) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_ff(-60, 1, 1, True) self.analog_nbfm_tx_0 = analog.nbfm_tx( audio_rate=int(audio_rate), quad_rate=int(out_intermediary_rate), tau=0, max_dev=dstar_bandwidth, ) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=audio_rate, quad_rate=audio_rate, tau=0.000000000000000000001, max_dev=dstar_bandwidth*2, ) ################################################## # Connections ################################################## self.connect((self.analog_nbfm_rx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.analog_nbfm_tx_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.analog_pwr_squelch_xx_1, 0), (self.analog_nbfm_rx_0, 0)) self.connect((self.audio_source_0, 0), (self.dc_blocker_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.audio_sink_1, 0)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.low_pass_filter_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.rational_resampler_xxx_3, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_nbfm_tx_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.analog_pwr_squelch_xx_1, 0)) self.connect((self.rational_resampler_xxx_3, 0), (self.osmosdr_sink_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_1, 0))
def __init__(self): gr.top_block.__init__(self, "2M Multi-RX -- 7 simultaneous channels") Qt.QWidget.__init__(self) self.setWindowTitle("2M Multi-RX -- 7 simultaneous channels") 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", "noaa_demo") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.noaa_num_chans = noaa_num_chans = 7 self.noaa_chan_width = noaa_chan_width = int(15e3) self.noaa_band_start = noaa_band_start = 146.475e6 self.oversampled_width = oversampled_width = noaa_chan_width * ( noaa_num_chans + 1) self.noaa_fm_dev = noaa_fm_dev = int(5e3) self.noaa_band_center = noaa_band_center = noaa_band_start + ( noaa_num_chans / 2 * noaa_chan_width) self.hardware_rate = hardware_rate = int(1e6) self.tuner_freq = tuner_freq = 146.4e6 self.target_freq = target_freq = noaa_band_center self.ppm = ppm = 0 self.pfb_taps = pfb_taps = firdes.low_pass(2.0, oversampled_width, noaa_fm_dev * 2, 1000, firdes.WIN_HAMMING, 6.76) self.lpf_taps = lpf_taps = firdes.low_pass(1.0, hardware_rate, oversampled_width / 2, noaa_chan_width, firdes.WIN_HAMMING, 6.76) self.channel_map = channel_map = range(0, noaa_num_chans) self.volume = volume = 0.4 self.tuner_offset = tuner_offset = target_freq - tuner_freq self.squelch = squelch = -55 self.sq_ramp = sq_ramp = 10 self.sq_alpha = sq_alpha = 0.005 self.ppm_corr = ppm_corr = tuner_freq * (ppm / 1e6) self.pfb_sizeof_taps = pfb_sizeof_taps = len(pfb_taps) self.noaa_band_width = noaa_band_width = noaa_chan_width * noaa_num_chans self.noaa_band_end = noaa_band_end = noaa_band_start + ( noaa_num_chans * noaa_chan_width) self.lpf_sizeof_taps = lpf_sizeof_taps = len(lpf_taps) self.fftwidth = fftwidth = 512 self.fft_interval = fft_interval = 1.0 / 20 self.decimation = decimation = hardware_rate / oversampled_width self.channelizer_map = channelizer_map = 5, 6, 7, 0, 1, 2, 3 self.channel_names = channel_names = map( lambda x: "%.3fMHz" % (146.475 + (x * 0.015)), channel_map) self.ch6_mute = ch6_mute = 1 self.ch5_mute = ch5_mute = 1 self.ch4_mute = ch4_mute = 1 self.ch3_mute = ch3_mute = 1 self.ch2_mute = ch2_mute = 1 self.ch1_mute = ch1_mute = 1 self.ch0_mute = ch0_mute = 1 self.audio_rate = audio_rate = 15000 ################################################## # Blocks ################################################## self._volume_range = Range(0, 1, 0.01, 0.4, 50) self._volume_win = RangeWidget(self._volume_range, self.set_volume, "volume", "slider", float) self.top_grid_layout.addWidget(self._volume_win, 0, 0, 1, 3) self._squelch_range = Range(-70, -30, 2, -55, 50) self._squelch_win = RangeWidget(self._squelch_range, self.set_squelch, "squelch", "slider", float) self.top_grid_layout.addWidget(self._squelch_win, 0, 3, 1, 3) self._ch6_mute_options = ( 0, 1, ) self._ch6_mute_labels = ( "Mute", "Unmute", ) self._ch6_mute_group_box = Qt.QGroupBox("Ch6") self._ch6_mute_box = Qt.QVBoxLayout() 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._ch6_mute_button_group = variable_chooser_button_group() self._ch6_mute_group_box.setLayout(self._ch6_mute_box) for i, label in enumerate(self._ch6_mute_labels): radio_button = Qt.QRadioButton(label) self._ch6_mute_box.addWidget(radio_button) self._ch6_mute_button_group.addButton(radio_button, i) self._ch6_mute_callback = lambda i: Qt.QMetaObject.invokeMethod( self._ch6_mute_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._ch6_mute_options.index(i))) self._ch6_mute_callback(self.ch6_mute) self._ch6_mute_button_group.buttonClicked[int].connect( lambda i: self.set_ch6_mute(self._ch6_mute_options[i])) self.top_grid_layout.addWidget(self._ch6_mute_group_box, 1, 6, 1, 1) self._ch5_mute_options = ( 0, 1, ) self._ch5_mute_labels = ( "Mute", "Unmute", ) self._ch5_mute_group_box = Qt.QGroupBox("Ch5") self._ch5_mute_box = Qt.QVBoxLayout() 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._ch5_mute_button_group = variable_chooser_button_group() self._ch5_mute_group_box.setLayout(self._ch5_mute_box) for i, label in enumerate(self._ch5_mute_labels): radio_button = Qt.QRadioButton(label) self._ch5_mute_box.addWidget(radio_button) self._ch5_mute_button_group.addButton(radio_button, i) self._ch5_mute_callback = lambda i: Qt.QMetaObject.invokeMethod( self._ch5_mute_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._ch5_mute_options.index(i))) self._ch5_mute_callback(self.ch5_mute) self._ch5_mute_button_group.buttonClicked[int].connect( lambda i: self.set_ch5_mute(self._ch5_mute_options[i])) self.top_grid_layout.addWidget(self._ch5_mute_group_box, 1, 5, 1, 1) self._ch4_mute_options = ( 0, 1, ) self._ch4_mute_labels = ( "Mute", "Unmute", ) self._ch4_mute_group_box = Qt.QGroupBox("Ch4") self._ch4_mute_box = Qt.QVBoxLayout() 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._ch4_mute_button_group = variable_chooser_button_group() self._ch4_mute_group_box.setLayout(self._ch4_mute_box) for i, label in enumerate(self._ch4_mute_labels): radio_button = Qt.QRadioButton(label) self._ch4_mute_box.addWidget(radio_button) self._ch4_mute_button_group.addButton(radio_button, i) self._ch4_mute_callback = lambda i: Qt.QMetaObject.invokeMethod( self._ch4_mute_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._ch4_mute_options.index(i))) self._ch4_mute_callback(self.ch4_mute) self._ch4_mute_button_group.buttonClicked[int].connect( lambda i: self.set_ch4_mute(self._ch4_mute_options[i])) self.top_grid_layout.addWidget(self._ch4_mute_group_box, 1, 4, 1, 1) self._ch2_mute_options = ( 0, 1, ) self._ch2_mute_labels = ( "Mute", "Unmute", ) self._ch2_mute_group_box = Qt.QGroupBox("Ch2") self._ch2_mute_box = Qt.QVBoxLayout() 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._ch2_mute_button_group = variable_chooser_button_group() self._ch2_mute_group_box.setLayout(self._ch2_mute_box) for i, label in enumerate(self._ch2_mute_labels): radio_button = Qt.QRadioButton(label) self._ch2_mute_box.addWidget(radio_button) self._ch2_mute_button_group.addButton(radio_button, i) self._ch2_mute_callback = lambda i: Qt.QMetaObject.invokeMethod( self._ch2_mute_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._ch2_mute_options.index(i))) self._ch2_mute_callback(self.ch2_mute) self._ch2_mute_button_group.buttonClicked[int].connect( lambda i: self.set_ch2_mute(self._ch2_mute_options[i])) self.top_grid_layout.addWidget(self._ch2_mute_group_box, 1, 2, 1, 1) self._ch1_mute_options = ( 0, 1, ) self._ch1_mute_labels = ( "Mute", "Unmute", ) self._ch1_mute_group_box = Qt.QGroupBox("Ch1") self._ch1_mute_box = Qt.QVBoxLayout() 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._ch1_mute_button_group = variable_chooser_button_group() self._ch1_mute_group_box.setLayout(self._ch1_mute_box) for i, label in enumerate(self._ch1_mute_labels): radio_button = Qt.QRadioButton(label) self._ch1_mute_box.addWidget(radio_button) self._ch1_mute_button_group.addButton(radio_button, i) self._ch1_mute_callback = lambda i: Qt.QMetaObject.invokeMethod( self._ch1_mute_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._ch1_mute_options.index(i))) self._ch1_mute_callback(self.ch1_mute) self._ch1_mute_button_group.buttonClicked[int].connect( lambda i: self.set_ch1_mute(self._ch1_mute_options[i])) self.top_grid_layout.addWidget(self._ch1_mute_group_box, 1, 1, 1, 1) self._ch0_mute_options = ( 0, 1, ) self._ch0_mute_labels = ( "Mute", "Unmute", ) self._ch0_mute_group_box = Qt.QGroupBox("Ch0") self._ch0_mute_box = Qt.QVBoxLayout() 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._ch0_mute_button_group = variable_chooser_button_group() self._ch0_mute_group_box.setLayout(self._ch0_mute_box) for i, label in enumerate(self._ch0_mute_labels): radio_button = Qt.QRadioButton(label) self._ch0_mute_box.addWidget(radio_button) self._ch0_mute_button_group.addButton(radio_button, i) self._ch0_mute_callback = lambda i: Qt.QMetaObject.invokeMethod( self._ch0_mute_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._ch0_mute_options.index(i))) self._ch0_mute_callback(self.ch0_mute) self._ch0_mute_button_group.buttonClicked[int].connect( lambda i: self.set_ch0_mute(self._ch0_mute_options[i])) self.top_grid_layout.addWidget(self._ch0_mute_group_box, 1, 0, 1, 1) self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "") self.rtlsdr_source_0.set_clock_source("internal", 0) self.rtlsdr_source_0.set_sample_rate(hardware_rate) self.rtlsdr_source_0.set_center_freq(tuner_freq, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(10, 0) self.rtlsdr_source_0.set_if_gain(30, 0) self.rtlsdr_source_0.set_bb_gain(40, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.rational_resampler_xxx_0_0_0 = filter.rational_resampler_fff( interpolation=48, decimation=15, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0_0_0 = qtgui.waterfall_sink_c( fftwidth, #size firdes.WIN_BLACKMAN_hARRIS, #wintype target_freq, #fc oversampled_width, #bw "Band Monitor", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0_0_0.set_update_time(fft_interval) self.qtgui_waterfall_sink_x_0_0_0.enable_grid(True) if not True: self.qtgui_waterfall_sink_x_0_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0_0_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [5, 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_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0_0_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0_0_0.set_intensity_range(-100, 0) self._qtgui_waterfall_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_0_0_win, 2, 0, 1, 9) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( fftwidth, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc noaa_chan_width, #bw "Channelizer Output", #name noaa_num_chans #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(fft_interval) self.qtgui_freq_sink_x_0.set_y_axis(-100, 0) 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.1) 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 = [ channel_names[0], channel_names[1], channel_names[2], channel_names[3], channel_names[4], channel_names[5], channel_names[6], "channel_names[7]", "", "" ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "dark red", "dark green", "dark blue", "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(noaa_num_chans): 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, 3, 0, 1, 9) self._ppm_range = Range(-60, 60, 1, 0, 50) self._ppm_win = RangeWidget(self._ppm_range, self.set_ppm, "ppm", "slider", float) self.top_grid_layout.addWidget(self._ppm_win, 0, 6, 1, 3) self.pfb_channelizer_ccf_0 = pfb.channelizer_ccf( noaa_num_chans + 1, (pfb_taps), 1, 1) self.pfb_channelizer_ccf_0.set_channel_map((channelizer_map)) self.pfb_channelizer_ccf_0.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc( int(decimation), (lpf_taps), tuner_offset + ppm_corr, hardware_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) self._ch3_mute_options = ( 0, 1, ) self._ch3_mute_labels = ( "Mute", "Unmute", ) self._ch3_mute_group_box = Qt.QGroupBox("Ch3") self._ch3_mute_box = Qt.QVBoxLayout() 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._ch3_mute_button_group = variable_chooser_button_group() self._ch3_mute_group_box.setLayout(self._ch3_mute_box) for i, label in enumerate(self._ch3_mute_labels): radio_button = Qt.QRadioButton(label) self._ch3_mute_box.addWidget(radio_button) self._ch3_mute_button_group.addButton(radio_button, i) self._ch3_mute_callback = lambda i: Qt.QMetaObject.invokeMethod( self._ch3_mute_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._ch3_mute_options.index(i))) self._ch3_mute_callback(self.ch3_mute) self._ch3_mute_button_group.buttonClicked[int].connect( lambda i: self.set_ch3_mute(self._ch3_mute_options[i])) self.top_grid_layout.addWidget(self._ch3_mute_group_box, 1, 3, 1, 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_multiply_const_vxx_1_2_0_1 = blocks.multiply_const_vcc( (ch6_mute, )) self.blocks_multiply_const_vxx_1_2_0_0 = blocks.multiply_const_vcc( (ch5_mute, )) self.blocks_multiply_const_vxx_1_2_0 = blocks.multiply_const_vcc( (ch4_mute, )) self.blocks_multiply_const_vxx_1_1_0 = blocks.multiply_const_vcc( (ch2_mute, )) self.blocks_multiply_const_vxx_1_1 = blocks.multiply_const_vcc( (ch2_mute, )) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vcc( (ch1_mute, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc( (ch0_mute, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (volume, )) self.blocks_add_xx_0_0 = blocks.add_vff(1) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_pwr_squelch_xx_0_2_0_1 = analog.pwr_squelch_cc( squelch, sq_alpha, sq_ramp, False) self.analog_pwr_squelch_xx_0_2_0_0 = analog.pwr_squelch_cc( squelch, sq_alpha, sq_ramp, False) self.analog_pwr_squelch_xx_0_2_0 = analog.pwr_squelch_cc( squelch, sq_alpha, sq_ramp, False) self.analog_pwr_squelch_xx_0_2 = analog.pwr_squelch_cc( squelch, sq_alpha, sq_ramp, False) self.analog_pwr_squelch_xx_0_1 = analog.pwr_squelch_cc( squelch, sq_alpha, sq_ramp, False) self.analog_pwr_squelch_xx_0_0 = analog.pwr_squelch_cc( squelch, sq_alpha, sq_ramp, False) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc( squelch, sq_alpha, sq_ramp, False) self.analog_nbfm_rx_0_2_0_1 = analog.nbfm_rx( audio_rate=audio_rate, quad_rate=noaa_chan_width, tau=75e-6, max_dev=noaa_fm_dev, ) self.analog_nbfm_rx_0_2_0_0 = analog.nbfm_rx( audio_rate=audio_rate, quad_rate=noaa_chan_width, tau=75e-6, max_dev=noaa_fm_dev, ) self.analog_nbfm_rx_0_2_0 = analog.nbfm_rx( audio_rate=audio_rate, quad_rate=noaa_chan_width, tau=75e-6, max_dev=noaa_fm_dev, ) self.analog_nbfm_rx_0_2 = analog.nbfm_rx( audio_rate=audio_rate, quad_rate=noaa_chan_width, tau=75e-6, max_dev=noaa_fm_dev, ) self.analog_nbfm_rx_0_1 = analog.nbfm_rx( audio_rate=audio_rate, quad_rate=noaa_chan_width, tau=75e-6, max_dev=noaa_fm_dev, ) self.analog_nbfm_rx_0_0 = analog.nbfm_rx( audio_rate=audio_rate, quad_rate=noaa_chan_width, tau=75e-6, max_dev=noaa_fm_dev, ) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=audio_rate, quad_rate=noaa_chan_width, tau=75e-6, max_dev=noaa_fm_dev, ) ################################################## # Connections ################################################## self.connect((self.analog_nbfm_rx_0, 0), (self.blocks_add_xx_0_0, 0)) self.connect((self.analog_nbfm_rx_0_0, 0), (self.blocks_add_xx_0_0, 1)) self.connect((self.analog_nbfm_rx_0_1, 0), (self.blocks_add_xx_0_0, 2)) self.connect((self.analog_nbfm_rx_0_2, 0), (self.blocks_add_xx_0_0, 3)) self.connect((self.analog_nbfm_rx_0_2_0, 0), (self.blocks_add_xx_0_0, 4)) self.connect((self.analog_nbfm_rx_0_2_0_0, 0), (self.blocks_add_xx_0_0, 5)) self.connect((self.analog_nbfm_rx_0_2_0_1, 0), (self.blocks_add_xx_0_0, 6)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.analog_pwr_squelch_xx_0_0, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.analog_pwr_squelch_xx_0_1, 0), (self.blocks_multiply_const_vxx_1_1, 0)) self.connect((self.analog_pwr_squelch_xx_0_2, 0), (self.blocks_multiply_const_vxx_1_1_0, 0)) self.connect((self.analog_pwr_squelch_xx_0_2_0, 0), (self.blocks_multiply_const_vxx_1_2_0, 0)) self.connect((self.analog_pwr_squelch_xx_0_2_0_0, 0), (self.blocks_multiply_const_vxx_1_2_0_0, 0)) self.connect((self.analog_pwr_squelch_xx_0_2_0_1, 0), (self.blocks_multiply_const_vxx_1_2_0_1, 0)) self.connect((self.blocks_add_xx_0_0, 0), (self.rational_resampler_xxx_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.analog_nbfm_rx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.analog_nbfm_rx_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_1, 0), (self.analog_nbfm_rx_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_1_1_0, 0), (self.analog_nbfm_rx_0_2, 0)) self.connect((self.blocks_multiply_const_vxx_1_2_0, 0), (self.analog_nbfm_rx_0_2_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_2_0_0, 0), (self.analog_nbfm_rx_0_2_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_2_0_1, 0), (self.analog_nbfm_rx_0_2_0_1, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.pfb_channelizer_ccf_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.qtgui_waterfall_sink_x_0_0_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 1), (self.analog_pwr_squelch_xx_0_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 2), (self.analog_pwr_squelch_xx_0_1, 0)) self.connect((self.pfb_channelizer_ccf_0, 3), (self.analog_pwr_squelch_xx_0_2, 0)) self.connect((self.pfb_channelizer_ccf_0, 4), (self.analog_pwr_squelch_xx_0_2_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 5), (self.analog_pwr_squelch_xx_0_2_0_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 6), (self.analog_pwr_squelch_xx_0_2_0_1, 0)) self.connect((self.pfb_channelizer_ccf_0, 7), (self.blocks_null_sink_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 1), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.pfb_channelizer_ccf_0, 2), (self.qtgui_freq_sink_x_0, 2)) self.connect((self.pfb_channelizer_ccf_0, 3), (self.qtgui_freq_sink_x_0, 3)) self.connect((self.pfb_channelizer_ccf_0, 4), (self.qtgui_freq_sink_x_0, 4)) self.connect((self.pfb_channelizer_ccf_0, 5), (self.qtgui_freq_sink_x_0, 5)) self.connect((self.pfb_channelizer_ccf_0, 6), (self.qtgui_freq_sink_x_0, 6)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="CP v0.1a") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.freq = freq = 92.9e6 self.samp_rate = samp_rate = 2.4e6 self.ch2_volume = ch2_volume = 1 self.ch2_squelch = ch2_squelch = -30 self.ch2_mute = ch2_mute = 1 self.ch2_modulation = ch2_modulation = 0 self.ch2_invert = ch2_invert = 1 self.ch2_freq = ch2_freq = freq self.ch1_volume = ch1_volume = 1 self.ch1_squelch = ch1_squelch = -30 self.ch1_mute = ch1_mute = 1 self.ch1_modulation = ch1_modulation = 0 self.ch1_invert = ch1_invert = 1 self.ch1_freq = ch1_freq = freq ################################################## # Blocks ################################################## self.tab = self.tab = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.tab.AddPage(grc_wxgui.Panel(self.tab), "Ch 1") self.tab.AddPage(grc_wxgui.Panel(self.tab), "Ch 2") self.GridAdd(self.tab, 3, 0, 1, 7) self._freq_text_box = forms.text_box( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Radio Center Freq", converter=forms.float_converter(), ) self.GridAdd(self._freq_text_box, 19, 0, 1, 10) _ch2_volume_sizer = wx.BoxSizer(wx.VERTICAL) self._ch2_volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_ch2_volume_sizer, value=self.ch2_volume, callback=self.set_ch2_volume, label="Volume", converter=forms.float_converter(), proportion=0, ) self._ch2_volume_slider = forms.slider( parent=self.GetWin(), sizer=_ch2_volume_sizer, value=self.ch2_volume, callback=self.set_ch2_volume, minimum=0, maximum=10, num_steps=20, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_ch2_volume_sizer, 2, 2, 1, 1) _ch2_squelch_sizer = wx.BoxSizer(wx.VERTICAL) self._ch2_squelch_text_box = forms.text_box( parent=self.GetWin(), sizer=_ch2_squelch_sizer, value=self.ch2_squelch, callback=self.set_ch2_squelch, label="Squelch", converter=forms.float_converter(), proportion=0, ) self._ch2_squelch_slider = forms.slider( parent=self.GetWin(), sizer=_ch2_squelch_sizer, value=self.ch2_squelch, callback=self.set_ch2_squelch, minimum=-70, maximum=0, num_steps=14, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_ch2_squelch_sizer, 2, 3, 1, 1) self._ch2_mute_check_box = forms.check_box( parent=self.GetWin(), value=self.ch2_mute, callback=self.set_ch2_mute, label="Mute", true=0, false=1, ) self.GridAdd(self._ch2_mute_check_box, 2, 5, 1, 1) self._ch2_modulation_chooser = forms.button( parent=self.GetWin(), value=self.ch2_modulation, callback=self.set_ch2_modulation, label="Modulation", choices=[0, 1], labels=["DMR","NBFM"], ) self.GridAdd(self._ch2_modulation_chooser, 2, 1, 1, 1) self._ch2_invert_check_box = forms.check_box( parent=self.GetWin(), value=self.ch2_invert, callback=self.set_ch2_invert, label="Invert", true=-1, false=1, ) self.GridAdd(self._ch2_invert_check_box, 2, 4, 1, 1) self._ch2_freq_text_box = forms.text_box( parent=self.GetWin(), value=self.ch2_freq, callback=self.set_ch2_freq, label="Ch2 Freq", converter=forms.float_converter(), ) self.GridAdd(self._ch2_freq_text_box, 2, 0, 1, 1) _ch1_volume_sizer = wx.BoxSizer(wx.VERTICAL) self._ch1_volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_ch1_volume_sizer, value=self.ch1_volume, callback=self.set_ch1_volume, label="Volume", converter=forms.float_converter(), proportion=0, ) self._ch1_volume_slider = forms.slider( parent=self.GetWin(), sizer=_ch1_volume_sizer, value=self.ch1_volume, callback=self.set_ch1_volume, minimum=0, maximum=10, num_steps=40, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_ch1_volume_sizer, 0, 2, 1, 1) _ch1_squelch_sizer = wx.BoxSizer(wx.VERTICAL) self._ch1_squelch_text_box = forms.text_box( parent=self.GetWin(), sizer=_ch1_squelch_sizer, value=self.ch1_squelch, callback=self.set_ch1_squelch, label="Squelch", converter=forms.float_converter(), proportion=0, ) self._ch1_squelch_slider = forms.slider( parent=self.GetWin(), sizer=_ch1_squelch_sizer, value=self.ch1_squelch, callback=self.set_ch1_squelch, minimum=-70, maximum=0, num_steps=14, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_ch1_squelch_sizer, 0, 3, 1, 1) self._ch1_mute_check_box = forms.check_box( parent=self.GetWin(), value=self.ch1_mute, callback=self.set_ch1_mute, label="Mute", true=0, false=1, ) self.GridAdd(self._ch1_mute_check_box, 0, 5, 1, 1) self._ch1_modulation_chooser = forms.button( parent=self.GetWin(), value=self.ch1_modulation, callback=self.set_ch1_modulation, label="Modulation", choices=[0, 1], labels=["DMR","NBFM"], ) self.GridAdd(self._ch1_modulation_chooser, 0, 1, 1, 1) self._ch1_invert_check_box = forms.check_box( parent=self.GetWin(), value=self.ch1_invert, callback=self.set_ch1_invert, label="Invert", true=-1, false=1, ) self.GridAdd(self._ch1_invert_check_box, 0, 4, 1, 1) self._ch1_freq_text_box = forms.text_box( parent=self.GetWin(), value=self.ch1_freq, callback=self.set_ch1_freq, label="Ch1 Freq", converter=forms.float_converter(), ) self.GridAdd(self._ch1_freq_text_box, 0, 0, 1, 1) self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c( self.GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.GridAdd(self.wxgui_waterfallsink2_1.win, 4, 0, 15, 10) self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c( self.tab.GetPage(1).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=15, average=True, avg_alpha=0.1333, title="Channel 2", peak_hold=False, ) self.tab.GetPage(1).GridAdd(self.wxgui_fftsink2_0_0.win, 0, 0, 12, 7) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.tab.GetPage(0).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=15, average=True, avg_alpha=0.1333, title="Channel 1", peak_hold=False, ) self.tab.GetPage(0).GridAdd(self.wxgui_fftsink2_0.win, 0, 0, 12, 7) 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(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(10, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.rational_resampler_xxx_3_0 = filter.rational_resampler_fff( interpolation=48000, decimation=8000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_3 = filter.rational_resampler_fff( interpolation=48000, decimation=8000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_2_0 = filter.rational_resampler_ccc( interpolation=48000, decimation=2400000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_2 = filter.rational_resampler_ccc( interpolation=48000, decimation=2400000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=192000, decimation=int(samp_rate), taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=192000, decimation=int(samp_rate), taps=None, fractional_bw=None, ) self.low_pass_filter_1_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, 192000, 5e3, 5e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_1 = filter.fir_filter_ccf(1, firdes.low_pass( 1, 192000, 5e3, 5e3, firdes.WIN_HAMMING, 6.76)) self.freq_xlating_fft_filter_ccc_0_0 = filter.freq_xlating_fft_filter_ccc(1, (firdes.low_pass(1,samp_rate,200000,10000)), ch2_freq - freq, samp_rate) self.freq_xlating_fft_filter_ccc_0_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0_0.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc(1, (firdes.low_pass(1,samp_rate,200000,10000)), ch1_freq - freq, samp_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) self.dsd_block_ff_0_0 = dsd.block_ff(dsd.dsd_FRAME_DMR_MOTOTRBO,dsd.dsd_MOD_GFSK,3,True,3) self.dsd_block_ff_0 = dsd.block_ff(dsd.dsd_FRAME_DMR_MOTOTRBO,dsd.dsd_MOD_GFSK,3,True,3) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((ch2_invert * ch2_mute, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((ch1_invert * ch1_mute, )) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((ch2_volume, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((ch1_volume, )) self.blks2_selector_0_1 = grc_blks2.selector( item_size=gr.sizeof_gr_complex*1, num_inputs=1, num_outputs=2, input_index=0, output_index=ch2_modulation, ) self.blks2_selector_0_0_0 = grc_blks2.selector( item_size=gr.sizeof_float*1, num_inputs=2, num_outputs=1, input_index=ch2_modulation, output_index=0, ) self.blks2_selector_0_0 = grc_blks2.selector( item_size=gr.sizeof_float*1, num_inputs=2, num_outputs=1, input_index=ch1_modulation, output_index=0, ) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex*1, num_inputs=1, num_outputs=2, input_index=0, output_index=ch1_modulation, ) self.audio_sink_0_0 = audio.sink(48000, "", True) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_quadrature_demod_cf_1_0 = analog.quadrature_demod_cf(1.6) self.analog_quadrature_demod_cf_1 = analog.quadrature_demod_cf(1.6) self.analog_pwr_squelch_xx_0_0_0 = analog.pwr_squelch_cc(ch2_squelch, 1e-4, 0, True) self.analog_pwr_squelch_xx_0_0 = analog.pwr_squelch_cc(ch1_squelch, 1e-4, 0, True) self.analog_nbfm_rx_0_0 = analog.nbfm_rx( audio_rate=48000, quad_rate=192000, tau=75e-6, max_dev=2.5e3, ) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=48000, quad_rate=192000, tau=75e-6, max_dev=2.5e3, ) ################################################## # Connections ################################################## self.connect((self.analog_nbfm_rx_0, 0), (self.blks2_selector_0_0, 1)) self.connect((self.analog_nbfm_rx_0_0, 0), (self.blks2_selector_0_0_0, 1)) self.connect((self.analog_pwr_squelch_xx_0_0, 0), (self.blks2_selector_0, 0)) self.connect((self.analog_pwr_squelch_xx_0_0_0, 0), (self.blks2_selector_0_1, 0)) self.connect((self.analog_quadrature_demod_cf_1, 0), (self.dsd_block_ff_0, 0)) self.connect((self.analog_quadrature_demod_cf_1_0, 0), (self.dsd_block_ff_0_0, 0)) self.connect((self.blks2_selector_0, 1), (self.rational_resampler_xxx_0, 0)) self.connect((self.blks2_selector_0, 0), (self.rational_resampler_xxx_2, 0)) self.connect((self.blks2_selector_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blks2_selector_0_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blks2_selector_0_1, 1), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.blks2_selector_0_1, 0), (self.rational_resampler_xxx_2_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.audio_sink_0_0, 0)) self.connect((self.dsd_block_ff_0, 0), (self.rational_resampler_xxx_3, 0)) self.connect((self.dsd_block_ff_0_0, 0), (self.rational_resampler_xxx_3_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.analog_pwr_squelch_xx_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.analog_pwr_squelch_xx_0_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.wxgui_fftsink2_0_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.analog_nbfm_rx_0, 0)) self.connect((self.low_pass_filter_1_0, 0), (self.analog_nbfm_rx_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.low_pass_filter_1_0, 0)) self.connect((self.rational_resampler_xxx_2, 0), (self.analog_quadrature_demod_cf_1, 0)) self.connect((self.rational_resampler_xxx_2_0, 0), (self.analog_quadrature_demod_cf_1_0, 0)) self.connect((self.rational_resampler_xxx_3, 0), (self.blks2_selector_0_0, 0)) self.connect((self.rational_resampler_xxx_3_0, 0), (self.blks2_selector_0_0_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.wxgui_waterfallsink2_1, 0))
def __init__(self): gr.top_block.__init__(self, "Downsampling") Qt.QWidget.__init__(self) self.setWindowTitle("Downsampling") 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", "downsampling") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.taps0 = taps0 = [ 1, ] self.taps1 = taps1 = firdes.low_pass_2(1, 1, 0.2, 0.05, 80) self.taps = taps = taps0 self.sps = sps = 32 self.samp_rate = samp_rate = 100000 self.decim = decim = 4 self.cfreq = cfreq = 35e3 self.arity = arity = 4 ################################################## # Blocks ################################################## self._taps_options = ( taps0, taps1, ) self._taps_labels = ( 'No Filter', 'LPF', ) self._taps_group_box = Qt.QGroupBox('Tap Select') self._taps_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._taps_button_group = variable_chooser_button_group() self._taps_group_box.setLayout(self._taps_box) for i, label in enumerate(self._taps_labels): radio_button = Qt.QRadioButton(label) self._taps_box.addWidget(radio_button) self._taps_button_group.addButton(radio_button, i) self._taps_callback = lambda i: Qt.QMetaObject.invokeMethod( self._taps_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._taps_options.index(i))) self._taps_callback(self.taps) self._taps_button_group.buttonClicked[int].connect( lambda i: self.set_taps(self._taps_options[i])) self.top_grid_layout.addWidget(self._taps_group_box, 0, 1, 1, 1) self._cfreq_range = Range(0, samp_rate / 2, 1e3, 35e3, 200) self._cfreq_win = RangeWidget(self._cfreq_range, self.set_cfreq, 'Cent. Freq.', "counter_slider", float) self.top_grid_layout.addWidget(self._cfreq_win, 0, 0, 1, 1) self.qtgui_freq_sink_x_0_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw 'RF Spectrum', #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, 0) 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(False) self.qtgui_freq_sink_x_0_0_0.set_fft_average(1.0) 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 True: 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 = ['', '', '', '', '', '', '', '', '', ''] widths = [2, 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, 0, 1, 1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim, #bw 'Down-Sampled', #name 2 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 0) 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 True: 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 = [2, 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, 1, 1, 1, 1) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc( 1, (firdes.low_pass_2(1, 1, 0.45, 0.05, 60)), -cfreq, samp_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) self.fir_filter_xxx_0_0 = filter.fir_filter_ccc(decim, (taps)) self.fir_filter_xxx_0_0.declare_sample_delay(0) self.fir_filter_xxx_0 = filter.fir_filter_ccc(decim, (taps)) self.fir_filter_xxx_0.declare_sample_delay(0) self.digital_psk_mod_0_0 = digital.psk.psk_mod( constellation_points=arity, mod_code="gray", differential=True, samples_per_symbol=sps * 2, excess_bw=0.35, verbose=False, log=False, ) self.digital_psk_mod_0 = digital.psk.psk_mod( constellation_points=arity, mod_code="gray", differential=True, samples_per_symbol=sps, excess_bw=0.35, verbose=False, log=False, ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_random_source_x_0_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 256, 1000)), True) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 256, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_psk_mod_0, 0)) self.connect((self.analog_random_source_x_0_0, 0), (self.digital_psk_mod_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0_0_0, 0)) self.connect((self.digital_psk_mod_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.digital_psk_mod_0_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.fir_filter_xxx_0_0, 0), (self.qtgui_freq_sink_x_0_0, 1)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.fir_filter_xxx_0_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="CP v0.3a") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.freq = freq = 92.9e6 self.samp_rate = samp_rate = 2.4e6 self.ch3_volume = ch3_volume = 1 self.ch3_squelch = ch3_squelch = -30 self.ch3_mute = ch3_mute = 1 self.ch3_modulation = ch3_modulation = 0 self.ch3_invert = ch3_invert = 1 self.ch3_freq = ch3_freq = freq self.ch2_volume = ch2_volume = 1 self.ch2_squelch = ch2_squelch = -30 self.ch2_mute = ch2_mute = 1 self.ch2_modulation = ch2_modulation = 0 self.ch2_invert = ch2_invert = 1 self.ch2_freq = ch2_freq = freq self.ch1_volume = ch1_volume = 1 self.ch1_squelch = ch1_squelch = -30 self.ch1_mute = ch1_mute = 1 self.ch1_modulation = ch1_modulation = 0 self.ch1_invert = ch1_invert = 1 self.ch1_freq = ch1_freq = freq ################################################## # Blocks ################################################## self.tab = self.tab = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.tab.AddPage(grc_wxgui.Panel(self.tab), "Ch 1") self.tab.AddPage(grc_wxgui.Panel(self.tab), "Ch 2") self.tab.AddPage(grc_wxgui.Panel(self.tab), "Ch 3") self.GridAdd(self.tab, 5, 0, 1, 7) self._freq_text_box = forms.text_box( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Radio Center Freq", converter=forms.float_converter(), ) self.GridAdd(self._freq_text_box, 21, 0, 1, 10) _ch3_volume_sizer = wx.BoxSizer(wx.VERTICAL) self._ch3_volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_ch3_volume_sizer, value=self.ch3_volume, callback=self.set_ch3_volume, label="Volume", converter=forms.float_converter(), proportion=0, ) self._ch3_volume_slider = forms.slider( parent=self.GetWin(), sizer=_ch3_volume_sizer, value=self.ch3_volume, callback=self.set_ch3_volume, minimum=0, maximum=10, num_steps=20, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_ch3_volume_sizer, 4, 2, 1, 1) _ch3_squelch_sizer = wx.BoxSizer(wx.VERTICAL) self._ch3_squelch_text_box = forms.text_box( parent=self.GetWin(), sizer=_ch3_squelch_sizer, value=self.ch3_squelch, callback=self.set_ch3_squelch, label="Squelch", converter=forms.float_converter(), proportion=0, ) self._ch3_squelch_slider = forms.slider( parent=self.GetWin(), sizer=_ch3_squelch_sizer, value=self.ch3_squelch, callback=self.set_ch3_squelch, minimum=-70, maximum=0, num_steps=14, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_ch3_squelch_sizer, 4, 3, 1, 1) self._ch3_mute_check_box = forms.check_box( parent=self.GetWin(), value=self.ch3_mute, callback=self.set_ch3_mute, label="Mute", true=0, false=1, ) self.GridAdd(self._ch3_mute_check_box, 4, 5, 1, 1) self._ch3_modulation_chooser = forms.drop_down( parent=self.GetWin(), value=self.ch3_modulation, callback=self.set_ch3_modulation, label="Modulation", choices=[0, 1,2], labels=["DMR","NBFM","WBFM"], ) self.GridAdd(self._ch3_modulation_chooser, 4, 1, 1, 1) self._ch3_invert_check_box = forms.check_box( parent=self.GetWin(), value=self.ch3_invert, callback=self.set_ch3_invert, label="Invert", true=-1, false=1, ) self.GridAdd(self._ch3_invert_check_box, 4, 4, 1, 1) self._ch3_freq_text_box = forms.text_box( parent=self.GetWin(), value=self.ch3_freq, callback=self.set_ch3_freq, label="Ch3 Freq", converter=forms.float_converter(), ) self.GridAdd(self._ch3_freq_text_box, 4, 0, 1, 1) _ch2_volume_sizer = wx.BoxSizer(wx.VERTICAL) self._ch2_volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_ch2_volume_sizer, value=self.ch2_volume, callback=self.set_ch2_volume, label="Volume", converter=forms.float_converter(), proportion=0, ) self._ch2_volume_slider = forms.slider( parent=self.GetWin(), sizer=_ch2_volume_sizer, value=self.ch2_volume, callback=self.set_ch2_volume, minimum=0, maximum=10, num_steps=20, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_ch2_volume_sizer, 2, 2, 1, 1) _ch2_squelch_sizer = wx.BoxSizer(wx.VERTICAL) self._ch2_squelch_text_box = forms.text_box( parent=self.GetWin(), sizer=_ch2_squelch_sizer, value=self.ch2_squelch, callback=self.set_ch2_squelch, label="Squelch", converter=forms.float_converter(), proportion=0, ) self._ch2_squelch_slider = forms.slider( parent=self.GetWin(), sizer=_ch2_squelch_sizer, value=self.ch2_squelch, callback=self.set_ch2_squelch, minimum=-70, maximum=0, num_steps=14, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_ch2_squelch_sizer, 2, 3, 1, 1) self._ch2_mute_check_box = forms.check_box( parent=self.GetWin(), value=self.ch2_mute, callback=self.set_ch2_mute, label="Mute", true=0, false=1, ) self.GridAdd(self._ch2_mute_check_box, 2, 5, 1, 1) self._ch2_modulation_chooser = forms.drop_down( parent=self.GetWin(), value=self.ch2_modulation, callback=self.set_ch2_modulation, label="Modulation", choices=[0, 1,2], labels=["DMR","NBFM","WBFM"], ) self.GridAdd(self._ch2_modulation_chooser, 2, 1, 1, 1) self._ch2_invert_check_box = forms.check_box( parent=self.GetWin(), value=self.ch2_invert, callback=self.set_ch2_invert, label="Invert", true=-1, false=1, ) self.GridAdd(self._ch2_invert_check_box, 2, 4, 1, 1) self._ch2_freq_text_box = forms.text_box( parent=self.GetWin(), value=self.ch2_freq, callback=self.set_ch2_freq, label="Ch2 Freq", converter=forms.float_converter(), ) self.GridAdd(self._ch2_freq_text_box, 2, 0, 1, 1) _ch1_volume_sizer = wx.BoxSizer(wx.VERTICAL) self._ch1_volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_ch1_volume_sizer, value=self.ch1_volume, callback=self.set_ch1_volume, label="Volume", converter=forms.float_converter(), proportion=0, ) self._ch1_volume_slider = forms.slider( parent=self.GetWin(), sizer=_ch1_volume_sizer, value=self.ch1_volume, callback=self.set_ch1_volume, minimum=0, maximum=10, num_steps=40, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_ch1_volume_sizer, 0, 2, 1, 1) _ch1_squelch_sizer = wx.BoxSizer(wx.VERTICAL) self._ch1_squelch_text_box = forms.text_box( parent=self.GetWin(), sizer=_ch1_squelch_sizer, value=self.ch1_squelch, callback=self.set_ch1_squelch, label="Squelch", converter=forms.float_converter(), proportion=0, ) self._ch1_squelch_slider = forms.slider( parent=self.GetWin(), sizer=_ch1_squelch_sizer, value=self.ch1_squelch, callback=self.set_ch1_squelch, minimum=-70, maximum=0, num_steps=14, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_ch1_squelch_sizer, 0, 3, 1, 1) self._ch1_mute_check_box = forms.check_box( parent=self.GetWin(), value=self.ch1_mute, callback=self.set_ch1_mute, label="Mute", true=0, false=1, ) self.GridAdd(self._ch1_mute_check_box, 0, 5, 1, 1) self._ch1_modulation_chooser = forms.drop_down( parent=self.GetWin(), value=self.ch1_modulation, callback=self.set_ch1_modulation, label="Modulation", choices=[0, 1,2], labels=["DMR","NBFM","WBFM"], ) self.GridAdd(self._ch1_modulation_chooser, 0, 1, 1, 1) self._ch1_invert_check_box = forms.check_box( parent=self.GetWin(), value=self.ch1_invert, callback=self.set_ch1_invert, label="Invert", true=-1, false=1, ) self.GridAdd(self._ch1_invert_check_box, 0, 4, 1, 1) self._ch1_freq_text_box = forms.text_box( parent=self.GetWin(), value=self.ch1_freq, callback=self.set_ch1_freq, label="Ch1 Freq", converter=forms.float_converter(), ) self.GridAdd(self._ch1_freq_text_box, 0, 0, 1, 1) self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c( self.GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.GridAdd(self.wxgui_waterfallsink2_1.win, 6, 0, 15, 10) self.wxgui_fftsink2_0_0_0 = fftsink2.fft_sink_c( self.tab.GetPage(2).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=15, average=True, avg_alpha=0.1333, title="Channel 3", peak_hold=False, ) self.tab.GetPage(2).GridAdd(self.wxgui_fftsink2_0_0_0.win, 0, 0, 12, 7) self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c( self.tab.GetPage(1).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=15, average=True, avg_alpha=0.1333, title="Channel 2", peak_hold=False, ) self.tab.GetPage(1).GridAdd(self.wxgui_fftsink2_0_0.win, 0, 0, 12, 7) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.tab.GetPage(0).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=15, average=True, avg_alpha=0.1333, title="Channel 1", peak_hold=False, ) self.tab.GetPage(0).GridAdd(self.wxgui_fftsink2_0.win, 0, 0, 12, 7) self.wbfm_chain_0_0_0 = wbfm_chain() self.wbfm_chain_0_0 = wbfm_chain() self.wbfm_chain_0 = wbfm_chain() 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(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(10, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.nbfm_chain_1_0 = nbfm_chain() self.nbfm_chain_1 = nbfm_chain() self.nbfm_chain_0 = nbfm_chain() self.freq_xlating_fft_filter_ccc_0_0_0 = filter.freq_xlating_fft_filter_ccc(1, (firdes.low_pass(1,samp_rate,200000,10000)), ch3_freq - freq, samp_rate) self.freq_xlating_fft_filter_ccc_0_0_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0_0_0.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0_0 = filter.freq_xlating_fft_filter_ccc(1, (firdes.low_pass(1,samp_rate,200000,10000)), ch2_freq - freq, samp_rate) self.freq_xlating_fft_filter_ccc_0_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0_0.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc(1, (firdes.low_pass(1,samp_rate,200000,10000)), ch1_freq - freq, samp_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) self.dsd_chain_1_0 = dsd_chain() self.dsd_chain_1 = dsd_chain() self.dsd_chain_0 = dsd_chain() self.blocks_multiply_const_vxx_2_0 = blocks.multiply_const_vff((ch3_invert * ch3_mute, )) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((ch2_invert * ch2_mute, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((ch1_invert * ch1_mute, )) self.blocks_multiply_const_vxx_0_0_0 = blocks.multiply_const_vff((ch3_volume, )) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((ch2_volume, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((ch1_volume, )) self.blks2_selector_0_1_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex*1, num_inputs=1, num_outputs=3, input_index=0, output_index=ch3_modulation, ) self.blks2_selector_0_1 = grc_blks2.selector( item_size=gr.sizeof_gr_complex*1, num_inputs=1, num_outputs=3, input_index=0, output_index=ch2_modulation, ) self.blks2_selector_0_0_0_0 = grc_blks2.selector( item_size=gr.sizeof_float*1, num_inputs=3, num_outputs=1, input_index=ch3_modulation, output_index=0, ) self.blks2_selector_0_0_0 = grc_blks2.selector( item_size=gr.sizeof_float*1, num_inputs=3, num_outputs=1, input_index=ch2_modulation, output_index=0, ) self.blks2_selector_0_0 = grc_blks2.selector( item_size=gr.sizeof_float*1, num_inputs=3, num_outputs=1, input_index=ch1_modulation, output_index=0, ) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex*1, num_inputs=1, num_outputs=3, input_index=0, output_index=ch1_modulation, ) self.audio_sink_0_0_0 = audio.sink(48000, "", True) self.audio_sink_0_0 = audio.sink(48000, "", True) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_pwr_squelch_xx_0_0_0_0 = analog.pwr_squelch_cc(ch3_squelch, 1e-4, 0, True) self.analog_pwr_squelch_xx_0_0_0 = analog.pwr_squelch_cc(ch2_squelch, 1e-4, 0, True) self.analog_pwr_squelch_xx_0_0 = analog.pwr_squelch_cc(ch1_squelch, 1e-4, 0, True) ################################################## # Connections ################################################## self.connect((self.analog_pwr_squelch_xx_0_0, 0), (self.blks2_selector_0, 0)) self.connect((self.analog_pwr_squelch_xx_0_0_0, 0), (self.blks2_selector_0_1, 0)) self.connect((self.analog_pwr_squelch_xx_0_0_0_0, 0), (self.blks2_selector_0_1_0, 0)) self.connect((self.blks2_selector_0, 0), (self.dsd_chain_0, 0)) self.connect((self.blks2_selector_0, 1), (self.nbfm_chain_0, 0)) self.connect((self.blks2_selector_0, 2), (self.wbfm_chain_0, 0)) self.connect((self.blks2_selector_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blks2_selector_0_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blks2_selector_0_0_0_0, 0), (self.blocks_multiply_const_vxx_0_0_0, 0)) self.connect((self.blks2_selector_0_1, 0), (self.dsd_chain_1, 0)) self.connect((self.blks2_selector_0_1, 1), (self.nbfm_chain_1, 0)) self.connect((self.blks2_selector_0_1, 2), (self.wbfm_chain_0_0, 0)) self.connect((self.blks2_selector_0_1_0, 0), (self.dsd_chain_1_0, 0)) self.connect((self.blks2_selector_0_1_0, 1), (self.nbfm_chain_1_0, 0)) self.connect((self.blks2_selector_0_1_0, 2), (self.wbfm_chain_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.blocks_multiply_const_vxx_0_0_0, 0), (self.blocks_multiply_const_vxx_2_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.audio_sink_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.audio_sink_0_0_0, 0)) self.connect((self.dsd_chain_0, 0), (self.blks2_selector_0_0, 0)) self.connect((self.dsd_chain_1, 0), (self.blks2_selector_0_0_0, 0)) self.connect((self.dsd_chain_1_0, 0), (self.blks2_selector_0_0_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.analog_pwr_squelch_xx_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.analog_pwr_squelch_xx_0_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.wxgui_fftsink2_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0_0, 0), (self.analog_pwr_squelch_xx_0_0_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0_0, 0), (self.wxgui_fftsink2_0_0_0, 0)) self.connect((self.nbfm_chain_0, 0), (self.blks2_selector_0_0, 1)) self.connect((self.nbfm_chain_1, 0), (self.blks2_selector_0_0_0, 1)) self.connect((self.nbfm_chain_1_0, 0), (self.blks2_selector_0_0_0_0, 1)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.wxgui_waterfallsink2_1, 0)) self.connect((self.wbfm_chain_0, 0), (self.blks2_selector_0_0, 2)) self.connect((self.wbfm_chain_0_0, 0), (self.blks2_selector_0_0_0, 2)) self.connect((self.wbfm_chain_0_0_0, 0), (self.blks2_selector_0_0_0_0, 2))
def __init__(self): gr.top_block.__init__(self, "OFDM PU Phy") Qt.QWidget.__init__(self) self.setWindowTitle("OFDM PU Phy") 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", "ofdm_trans") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 10e6 self.usrp_samp_rate = usrp_samp_rate = 10e6 self.taps = taps = filter.firdes.low_pass(1, samp_rate, 0.98e6, 0.5e6) self.sync_word2 = sync_word2 = [ 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 0, 0, 0, 0, 0 ] self.sync_word1 = sync_word1 = [ 0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0. ] self.pilot_symbols = pilot_symbols = (( 1, 1, 1, -1, ), ) self.pilot_carriers = pilot_carriers = (( -21, -7, 7, 21, ), ) self.packet_len = packet_len = 64 self.occupied_carriers = occupied_carriers = ( range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27), ) self.len_tag_key = len_tag_key = "packet_len" self.interp_factor = interp_factor = 5 self.fft_len = fft_len = 64 self.decim_factor = decim_factor = 1 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0_0_1_1 = filter.rational_resampler_ccc( interpolation=interp_factor, decimation=decim_factor, taps=(taps), fractional_bw=None, ) self.rational_resampler_xxx_0_0_1_0 = filter.rational_resampler_ccc( interpolation=interp_factor, decimation=decim_factor, taps=(taps), fractional_bw=None, ) self.rational_resampler_xxx_0_0_1 = filter.rational_resampler_ccc( interpolation=interp_factor, decimation=decim_factor, taps=(taps), fractional_bw=None, ) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=interp_factor, decimation=decim_factor, taps=(taps), fractional_bw=None, ) self.freq_xlating_fft_filter_ccc_0_2 = filter.freq_xlating_fft_filter_ccc( interp_factor, (filter.firdes.low_pass( 1, usrp_samp_rate, samp_rate / 2.0 * .98, 0.5e6)), -3.75e6, usrp_samp_rate) self.freq_xlating_fft_filter_ccc_0_2.set_nthreads(4) self.freq_xlating_fft_filter_ccc_0_2.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0_1 = filter.freq_xlating_fft_filter_ccc( interp_factor, (filter.firdes.low_pass( 1, usrp_samp_rate, samp_rate / 2.0 * 0.98, 0.5e6)), 3.75e6, usrp_samp_rate) self.freq_xlating_fft_filter_ccc_0_1.set_nthreads(4) self.freq_xlating_fft_filter_ccc_0_1.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0_0 = filter.freq_xlating_fft_filter_ccc( interp_factor, (filter.firdes.low_pass( 1, usrp_samp_rate, samp_rate / 2.0 * 0.98, 0.5e6)), -1.25e6, usrp_samp_rate) self.freq_xlating_fft_filter_ccc_0_0.set_nthreads(4) self.freq_xlating_fft_filter_ccc_0_0.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc( interp_factor, (filter.firdes.low_pass( 1, usrp_samp_rate, samp_rate / 2.0 * 0.98, 0.5e6)), 1.25e6, usrp_samp_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(4) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len / 4, packet_length_tag_key=len_tag_key, occupied_carriers=occupied_carriers, pilot_carriers=pilot_carriers, pilot_symbols=pilot_symbols, sync_word1=sync_word1, sync_word2=sync_word2, bps_header=1, bps_payload=2, rolloff=0, debug_log=False, scramble_bits=False) self.digital_ofdm_rx_0_2 = digital.ofdm_rx( fft_len=fft_len, cp_len=fft_len / 4, frame_length_tag_key='frame_' + "rx_len", packet_length_tag_key="rx_len", occupied_carriers=occupied_carriers, pilot_carriers=pilot_carriers, pilot_symbols=pilot_symbols, sync_word1=sync_word1, sync_word2=sync_word2, bps_header=1, bps_payload=2, debug_log=False, scramble_bits=False) self.digital_ofdm_rx_0_1 = digital.ofdm_rx( fft_len=fft_len, cp_len=fft_len / 4, frame_length_tag_key='frame_' + "rx_len", packet_length_tag_key="rx_len", occupied_carriers=occupied_carriers, pilot_carriers=pilot_carriers, pilot_symbols=pilot_symbols, sync_word1=sync_word1, sync_word2=sync_word2, bps_header=1, bps_payload=2, debug_log=False, scramble_bits=False) self.digital_ofdm_rx_0_0 = digital.ofdm_rx( fft_len=fft_len, cp_len=fft_len / 4, frame_length_tag_key='frame_' + "rx_len", packet_length_tag_key="rx_len", occupied_carriers=occupied_carriers, pilot_carriers=pilot_carriers, pilot_symbols=pilot_symbols, sync_word1=sync_word1, sync_word2=sync_word2, bps_header=1, bps_payload=2, debug_log=False, scramble_bits=False) self.digital_ofdm_rx_0 = digital.ofdm_rx( fft_len=fft_len, cp_len=fft_len / 4, frame_length_tag_key='frame_' + "rx_len", packet_length_tag_key="rx_len", occupied_carriers=occupied_carriers, pilot_carriers=pilot_carriers, pilot_symbols=pilot_symbols, sync_word1=sync_word1, sync_word2=sync_word2, bps_header=1, bps_payload=2, debug_log=False, scramble_bits=False) self.dbconnect_pktrecv_0 = dbconnect.pktrecv("127.0.0.1", 5002, False) self.dbconnect_packet_controller_0 = dbconnect.packet_controller( samp_rate / interp_factor, (10000, ), 5, 10, 2, 5, 5, 5, 6643, 60000, (10, 20, 30), (), False) self.dbconnect_cmd_pktgen_0 = dbconnect.cmd_pktgen( "127.0.0.1", 5002, 64, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_tagged_stream_to_pdu_0_2 = blocks.tagged_stream_to_pdu( blocks.byte_t, "rx_len") self.blocks_tagged_stream_to_pdu_0_1 = blocks.tagged_stream_to_pdu( blocks.byte_t, "rx_len") self.blocks_tagged_stream_to_pdu_0_0_0 = blocks.tagged_stream_to_pdu( blocks.byte_t, "rx_len") self.blocks_tagged_stream_to_pdu_0_0 = blocks.tagged_stream_to_pdu( blocks.byte_t, "rx_len") self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.complex_t, "packet_len") self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, "packet_len") self.blocks_multiply_xx_0_3 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_2 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.09, )) self.blocks_message_debug_0 = blocks.message_debug() self.blocks_add_xx_2 = blocks.add_vcc(1) self.analog_sig_source_x_0_3 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -3.75e6, 1, 0) self.analog_sig_source_x_0_2 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 3.75e6, 1, 0) self.analog_sig_source_x_0_1 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -1.25e6, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 1.25e6, 1, 0) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.dbconnect_packet_controller_0, 'in0')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0, 'pdus'), (self.dbconnect_pktrecv_0, 'in0')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0_0, 'pdus'), (self.dbconnect_pktrecv_0, 'in1')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0_1, 'pdus'), (self.dbconnect_pktrecv_0, 'in2')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0_2, 'pdus'), (self.dbconnect_pktrecv_0, 'in3')) self.msg_connect((self.dbconnect_cmd_pktgen_0, 'out0'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.dbconnect_packet_controller_0, 'cmd'), (self.blocks_message_debug_0, 'print')) self.msg_connect((self.dbconnect_packet_controller_0, 'gcmd'), (self.blocks_message_debug_0, 'print')) self.msg_connect((self.dbconnect_packet_controller_0, 'cmd'), (self.dbconnect_cmd_pktgen_0, 'cmd')) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_0_1, 0), (self.blocks_multiply_xx_0_1, 1)) self.connect((self.analog_sig_source_x_0_2, 0), (self.blocks_multiply_xx_0_2, 1)) self.connect((self.analog_sig_source_x_0_3, 0), (self.blocks_multiply_xx_0_3, 1)) self.connect((self.blocks_add_xx_2, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_2, 0)) self.connect((self.blocks_multiply_xx_0_1, 0), (self.blocks_add_xx_2, 1)) self.connect((self.blocks_multiply_xx_0_2, 0), (self.blocks_add_xx_2, 2)) self.connect((self.blocks_multiply_xx_0_3, 0), (self.blocks_add_xx_2, 3)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fft_filter_ccc_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fft_filter_ccc_0_1, 0)) self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fft_filter_ccc_0_2, 0)) self.connect((self.dbconnect_packet_controller_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.dbconnect_packet_controller_0, 1), (self.rational_resampler_xxx_0_0_1, 0)) self.connect((self.dbconnect_packet_controller_0, 2), (self.rational_resampler_xxx_0_0_1_0, 0)) self.connect((self.dbconnect_packet_controller_0, 3), (self.rational_resampler_xxx_0_0_1_1, 0)) self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_tagged_stream_to_pdu_0_0, 0)) self.connect((self.digital_ofdm_rx_0_0, 0), (self.blocks_tagged_stream_to_pdu_0_0_0, 0)) self.connect((self.digital_ofdm_rx_0_1, 0), (self.blocks_tagged_stream_to_pdu_0_1, 0)) self.connect((self.digital_ofdm_rx_0_2, 0), (self.blocks_tagged_stream_to_pdu_0_2, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.digital_ofdm_rx_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.digital_ofdm_rx_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_1, 0), (self.digital_ofdm_rx_0_1, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_2, 0), (self.digital_ofdm_rx_0_2, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.rational_resampler_xxx_0_0_1, 0), (self.blocks_multiply_xx_0_1, 0)) self.connect((self.rational_resampler_xxx_0_0_1_0, 0), (self.blocks_multiply_xx_0_2, 0)) self.connect((self.rational_resampler_xxx_0_0_1_1, 0), (self.blocks_multiply_xx_0_3, 0))
def __init__(self): gr.top_block.__init__(self, "PFB Channelizer Demo") Qt.QWidget.__init__(self) self.setWindowTitle("PFB Channelizer Demo") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "pfb_channelizer_demo") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.noaa_num_chans = noaa_num_chans = 7 self.noaa_chan_width = noaa_chan_width = int(25e3) self.noaa_band_start = noaa_band_start = 162.4e6 self.oversampled_width = oversampled_width = noaa_chan_width * (noaa_num_chans + 1) self.noaa_fm_dev = noaa_fm_dev = int(5e3) self.noaa_band_width = noaa_band_width = noaa_chan_width * noaa_num_chans self.noaa_band_center = noaa_band_center = noaa_band_start + (noaa_num_chans / 2 * noaa_chan_width) self.hardware_rate = hardware_rate = int(1e6) self.tuner_freq = tuner_freq = 162.3e6 self.target_freq = target_freq = noaa_band_center self.ppm = ppm = 0 self.pfb_taps = pfb_taps = firdes.low_pass(2.0, oversampled_width, noaa_fm_dev * 2, 2500, firdes.WIN_HAMMING, 6.76) self.lpf_taps = lpf_taps = firdes.low_pass(1.0, hardware_rate, noaa_band_width / 2, noaa_chan_width, firdes.WIN_HAMMING, 6.76) self.channel_map = channel_map = range(0, noaa_num_chans+1) self.tuner_offset = tuner_offset = target_freq - tuner_freq self.ppm_corr = ppm_corr = tuner_freq * (ppm/1e6) self.pfb_sizeof_taps = pfb_sizeof_taps = len(pfb_taps) self.noaa_band_end = noaa_band_end = noaa_band_start + (noaa_num_chans * noaa_chan_width) self.lpf_sizeof_taps = lpf_sizeof_taps = len(lpf_taps) self.fftwidth = fftwidth = 512 self.fft_interval = fft_interval = 1.0/20 self.decimation = decimation = hardware_rate / oversampled_width self.channel_names = channel_names = map(lambda x: "%.3fMHz" % (162.4 + (x*0.025)), channel_map) self.chan_num = chan_num = channel_map[0] ################################################## # Blocks ################################################## self._chan_num_options = channel_map self._chan_num_labels = channel_names self._chan_num_tool_bar = Qt.QToolBar(self) self._chan_num_tool_bar.addWidget(Qt.QLabel("Channel"+": ")) self._chan_num_combo_box = Qt.QComboBox() self._chan_num_tool_bar.addWidget(self._chan_num_combo_box) for label in self._chan_num_labels: self._chan_num_combo_box.addItem(label) self._chan_num_callback = lambda i: Qt.QMetaObject.invokeMethod(self._chan_num_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._chan_num_options.index(i))) self._chan_num_callback(self.chan_num) self._chan_num_combo_box.currentIndexChanged.connect( lambda i: self.set_chan_num(self._chan_num_options[i])) self.top_grid_layout.addWidget(self._chan_num_tool_bar, 0,0,1,2) self.qtgui_waterfall_sink_x_0_0_0 = qtgui.waterfall_sink_c( fftwidth, #size firdes.WIN_BLACKMAN_hARRIS, #wintype target_freq, #fc oversampled_width, #bw "Band Monitor", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0_0_0.set_update_time(fft_interval) self.qtgui_waterfall_sink_x_0_0_0.enable_grid(True) if not True: self.qtgui_waterfall_sink_x_0_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0_0_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [5, 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_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0_0_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0_0_0.set_intensity_range(-80, -35) self._qtgui_waterfall_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_0_0_win, 1,0,1,2) self.qtgui_waterfall_sink_x_0_0 = qtgui.waterfall_sink_c( fftwidth, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc noaa_chan_width, #bw "Channel Monitor", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0_0.set_update_time(fft_interval) self.qtgui_waterfall_sink_x_0_0.enable_grid(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 = [5, 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(-67, -37) 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, 1,2,1,2) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( fftwidth, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc noaa_chan_width, #bw "Channelizer Output", #name noaa_num_chans +1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(fft_interval) self.qtgui_freq_sink_x_0.set_y_axis(-80, -35) 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.1) 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 = [channel_names[0], channel_names[1], channel_names[2], channel_names[3], channel_names[4], channel_names[5], channel_names[6], channel_names[7], "", ""] 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(noaa_num_chans +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, 2,0,1,4) self._ppm_range = Range(-20, 20, 0.5, 0, 100) self._ppm_win = RangeWidget(self._ppm_range, self.set_ppm, "ppm", "counter_slider", float) self.top_grid_layout.addWidget(self._ppm_win, 0,2,1,2) self.pfb_channelizer_ccf_0 = pfb.channelizer_ccf( noaa_num_chans+1, (pfb_taps), 1, 100) self.pfb_channelizer_ccf_0.set_channel_map((channel_map)) self.pfb_channelizer_ccf_0.declare_sample_delay(0) self.osmosdr_source_0_0 = osmosdr.source( args="numchan=" + str(1) + " " + "type=usrp2" ) self.osmosdr_source_0_0.set_sample_rate(hardware_rate) self.osmosdr_source_0_0.set_center_freq(tuner_freq, 0) self.osmosdr_source_0_0.set_freq_corr(0, 0) self.osmosdr_source_0_0.set_dc_offset_mode(2, 0) self.osmosdr_source_0_0.set_iq_balance_mode(2, 0) self.osmosdr_source_0_0.set_gain_mode(True, 0) self.osmosdr_source_0_0.set_gain(10, 0) self.osmosdr_source_0_0.set_if_gain(20, 0) self.osmosdr_source_0_0.set_bb_gain(20, 0) self.osmosdr_source_0_0.set_antenna("TX/RX", 0) self.osmosdr_source_0_0.set_bandwidth(0, 0) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc(int(decimation), (lpf_taps), tuner_offset + ppm_corr, hardware_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) self.blocks_multiply_const_vxx_0_5_0 = blocks.multiply_const_vcc((1, )) self.blocks_multiply_const_vxx_0_5 = blocks.multiply_const_vcc((1 if chan_num is 6 else 0, )) self.blocks_multiply_const_vxx_0_4 = blocks.multiply_const_vcc((1 if chan_num is 5 else 0, )) self.blocks_multiply_const_vxx_0_3 = blocks.multiply_const_vcc((1 if chan_num is 4 else 0, )) self.blocks_multiply_const_vxx_0_2 = blocks.multiply_const_vcc((1 if chan_num is 3 else 0, )) self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_vcc((1 if chan_num is 2 else 0, )) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((1 if chan_num is 1 else 0, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((1 if chan_num is 0 else 0, )) self.blocks_add_xx_0 = blocks.add_vcc(1) self.audio_sink_0 = audio.sink(24000, "", True) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=noaa_chan_width, quad_rate=noaa_chan_width, tau=75e-6, max_dev=noaa_fm_dev, ) (self.analog_nbfm_rx_0).set_max_output_buffer(512) ################################################## # Connections ################################################## self.connect((self.analog_nbfm_rx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.analog_nbfm_rx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_waterfall_sink_x_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_0_1, 0), (self.blocks_add_xx_0, 2)) self.connect((self.blocks_multiply_const_vxx_0_2, 0), (self.blocks_add_xx_0, 3)) self.connect((self.blocks_multiply_const_vxx_0_3, 0), (self.blocks_add_xx_0, 4)) self.connect((self.blocks_multiply_const_vxx_0_4, 0), (self.blocks_add_xx_0, 5)) self.connect((self.blocks_multiply_const_vxx_0_5, 0), (self.blocks_add_xx_0, 6)) self.connect((self.blocks_multiply_const_vxx_0_5_0, 0), (self.blocks_add_xx_0, 7)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.pfb_channelizer_ccf_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.qtgui_waterfall_sink_x_0_0_0, 0)) self.connect((self.osmosdr_source_0_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 1), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 2), (self.blocks_multiply_const_vxx_0_1, 0)) self.connect((self.pfb_channelizer_ccf_0, 3), (self.blocks_multiply_const_vxx_0_2, 0)) self.connect((self.pfb_channelizer_ccf_0, 4), (self.blocks_multiply_const_vxx_0_3, 0)) self.connect((self.pfb_channelizer_ccf_0, 5), (self.blocks_multiply_const_vxx_0_4, 0)) self.connect((self.pfb_channelizer_ccf_0, 6), (self.blocks_multiply_const_vxx_0_5, 0)) self.connect((self.pfb_channelizer_ccf_0, 7), (self.blocks_multiply_const_vxx_0_5_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.pfb_channelizer_ccf_0, 1), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.pfb_channelizer_ccf_0, 2), (self.qtgui_freq_sink_x_0, 2)) self.connect((self.pfb_channelizer_ccf_0, 3), (self.qtgui_freq_sink_x_0, 3)) self.connect((self.pfb_channelizer_ccf_0, 4), (self.qtgui_freq_sink_x_0, 4)) self.connect((self.pfb_channelizer_ccf_0, 5), (self.qtgui_freq_sink_x_0, 5)) self.connect((self.pfb_channelizer_ccf_0, 6), (self.qtgui_freq_sink_x_0, 6)) self.connect((self.pfb_channelizer_ccf_0, 7), (self.qtgui_freq_sink_x_0, 7))
def __init__(self, freq=394e6, gain=0, sample_rate=2400000, args="", channel_bw=12500, listen_port=60100, ppm=0, output="channel%d.bits", output_offset=None, auto_tune=-1): gr.top_block.__init__(self, "TETRAPOL multichannel reciever") ################################################## # Parameters and variables ################################################## self.freq = freq self.gain = gain self.sample_rate = sample_rate self.args = args self.channel_bw = channel_bw self.listen_port = listen_port self.ppm = ppm self.output = output self.auto_tune = auto_tune # TODO: parametrize self.debug = True self.channels = channels = int(sample_rate/channel_bw) channel_symb_rate = 8000 samples_per_symbol = 2 self.channel_samp_rate = channel_samp_rate = \ channel_symb_rate * samples_per_symbol afc_period = 6 self.afc_gain = 1 self.afc_ppm_threshold = 100 if output_offset is None: self.output_offset = 0 else: self.output_offset = output_offset - ((channels - 1) // 2) ################################################## # Blocks - RPC server ################################################## self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer( ("localhost", listen_port), allow_none=True) self.xmlrpc_server_0.register_instance(self) threading.Thread(target=self.xmlrpc_server_0.serve_forever).start() ################################################## # Blocks - RX, demod, sink ################################################## self.src = osmosdr.source( args="numchan=" + str(1) + " " + "" + self.args ) self.src.set_sample_rate(sample_rate) self.src.set_center_freq(freq, 0) self.src.set_freq_corr(ppm, 0) # TODO: manual gain control self.src.set_gain_mode(True, 0) #self.src.set_gain(gain, 0) self.freq_xlating = freq_xlating_fft_filter_ccc(1, (1, ), 0, sample_rate) bw = (9200 + self.afc_ppm_threshold)/2 self.channelizer = pfb.channelizer_ccf( channels, firdes.low_pass(1, sample_rate, bw, bw*0.15, firdes.WIN_HANN), float(channel_samp_rate)/(sample_rate/channels), 100) self.connect( (self.src, 0), (self.freq_xlating, 0), (self.channelizer, 0)) self.valves = [] self.gmsk_demods = [] self.file_sinks = [] even_no_of_chs = not (channels % 2) center_ch = channels // 2 for ch_in in range(0, channels): ch_out = (ch_in + center_ch + 1) % channels if ch_out == center_ch and even_no_of_chs: null_sink = blocks.null_sink(gr.sizeof_gr_complex) self.connect( (self.channelizer, ch_out), (null_sink, 0)) continue valve = grc_blks2.valve(item_size=gr.sizeof_gr_complex, open=True) gmsk_demod = digital.gmsk_demod( samples_per_symbol=samples_per_symbol, gain_mu=0.050, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) o = output % (ch_in + self.output_offset) file_sink = blocks.file_sink(gr.sizeof_char, o, False) file_sink.set_unbuffered(True) self.connect( (self.channelizer, ch_out), (valve, 0), (gmsk_demod, 0), (file_sink, 0)) self.valves.append(valve) self.gmsk_demods.append(gmsk_demod) self.file_sinks.append(file_sink) ################################################## # Blocks - automatic fine tune ################################################## self.afc_selector = grc_blks2.selector( item_size=gr.sizeof_gr_complex*1, num_inputs=channels - even_no_of_chs, num_outputs=1, input_index=0, output_index=0, ) if auto_tune != -1: self.afc_selector.set_input_index(auto_tune) self.afc_demod = analog.quadrature_demod_cf(channel_samp_rate/(2*math.pi)) afc_samp = channel_samp_rate * afc_period / 2 self.afc_avg = blocks.moving_average_ff(afc_samp, 1./afc_samp*self.afc_gain) self.afc_probe = blocks.probe_signal_f() def _afc_probe(): while True: time.sleep(afc_period) if self.auto_tune == -1: continue err = self.afc_probe.level() if abs(err) < self.afc_ppm_threshold: continue freq = self.freq_xlating.center_freq + err * self.afc_gain if self.debug: print "freq err: % .0f\tfreq: %f" % (err, freq) self.freq_xlating.set_center_freq(freq) self._afc_err_thread = threading.Thread(target=_afc_probe) self._afc_err_thread.daemon = True self._afc_err_thread.start() for ch_in in range(0, channels - even_no_of_chs): ch_out = (ch_in + center_ch + 1) % channels self.connect((self.channelizer, ch_out), (self.afc_selector, ch_in)) self.connect((self.afc_selector, 0), (self.afc_demod, 0), (self.afc_avg, 0), (self.afc_probe, 0)) ################################################## # Blocks - signal strenght indication ################################################## self.pwr_probes = [] for ch in range(self.channels - even_no_of_chs): ch = (ch + center_ch + 1) % channels pwr_probe = analog.probe_avg_mag_sqrd_c(0, 1./channel_samp_rate) self.connect((self.channelizer, ch), (pwr_probe, 0)) self.pwr_probes.append(pwr_probe)
def __init__(self): gr.top_block.__init__(self, "OFDM RX Phy") Qt.QWidget.__init__(self) self.setWindowTitle("OFDM RX Phy") 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", "rx_ofdm") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.usrp_samp_rate = usrp_samp_rate = 10e6 self.sync_word2 = sync_word2 = [ 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 0, 0, 0, 0, 0 ] self.sync_word1 = sync_word1 = [ 0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0. ] self.samp_rate = samp_rate = 2.5e6 self.pilot_symbols = pilot_symbols = (( 1, 1, 1, -1, ), ) self.pilot_carriers = pilot_carriers = (( -21, -7, 7, 21, ), ) self.packet_len = packet_len = 64 self.occupied_carriers = occupied_carriers = ( range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27), ) self.fft_len = fft_len = 64 self.decim_factor = decim_factor = 5 ################################################## # Blocks ################################################## self.uhd_usrp_source_1 = uhd.usrp_source( ",".join(("addr=192.168.20.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_1.set_samp_rate(usrp_samp_rate) self.uhd_usrp_source_1.set_center_freq(1255e6, 0) self.uhd_usrp_source_1.set_gain(5, 0) self.uhd_usrp_source_1.set_antenna("RX2", 0) self.freq_xlating_fft_filter_ccc_0_2 = filter.freq_xlating_fft_filter_ccc( decim_factor, (filter.firdes.low_pass( 1, usrp_samp_rate, samp_rate / 2.0 * 0.98, 5000)), -3.75e6, usrp_samp_rate) self.freq_xlating_fft_filter_ccc_0_2.set_nthreads(4) self.freq_xlating_fft_filter_ccc_0_2.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0_1 = filter.freq_xlating_fft_filter_ccc( decim_factor, (filter.firdes.low_pass( 1, usrp_samp_rate, samp_rate / 2.0 * 0.98, 5000)), 3.75e6, usrp_samp_rate) self.freq_xlating_fft_filter_ccc_0_1.set_nthreads(4) self.freq_xlating_fft_filter_ccc_0_1.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0_0 = filter.freq_xlating_fft_filter_ccc( decim_factor, (filter.firdes.low_pass( 1, usrp_samp_rate, samp_rate / 2.0 * 0.98, 5000)), -1.25e6, usrp_samp_rate) self.freq_xlating_fft_filter_ccc_0_0.set_nthreads(4) self.freq_xlating_fft_filter_ccc_0_0.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc( decim_factor, (filter.firdes.low_pass( 1, usrp_samp_rate, samp_rate / 2.0 * 0.98, 5000)), 1.25e6, usrp_samp_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(4) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) self.digital_ofdm_rx_0_2 = digital.ofdm_rx( fft_len=fft_len, cp_len=fft_len / 4, frame_length_tag_key='frame_' + "rx_len", packet_length_tag_key="rx_len", occupied_carriers=occupied_carriers, pilot_carriers=pilot_carriers, pilot_symbols=pilot_symbols, sync_word1=sync_word1, sync_word2=sync_word2, bps_header=1, bps_payload=2, debug_log=False, scramble_bits=False) self.digital_ofdm_rx_0_1 = digital.ofdm_rx( fft_len=fft_len, cp_len=fft_len / 4, frame_length_tag_key='frame_' + "rx_len", packet_length_tag_key="rx_len", occupied_carriers=occupied_carriers, pilot_carriers=pilot_carriers, pilot_symbols=pilot_symbols, sync_word1=sync_word1, sync_word2=sync_word2, bps_header=1, bps_payload=2, debug_log=False, scramble_bits=False) self.digital_ofdm_rx_0_0 = digital.ofdm_rx( fft_len=fft_len, cp_len=fft_len / 4, frame_length_tag_key='frame_' + "rx_len", packet_length_tag_key="rx_len", occupied_carriers=occupied_carriers, pilot_carriers=pilot_carriers, pilot_symbols=pilot_symbols, sync_word1=sync_word1, sync_word2=sync_word2, bps_header=1, bps_payload=2, debug_log=False, scramble_bits=False) self.digital_ofdm_rx_0 = digital.ofdm_rx( fft_len=fft_len, cp_len=fft_len / 4, frame_length_tag_key='frame_' + "rx_len", packet_length_tag_key="rx_len", occupied_carriers=occupied_carriers, pilot_carriers=pilot_carriers, pilot_symbols=pilot_symbols, sync_word1=sync_word1, sync_word2=sync_word2, bps_header=1, bps_payload=2, debug_log=False, scramble_bits=False) self.dbconnect_pktrecv_0 = dbconnect.pktrecv("127.0.0.1", 5002, False) self.blocks_tagged_stream_to_pdu_0_2 = blocks.tagged_stream_to_pdu( blocks.byte_t, "rx_len") self.blocks_tagged_stream_to_pdu_0_1 = blocks.tagged_stream_to_pdu( blocks.byte_t, "rx_len") self.blocks_tagged_stream_to_pdu_0_0 = blocks.tagged_stream_to_pdu( blocks.byte_t, "rx_len") self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.byte_t, "rx_len") ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.dbconnect_pktrecv_0, 'in0')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0, 'pdus'), (self.dbconnect_pktrecv_0, 'in1')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0_1, 'pdus'), (self.dbconnect_pktrecv_0, 'in2')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0_2, 'pdus'), (self.dbconnect_pktrecv_0, 'in3')) self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.digital_ofdm_rx_0_0, 0), (self.blocks_tagged_stream_to_pdu_0_0, 0)) self.connect((self.digital_ofdm_rx_0_1, 0), (self.blocks_tagged_stream_to_pdu_0_1, 0)) self.connect((self.digital_ofdm_rx_0_2, 0), (self.blocks_tagged_stream_to_pdu_0_2, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.digital_ofdm_rx_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.digital_ofdm_rx_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_1, 0), (self.digital_ofdm_rx_0_1, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_2, 0), (self.digital_ofdm_rx_0_2, 0)) self.connect((self.uhd_usrp_source_1, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.uhd_usrp_source_1, 0), (self.freq_xlating_fft_filter_ccc_0_0, 0)) self.connect((self.uhd_usrp_source_1, 0), (self.freq_xlating_fft_filter_ccc_0_1, 0)) self.connect((self.uhd_usrp_source_1, 0), (self.freq_xlating_fft_filter_ccc_0_2, 0))
def __init__(self, seq1, seq2, factor, alpha, freqs, debug_onoff, debug_port, prefix): """ Description: frequency timing estimator class does frequency/timing acquisition from scratch.It uses a bank of parallel correlators at each specified frequency. It then takes the max abs value of all these and passes it through a peak detector to find timing. Args: seq1: sequence1 of kronecker filter, which is the given training sequence. seq2: sequence2 of kronecker filter, which is the pulse for each training symbol. factor: the rise and fall factors in peak detector, which is the factor determining when a peak has started and ended. In the peak detector, an average of the signal is calculated. When the value of the signal goes over factor*average, we start looking for a peak. When the value of the signal goes below factor*average, we stop looking for a peak. alpha: the smoothing factor of a moving average filter used in the peak detector taking values in (0,1). freqs: the vector of normalized center frequencies for each matched filter. Note that for a training sequence of length Nt, each matched filter can recover a sequence with normalized frequency offset ~ 1/(2Nt). """ gr.hier_block2.__init__(self, "freq_timing_estimator", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signaturev(3, 3, [gr.sizeof_char*1, gr.sizeof_float*1, gr.sizeof_float*1]), ) ################################################## # Parameters ################################################## self.seq1 = seq1 self.seq2 = seq2 self.factor = factor self.alpha = alpha self.freqs = freqs self.n = n = len(freqs) self.on = 1 self.debug_onoff = debug_onoff # 1: dump ports info to file 0: no debug output self.debug_port = debug_port # 0-n_filt-1 is the output of each filter branck; n_filter is the output of maximum self.prefix = prefix ################################################## # Blocks ################################################## self._filter=[0]*self.n self._c2mag2=[0]*self.n for i in range(self.n): #self._filter[i]= cdma.kronecker_filter(seq1,seq2,1,self.freqs[i]) #self._filter[i]= filter.freq_xlating_fir_filter_ccc(1, numpy.kron(seq1,seq2), self.freqs[i], 1) self._filter[i]= filter.freq_xlating_fft_filter_ccc(1, numpy.kron(seq1,seq2), self.freqs[i], 1) self._c2mag2[i] = blocks.complex_to_mag_squared(1) self.blocks_max = blocks.max_ff(1) self.blocks_peak_detector = cdma.switched_peak_detector_fb(self.factor, self.factor, 0, self.alpha, self.on) self.blocks_argmax = blocks.argmax_fs(1) self.blocks_null_sink = blocks.null_sink(gr.sizeof_short*1) self.digital_chunks_to_symbols = digital.chunks_to_symbols_sf((freqs), 1) self.blocks_sample_and_hold = blocks.sample_and_hold_ff() if self.debug_onoff == True: num_of_file_sinks = len(self.debug_port) self._filesink = [0]*num_of_file_sinks for i in range(num_of_file_sinks): if self.debug_port[i] == self.n: filename = prefix+"max.dat" else: filename = prefix+"filter"+str(i)+".dat" print filename self._filesink[i] = blocks.file_sink(gr.sizeof_float*1, filename, False) self._filesink[i].set_unbuffered(False) # this is the block for bundling the outputs of each branch of filters and the input of peak detector ################################################## # Connections ################################################## for i in range(self.n): self.connect((self, 0), (self._filter[i], 0)) self.connect((self._filter[i], 0), (self._c2mag2[i], 0)) self.connect((self._c2mag2[i], 0), (self.blocks_max, i)) self.connect((self._c2mag2[i], 0), (self.blocks_argmax, i)) self.connect((self.blocks_max, 0), (self.blocks_peak_detector, 0)) self.connect((self.blocks_peak_detector, 0), (self, 0)) self.connect((self.blocks_argmax, 0), (self.blocks_null_sink, 0)) self.connect((self.blocks_argmax, 1), (self.digital_chunks_to_symbols, 0)) self.connect((self.digital_chunks_to_symbols, 0), (self.blocks_sample_and_hold, 0)) self.connect((self.blocks_peak_detector, 0), (self.blocks_sample_and_hold, 1)) self.connect((self.blocks_sample_and_hold, 0), (self, 1)) self.connect((self.blocks_max, 0), (self, 2)) if self.debug_onoff == True: for i in range(num_of_file_sinks): port_index = self.debug_port[i] if port_index == self.n: self.connect((self.blocks_max, 0), (self._filesink[i], 0)) else: self.connect((self._c2mag2[port_index], 0), (self._filesink[i], 0))
def __init__(self): gr.top_block.__init__(self, "WBFM 2 Channel") Qt.QWidget.__init__(self) self.setWindowTitle("WBFM 2 Channel") 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", "wbfm_2ch") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.radio_freq = radio_freq = 100 self.samp_rate = samp_rate = 240e4 self.rf_gain = rf_gain = 10 self.freq = freq = radio_freq * 1000000 self.ch2volume = ch2volume = 5 self.ch2squelch = ch2squelch = -30 self.ch2mute = ch2mute = 1 self.ch2freq = ch2freq = radio_freq self.ch1volume = ch1volume = 5 self.ch1squelch = ch1squelch = -30 self.ch1mute = ch1mute = 1 self.ch1freq = ch1freq = radio_freq ################################################## # Blocks ################################################## self.ch2 = Qt.QTabWidget() self.ch2_widget_0 = Qt.QWidget() self.ch2_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.ch2_widget_0) self.ch2_grid_layout_0 = Qt.QGridLayout() self.ch2_layout_0.addLayout(self.ch2_grid_layout_0) self.ch2.addTab(self.ch2_widget_0, "Ch 2") self.top_grid_layout.addWidget(self.ch2, 2,1,1,1) self.ch1 = Qt.QTabWidget() self.ch1_widget_0 = Qt.QWidget() self.ch1_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.ch1_widget_0) self.ch1_grid_layout_0 = Qt.QGridLayout() self.ch1_layout_0.addLayout(self.ch1_grid_layout_0) self.ch1.addTab(self.ch1_widget_0, "Ch 1") self.top_grid_layout.addWidget(self.ch1, 2,0,1,1) self._rf_gain_range = Range(0, 50, 1, 10, 200) self._rf_gain_win = RangeWidget(self._rf_gain_range, self.set_rf_gain, "RF Gain", "counter_slider", float) self.top_grid_layout.addWidget(self._rf_gain_win, 1,0,1,2) self._ch2volume_range = Range(0, 10, 1, 5, 200) self._ch2volume_win = RangeWidget(self._ch2volume_range, self.set_ch2volume, "Ch2 Volume", "counter_slider", float) self.ch2_grid_layout_0.addWidget(self._ch2volume_win, 1,0,1,2) self._ch2squelch_range = Range(-70, 0, 10, -30, 200) self._ch2squelch_win = RangeWidget(self._ch2squelch_range, self.set_ch2squelch, "Ch2 Squelch", "counter_slider", int) self.ch2_grid_layout_0.addWidget(self._ch2squelch_win, 2,0,1,2) _ch2mute_check_box = Qt.QCheckBox("Mute") self._ch2mute_choices = {True: 0, False: 1} self._ch2mute_choices_inv = dict((v,k) for k,v in self._ch2mute_choices.iteritems()) self._ch2mute_callback = lambda i: Qt.QMetaObject.invokeMethod(_ch2mute_check_box, "setChecked", Qt.Q_ARG("bool", self._ch2mute_choices_inv[i])) self._ch2mute_callback(self.ch2mute) _ch2mute_check_box.stateChanged.connect(lambda i: self.set_ch2mute(self._ch2mute_choices[bool(i)])) self.ch2_grid_layout_0.addWidget(_ch2mute_check_box, 0,1,1,1) self._ch2freq_tool_bar = Qt.QToolBar(self) self._ch2freq_tool_bar.addWidget(Qt.QLabel("Ch2 Freq"+": ")) self._ch2freq_line_edit = Qt.QLineEdit(str(self.ch2freq)) self._ch2freq_tool_bar.addWidget(self._ch2freq_line_edit) self._ch2freq_line_edit.returnPressed.connect( lambda: self.set_ch2freq(eng_notation.str_to_num(str(self._ch2freq_line_edit.text().toAscii())))) self.ch2_grid_layout_0.addWidget(self._ch2freq_tool_bar, 0,0,1,1) self._ch1volume_range = Range(0, 10, 1, 5, 200) self._ch1volume_win = RangeWidget(self._ch1volume_range, self.set_ch1volume, "Ch1 Volume", "counter_slider", float) self.ch1_grid_layout_0.addWidget(self._ch1volume_win, 1,0,1,2) self._ch1squelch_range = Range(-70, 0, 10, -30, 200) self._ch1squelch_win = RangeWidget(self._ch1squelch_range, self.set_ch1squelch, "Ch1 Squelch", "counter_slider", int) self.ch1_grid_layout_0.addWidget(self._ch1squelch_win, 2,0,1,2) _ch1mute_check_box = Qt.QCheckBox("Mute") self._ch1mute_choices = {True: 0, False: 1} self._ch1mute_choices_inv = dict((v,k) for k,v in self._ch1mute_choices.iteritems()) self._ch1mute_callback = lambda i: Qt.QMetaObject.invokeMethod(_ch1mute_check_box, "setChecked", Qt.Q_ARG("bool", self._ch1mute_choices_inv[i])) self._ch1mute_callback(self.ch1mute) _ch1mute_check_box.stateChanged.connect(lambda i: self.set_ch1mute(self._ch1mute_choices[bool(i)])) self.ch1_grid_layout_0.addWidget(_ch1mute_check_box, 0,1,1,1) self._ch1freq_tool_bar = Qt.QToolBar(self) self._ch1freq_tool_bar.addWidget(Qt.QLabel("Ch1 Freq"+": ")) self._ch1freq_line_edit = Qt.QLineEdit(str(self.ch1freq)) self._ch1freq_tool_bar.addWidget(self._ch1freq_line_edit) self._ch1freq_line_edit.returnPressed.connect( lambda: self.set_ch1freq(eng_notation.str_to_num(str(self._ch1freq_line_edit.text().toAscii())))) self.ch1_grid_layout_0.addWidget(self._ch1freq_tool_bar, 0,0,1,1) 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(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(rf_gain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.rational_resampler_xxx_2_0 = filter.rational_resampler_ccc( interpolation=400000, decimation=2400000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_2 = filter.rational_resampler_ccc( interpolation=400000, decimation=2400000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_1_0 = filter.rational_resampler_fff( interpolation=48, decimation=50, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_1 = filter.rational_resampler_fff( interpolation=48, decimation=50, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=500000, decimation=2400000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=500000, decimation=2400000, taps=None, fractional_bw=None, ) self._radio_freq_tool_bar = Qt.QToolBar(self) self._radio_freq_tool_bar.addWidget(Qt.QLabel("Frequency (MHz)"+": ")) self._radio_freq_line_edit = Qt.QLineEdit(str(self.radio_freq)) self._radio_freq_tool_bar.addWidget(self._radio_freq_line_edit) self._radio_freq_line_edit.returnPressed.connect( lambda: self.set_radio_freq(eng_notation.str_to_num(str(self._radio_freq_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._radio_freq_tool_bar, 0,0,1,2) 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) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if complex == type(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(-100, 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, 3,0,1,2) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype ch2freq, #fc 400000, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-100, 10) 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_control_panel(False) if not False: self.qtgui_freq_sink_x_0_0.disable_legend() if complex == type(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(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.ch2_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_0_win, 3,0,1,2) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype ch1freq, #fc 400000, #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(-100, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() 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.ch1_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 3,0,1,2) self.low_pass_filter_0_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, 500000, 100e3, 8000, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, 500000, 100e3, 8000, firdes.WIN_HAMMING, 6.76)) self.freq_xlating_fft_filter_ccc_0_0 = filter.freq_xlating_fft_filter_ccc(1, (firdes.low_pass(1,samp_rate,200000,10000)), (ch2freq * 1000000) - freq, samp_rate) self.freq_xlating_fft_filter_ccc_0_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0_0.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc(1, (firdes.low_pass(1,samp_rate,200000,10000)), (ch1freq * 1000000) - freq, samp_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff((ch2mute, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((ch1mute, )) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((ch2volume, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((ch1volume, )) self.audio_sink_0_0 = audio.sink(48000, "", True) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_wfm_rcv_0_0 = analog.wfm_rcv( quad_rate=500000, audio_decimation=10, ) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=500000, audio_decimation=10, ) self.analog_pwr_squelch_xx_0_0 = analog.pwr_squelch_cc(ch2squelch, 1e-4, 0, True) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(ch1squelch, 1e-4, 0, True) ################################################## # Connections ################################################## self.connect((self.analog_pwr_squelch_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.analog_pwr_squelch_xx_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.analog_wfm_rcv_0_0, 0), (self.rational_resampler_xxx_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.audio_sink_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.rational_resampler_xxx_2, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.analog_pwr_squelch_xx_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.rational_resampler_xxx_2_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.analog_wfm_rcv_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.rational_resampler_xxx_1_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.rational_resampler_xxx_2, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_2_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self, seq1, seq2, factor, alpha, freqs): """ Description: frequency timing estimator class does frequency/timing acquisition from scratch.It uses a bank of parallel correlators at each specified frequency. It then takes the max abs value of all these and passes it through a peak detector to find timing. Args: seq1: sequence1 of kronecker filter, which is the given training sequence. seq2: sequence2 of kronecker filter, which is the pulse for each training symbol. factor: the rise and fall factors in peak detector, which is the factor determining when a peak has started and ended. In the peak detector, an average of the signal is calculated. When the value of the signal goes over factor*average, we start looking for a peak. When the value of the signal goes below factor*average, we stop looking for a peak. alpha: the smoothing factor of a moving average filter used in the peak detector taking values in (0,1). freqs: the vector of normalized center frequencies for each matched filter. Note that for a training sequence of length Nt, each matched filter can recover a sequence with normalized frequency offset ~ 1/(2Nt). """ gr.hier_block2.__init__( self, "freq_timing_estimator", gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), gr.io_signaturev( 3, 3, [gr.sizeof_char * 1, gr.sizeof_float * 1, gr.sizeof_float * 1 ]), ) ################################################## # Parameters ################################################## self.seq1 = seq1 self.seq2 = seq2 self.factor = factor self.alpha = alpha self.freqs = freqs self.n = n = len(freqs) self.on = 1 ################################################## # Blocks ################################################## self._filter = [0] * self.n self._c2mag2 = [0] * self.n for i in range(self.n): #self._filter[i]= cdma.kronecker_filter(seq1,seq2,1,self.freqs[i]) #self._filter[i]= filter.freq_xlating_fir_filter_ccc(1, numpy.kron(seq1,seq2), self.freqs[i], 1) self._filter[i] = filter.freq_xlating_fft_filter_ccc( 1, numpy.kron(seq1, seq2), self.freqs[i], 1) self._c2mag2[i] = blocks.complex_to_mag_squared(1) self.blocks_max = blocks.max_ff(1) self.blocks_peak_detector = cdma.switched_peak_detector_fb( self.factor, self.factor, 0, self.alpha, self.on) self.blocks_argmax = blocks.argmax_fs(1) self.blocks_null_sink = blocks.null_sink(gr.sizeof_short * 1) self.digital_chunks_to_symbols = digital.chunks_to_symbols_sf((freqs), 1) self.blocks_sample_and_hold = blocks.sample_and_hold_ff() ################################################## # Connections ################################################## for i in range(self.n): self.connect((self, 0), (self._filter[i], 0)) self.connect((self._filter[i], 0), (self._c2mag2[i], 0)) self.connect((self._c2mag2[i], 0), (self.blocks_max, i)) self.connect((self._c2mag2[i], 0), (self.blocks_argmax, i)) self.connect((self.blocks_max, 0), (self.blocks_peak_detector, 0)) self.connect((self.blocks_peak_detector, 0), (self, 0)) self.connect((self.blocks_argmax, 0), (self.blocks_null_sink, 0)) self.connect((self.blocks_argmax, 1), (self.digital_chunks_to_symbols, 0)) self.connect((self.digital_chunks_to_symbols, 0), (self.blocks_sample_and_hold, 0)) self.connect((self.blocks_peak_detector, 0), (self.blocks_sample_and_hold, 1)) self.connect((self.blocks_sample_and_hold, 0), (self, 1)) self.connect((self.blocks_max, 0), (self, 2))
def __init__(self): gr.top_block.__init__(self, "Tetra Rx Multi") options = self.get_options() ################################################## # Variables ################################################## self.srate_rx = srate_rx = options.sample_rate self.channels = srate_rx / 25000 self.srate_channel = 36000 self.afc_period = 5 self.afc_gain = 1. self.afc_channel = options.auto_tune or -1 self.afc_ppm_step = 100 self.debug = options.debug self.last_pwr = -100000 self.sig_det_period = 1 self.sig_det_bw = sig_det_bw = options.sig_detection_bw or srate_rx if self.sig_det_bw <= 1.: self.sig_det_bw *= srate_rx self.sig_det_threshold = options.sig_detection_threshold self.sig_det_channels = [] for ch in range(self.channels): if ch >= self.channels / 2: ch_ = (self.channels - ch - 1) else: ch_ = ch if (float(ch_) / self.channels * 2) <= (self.sig_det_bw / srate_rx): self.sig_det_channels.append(ch) ################################################## # RPC server ################################################## self.xmlrpc_server = SimpleXMLRPCServer.SimpleXMLRPCServer( ("localhost", options.listen_port), allow_none=True) self.xmlrpc_server.register_instance(self) threading.Thread(target=self.xmlrpc_server.serve_forever).start() ################################################## # Rx Blocks and connections ################################################## self.src = osmosdr.source( args=options.args ) self.src.set_sample_rate(srate_rx) self.src.set_center_freq(options.frequency, 0) self.src.set_freq_corr(options.ppm, 0) self.src.set_dc_offset_mode(0, 0) self.src.set_iq_balance_mode(0, 0) if options.gain is not None: self.src.set_gain_mode(False, 0) self.src.set_gain(36, 0) else: self.src.set_gain_mode(True, 0) out_type, dst_path = options.output.split("://", 1) if out_type == "udp": dst_ip, dst_port = dst_path.split(':', 1) self.freq_xlating = freq_xlating_fft_filter_ccc(1, (1, ), 0, srate_rx) self.channelizer = pfb.channelizer_ccf( self.channels, (firdes.root_raised_cosine(1, srate_rx, 18000, 0.35, 1024)), 36./25., 100) self.squelch = [] self.digital_mpsk_receiver_cc = [] self.diff_phasor = [] self.complex_to_arg = [] self.multiply_const = [] self.add_const = [] self.float_to_uchar = [] self.map_bits = [] self.unpack_k_bits = [] self.blocks_sink = [] for ch in range(0, self.channels): squelch = analog.pwr_squelch_cc(0, 0.001, 0, True) mpsk = digital.mpsk_receiver_cc( 4, math.pi/4, math.pi/100.0, -0.5, 0.5, 0.25, 0.001, 2, 0.001, 0.001) diff_phasor = digital.diff_phasor_cc() complex_to_arg = blocks.complex_to_arg(1) multiply_const = blocks.multiply_const_vff((2./math.pi, )) add_const = blocks.add_const_vff((1.5, )) float_to_uchar = blocks.float_to_uchar() map_bits = digital.map_bb(([3, 2, 0, 1, 3])) unpack_k_bits = blocks.unpack_k_bits_bb(2) if out_type == 'udp': sink = blocks.udp_sink(gr.sizeof_gr_char, dst_ip, int(dst_port)+ch, 1472, True) elif out_type == 'file': sink = blocks.file_sink(gr.sizeof_char, dst_path % ch, False) sink.set_unbuffered(True) else: raise ValueError("Invalid output URL '%s'" % options.output) self.connect((self.channelizer, ch), (squelch, 0), (mpsk, 0), (diff_phasor, 0), (complex_to_arg, 0), (multiply_const, 0), (add_const, 0), (float_to_uchar, 0), (map_bits, 0), (unpack_k_bits, 0), (sink, 0)) self.squelch.append(squelch) self.digital_mpsk_receiver_cc.append(mpsk) self.diff_phasor.append(diff_phasor) self.complex_to_arg.append(complex_to_arg) self.multiply_const.append(multiply_const) self.add_const.append(add_const) self.float_to_uchar.append(float_to_uchar) self.map_bits.append(map_bits) self.unpack_k_bits.append(unpack_k_bits) self.blocks_sink.append(sink) self.connect( (self.src, 0), (self.freq_xlating, 0), (self.channelizer, 0)) ################################################## # signal strenght identification ################################################## self.pwr_probes = [] for ch in range(self.channels): pwr_probe = analog.probe_avg_mag_sqrd_c(0, 1./self.srate_channel) self.pwr_probes.append(pwr_probe) self.connect((self.channelizer, ch), (pwr_probe, 0)) def _sig_det_probe(): while True: pwr = [self.pwr_probes[ch].level() for ch in range(self.channels) if ch in self.sig_det_channels] pwr = [10 * math.log10(p) for p in pwr if p > 0.] if not pwr: continue pwr = min(pwr) + self.sig_det_threshold print "Power level for squelch % 5.1f" % pwr if abs(pwr - self.last_pwr) > (self.sig_det_threshold / 2): for s in self.squelch: s.set_threshold(pwr) self.last_pwr = pwr time.sleep(self.sig_det_period) if self.sig_det_threshold is not None: self._sig_det_probe_thread = threading.Thread(target=_sig_det_probe) self._sig_det_probe_thread.daemon = True self._sig_det_probe_thread.start() ################################################## # AFC blocks and connections ################################################## self.afc_selector = grc_blks2.selector( item_size=gr.sizeof_gr_complex, num_inputs=self.channels, num_outputs=1, input_index=0, output_index=0, ) self.afc_demod = analog.quadrature_demod_cf(self.srate_channel/(2*math.pi)) samp_afc = self.srate_channel*self.afc_period / 2 self.afc_avg = blocks.moving_average_ff(samp_afc, 1./samp_afc*self.afc_gain) self.afc_probe = blocks.probe_signal_f() def _afc_probe(): while True: time.sleep(self.afc_period) if self.afc_channel == -1: continue err = self.afc_probe.level() if abs(err) < self.afc_ppm_step: continue freq = self.freq_xlating.center_freq + err * self.afc_gain if self.debug: print "err: %f\tfreq: %f" % (err, freq, ) self.freq_xlating.set_center_freq(freq) self._afc_err_thread = threading.Thread(target=_afc_probe) self._afc_err_thread.daemon = True self._afc_err_thread.start() for ch in range(self.channels): self.connect((self.channelizer, ch), (self.afc_selector, ch)) self.connect( (self.afc_selector, 0), (self.afc_demod, 0), (self.afc_avg, 0), (self.afc_probe, 0)) if self.afc_channel != -1: self.afc_selector.set_input_index(self.afc_channel)
def __init__(self): gr.top_block.__init__(self, "CP v0.4a") Qt.QWidget.__init__(self) self.setWindowTitle("CP v0.4a") 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", "cp04a") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.radio_freq = radio_freq = 100 self.samp_rate = samp_rate = 2.4e6 self.rf_gain = rf_gain = 10 self.freq = freq = radio_freq * 1000000 self.ch3_volume = ch3_volume = 1 self.ch3_squelch = ch3_squelch = -30 self.ch3_mute = ch3_mute = 1 self.ch3_modulation = ch3_modulation = 0 self.ch3_invert = ch3_invert = 1 self.ch3_freq = ch3_freq = radio_freq self.ch2_volume = ch2_volume = 1 self.ch2_squelch = ch2_squelch = -30 self.ch2_mute = ch2_mute = 1 self.ch2_modulation = ch2_modulation = 0 self.ch2_invert = ch2_invert = 1 self.ch2_freq = ch2_freq = radio_freq self.ch1_volume = ch1_volume = 1 self.ch1_squelch = ch1_squelch = -30 self.ch1_mute = ch1_mute = 1 self.ch1_modulation = ch1_modulation = 0 self.ch1_invert = ch1_invert = 1 self.ch1_freq = ch1_freq = radio_freq ################################################## # Blocks ################################################## self.settings = Qt.QTabWidget() self.settings_widget_0 = Qt.QWidget() self.settings_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.settings_widget_0) self.settings_grid_layout_0 = Qt.QGridLayout() self.settings_layout_0.addLayout(self.settings_grid_layout_0) self.settings.addTab(self.settings_widget_0, "Settings") self.top_grid_layout.addWidget(self.settings, 4,3,2,3) self.tabs = Qt.QTabWidget() self.tabs_widget_0 = Qt.QWidget() self.tabs_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_0) self.tabs_grid_layout_0 = Qt.QGridLayout() self.tabs_layout_0.addLayout(self.tabs_grid_layout_0) self.tabs.addTab(self.tabs_widget_0, "Ch 1") self.tabs_widget_1 = Qt.QWidget() self.tabs_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_1) self.tabs_grid_layout_1 = Qt.QGridLayout() self.tabs_layout_1.addLayout(self.tabs_grid_layout_1) self.tabs.addTab(self.tabs_widget_1, "Ch 2") self.tabs_widget_2 = Qt.QWidget() self.tabs_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_2) self.tabs_grid_layout_2 = Qt.QGridLayout() self.tabs_layout_2.addLayout(self.tabs_grid_layout_2) self.tabs.addTab(self.tabs_widget_2, "Ch 3") self.top_grid_layout.addWidget(self.tabs, 4,0,2,3) self._rf_gain_range = Range(0, 50, 1, 10, 100) self._rf_gain_win = RangeWidget(self._rf_gain_range, self.set_rf_gain, "RF Gain", "counter_slider", float) self.settings_grid_layout_0.addWidget(self._rf_gain_win, 1,0,1,1) self._ch2_volume_range = Range(0, 10, 1, 1, 50) self._ch2_volume_win = RangeWidget(self._ch2_volume_range, self.set_ch2_volume, "Volume", "counter_slider", int) self.top_grid_layout.addWidget(self._ch2_volume_win, 1,2,1,1) self._ch2_squelch_range = Range(-70, 0, 10, -30, 50) self._ch2_squelch_win = RangeWidget(self._ch2_squelch_range, self.set_ch2_squelch, "Squelch", "counter_slider", int) self.top_grid_layout.addWidget(self._ch2_squelch_win, 1,3,1,1) _ch2_mute_check_box = Qt.QCheckBox("Mute") self._ch2_mute_choices = {True: 0, False: 1} self._ch2_mute_choices_inv = dict((v,k) for k,v in self._ch2_mute_choices.iteritems()) self._ch2_mute_callback = lambda i: Qt.QMetaObject.invokeMethod(_ch2_mute_check_box, "setChecked", Qt.Q_ARG("bool", self._ch2_mute_choices_inv[i])) self._ch2_mute_callback(self.ch2_mute) _ch2_mute_check_box.stateChanged.connect(lambda i: self.set_ch2_mute(self._ch2_mute_choices[bool(i)])) self.top_grid_layout.addWidget(_ch2_mute_check_box, 1,5,1,1) self._ch2_modulation_options = (0, 1, 2, ) self._ch2_modulation_labels = ("DMR", "NBFM", "WBFM", ) self._ch2_modulation_tool_bar = Qt.QToolBar(self) self._ch2_modulation_tool_bar.addWidget(Qt.QLabel("Modulation"+": ")) self._ch2_modulation_combo_box = Qt.QComboBox() self._ch2_modulation_tool_bar.addWidget(self._ch2_modulation_combo_box) for label in self._ch2_modulation_labels: self._ch2_modulation_combo_box.addItem(label) self._ch2_modulation_callback = lambda i: Qt.QMetaObject.invokeMethod(self._ch2_modulation_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._ch2_modulation_options.index(i))) self._ch2_modulation_callback(self.ch2_modulation) self._ch2_modulation_combo_box.currentIndexChanged.connect( lambda i: self.set_ch2_modulation(self._ch2_modulation_options[i])) self.top_grid_layout.addWidget(self._ch2_modulation_tool_bar, 1,1,1,1) _ch2_invert_check_box = Qt.QCheckBox("Invert") self._ch2_invert_choices = {True: -1, False: 1} self._ch2_invert_choices_inv = dict((v,k) for k,v in self._ch2_invert_choices.iteritems()) self._ch2_invert_callback = lambda i: Qt.QMetaObject.invokeMethod(_ch2_invert_check_box, "setChecked", Qt.Q_ARG("bool", self._ch2_invert_choices_inv[i])) self._ch2_invert_callback(self.ch2_invert) _ch2_invert_check_box.stateChanged.connect(lambda i: self.set_ch2_invert(self._ch2_invert_choices[bool(i)])) self.top_grid_layout.addWidget(_ch2_invert_check_box, 1,4,1,1) self._ch2_freq_tool_bar = Qt.QToolBar(self) self._ch2_freq_tool_bar.addWidget(Qt.QLabel("Ch2 Freq (MHz)"+": ")) self._ch2_freq_line_edit = Qt.QLineEdit(str(self.ch2_freq)) self._ch2_freq_tool_bar.addWidget(self._ch2_freq_line_edit) self._ch2_freq_line_edit.returnPressed.connect( lambda: self.set_ch2_freq(eng_notation.str_to_num(str(self._ch2_freq_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._ch2_freq_tool_bar, 1,0,1,1) self._ch1_volume_range = Range(0, 10, 1, 1, 100) self._ch1_volume_win = RangeWidget(self._ch1_volume_range, self.set_ch1_volume, "Volume", "counter_slider", int) self.top_grid_layout.addWidget(self._ch1_volume_win, 0,2,1,1) self._ch1_squelch_range = Range(-70, 0, 10, -30, 100) self._ch1_squelch_win = RangeWidget(self._ch1_squelch_range, self.set_ch1_squelch, "Squelch", "counter_slider", int) self.top_grid_layout.addWidget(self._ch1_squelch_win, 0,3,1,1) _ch1_mute_check_box = Qt.QCheckBox("Mute") self._ch1_mute_choices = {True: 0, False: 1} self._ch1_mute_choices_inv = dict((v,k) for k,v in self._ch1_mute_choices.iteritems()) self._ch1_mute_callback = lambda i: Qt.QMetaObject.invokeMethod(_ch1_mute_check_box, "setChecked", Qt.Q_ARG("bool", self._ch1_mute_choices_inv[i])) self._ch1_mute_callback(self.ch1_mute) _ch1_mute_check_box.stateChanged.connect(lambda i: self.set_ch1_mute(self._ch1_mute_choices[bool(i)])) self.top_grid_layout.addWidget(_ch1_mute_check_box, 0,5,1,1) self._ch1_modulation_options = (0, 1, 2, ) self._ch1_modulation_labels = ("DMR", "NBFM", "WBFM", ) self._ch1_modulation_tool_bar = Qt.QToolBar(self) self._ch1_modulation_tool_bar.addWidget(Qt.QLabel("Modulation"+": ")) self._ch1_modulation_combo_box = Qt.QComboBox() self._ch1_modulation_tool_bar.addWidget(self._ch1_modulation_combo_box) for label in self._ch1_modulation_labels: self._ch1_modulation_combo_box.addItem(label) self._ch1_modulation_callback = lambda i: Qt.QMetaObject.invokeMethod(self._ch1_modulation_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._ch1_modulation_options.index(i))) self._ch1_modulation_callback(self.ch1_modulation) self._ch1_modulation_combo_box.currentIndexChanged.connect( lambda i: self.set_ch1_modulation(self._ch1_modulation_options[i])) self.top_grid_layout.addWidget(self._ch1_modulation_tool_bar, 0,1,1,1) _ch1_invert_check_box = Qt.QCheckBox("Invert") self._ch1_invert_choices = {True: -1, False: 1} self._ch1_invert_choices_inv = dict((v,k) for k,v in self._ch1_invert_choices.iteritems()) self._ch1_invert_callback = lambda i: Qt.QMetaObject.invokeMethod(_ch1_invert_check_box, "setChecked", Qt.Q_ARG("bool", self._ch1_invert_choices_inv[i])) self._ch1_invert_callback(self.ch1_invert) _ch1_invert_check_box.stateChanged.connect(lambda i: self.set_ch1_invert(self._ch1_invert_choices[bool(i)])) self.top_grid_layout.addWidget(_ch1_invert_check_box, 0,4,1,1) self._ch1_freq_tool_bar = Qt.QToolBar(self) self._ch1_freq_tool_bar.addWidget(Qt.QLabel("Ch1 Freq (MHz)"+": ")) self._ch1_freq_line_edit = Qt.QLineEdit(str(self.ch1_freq)) self._ch1_freq_tool_bar.addWidget(self._ch1_freq_line_edit) self._ch1_freq_line_edit.returnPressed.connect( lambda: self.set_ch1_freq(eng_notation.str_to_num(str(self._ch1_freq_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._ch1_freq_tool_bar, 0,0,1,1) self.wbfm_chain_0_0 = wbfm_chain() self.wbfm_chain_0 = wbfm_chain() 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(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(rf_gain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=400000, decimation=2400000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=400000, decimation=2400000, taps=None, fractional_bw=None, ) self._radio_freq_tool_bar = Qt.QToolBar(self) self._radio_freq_tool_bar.addWidget(Qt.QLabel("Radio Freq (MHz)"+": ")) self._radio_freq_line_edit = Qt.QLineEdit(str(self.radio_freq)) self._radio_freq_tool_bar.addWidget(self._radio_freq_line_edit) self._radio_freq_line_edit.returnPressed.connect( lambda: self.set_radio_freq(eng_notation.str_to_num(str(self._radio_freq_line_edit.text().toAscii())))) self.settings_grid_layout_0.addWidget(self._radio_freq_tool_bar, 0,0,1,1) 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) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if complex == type(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, 10,0,10,6) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 512, #size firdes.WIN_BLACKMAN_hARRIS, #wintype (ch2_freq * 1000000), #fc 400000, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) 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(0.2) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0.disable_legend() if complex == type(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(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.tabs_grid_layout_1.addWidget(self._qtgui_freq_sink_x_0_0_win, 0,0,1,1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 512, #size firdes.WIN_BLACKMAN_hARRIS, #wintype (ch1_freq * 1000000), #fc 400000, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() 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.tabs_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0,0,1,1) self.nbfm_chain_0_0 = nbfm_chain() self.nbfm_chain_0 = nbfm_chain() self.freq_xlating_fft_filter_ccc_0_0 = filter.freq_xlating_fft_filter_ccc(1, (firdes.low_pass(1,samp_rate,200000,10000)), (ch2_freq * 1000000) - freq, samp_rate) self.freq_xlating_fft_filter_ccc_0_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0_0.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc(1, (firdes.low_pass(1,samp_rate,200000,10000)), (ch1_freq * 1000000) - freq, samp_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) self.dsd_chain_0_0 = dsd_chain() self.dsd_chain_0 = dsd_chain() self._ch3_volume_range = Range(0, 10, 1, 1, 50) self._ch3_volume_win = RangeWidget(self._ch3_volume_range, self.set_ch3_volume, "Volume", "counter_slider", int) self.top_grid_layout.addWidget(self._ch3_volume_win, 2,2,1,1) self._ch3_squelch_range = Range(-70, 0, 10, -30, 50) self._ch3_squelch_win = RangeWidget(self._ch3_squelch_range, self.set_ch3_squelch, "Squelch", "counter_slider", int) self.top_grid_layout.addWidget(self._ch3_squelch_win, 2,3,1,1) _ch3_mute_check_box = Qt.QCheckBox("Mute") self._ch3_mute_choices = {True: 0, False: 1} self._ch3_mute_choices_inv = dict((v,k) for k,v in self._ch3_mute_choices.iteritems()) self._ch3_mute_callback = lambda i: Qt.QMetaObject.invokeMethod(_ch3_mute_check_box, "setChecked", Qt.Q_ARG("bool", self._ch3_mute_choices_inv[i])) self._ch3_mute_callback(self.ch3_mute) _ch3_mute_check_box.stateChanged.connect(lambda i: self.set_ch3_mute(self._ch3_mute_choices[bool(i)])) self.top_grid_layout.addWidget(_ch3_mute_check_box, 2,5,1,1) self._ch3_modulation_options = (0, 1, 2, ) self._ch3_modulation_labels = ("DMR", "NBFM", "WBFM", ) self._ch3_modulation_tool_bar = Qt.QToolBar(self) self._ch3_modulation_tool_bar.addWidget(Qt.QLabel("Modulation"+": ")) self._ch3_modulation_combo_box = Qt.QComboBox() self._ch3_modulation_tool_bar.addWidget(self._ch3_modulation_combo_box) for label in self._ch3_modulation_labels: self._ch3_modulation_combo_box.addItem(label) self._ch3_modulation_callback = lambda i: Qt.QMetaObject.invokeMethod(self._ch3_modulation_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._ch3_modulation_options.index(i))) self._ch3_modulation_callback(self.ch3_modulation) self._ch3_modulation_combo_box.currentIndexChanged.connect( lambda i: self.set_ch3_modulation(self._ch3_modulation_options[i])) self.top_grid_layout.addWidget(self._ch3_modulation_tool_bar, 2,1,1,1) _ch3_invert_check_box = Qt.QCheckBox("Invert") self._ch3_invert_choices = {True: -1, False: 1} self._ch3_invert_choices_inv = dict((v,k) for k,v in self._ch3_invert_choices.iteritems()) self._ch3_invert_callback = lambda i: Qt.QMetaObject.invokeMethod(_ch3_invert_check_box, "setChecked", Qt.Q_ARG("bool", self._ch3_invert_choices_inv[i])) self._ch3_invert_callback(self.ch3_invert) _ch3_invert_check_box.stateChanged.connect(lambda i: self.set_ch3_invert(self._ch3_invert_choices[bool(i)])) self.top_grid_layout.addWidget(_ch3_invert_check_box, 2,4,1,1) self._ch3_freq_tool_bar = Qt.QToolBar(self) self._ch3_freq_tool_bar.addWidget(Qt.QLabel("Ch3 Freq (MHz)"+": ")) self._ch3_freq_line_edit = Qt.QLineEdit(str(self.ch3_freq)) self._ch3_freq_tool_bar.addWidget(self._ch3_freq_line_edit) self._ch3_freq_line_edit.returnPressed.connect( lambda: self.set_ch3_freq(eng_notation.str_to_num(str(self._ch3_freq_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._ch3_freq_tool_bar, 2,0,1,1) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff((ch2_invert * ch2_mute, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((ch1_invert * ch1_mute, )) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((ch2_volume, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((ch1_volume, )) self.blks2_selector_0_1 = grc_blks2.selector( item_size=gr.sizeof_gr_complex*1, num_inputs=1, num_outputs=3, input_index=0, output_index=ch2_modulation, ) self.blks2_selector_0_0_0 = grc_blks2.selector( item_size=gr.sizeof_float*1, num_inputs=3, num_outputs=1, input_index=ch2_modulation, output_index=0, ) self.blks2_selector_0_0 = grc_blks2.selector( item_size=gr.sizeof_float*1, num_inputs=3, num_outputs=1, input_index=ch1_modulation, output_index=0, ) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex*1, num_inputs=1, num_outputs=3, input_index=0, output_index=ch1_modulation, ) self.audio_sink_0_0 = audio.sink(48000, "", True) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_pwr_squelch_xx_0_0_0 = analog.pwr_squelch_cc(ch2_squelch, 1e-4, 0, True) self.analog_pwr_squelch_xx_0_0 = analog.pwr_squelch_cc(ch1_squelch, 1e-4, 0, True) ################################################## # Connections ################################################## self.connect((self.analog_pwr_squelch_xx_0_0, 0), (self.blks2_selector_0, 0)) self.connect((self.analog_pwr_squelch_xx_0_0_0, 0), (self.blks2_selector_0_1, 0)) self.connect((self.blks2_selector_0, 0), (self.dsd_chain_0, 0)) self.connect((self.blks2_selector_0, 1), (self.nbfm_chain_0, 0)) self.connect((self.blks2_selector_0, 2), (self.wbfm_chain_0, 0)) self.connect((self.blks2_selector_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blks2_selector_0_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blks2_selector_0_1, 0), (self.dsd_chain_0_0, 0)) self.connect((self.blks2_selector_0_1, 1), (self.nbfm_chain_0_0, 0)) self.connect((self.blks2_selector_0_1, 2), (self.wbfm_chain_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.audio_sink_0_0, 0)) self.connect((self.dsd_chain_0, 0), (self.blks2_selector_0_0, 0)) self.connect((self.dsd_chain_0_0, 0), (self.blks2_selector_0_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.analog_pwr_squelch_xx_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.analog_pwr_squelch_xx_0_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.nbfm_chain_0, 0), (self.blks2_selector_0_0, 1)) self.connect((self.nbfm_chain_0_0, 0), (self.blks2_selector_0_0_0, 1)) 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.qtgui_freq_sink_x_0_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.wbfm_chain_0, 0), (self.blks2_selector_0_0, 2)) self.connect((self.wbfm_chain_0_0, 0), (self.blks2_selector_0_0_0, 2))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Pager 6Ch Decode") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2000000 self.xlate_decimation = xlate_decimation = 40 self.hunter_freq_5 = hunter_freq_5 = 0 self.hunter_freq_4 = hunter_freq_4 = 0 self.hunter_freq_3 = hunter_freq_3 = 0 self.hunter_freq_2 = hunter_freq_2 = 0 self.hunter_freq_1 = hunter_freq_1 = 0 self.hunter_freq_0 = hunter_freq_0 = 0 self.gain = gain = 10 self.frequency = frequency = 929000000 self.filter_width = filter_width = 5120 self.fft_taps = fft_taps = filter.firdes.low_pass_2(1, samp_rate, 2000, 1000, 0.1) self.fft_n_elements = fft_n_elements = 2048 ################################################## # Blocks ################################################## _hunter_freq_5_sizer = wx.BoxSizer(wx.VERTICAL) self._hunter_freq_5_text_box = forms.text_box( parent=self.GetWin(), sizer=_hunter_freq_5_sizer, value=self.hunter_freq_5, callback=self.set_hunter_freq_5, label='hunter_freq_5', converter=forms.int_converter(), proportion=0, ) self._hunter_freq_5_slider = forms.slider( parent=self.GetWin(), sizer=_hunter_freq_5_sizer, value=self.hunter_freq_5, callback=self.set_hunter_freq_5, minimum=-1000000, maximum=1000000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_hunter_freq_5_sizer) _hunter_freq_4_sizer = wx.BoxSizer(wx.VERTICAL) self._hunter_freq_4_text_box = forms.text_box( parent=self.GetWin(), sizer=_hunter_freq_4_sizer, value=self.hunter_freq_4, callback=self.set_hunter_freq_4, label='hunter_freq_4', converter=forms.int_converter(), proportion=0, ) self._hunter_freq_4_slider = forms.slider( parent=self.GetWin(), sizer=_hunter_freq_4_sizer, value=self.hunter_freq_4, callback=self.set_hunter_freq_4, minimum=-1000000, maximum=1000000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_hunter_freq_4_sizer) _hunter_freq_3_sizer = wx.BoxSizer(wx.VERTICAL) self._hunter_freq_3_text_box = forms.text_box( parent=self.GetWin(), sizer=_hunter_freq_3_sizer, value=self.hunter_freq_3, callback=self.set_hunter_freq_3, label='hunter_freq_3', converter=forms.int_converter(), proportion=0, ) self._hunter_freq_3_slider = forms.slider( parent=self.GetWin(), sizer=_hunter_freq_3_sizer, value=self.hunter_freq_3, callback=self.set_hunter_freq_3, minimum=-1000000, maximum=1000000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_hunter_freq_3_sizer) _hunter_freq_2_sizer = wx.BoxSizer(wx.VERTICAL) self._hunter_freq_2_text_box = forms.text_box( parent=self.GetWin(), sizer=_hunter_freq_2_sizer, value=self.hunter_freq_2, callback=self.set_hunter_freq_2, label='hunter_freq_2', converter=forms.int_converter(), proportion=0, ) self._hunter_freq_2_slider = forms.slider( parent=self.GetWin(), sizer=_hunter_freq_2_sizer, value=self.hunter_freq_2, callback=self.set_hunter_freq_2, minimum=-1000000, maximum=1000000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_hunter_freq_2_sizer) _hunter_freq_1_sizer = wx.BoxSizer(wx.VERTICAL) self._hunter_freq_1_text_box = forms.text_box( parent=self.GetWin(), sizer=_hunter_freq_1_sizer, value=self.hunter_freq_1, callback=self.set_hunter_freq_1, label='hunter_freq_1', converter=forms.int_converter(), proportion=0, ) self._hunter_freq_1_slider = forms.slider( parent=self.GetWin(), sizer=_hunter_freq_1_sizer, value=self.hunter_freq_1, callback=self.set_hunter_freq_1, minimum=-1000000, maximum=1000000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_hunter_freq_1_sizer) _hunter_freq_0_sizer = wx.BoxSizer(wx.VERTICAL) self._hunter_freq_0_text_box = forms.text_box( parent=self.GetWin(), sizer=_hunter_freq_0_sizer, value=self.hunter_freq_0, callback=self.set_hunter_freq_0, label='hunter_freq_0', converter=forms.int_converter(), proportion=0, ) self._hunter_freq_0_slider = forms.slider( parent=self.GetWin(), sizer=_hunter_freq_0_sizer, value=self.hunter_freq_0, callback=self.set_hunter_freq_0, minimum=-1000000, maximum=1000000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_hunter_freq_0_sizer) _frequency_sizer = wx.BoxSizer(wx.VERTICAL) self._frequency_text_box = forms.text_box( parent=self.GetWin(), sizer=_frequency_sizer, value=self.frequency, callback=self.set_frequency, label='Frequency', converter=forms.int_converter(), proportion=0, ) self._frequency_slider = forms.slider( parent=self.GetWin(), sizer=_frequency_sizer, value=self.frequency, callback=self.set_frequency, minimum=80000000, maximum=1100000000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_frequency_sizer) self.zeromq_push_sink_0_0 = zeromq.push_sink(gr.sizeof_float, fft_n_elements, 'tcp://127.0.0.1:9000', 100, False, -1) self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(('localhost', 8080), allow_none=True) self.xmlrpc_server_0.register_instance(self) self.xmlrpc_server_0_thread = threading.Thread(target=self.xmlrpc_server_0.serve_forever) self.xmlrpc_server_0_thread.daemon = True self.xmlrpc_server_0_thread.start() self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=frequency, 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='master_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(frequency, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(10, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(0, 0) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label='gain', converter=forms.int_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=50, num_steps=50, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_gain_sizer) self.freq_xlating_fft_filter_ccc_0_0_3 = filter.freq_xlating_fft_filter_ccc(xlate_decimation, (fft_taps), frequency + hunter_freq_5, samp_rate) self.freq_xlating_fft_filter_ccc_0_0_3.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0_0_3.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0_0_2 = filter.freq_xlating_fft_filter_ccc(xlate_decimation, (fft_taps), frequency + hunter_freq_4, samp_rate) self.freq_xlating_fft_filter_ccc_0_0_2.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0_0_2.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0_0_1 = filter.freq_xlating_fft_filter_ccc(xlate_decimation, (fft_taps), frequency + hunter_freq_3, samp_rate) self.freq_xlating_fft_filter_ccc_0_0_1.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0_0_1.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0_0_0 = filter.freq_xlating_fft_filter_ccc(xlate_decimation, (fft_taps), frequency + hunter_freq_2, samp_rate) self.freq_xlating_fft_filter_ccc_0_0_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0_0_0.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0_0 = filter.freq_xlating_fft_filter_ccc(xlate_decimation, (fft_taps), frequency + hunter_freq_1, samp_rate) self.freq_xlating_fft_filter_ccc_0_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0_0.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc(xlate_decimation, (fft_taps), frequency + hunter_freq_0, samp_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) _filter_width_sizer = wx.BoxSizer(wx.VERTICAL) self._filter_width_text_box = forms.text_box( parent=self.GetWin(), sizer=_filter_width_sizer, value=self.filter_width, callback=self.set_filter_width, label='filter_width', converter=forms.int_converter(), proportion=0, ) self._filter_width_slider = forms.slider( parent=self.GetWin(), sizer=_filter_width_sizer, value=self.filter_width, callback=self.set_filter_width, minimum=2048, maximum=40960, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_filter_width_sizer) self.fft_vxx_0 = fft.fft_vcc(fft_n_elements, True, (window.blackmanharris(fft_n_elements)), True, 1) self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, fft_n_elements) self.blocks_stream_to_vector_1 = blocks.stream_to_vector(gr.sizeof_float*1, fft_n_elements) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fft_n_elements) self.blocks_null_sink_0_0_3 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_null_sink_0_0_2 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_null_sink_0_0_1 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_null_sink_0_0_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_stream_to_vector_1, 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.zeromq_push_sink_0_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.blocks_null_sink_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0_0, 0), (self.blocks_null_sink_0_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0_1, 0), (self.blocks_null_sink_0_0_1, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0_2, 0), (self.blocks_null_sink_0_0_2, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0_3, 0), (self.blocks_null_sink_0_0_3, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0_1, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0_2, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0_3, 0)) self.connect((self.rtlsdr_source_0, 0), (self.wxgui_fftsink2_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.tx_signal_dat = tx_signal_dat = "/home/uone/gnuradio/gnuradioworkspace/BackChannel/dataSet/waveform_all_ones.dat" self.tx_ip_rx = tx_ip_rx = "192.168.10.2" self.shiftRight = shiftRight = -2*np.pi*14/64 self.shiftLeft = shiftLeft = 2*np.pi*13/64 self.samp_rate = samp_rate = 20e6 self.integration_tap = integration_tap = np.ones(80) self.FIR_tap = FIR_tap = [0.00268064371500599, 0.00559769448287630, -0.0185697491724867, -0.0484772257271579, 0.0470013313844807, 0.292949628782855, 0.437635353068854, 0.292949628782855, 0.0470013313844807, -0.0484772257271579, -0.0185697491724867, 0.00559769448287630, 0.00268064371500599] self.CarrierFreq = CarrierFreq = 2.4e9 ################################################## # Blocks ################################################## _shiftRight_sizer = wx.BoxSizer(wx.VERTICAL) self._shiftRight_text_box = forms.text_box( parent=self.GetWin(), sizer=_shiftRight_sizer, value=self.shiftRight, callback=self.set_shiftRight, label='shiftRight', converter=forms.float_converter(), proportion=0, ) self._shiftRight_slider = forms.slider( parent=self.GetWin(), sizer=_shiftRight_sizer, value=self.shiftRight, callback=self.set_shiftRight, minimum=-2*np.pi, maximum=0, num_steps=64, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_shiftRight_sizer) _shiftLeft_sizer = wx.BoxSizer(wx.VERTICAL) self._shiftLeft_text_box = forms.text_box( parent=self.GetWin(), sizer=_shiftLeft_sizer, value=self.shiftLeft, callback=self.set_shiftLeft, label='shiftLeft', converter=forms.float_converter(), proportion=0, ) self._shiftLeft_slider = forms.slider( parent=self.GetWin(), sizer=_shiftLeft_sizer, value=self.shiftLeft, callback=self.set_shiftLeft, minimum=0, maximum=2*np.pi, num_steps=64, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_shiftLeft_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, fft_size=64, fft_rate=15, average=False, avg_alpha=None, title='FFT Plot', peak_hold=False, ) self.Add(self.wxgui_fftsink2_0_0_0.win) self.wxgui_fftsink2_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, fft_size=64, fft_rate=15, average=False, avg_alpha=None, title='FFT Plot', peak_hold=False, ) self.Add(self.wxgui_fftsink2_0_0.win) 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=64, fft_rate=15, average=False, avg_alpha=None, title='FFT Plot', peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.freq_xlating_fft_filter_ccc_0_0 = filter.freq_xlating_fft_filter_ccc(1, (FIR_tap), shiftRight, samp_rate) self.freq_xlating_fft_filter_ccc_0_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0_0.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc(1, (FIR_tap), shiftLeft, samp_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, tx_signal_dat, True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fft_filter_ccc_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.wxgui_fftsink2_0_0, 0))