コード例 #1
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="NRF905 Demodulator")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.slider_rf_gain = slider_rf_gain = 30
        self.slider_if_gain = slider_if_gain = 30
        self.slider_freq = slider_freq = 868415e3
        self.samp_rate = samp_rate = 1000000
        self.checkbox_agc = checkbox_agc = True

        ##################################################
        # Blocks
        ##################################################
        _slider_rf_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._slider_rf_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_slider_rf_gain_sizer,
        	value=self.slider_rf_gain,
        	callback=self.set_slider_rf_gain,
        	label="RF Gain",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._slider_rf_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_slider_rf_gain_sizer,
        	value=self.slider_rf_gain,
        	callback=self.set_slider_rf_gain,
        	minimum=0,
        	maximum=40,
        	num_steps=40,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_slider_rf_gain_sizer)
        _slider_if_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._slider_if_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_slider_if_gain_sizer,
        	value=self.slider_if_gain,
        	callback=self.set_slider_if_gain,
        	label="IF Gain",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._slider_if_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_slider_if_gain_sizer,
        	value=self.slider_if_gain,
        	callback=self.set_slider_if_gain,
        	minimum=0,
        	maximum=56,
        	num_steps=56,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_slider_if_gain_sizer)
        _slider_freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._slider_freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_slider_freq_sizer,
        	value=self.slider_freq,
        	callback=self.set_slider_freq,
        	label="Frequency",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._slider_freq_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_slider_freq_sizer,
        	value=self.slider_freq,
        	callback=self.set_slider_freq,
        	minimum=863e6,
        	maximum=870e6,
        	num_steps=(8700-8630),
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_slider_freq_sizer)
        self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "FFT")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "scope")
        self.Add(self.notebook_0)
        self._checkbox_agc_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.checkbox_agc,
        	callback=self.set_checkbox_agc,
        	label="AGC",
        	true=True,
        	false=False,
        )
        self.Add(self._checkbox_agc_check_box)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.notebook_0.GetPage(0).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,
        )
        self.notebook_0.GetPage(0).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(slider_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(checkbox_agc, 0)
        self.rtlsdr_source_0.set_gain(slider_rf_gain, 0)
        self.rtlsdr_source_0.set_if_gain(slider_if_gain, 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.digital_gfsk_demod_0 = digital.gfsk_demod(
        	samples_per_symbol=int(samp_rate/100e3),
        	sensitivity=1.0,
        	gain_mu=0.175,
        	mu=0.5,
        	omega_relative_limit=0.005,
        	freq_error=0.0,
        	verbose=False,
        	log=False,
        )
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/tmp/nrf.dat", False)
        self.blocks_file_sink_0.set_unbuffered(False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.rtlsdr_source_0, 0), (self.digital_gfsk_demod_0, 0))
        self.connect((self.digital_gfsk_demod_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.wxgui_fftsink2_0, 0))
コード例 #2
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Power")

        ##################################################
        # Variables
        ##################################################
        self.vect_len = vect_len = 1024
        self.samp_rate = samp_rate = 100e3
        self.mean_length = mean_length = 5e3
        self.freq = freq = 5.8e09
        self.MuteTx = MuteTx = False

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_c(
        	self.GetWin(),
        	title="RXScope Plot",
        	sample_rate=samp_rate,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_1.win)
	###
        self.wxgui_numbersink2_1 = numbersink2.number_sink_f(
        	self.GetWin(),
        	unit="mW",
        	minval=-100,
        	maxval=100,
        	factor=1.0,
        	decimal_places=2,
        	ref_level=0,
        	sample_rate=samp_rate,
        	number_rate=1,
        	average=True,
        	avg_alpha=1,
        	label="RX mag",
        	peak_hold=False,
        	show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_1.win)
	###
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_subdev_spec("A:B", 0)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(freq, 0)
        self.uhd_usrp_source_0.set_gain(56, 0)
        self.uhd_usrp_source_0.set_antenna("TX/RX", 0)
	###
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_0.set_subdev_spec("A:A", 0)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(freq, 0)
        self.uhd_usrp_sink_0.set_gain(56, 0)
        self.uhd_usrp_sink_0.set_antenna("TX/RX", 0)
	###
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((1e3, ))
	###        
	self.blocks_complex_to_mag_1 = blocks.complex_to_mag(1)
	###        
	self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_SIN_WAVE, mean_length, 1, 0)
	###        
	self._MuteTx_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.MuteTx,
        	callback=self.set_MuteTx,
        	label='MuteTx',
        	true=True,
        	false=False,
        )
        self.Add(self._MuteTx_check_box)        
	self.Mute = blocks.mute_cc(bool(MuteTx))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.Mute, 0), (self.uhd_usrp_sink_0, 0))    
        self.connect((self.analog_sig_source_x_0, 0), (self.Mute, 0))    
        self.connect((self.blocks_complex_to_mag_1, 0), (self.blocks_multiply_const_vxx_1, 0))    
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.wxgui_numbersink2_1, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_complex_to_mag_1, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_scopesink2_1, 0))    
コード例 #3
0
	def __init__(self, decim=50, satellite='Meteor-M-N1', frames_file=os.environ['HOME'] + '/MN1_hrpt_frames.hmf', baseband_file="/home/martin/GNURadioData/hrpt/baseband/HRPT_Meteor-M-N1_2011-02-27_09-30-46_UTC_U2_d50.sam", symb_rate=600*1109, clock_alpha=0.050, pll_alpha=0.05, deframer_outsync_frames=100, deframer_insync_frames=3, deframer_sync_check=False):
		grc_wxgui.top_block_gui.__init__(self, title="Meteor M-N1 HRPT Receiver from baseband file")
		_icon_path = "/home/martin/.local/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
		self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

		##################################################
		# Parameters
		##################################################
		self.decim = decim
		self.satellite = satellite
		self.frames_file = frames_file
		self.baseband_file = baseband_file
		self.symb_rate = symb_rate
		self.clock_alpha = clock_alpha
		self.pll_alpha = pll_alpha
		self.deframer_outsync_frames = deframer_outsync_frames
		self.deframer_insync_frames = deframer_insync_frames
		self.deframer_sync_check = deframer_sync_check

		##################################################
		# Variables
		##################################################
		self.decim_tb = decim_tb = decim
		self.symb_rate_tb = symb_rate_tb = symb_rate
		self.samp_rate = samp_rate = 100e6/decim_tb
		self.sps = sps = samp_rate/symb_rate_tb
		self.v = v = True
		self.satellite_text = satellite_text = satellite
		self.samp_rate_st = samp_rate_st = samp_rate
		self.pll_alpha_sl = pll_alpha_sl = pll_alpha
		self.max_clock_offset = max_clock_offset = 0.1
		self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/samp_rate
		self.hs = hs = int(sps/2.0)
		self.frames_file_text_inf = frames_file_text_inf = frames_file
		self.deframer_sync_after_text = deframer_sync_after_text = deframer_insync_frames
		self.deframer_nosync_after_text = deframer_nosync_after_text = deframer_outsync_frames
		self.deframer_check_sync_text = deframer_check_sync_text = deframer_sync_check
		self.datetime_text = datetime_text = strftime("%A, %B %d %Y %H:%M:%S", localtime())
		self.clock_alpha_sl = clock_alpha_sl = clock_alpha
		self.baseband_file_text_inf = baseband_file_text_inf = baseband_file

		##################################################
		# Blocks
		##################################################
		self.rx_ntb = self.rx_ntb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
		self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Input baseband")
		self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "PLL demodulator and Clock sync")
		self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Deframer")
		self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Output")
		self.Add(self.rx_ntb)
		self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
			self.GetWin(),
			title="Scope Plot",
			sample_rate=samp_rate,
			v_scale=0,
			v_offset=0,
			t_scale=0,
			ac_couple=False,
			xy_mode=False,
			num_inputs=1,
			trig_mode=gr.gr_TRIG_MODE_AUTO,
			y_axis_label="Counts",
		)
		self.Add(self.wxgui_scopesink2_0.win)
		self.wxgui_fftsink1 = fftsink2.fft_sink_c(
			self.rx_ntb.GetPage(0).GetWin(),
			baseband_freq=0,
			y_per_div=5,
			y_divs=10,
			ref_level=50,
			ref_scale=2.0,
			sample_rate=samp_rate,
			fft_size=1024,
			fft_rate=30,
			average=True,
			avg_alpha=0.1,
			title="Not filtered spectrum",
			peak_hold=False,
		)
		self.rx_ntb.GetPage(0).Add(self.wxgui_fftsink1.win)
		self._v_check_box = forms.check_box(
			parent=self.GetWin(),
			value=self.v,
			callback=self.set_v,
			label="Open",
			true=True,
			false=False,
		)
		self.Add(self._v_check_box)
		self._symb_rate_tb_text_box = forms.text_box(
			parent=self.rx_ntb.GetPage(1).GetWin(),
			value=self.symb_rate_tb,
			callback=self.set_symb_rate_tb,
			label="Symbol rate",
			converter=forms.int_converter(),
		)
		self.rx_ntb.GetPage(1).GridAdd(self._symb_rate_tb_text_box, 2, 1, 1, 1)
		self._satellite_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(0).GetWin(),
			value=self.satellite_text,
			callback=self.set_satellite_text,
			label="Sat ",
			converter=forms.str_converter(),
		)
		self.rx_ntb.GetPage(0).GridAdd(self._satellite_text_static_text, 1, 0, 1, 1)
		self._samp_rate_st_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(0).GetWin(),
			value=self.samp_rate_st,
			callback=self.set_samp_rate_st,
			label="Sample rate",
			converter=forms.float_converter(),
		)
		self.rx_ntb.GetPage(0).GridAdd(self._samp_rate_st_static_text, 1, 4, 1, 1)
		self.poesweather_meteor_cadu_deframer_0 = poesweather.meteor_cadu_deframer(deframer_sync_check, 256, deframer_insync_frames, deframer_outsync_frames)
		_pll_alpha_sl_sizer = wx.BoxSizer(wx.VERTICAL)
		self._pll_alpha_sl_text_box = forms.text_box(
			parent=self.rx_ntb.GetPage(1).GetWin(),
			sizer=_pll_alpha_sl_sizer,
			value=self.pll_alpha_sl,
			callback=self.set_pll_alpha_sl,
			label="PLL Alpha",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._pll_alpha_sl_slider = forms.slider(
			parent=self.rx_ntb.GetPage(1).GetWin(),
			sizer=_pll_alpha_sl_sizer,
			value=self.pll_alpha_sl,
			callback=self.set_pll_alpha_sl,
			minimum=0.001,
			maximum=0.1,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.rx_ntb.GetPage(1).GridAdd(_pll_alpha_sl_sizer, 1, 0, 1, 1)
		self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset)
		self.gr_throttle_0 = gr.throttle(gr.sizeof_short*1, samp_rate*10)
		self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((-1, ))
		self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0/hs, 4000)
		self.gr_file_source_0_0 = gr.file_source(gr.sizeof_short*1, "/home/martin/hrpt/baseband/METEOR-M-1/2011/07/24/METEOR-M-1_2011-07-24T113448_U2d50.sam", False)
		self.gr_file_sink_0_0_0 = gr.file_sink(gr.sizeof_char*1, "frames.mn1")
		self.gr_file_sink_0_0_0.set_unbuffered(False)
		self.gr_clock_recovery_mm_xx_0 = gr.clock_recovery_mm_ff(sps/2.0, clock_alpha**2/4.0, 0.5, clock_alpha, max_clock_offset)
		self.gr_binary_slicer_fb_0 = gr.binary_slicer_fb()
		self.gr_agc_xx_0_0 = gr.agc_cc(10e-6, 1, 1.0/32767.0, 1.0)
		self._frames_file_text_inf_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(3).GetWin(),
			value=self.frames_file_text_inf,
			callback=self.set_frames_file_text_inf,
			label="Frames filename",
			converter=forms.str_converter(),
		)
		self.rx_ntb.GetPage(3).GridAdd(self._frames_file_text_inf_static_text, 3, 0, 1, 1)
		self._deframer_sync_after_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(2).GetWin(),
			value=self.deframer_sync_after_text,
			callback=self.set_deframer_sync_after_text,
			label="Deframe sync after",
			converter=forms.float_converter(),
		)
		self.rx_ntb.GetPage(2).GridAdd(self._deframer_sync_after_text_static_text, 3, 0, 1, 1)
		self._deframer_nosync_after_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(2).GetWin(),
			value=self.deframer_nosync_after_text,
			callback=self.set_deframer_nosync_after_text,
			label="Deframer out of sync after",
			converter=forms.float_converter(),
		)
		self.rx_ntb.GetPage(2).GridAdd(self._deframer_nosync_after_text_static_text, 4, 0, 1, 1)
		self._deframer_check_sync_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(2).GetWin(),
			value=self.deframer_check_sync_text,
			callback=self.set_deframer_check_sync_text,
			label="Deframer check sync enable",
			converter=forms.str_converter(),
		)
		self.rx_ntb.GetPage(2).GridAdd(self._deframer_check_sync_text_static_text, 2, 0, 1, 1)
		self._decim_tb_text_box = forms.text_box(
			parent=self.rx_ntb.GetPage(0).GetWin(),
			value=self.decim_tb,
			callback=self.set_decim_tb,
			label="Decimation",
			converter=forms.int_converter(),
		)
		self.rx_ntb.GetPage(0).GridAdd(self._decim_tb_text_box, 1, 3, 1, 1)
		self._datetime_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(3).GetWin(),
			value=self.datetime_text,
			callback=self.set_datetime_text,
			label="Local time of aquisition start",
			converter=forms.str_converter(),
		)
		self.rx_ntb.GetPage(3).GridAdd(self._datetime_text_static_text, 1, 0, 1, 1)
		self.cs2cf = gr.interleaved_short_to_complex()
		_clock_alpha_sl_sizer = wx.BoxSizer(wx.VERTICAL)
		self._clock_alpha_sl_text_box = forms.text_box(
			parent=self.rx_ntb.GetPage(1).GetWin(),
			sizer=_clock_alpha_sl_sizer,
			value=self.clock_alpha_sl,
			callback=self.set_clock_alpha_sl,
			label="Clock alpha",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._clock_alpha_sl_slider = forms.slider(
			parent=self.rx_ntb.GetPage(1).GetWin(),
			sizer=_clock_alpha_sl_sizer,
			value=self.clock_alpha_sl,
			callback=self.set_clock_alpha_sl,
			minimum=0.001,
			maximum=0.1,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.rx_ntb.GetPage(1).GridAdd(_clock_alpha_sl_sizer, 1, 1, 1, 1)
		self._baseband_file_text_inf_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(3).GetWin(),
			value=self.baseband_file_text_inf,
			callback=self.set_baseband_file_text_inf,
			label="Baseband filename",
			converter=forms.str_converter(),
		)
		self.rx_ntb.GetPage(3).GridAdd(self._baseband_file_text_inf_static_text, 4, 0, 1, 1)

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_throttle_0, 0), (self.cs2cf, 0))
		self.connect((self.pll, 0), (self.gr_moving_average_xx_0, 0))
		self.connect((self.gr_moving_average_xx_0, 0), (self.gr_clock_recovery_mm_xx_0, 0))
		self.connect((self.cs2cf, 0), (self.gr_agc_xx_0_0, 0))
		self.connect((self.gr_agc_xx_0_0, 0), (self.pll, 0))
		self.connect((self.cs2cf, 0), (self.wxgui_fftsink1, 0))
		self.connect((self.gr_multiply_const_vxx_0, 0), (self.gr_binary_slicer_fb_0, 0))
		self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_multiply_const_vxx_0, 0))
		self.connect((self.poesweather_meteor_cadu_deframer_0, 0), (self.gr_file_sink_0_0_0, 0))
		self.connect((self.gr_binary_slicer_fb_0, 0), (self.poesweather_meteor_cadu_deframer_0, 0))
		self.connect((self.gr_file_source_0_0, 0), (self.gr_throttle_0, 0))
		self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.wxgui_scopesink2_0, 0))
コード例 #4
0
    self._rfgain_text_box = forms.text_box(
        parent=self.GetWin(),
        width=25,
        sizer=freq_sizer,
        value=self.rfgain,
        callback=set_rfgain,
        label="Gain",
        converter=forms.float_converter(),
        proportion=0,
    )
    self._agc_check_box = forms.check_box(
        sizer=freq_sizer,
        parent=self.GetWin(),
        value=self.iagc,
        callback=set_iagc,
        label="[Auto] ",
        true=1,
        false=0,
    )    
    self.btnincgain = forms.single_button(
            sizer=freq_sizer,
            width=25,
            parent=self.GetWin(),
            label='+',
            callback=incgain,)

    self.btndecgain = forms.single_button(
            sizer=freq_sizer,
            width=25,
            parent=self.GetWin(),
コード例 #5
0
ファイル: simple_fm_rcv.py プロジェクト: rpgsystem/sdr
	def __init__(self, devid="type=b100", rdsfile="rds_fifo", gain=35.0, freq=101.1e6, xmlport=13777, arate=int(48e3), mute=-15.0, ftune=0, ant="J1", subdev="A:0", ahw="pulse", deemph=75.0e-6, prenames='["UWRF","89.3","950","WEVR"]', prefreqs="[88.715e6,89.3e6,950.735e6,106.317e6]", volume=1.0):
		grc_wxgui.top_block_gui.__init__(self, title="Simple FM (Stereo) Receiver")
		_icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
		self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

		##################################################
		# Parameters
		##################################################
		self.devid = devid
		self.rdsfile = rdsfile
		self.gain = gain
		self.freq = freq
		self.xmlport = xmlport
		self.arate = arate
		self.mute = mute
		self.ftune = ftune
		self.ant = ant
		self.subdev = subdev
		self.ahw = ahw
		self.deemph = deemph
		self.prenames = prenames
		self.prefreqs = prefreqs
		self.volume = volume

		##################################################
		# Variables
		##################################################
		self.pthresh = pthresh = 350
		self.preselect = preselect = eval(prefreqs)[0]
		self.pilot_level = pilot_level = 0
		self.ifreq = ifreq = freq
		self.stpilotdet = stpilotdet = True if (pilot_level > pthresh) else False
		self.stereo = stereo = True
		self.rf_pwr_lvl = rf_pwr_lvl = 0
		self.cur_freq = cur_freq = simple_fm_helper.freq_select(ifreq,preselect)
		self.vol = vol = volume
		self.variable_static_text_0 = variable_static_text_0 = 10.0*math.log(rf_pwr_lvl+1.0e-11)/math.log(10)
		self.tone_med = tone_med = 5
		self.tone_low = tone_low = 5
		self.tone_high = tone_high = 5
		self.stereo_0 = stereo_0 = stpilotdet
		self.st_enabled = st_enabled = 1 if (stereo == True and pilot_level > pthresh) else 0
		self.squelch_probe = squelch_probe = 0
		self.sq_thresh = sq_thresh = mute
		self.samp_rate = samp_rate = 250e3
		self.rtext_0 = rtext_0 = cur_freq
		self.record = record = False
		self.rdsrate = rdsrate = 25e3
		self.osmo_taps = osmo_taps = firdes.low_pass(1.0,1.00e6,95e3,20e3,firdes.WIN_HAMMING,6.76)
		self.mod_reset = mod_reset = 0
		self.igain = igain = gain
		self.fine = fine = ftune
		self.farate = farate = arate
		self.dm = dm = deemph
		self.discrim_dc = discrim_dc = 0
		self.capture_file = capture_file = "capture.wav"
		self.asrate = asrate = 125e3

		##################################################
		# Blocks
		##################################################
		_sq_thresh_sizer = wx.BoxSizer(wx.VERTICAL)
		self._sq_thresh_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_sq_thresh_sizer,
			value=self.sq_thresh,
			callback=self.set_sq_thresh,
			label="Mute Level",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._sq_thresh_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_sq_thresh_sizer,
			value=self.sq_thresh,
			callback=self.set_sq_thresh,
			minimum=-30.0,
			maximum=-5.0,
			num_steps=40,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_sq_thresh_sizer, 1, 5, 1, 1)
		self.input_power = gr.probe_avg_mag_sqrd_c(sq_thresh, 1.0/(samp_rate/10))
		self.dc_level = gr.probe_signal_f()
		_vol_sizer = wx.BoxSizer(wx.VERTICAL)
		self._vol_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_vol_sizer,
			value=self.vol,
			callback=self.set_vol,
			label="Volume",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._vol_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_vol_sizer,
			value=self.vol,
			callback=self.set_vol,
			minimum=0,
			maximum=11,
			num_steps=110,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_vol_sizer, 0, 3, 1, 1)
		_tone_med_sizer = wx.BoxSizer(wx.VERTICAL)
		self._tone_med_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_tone_med_sizer,
			value=self.tone_med,
			callback=self.set_tone_med,
			label="1Khz-4Khz",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._tone_med_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_tone_med_sizer,
			value=self.tone_med,
			callback=self.set_tone_med,
			minimum=0,
			maximum=10,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_tone_med_sizer, 1, 3, 1, 1)
		_tone_low_sizer = wx.BoxSizer(wx.VERTICAL)
		self._tone_low_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_tone_low_sizer,
			value=self.tone_low,
			callback=self.set_tone_low,
			label="0-1Khz",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._tone_low_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_tone_low_sizer,
			value=self.tone_low,
			callback=self.set_tone_low,
			minimum=0,
			maximum=10,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_tone_low_sizer, 1, 2, 1, 1)
		_tone_high_sizer = wx.BoxSizer(wx.VERTICAL)
		self._tone_high_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_tone_high_sizer,
			value=self.tone_high,
			callback=self.set_tone_high,
			label="4Khz-15Khz",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._tone_high_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_tone_high_sizer,
			value=self.tone_high,
			callback=self.set_tone_high,
			minimum=0,
			maximum=10,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_tone_high_sizer, 1, 4, 1, 1)
		def _squelch_probe_probe():
			while True:
				val = self.input_power.unmuted()
				try: self.set_squelch_probe(val)
				except AttributeError, e: pass
				time.sleep(1.0/(10))
		_squelch_probe_thread = threading.Thread(target=_squelch_probe_probe)
		_squelch_probe_thread.daemon = True
		_squelch_probe_thread.start()
		self._record_check_box = forms.check_box(
			parent=self.GetWin(),
			value=self.record,
			callback=self.set_record,
			label="Record Audio",
			true=True,
			false=False,
		)
		self.GridAdd(self._record_check_box, 2, 2, 1, 1)
		self.pilot_probe = gr.probe_signal_f()
		_fine_sizer = wx.BoxSizer(wx.VERTICAL)
		self._fine_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_fine_sizer,
			value=self.fine,
			callback=self.set_fine,
			label="Fine Tuning",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._fine_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_fine_sizer,
			value=self.fine,
			callback=self.set_fine,
			minimum=-50.0e3,
			maximum=50.e03,
			num_steps=400,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_fine_sizer, 1, 0, 1, 1)
		def _discrim_dc_probe():
			while True:
				val = self.dc_level.level()
				try: self.set_discrim_dc(val)
				except AttributeError, e: pass
				time.sleep(1.0/(2.5))
		_discrim_dc_thread = threading.Thread(target=_discrim_dc_probe)
		_discrim_dc_thread.daemon = True
		_discrim_dc_thread.start()
		self._capture_file_text_box = forms.text_box(
			parent=self.GetWin(),
			value=self.capture_file,
			callback=self.set_capture_file,
			label="Record Filename",
			converter=forms.str_converter(),
		)
		self.GridAdd(self._capture_file_text_box, 2, 0, 1, 2)
		self.Main = self.Main = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
		self.Main.AddPage(grc_wxgui.Panel(self.Main), "L/R")
		self.Main.AddPage(grc_wxgui.Panel(self.Main), "FM Demod Spectrum")
		self.Add(self.Main)
		self.wxgui_waterfallsink2_0 = 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.Add(self.wxgui_waterfallsink2_0.win)
		self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
			self.Main.GetPage(0).GetWin(),
			title="Audio Channels (L and R)",
			sample_rate=farate,
			v_scale=0,
			v_offset=0,
			t_scale=0,
			ac_couple=False,
			xy_mode=False,
			num_inputs=2,
			trig_mode=gr.gr_TRIG_MODE_AUTO,
			y_axis_label="Rel. Audio Level",
		)
		self.Main.GetPage(0).Add(self.wxgui_scopesink2_0.win)
		self.wxgui_fftsink2_0 = fftsink2.fft_sink_f(
			self.Main.GetPage(1).GetWin(),
			baseband_freq=0,
			y_per_div=10,
			y_divs=10,
			ref_level=0,
			ref_scale=2.0,
			sample_rate=asrate,
			fft_size=1024,
			fft_rate=6,
			average=True,
			avg_alpha=0.1,
			title="FM Demod Spectrum",
			peak_hold=False,
		)
		self.Main.GetPage(1).Add(self.wxgui_fftsink2_0.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="RF Power ",
			converter=forms.float_converter(formatter=lambda x: "%4.1f" % x),
		)
		self.GridAdd(self._variable_static_text_0_static_text, 0, 2, 1, 1)
		self._stereo_0_check_box = forms.check_box(
			parent=self.GetWin(),
			value=self.stereo_0,
			callback=self.set_stereo_0,
			label="Stereo Detect",
			true=True,
			false=False,
		)
		self.GridAdd(self._stereo_0_check_box, 2, 5, 1, 1)
		self._stereo_check_box = forms.check_box(
			parent=self.GetWin(),
			value=self.stereo,
			callback=self.set_stereo,
			label="Stereo",
			true=True,
			false=False,
		)
		self.GridAdd(self._stereo_check_box, 2, 4, 1, 1)
		self.rtl2832_source_0 = baz.rtl_source_c(defer_creation=True)
		self.rtl2832_source_0.set_verbose(True)
		self.rtl2832_source_0.set_vid(0x0)
		self.rtl2832_source_0.set_pid(0x0)
		self.rtl2832_source_0.set_tuner_name("")
		self.rtl2832_source_0.set_default_timeout(0)
		self.rtl2832_source_0.set_use_buffer(True)
		self.rtl2832_source_0.set_fir_coefficients(([]))
		
		
		
		
		
		if self.rtl2832_source_0.create() == False: raise Exception("Failed to create RTL2832 Source: rtl2832_source_0")
		
		
		self.rtl2832_source_0.set_sample_rate(1.0e6)
		
		self.rtl2832_source_0.set_frequency(cur_freq+200e3)
		
		
		self.rtl2832_source_0.set_auto_gain_mode(False)
		self.rtl2832_source_0.set_relative_gain(True)
		self.rtl2832_source_0.set_gain(gain)
		  
		self._rtext_0_static_text = forms.static_text(
			parent=self.GetWin(),
			value=self.rtext_0,
			callback=self.set_rtext_0,
			label="CURRENT FREQUENCY>>",
			converter=forms.float_converter(),
		)
		self.GridAdd(self._rtext_0_static_text, 0, 1, 1, 1)
		def _rf_pwr_lvl_probe():
			while True:
				val = self.input_power.level()
				try: self.set_rf_pwr_lvl(val)
				except AttributeError, e: pass
				time.sleep(1.0/(2))
		_rf_pwr_lvl_thread = threading.Thread(target=_rf_pwr_lvl_probe)
		_rf_pwr_lvl_thread.daemon = True
		_rf_pwr_lvl_thread.start()
		self._preselect_chooser = forms.radio_buttons(
			parent=self.GetWin(),
			value=self.preselect,
			callback=self.set_preselect,
			label='preselect',
			choices=eval(prefreqs),
			labels=eval(prenames),
			style=wx.RA_HORIZONTAL,
		)
		self.GridAdd(self._preselect_chooser, 0, 4, 1, 1)
		def _pilot_level_probe():
			while True:
				val = self.pilot_probe.level()
				try: self.set_pilot_level(val)
				except AttributeError, e: pass
				time.sleep(1.0/(5))
		_pilot_level_thread = threading.Thread(target=_pilot_level_probe)
		_pilot_level_thread.daemon = True
		_pilot_level_thread.start()
		self.low_pass_filter_3 = gr.fir_filter_fff(1, firdes.low_pass(
			3, asrate/500, 10, 3, firdes.WIN_HAMMING, 6.76))
		self.low_pass_filter_2 = gr.fir_filter_fff(10, firdes.low_pass(
			3, asrate/50, 100, 30, firdes.WIN_HAMMING, 6.76))
		self.low_pass_filter_1 = gr.fir_filter_fff(10, firdes.low_pass(
			3, asrate/5, 1e3, 200, firdes.WIN_HAMMING, 6.76))
		self.low_pass_filter_0 = gr.fir_filter_fff(5, firdes.low_pass(
			3, asrate, 10e3, 2e3, firdes.WIN_HAMMING, 6.76))
		_igain_sizer = wx.BoxSizer(wx.VERTICAL)
		self._igain_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_igain_sizer,
			value=self.igain,
			callback=self.set_igain,
			label="RF Gain",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._igain_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_igain_sizer,
			value=self.igain,
			callback=self.set_igain,
			minimum=0,
			maximum=50,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_igain_sizer, 1, 1, 1, 1)
		_ifreq_sizer = wx.BoxSizer(wx.VERTICAL)
		self._ifreq_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_ifreq_sizer,
			value=self.ifreq,
			callback=self.set_ifreq,
			label="Center Frequency",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._ifreq_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_ifreq_sizer,
			value=self.ifreq,
			callback=self.set_ifreq,
			minimum=88.1e6,
			maximum=108.1e6,
			num_steps=200,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_ifreq_sizer, 0, 0, 1, 1)
		self.gr_wavfile_sink_0 = gr.wavfile_sink("/dev/null" if record == False else capture_file, 2, int(farate), 16)
		self.gr_sub_xx_0 = gr.sub_ff(1)
		self.gr_single_pole_iir_filter_xx_1 = gr.single_pole_iir_filter_ff(2.5/(asrate/500), 1)
		self.gr_single_pole_iir_filter_xx_0 = gr.single_pole_iir_filter_ff(1.0/(asrate/3), 1)
		self.gr_multiply_xx_1 = gr.multiply_vff(1)
		self.gr_multiply_xx_0_0 = gr.multiply_vff(1)
		self.gr_multiply_xx_0 = gr.multiply_vff(1)
		self.gr_multiply_const_vxx_3 = gr.multiply_const_vff((3.16e3 if st_enabled else 0, ))
		self.gr_multiply_const_vxx_2 = gr.multiply_const_vff((1.0 if st_enabled else 1.414, ))
		self.gr_multiply_const_vxx_1_0 = gr.multiply_const_vff((0 if st_enabled else 1, ))
		self.gr_multiply_const_vxx_1 = gr.multiply_const_vff((0 if squelch_probe == 0 else 1.0, ))
		self.gr_multiply_const_vxx_0_0 = gr.multiply_const_vff((vol*1.5*10.0, ))
		self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((vol*1.5*10.0 if st_enabled else 0, ))
		self.gr_keep_one_in_n_0 = gr.keep_one_in_n(gr.sizeof_float*1, int(asrate/3))
		self.gr_freq_xlating_fir_filter_xxx_0 = gr.freq_xlating_fir_filter_ccc(4, (osmo_taps), 200e3+fine+(-12e3*discrim_dc), 1.0e6)
		self.gr_fractional_interpolator_xx_0_0 = gr.fractional_interpolator_ff(0, asrate/farate)
		self.gr_fractional_interpolator_xx_0 = gr.fractional_interpolator_ff(0, asrate/farate)
		self.gr_fft_filter_xxx_1_0_0 = gr.fft_filter_fff(1, (firdes.band_pass(tone_high/10.0,asrate,3.5e3,15.0e3,5.0e3,firdes.WIN_HAMMING)), 1)
		self.gr_fft_filter_xxx_1_0 = gr.fft_filter_fff(1, (firdes.band_pass(tone_med/10.0,asrate,1.0e3,4.0e3,2.0e3,firdes.WIN_HAMMING)), 1)
		self.gr_fft_filter_xxx_1 = gr.fft_filter_fff(1, (firdes.low_pass(tone_low/10.0,asrate,1.2e3,500,firdes.WIN_HAMMING)), 1)
		self.gr_fft_filter_xxx_0_0_0 = gr.fft_filter_fff(1, (firdes.band_pass(tone_high/10.0,asrate,3.5e3,13.5e3,3.5e3,firdes.WIN_HAMMING)), 1)
		self.gr_fft_filter_xxx_0_0 = gr.fft_filter_fff(1, (firdes.band_pass(tone_med/10.0,asrate,1.0e3,4.0e3,2.0e3,firdes.WIN_HAMMING)), 1)
		self.gr_fft_filter_xxx_0 = gr.fft_filter_fff(1, (firdes.low_pass(tone_low/10.0,asrate,1.2e3,500,firdes.WIN_HAMMING)), 1)
		self.gr_divide_xx_0 = gr.divide_ff(1)
		self.gr_agc_xx_1 = gr.agc_cc(1e-2, 0.35, 1.0, 5000)
		self.gr_add_xx_2_0 = gr.add_vff(1)
		self.gr_add_xx_2 = gr.add_vff(1)
		self.gr_add_xx_1 = gr.add_vff(1)
		self.gr_add_xx_0 = gr.add_vff(1)
		self.gr_add_const_vxx_0 = gr.add_const_vff((1.0e-7, ))
		self._dm_chooser = forms.radio_buttons(
			parent=self.GetWin(),
			value=self.dm,
			callback=self.set_dm,
			label="FM Deemphasis",
			choices=[75.0e-6, 50.0e-6],
			labels=["NA", "EU"],
			style=wx.RA_HORIZONTAL,
		)
		self.GridAdd(self._dm_chooser, 0, 5, 1, 1)
		self.blks2_wfm_rcv_0 = blks2.wfm_rcv(
			quad_rate=samp_rate,
			audio_decimation=2,
		)
		self.blks2_fm_deemph_0_0 = blks2.fm_deemph(fs=farate, tau=deemph)
		self.blks2_fm_deemph_0 = blks2.fm_deemph(fs=farate, tau=deemph)
		self.band_pass_filter_2_0 = gr.fir_filter_fff(1, firdes.band_pass(
			20, asrate, 17.5e3, 17.9e3, 250, firdes.WIN_HAMMING, 6.76))
		self.band_pass_filter_2 = gr.fir_filter_fff(1, firdes.band_pass(
			10, asrate, 18.8e3, 19.2e3, 350, firdes.WIN_HAMMING, 6.76))
		self.band_pass_filter_0_0 = gr.fir_filter_fff(1, firdes.band_pass(
			1, asrate, 38e3-(15e3), 38e3+(15e3), 4.0e3, firdes.WIN_HAMMING, 6.76))
		self.audio_sink_0 = audio.sink(int(farate), "" if ahw == "Default" else ahw, True)

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_add_xx_1, 0), (self.gr_fractional_interpolator_xx_0, 0))
		self.connect((self.gr_sub_xx_0, 0), (self.gr_fractional_interpolator_xx_0_0, 0))
		self.connect((self.band_pass_filter_0_0, 0), (self.gr_multiply_xx_1, 0))
		self.connect((self.gr_multiply_const_vxx_1_0, 0), (self.gr_add_xx_0, 0))
		self.connect((self.band_pass_filter_2_0, 0), (self.gr_multiply_xx_0, 0))
		self.connect((self.band_pass_filter_2_0, 0), (self.gr_multiply_xx_0, 1))
		self.connect((self.gr_multiply_xx_0_0, 0), (self.gr_divide_xx_0, 0))
		self.connect((self.gr_divide_xx_0, 0), (self.gr_single_pole_iir_filter_xx_0, 0))
		self.connect((self.gr_multiply_xx_0, 0), (self.gr_add_const_vxx_0, 0))
		self.connect((self.gr_add_const_vxx_0, 0), (self.gr_divide_xx_0, 1))
		self.connect((self.gr_single_pole_iir_filter_xx_0, 0), (self.gr_keep_one_in_n_0, 0))
		self.connect((self.gr_keep_one_in_n_0, 0), (self.pilot_probe, 0))
		self.connect((self.band_pass_filter_2, 0), (self.gr_multiply_xx_1, 2))
		self.connect((self.band_pass_filter_2, 0), (self.gr_multiply_xx_0_0, 0))
		self.connect((self.gr_multiply_const_vxx_2, 0), (self.gr_add_xx_1, 0))
		self.connect((self.gr_multiply_const_vxx_2, 0), (self.gr_sub_xx_0, 0))
		self.connect((self.gr_multiply_const_vxx_3, 0), (self.gr_sub_xx_0, 1))
		self.connect((self.gr_multiply_const_vxx_3, 0), (self.gr_add_xx_1, 1))
		self.connect((self.gr_fractional_interpolator_xx_0, 0), (self.gr_multiply_const_vxx_0_0, 0))
		self.connect((self.gr_fractional_interpolator_xx_0_0, 0), (self.gr_multiply_const_vxx_0, 0))
		self.connect((self.band_pass_filter_2, 0), (self.gr_multiply_xx_1, 1))
		self.connect((self.gr_multiply_xx_1, 0), (self.gr_fft_filter_xxx_0, 0))
		self.connect((self.gr_fft_filter_xxx_1, 0), (self.gr_add_xx_2, 0))
		self.connect((self.gr_fft_filter_xxx_1_0, 0), (self.gr_add_xx_2, 1))
		self.connect((self.gr_fft_filter_xxx_1_0_0, 0), (self.gr_add_xx_2, 2))
		self.connect((self.gr_add_xx_2, 0), (self.gr_multiply_const_vxx_2, 0))
		self.connect((self.gr_add_xx_2_0, 0), (self.gr_multiply_const_vxx_3, 0))
		self.connect((self.gr_fft_filter_xxx_0, 0), (self.gr_add_xx_2_0, 0))
		self.connect((self.gr_fft_filter_xxx_0_0, 0), (self.gr_add_xx_2_0, 1))
		self.connect((self.gr_multiply_xx_1, 0), (self.gr_fft_filter_xxx_0_0, 0))
		self.connect((self.gr_fft_filter_xxx_0_0_0, 0), (self.gr_add_xx_2_0, 2))
		self.connect((self.gr_multiply_xx_1, 0), (self.gr_fft_filter_xxx_0_0_0, 0))
		self.connect((self.blks2_fm_deemph_0, 0), (self.gr_multiply_const_vxx_1_0, 0))
		self.connect((self.blks2_fm_deemph_0, 0), (self.gr_wavfile_sink_0, 0))
		self.connect((self.gr_multiply_const_vxx_1, 0), (self.gr_fft_filter_xxx_1, 0))
		self.connect((self.gr_multiply_const_vxx_1, 0), (self.gr_fft_filter_xxx_1_0, 0))
		self.connect((self.gr_multiply_const_vxx_1, 0), (self.gr_fft_filter_xxx_1_0_0, 0))
		self.connect((self.gr_multiply_const_vxx_1, 0), (self.wxgui_fftsink2_0, 0))
		self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.blks2_fm_deemph_0, 0))
		self.connect((self.gr_add_xx_0, 0), (self.audio_sink_0, 1))
		self.connect((self.gr_multiply_const_vxx_0, 0), (self.blks2_fm_deemph_0_0, 0))
		self.connect((self.blks2_fm_deemph_0_0, 0), (self.gr_add_xx_0, 1))
		self.connect((self.band_pass_filter_2, 0), (self.gr_multiply_xx_0_0, 1))
		self.connect((self.gr_multiply_const_vxx_1, 0), (self.band_pass_filter_2, 0))
		self.connect((self.blks2_fm_deemph_0, 0), (self.audio_sink_0, 0))
		self.connect((self.gr_multiply_const_vxx_1, 0), (self.band_pass_filter_2_0, 0))
		self.connect((self.gr_multiply_const_vxx_1, 0), (self.band_pass_filter_0_0, 0))
		self.connect((self.gr_add_xx_0, 0), (self.gr_wavfile_sink_0, 1))
		self.connect((self.blks2_fm_deemph_0, 0), (self.wxgui_scopesink2_0, 0))
		self.connect((self.gr_add_xx_0, 0), (self.wxgui_scopesink2_0, 1))
		self.connect((self.blks2_wfm_rcv_0, 0), (self.gr_multiply_const_vxx_1, 0))
		self.connect((self.gr_agc_xx_1, 0), (self.blks2_wfm_rcv_0, 0))
		self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.gr_agc_xx_1, 0))
		self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.input_power, 0))
		self.connect((self.blks2_wfm_rcv_0, 0), (self.low_pass_filter_0, 0))
		self.connect((self.low_pass_filter_0, 0), (self.low_pass_filter_1, 0))
		self.connect((self.low_pass_filter_1, 0), (self.low_pass_filter_2, 0))
		self.connect((self.low_pass_filter_2, 0), (self.low_pass_filter_3, 0))
		self.connect((self.gr_single_pole_iir_filter_xx_1, 0), (self.dc_level, 0))
		self.connect((self.low_pass_filter_3, 0), (self.gr_single_pole_iir_filter_xx_1, 0))
		self.connect((self.rtl2832_source_0, 0), (self.gr_freq_xlating_fir_filter_xxx_0, 0))
		self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_waterfallsink2_0, 0))
コード例 #6
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.sr = sr = 3.5e6
        self.variable_text_box_0 = variable_text_box_0 = 0
        self.variable_chooser_0 = variable_chooser_0 = 1
        self.variable_check_box_0 = variable_check_box_0 = True
        self.tw = tw = 10000
        self.samp_rate = samp_rate = sr
        self.rl = rl = -20
        self.gain = gain = 1
        self.co = co = 100000
        self.cf = cf = 100.3e6
        self.bw = bw = 2e6

        ##################################################
        # Blocks
        ##################################################
        self._gain_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.gain,
            callback=self.set_gain,
            label='gain',
            choices=[0.2, 0.4, 0.6, 0.8, 1, 1.5, 2, 2.5, 3, 3.5],
            labels=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
        )
        self.Add(self._gain_chooser)
        _cf_sizer = wx.BoxSizer(wx.VERTICAL)
        self._cf_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_cf_sizer,
            value=self.cf,
            callback=self.set_cf,
            label='cf',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._cf_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_cf_sizer,
            value=self.cf,
            callback=self.set_cf,
            minimum=88.5e6,
            maximum=108.5e6,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_cf_sizer)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=cf,
            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='Sample_Bandpass',
            peak_hold=False,
            win=window.hamming,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self._variable_text_box_0_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.variable_text_box_0,
            callback=self.set_variable_text_box_0,
            label='variable_text_box_0',
            converter=forms.float_converter(),
        )
        self.Add(self._variable_text_box_0_text_box)
        self._variable_chooser_0_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.variable_chooser_0,
            callback=self.set_variable_chooser_0,
            label='variable_chooser_0',
            choices=[1, 2, 3],
            labels=[],
        )
        self.Add(self._variable_chooser_0_chooser)
        self._variable_check_box_0_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.variable_check_box_0,
            callback=self.set_variable_check_box_0,
            label='variable_check_box_0',
            true=True,
            false=False,
        )
        self.Add(self._variable_check_box_0_check_box)
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=441,
            decimation=2500,
            taps=None,
            fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            int(samp_rate / 250000),
            firdes.low_pass(4, samp_rate, co, tw, firdes.WIN_HAMMING, 6.76))
        self.blocks_wavfile_sink_0 = blocks.wavfile_sink(
            'sample.wav', 1, 44100, 8)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((gain, ))
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=250000,
            audio_decimation=1,
        )
        self.analog_agc_xx_0 = analog.agc_ff(1e-4, 1.0, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)
        self.TekRSA_iq_stream_0_0 = TekRSA.iq_stream(cf, rl, bw, 1000000, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.TekRSA_iq_stream_0_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.TekRSA_iq_stream_0_0, 0),
                     (self.wxgui_fftsink2_0, 0))
        self.connect((self.analog_agc_xx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_wavfile_sink_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_agc_xx_0, 0))
コード例 #7
0
	def __init__(self, ahw="default", freq=150.0e6, ppm=0.0, vol=1.0, ftune=0.0, xftune=0.0, srate=1.0e6, upclo=0.0, devinfo="rtl=0", agc=0, arate=48.0e3, upce=0, mthresh=-10.0, offs=50.e3, flist="", dfifo="multimode_fifo", mbw=2.0e3, deemph=75.0e-6, dmode="NFM1"):
		grc_wxgui.top_block_gui.__init__(self, title="Multimode Radio Receiver")
		_icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
		self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

		##################################################
		# Parameters
		##################################################
		self.ahw = ahw
		self.freq = freq
		self.ppm = ppm
		self.vol = vol
		self.ftune = ftune
		self.xftune = xftune
		self.srate = srate
		self.upclo = upclo
		self.devinfo = devinfo
		self.agc = agc
		self.arate = arate
		self.upce = upce
		self.mthresh = mthresh
		self.offs = offs
		self.flist = flist
		self.dfifo = dfifo
		self.mbw = mbw
		self.deemph = deemph
		self.dmode = dmode

		##################################################
		# Variables
		##################################################
		self.sc_list_str = sc_list_str = flist
		self.zoom = zoom = 1
		self.thresh = thresh = mthresh
		self.scan_rate = scan_rate = 15
		self.scan_power = scan_power = 0
		self.sc_low = sc_low = 150e6
		self.sc_listm = sc_listm = False
		self.sc_list = sc_list = eval("["+sc_list_str+"]")
		self.sc_incr = sc_incr = 12.5e3
		self.sc_high = sc_high = 300e6
		self.sc_ena = sc_ena = False
		self.samp_rate = samp_rate = int(mh.get_good_rate(devinfo,srate))
		self.rf_power = rf_power = 0
		self.ifreq = ifreq = freq
		self.zoomed_lp = zoomed_lp = (samp_rate/2.1)/zoom
		self.wbfm = wbfm = 200e3
		self.rf_d_power = rf_d_power = 0
		self.mode = mode = dmode
		self.logpower = logpower = math.log10(rf_power+1.0e-14)*10.0
		self.cur_freq = cur_freq = mh.scan_freq_out(sc_ena,sc_low,sc_high,freq,ifreq,scan_power+1.0e-14,thresh,sc_incr,scan_rate,sc_listm,sc_list)
		self.bw = bw = mbw
		self.audio_int_rate = audio_int_rate = 40e3
		self.zoom_taps = zoom_taps = firdes.low_pass(1.0,samp_rate,zoomed_lp,zoomed_lp/3,firdes.WIN_HAMMING,6.76)
		self.xfine = xfine = xftune
		self.volume = volume = vol
		self.variable_static_text_1 = variable_static_text_1 = cur_freq
		self.variable_static_text_0_0 = variable_static_text_0_0 = samp_rate
		self.variable_static_text_0 = variable_static_text_0 = float(int(math.log10(rf_d_power+1.0e-14)*100.0)/10.0)
		self.upc_offset = upc_offset = upclo
		self.upc = upc = upce
		self.ssbo = ssbo = -bw/2 if mode == "LSB" else 0.0
		self.sc_list_len = sc_list_len = len(sc_list)
		self.rfgain = rfgain = 25
		self.record_file = record_file = "recording.wav"
		self.record = record = False
		self.offset = offset = offs
		self.muted = muted = 0.0 if logpower >= thresh else 1
		self.main_taps = main_taps = firdes.low_pass(1.0,wbfm,mh.get_mode_deviation(mode,bw)*1.05,mh.get_mode_deviation(mode,bw)/2.0,firdes.WIN_HAMMING,6.76)
		self.k = k = wbfm/(2*math.pi*mh.get_mode_deviation(mode,bw))
		self.iagc = iagc = agc
		self.freq_update = freq_update = 0
		self.fine = fine = ftune
		self.digi_rate = digi_rate = 50e3
		self.aratio = aratio = int(wbfm/audio_int_rate)

		##################################################
		# Blocks
		##################################################
		self.rf_probe = gr.probe_avg_mag_sqrd_c(0, 0.015)
		self.Main = self.Main = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
		self.Main.AddPage(grc_wxgui.Panel(self.Main), "Main Controls")
		self.Main.AddPage(grc_wxgui.Panel(self.Main), "Scan/Upconv Controls")
		self.Add(self.Main)
		self._zoom_chooser = forms.drop_down(
			parent=self.Main.GetPage(0).GetWin(),
			value=self.zoom,
			callback=self.set_zoom,
			label="Spectral Zoom Ratio",
			choices=[1, 2, 5, 10, 20, 50, 100],
			labels=[],
		)
		self.Main.GetPage(0).GridAdd(self._zoom_chooser, 1, 4, 1, 1)
		_xfine_sizer = wx.BoxSizer(wx.VERTICAL)
		self._xfine_text_box = forms.text_box(
			parent=self.Main.GetPage(0).GetWin(),
			sizer=_xfine_sizer,
			value=self.xfine,
			callback=self.set_xfine,
			label="Extra Fine Tuning",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._xfine_slider = forms.slider(
			parent=self.Main.GetPage(0).GetWin(),
			sizer=_xfine_sizer,
			value=self.xfine,
			callback=self.set_xfine,
			minimum=-1.0e3,
			maximum=1.0e3,
			num_steps=200,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Main.GetPage(0).GridAdd(_xfine_sizer, 0, 3, 1, 1)
		_volume_sizer = wx.BoxSizer(wx.VERTICAL)
		self._volume_text_box = forms.text_box(
			parent=self.Main.GetPage(0).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.Main.GetPage(0).GetWin(),
			sizer=_volume_sizer,
			value=self.volume,
			callback=self.set_volume,
			minimum=1.0,
			maximum=10.0,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Main.GetPage(0).GridAdd(_volume_sizer, 0, 0, 1, 1)
		self._upc_offset_text_box = forms.text_box(
			parent=self.Main.GetPage(1).GetWin(),
			value=self.upc_offset,
			callback=self.set_upc_offset,
			label="Upconv. LO Freq",
			converter=forms.float_converter(),
		)
		self.Main.GetPage(1).GridAdd(self._upc_offset_text_box, 3, 2, 1, 2)
		self._upc_check_box = forms.check_box(
			parent=self.Main.GetPage(1).GetWin(),
			value=self.upc,
			callback=self.set_upc,
			label="Ext. Upconv.",
			true=1,
			false=0,
		)
		self.Main.GetPage(1).GridAdd(self._upc_check_box, 3, 0, 1, 1)
		_rfgain_sizer = wx.BoxSizer(wx.VERTICAL)
		self._rfgain_text_box = forms.text_box(
			parent=self.Main.GetPage(0).GetWin(),
			sizer=_rfgain_sizer,
			value=self.rfgain,
			callback=self.set_rfgain,
			label="RF Gain",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._rfgain_slider = forms.slider(
			parent=self.Main.GetPage(0).GetWin(),
			sizer=_rfgain_sizer,
			value=self.rfgain,
			callback=self.set_rfgain,
			minimum=0,
			maximum=50,
			num_steps=200,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Main.GetPage(0).GridAdd(_rfgain_sizer, 2, 1, 1, 1)
		self._record_file_text_box = forms.text_box(
			parent=self.Main.GetPage(0).GetWin(),
			value=self.record_file,
			callback=self.set_record_file,
			label="Recording Filename",
			converter=forms.str_converter(),
		)
		self.Main.GetPage(0).GridAdd(self._record_file_text_box, 2, 3, 1, 3)
		self._record_check_box = forms.check_box(
			parent=self.Main.GetPage(0).GetWin(),
			value=self.record,
			callback=self.set_record,
			label="Record",
			true=True,
			false=False,
		)
		self.Main.GetPage(0).GridAdd(self._record_check_box, 2, 2, 1, 1)
		_offset_sizer = wx.BoxSizer(wx.VERTICAL)
		self._offset_text_box = forms.text_box(
			parent=self.Main.GetPage(0).GetWin(),
			sizer=_offset_sizer,
			value=self.offset,
			callback=self.set_offset,
			label="LO Offset",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._offset_slider = forms.slider(
			parent=self.Main.GetPage(0).GetWin(),
			sizer=_offset_sizer,
			value=self.offset,
			callback=self.set_offset,
			minimum=25e3,
			maximum=500e3,
			num_steps=200,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Main.GetPage(0).GridAdd(_offset_sizer, 1, 3, 1, 1)
		self._mode_chooser = forms.drop_down(
			parent=self.Main.GetPage(0).GetWin(),
			value=self.mode,
			callback=self.set_mode,
			label="Mode",
			choices=mh.get_modes_values(),
			labels=mh.get_modes_names(),
		)
		self.Main.GetPage(0).GridAdd(self._mode_chooser, 0, 4, 1, 1)
		self._iagc_check_box = forms.check_box(
			parent=self.Main.GetPage(0).GetWin(),
			value=self.iagc,
			callback=self.set_iagc,
			label="AGC",
			true=1,
			false=0,
		)
		self.Main.GetPage(0).GridAdd(self._iagc_check_box, 2, 0, 1, 1)
		def _freq_update_probe():
			while True:
				val = self.rf_probe.level()
				try: self.set_freq_update(val)
				except AttributeError, e: pass
				time.sleep(1.0/(1.0/(2.5)))
		_freq_update_thread = threading.Thread(target=_freq_update_probe)
		_freq_update_thread.daemon = True
		_freq_update_thread.start()
		_fine_sizer = wx.BoxSizer(wx.VERTICAL)
		self._fine_text_box = forms.text_box(
			parent=self.Main.GetPage(0).GetWin(),
			sizer=_fine_sizer,
			value=self.fine,
			callback=self.set_fine,
			label="Fine Tuning",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._fine_slider = forms.slider(
			parent=self.Main.GetPage(0).GetWin(),
			sizer=_fine_sizer,
			value=self.fine,
			callback=self.set_fine,
			minimum=-35e3,
			maximum=35e3,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Main.GetPage(0).GridAdd(_fine_sizer, 0, 2, 1, 1)
		self.display_probe = gr.probe_avg_mag_sqrd_c(0, 0.002)
		_bw_sizer = wx.BoxSizer(wx.VERTICAL)
		self._bw_text_box = forms.text_box(
			parent=self.Main.GetPage(0).GetWin(),
			sizer=_bw_sizer,
			value=self.bw,
			callback=self.set_bw,
			label="AM/SSB Bandwidth",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._bw_slider = forms.slider(
			parent=self.Main.GetPage(0).GetWin(),
			sizer=_bw_sizer,
			value=self.bw,
			callback=self.set_bw,
			minimum=1.0e3,
			maximum=audio_int_rate/2,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Main.GetPage(0).GridAdd(_bw_sizer, 1, 2, 1, 1)
		self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
			self.Main.GetPage(0).GetWin(),
			baseband_freq=mh.get_last_returned(freq_update),
			dynamic_range=40,
			ref_level=0,
			ref_scale=2.0,
			sample_rate=samp_rate/zoom,
			fft_size=1024,
			fft_rate=4,
			average=True,
			avg_alpha=None,
			title="Spectrogram",
			win=window.hamming,
		)
		self.Main.GetPage(0).Add(self.wxgui_waterfallsink2_0.win)
		def wxgui_waterfallsink2_0_callback(x, y):
			self.set_freq(x)
		
		self.wxgui_waterfallsink2_0.set_callback(wxgui_waterfallsink2_0_callback)
		self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
			self.Main.GetPage(0).GetWin(),
			baseband_freq=mh.get_last_returned(freq_update),
			y_per_div=10,
			y_divs=10,
			ref_level=0,
			ref_scale=2.0,
			sample_rate=samp_rate/zoom,
			fft_size=1024,
			fft_rate=4,
			average=True,
			avg_alpha=0.1,
			title="Panorama",
			peak_hold=False,
			win=window.hamming,
		)
		self.Main.GetPage(0).Add(self.wxgui_fftsink2_0.win)
		def wxgui_fftsink2_0_callback(x, y):
			self.set_freq(x)
		
		self.wxgui_fftsink2_0.set_callback(wxgui_fftsink2_0_callback)
		self._variable_static_text_1_static_text = forms.static_text(
			parent=self.Main.GetPage(1).GetWin(),
			value=self.variable_static_text_1,
			callback=self.set_variable_static_text_1,
			label="Current Scan Freq",
			converter=forms.float_converter(),
		)
		self.Main.GetPage(1).GridAdd(self._variable_static_text_1_static_text, 0, 5, 1, 2)
		self._variable_static_text_0_0_static_text = forms.static_text(
			parent=self.Main.GetPage(0).GetWin(),
			value=self.variable_static_text_0_0,
			callback=self.set_variable_static_text_0_0,
			label="Actual srate",
			converter=forms.float_converter(),
		)
		self.Main.GetPage(0).GridAdd(self._variable_static_text_0_0_static_text, 1, 5, 1, 1)
		self._variable_static_text_0_static_text = forms.static_text(
			parent=self.Main.GetPage(0).GetWin(),
			value=self.variable_static_text_0,
			callback=self.set_variable_static_text_0,
			label="RF Level",
			converter=forms.float_converter(),
		)
		self.Main.GetPage(0).GridAdd(self._variable_static_text_0_static_text, 1, 0, 1, 1)
		_thresh_sizer = wx.BoxSizer(wx.VERTICAL)
		self._thresh_text_box = forms.text_box(
			parent=self.Main.GetPage(0).GetWin(),
			sizer=_thresh_sizer,
			value=self.thresh,
			callback=self.set_thresh,
			label="Mute Threshold",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._thresh_slider = forms.slider(
			parent=self.Main.GetPage(0).GetWin(),
			sizer=_thresh_sizer,
			value=self.thresh,
			callback=self.set_thresh,
			minimum=-50,
			maximum=10,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Main.GetPage(0).GridAdd(_thresh_sizer, 1, 1, 1, 1)
		def _scan_power_probe():
			while True:
				val = self.rf_probe.level()
				try: self.set_scan_power(val)
				except AttributeError, e: pass
				time.sleep(1.0/(scan_rate))
		_scan_power_thread = threading.Thread(target=_scan_power_probe)
		_scan_power_thread.daemon = True
		_scan_power_thread.start()
		self._sc_low_text_box = forms.text_box(
			parent=self.Main.GetPage(1).GetWin(),
			value=self.sc_low,
			callback=self.set_sc_low,
			label="Scan Low",
			converter=forms.float_converter(),
		)
		self.Main.GetPage(1).GridAdd(self._sc_low_text_box, 0, 1, 1, 1)
		self._sc_listm_check_box = forms.check_box(
			parent=self.Main.GetPage(1).GetWin(),
			value=self.sc_listm,
			callback=self.set_sc_listm,
			label="Scan List Mode",
			true=True,
			false=False,
		)
		self.Main.GetPage(1).GridAdd(self._sc_listm_check_box, 2, 0, 1, 1)
		self._sc_list_str_text_box = forms.text_box(
			parent=self.Main.GetPage(1).GetWin(),
			value=self.sc_list_str,
			callback=self.set_sc_list_str,
			label="Scan List",
			converter=forms.str_converter(),
		)
		self.Main.GetPage(1).GridAdd(self._sc_list_str_text_box, 2, 1, 1, 5)
		self._sc_incr_chooser = forms.drop_down(
			parent=self.Main.GetPage(1).GetWin(),
			value=self.sc_incr,
			callback=self.set_sc_incr,
			label="Scan Increment (Hz)",
			choices=[5.0e3,6.25e3,10.0e3,12.5e3,15e3,25e3],
			labels=[],
		)
		self.Main.GetPage(1).GridAdd(self._sc_incr_chooser, 0, 0, 1, 1)
		self._sc_high_text_box = forms.text_box(
			parent=self.Main.GetPage(1).GetWin(),
			value=self.sc_high,
			callback=self.set_sc_high,
			label="Scan High",
			converter=forms.float_converter(),
		)
		self.Main.GetPage(1).GridAdd(self._sc_high_text_box, 0, 2, 1, 1)
		self._sc_ena_check_box = forms.check_box(
			parent=self.Main.GetPage(1).GetWin(),
			value=self.sc_ena,
			callback=self.set_sc_ena,
			label="Scan Enable",
			true=True,
			false=False,
		)
		self.Main.GetPage(1).GridAdd(self._sc_ena_check_box, 0, 3, 1, 1)
		def _rf_power_probe():
			while True:
				val = self.rf_probe.level()
				try: self.set_rf_power(val)
				except AttributeError, e: pass
				time.sleep(1.0/(10))
		_rf_power_thread = threading.Thread(target=_rf_power_probe)
		_rf_power_thread.daemon = True
		_rf_power_thread.start()
		def _rf_d_power_probe():
			while True:
				val = self.display_probe.level()
				try: self.set_rf_d_power(val)
				except AttributeError, e: pass
				time.sleep(1.0/(5))
		_rf_d_power_thread = threading.Thread(target=_rf_d_power_probe)
		_rf_d_power_thread.daemon = True
		_rf_d_power_thread.start()
		self.osmosdr_source_c_0 = osmosdr.source_c( args="nchan=" + str(1) + " " + devinfo )
		self.osmosdr_source_c_0.set_sample_rate(samp_rate)
		self.osmosdr_source_c_0.set_center_freq(cur_freq+offset+(upc_offset*float(upc)), 0)
		self.osmosdr_source_c_0.set_freq_corr(ppm, 0)
		self.osmosdr_source_c_0.set_gain_mode(iagc, 0)
		self.osmosdr_source_c_0.set_gain(25 if iagc == 1 else rfgain, 0)
		self.osmosdr_source_c_0.set_if_gain(20, 0)
			
		self._ifreq_text_box = forms.text_box(
			parent=self.Main.GetPage(0).GetWin(),
			value=self.ifreq,
			callback=self.set_ifreq,
			label="Frequency",
			converter=forms.float_converter(),
		)
		self.Main.GetPage(0).GridAdd(self._ifreq_text_box, 0, 1, 1, 1)
		self.gr_wavfile_sink_0 = gr.wavfile_sink("/dev/null" if record == False else record_file, 1, int(audio_int_rate), 8)
		self.gr_quadrature_demod_cf_0 = gr.quadrature_demod_cf(k)
		self.gr_multiply_const_vxx_2 = gr.multiply_const_vff((1.0 if mh.get_mode_type(mode) == "FM" else 0.0, ))
		self.gr_multiply_const_vxx_1 = gr.multiply_const_vff((0.0 if muted else volume/4.5, ))
		self.gr_multiply_const_vxx_0_0_0 = gr.multiply_const_vff((0.85 if mh.get_mode_type(mode) == "AM" else 0.0, ))
		self.gr_multiply_const_vxx_0_0 = gr.multiply_const_vff((0.85 if mh.get_mode_type(mode) == "SSB" else 0.0, ))
		self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc(((1.0/math.sqrt(mh.get_mode_deviation(mode,bw))*250), ))
		self.gr_keep_one_in_n_1 = gr.keep_one_in_n(gr.sizeof_gr_complex*1, aratio)
		self.gr_keep_one_in_n_0_0 = gr.keep_one_in_n(gr.sizeof_gr_complex*1, zoom)
		self.gr_keep_one_in_n_0 = gr.keep_one_in_n(gr.sizeof_gr_complex*1, int(wbfm/digi_rate))
		self.gr_freq_xlating_fir_filter_xxx_0_1 = gr.freq_xlating_fir_filter_ccc(1, (1.0, ), (offset+fine+xfine)/(samp_rate/1.0e6), samp_rate)
		self.gr_fractional_interpolator_xx_0 = gr.fractional_interpolator_ff(0, audio_int_rate/arate)
		self.gr_file_sink_0 = gr.file_sink(gr.sizeof_gr_complex*1, "/dev/null" if mh.get_mode_type(mode) != "DIG" else dfifo)
		self.gr_file_sink_0.set_unbuffered(True)
		self.gr_fft_filter_xxx_3 = gr.fft_filter_ccc(1, (zoom_taps), 1)
		self.gr_fft_filter_xxx_2_0 = gr.fft_filter_fff(5, (firdes.low_pass(1.0,wbfm,14.5e3,8.5e3,firdes.WIN_HAMMING,6.76)), 1)
		self.gr_fft_filter_xxx_2 = gr.fft_filter_ccc(1, (main_taps), 1)
		self.gr_fft_filter_xxx_0 = gr.fft_filter_ccc(int(samp_rate/wbfm), (firdes.low_pass(1.0,samp_rate,98.5e3,66e3,firdes.WIN_HAMMING,6.76)), 1)
		self.gr_feedforward_agc_cc_0 = gr.feedforward_agc_cc(1024, 0.75)
		self.gr_complex_to_real_0 = gr.complex_to_real(1)
		self.gr_complex_to_mag_squared_0 = gr.complex_to_mag_squared(1)
		self.gr_add_xx_0 = gr.add_vff(1)
		self.blks2_fm_deemph_0 = blks2.fm_deemph(fs=audio_int_rate, tau=deemph)
		self.audio_sink_0 = audio.sink(int(arate), ahw, True)

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.gr_add_xx_0, 1))
		self.connect((self.gr_fractional_interpolator_xx_0, 0), (self.gr_multiply_const_vxx_1, 0))
		self.connect((self.gr_multiply_const_vxx_1, 0), (self.audio_sink_0, 0))
		self.connect((self.gr_multiply_const_vxx_1, 0), (self.audio_sink_0, 1))
		self.connect((self.gr_feedforward_agc_cc_0, 0), (self.gr_complex_to_mag_squared_0, 0))
		self.connect((self.osmosdr_source_c_0, 0), (self.gr_freq_xlating_fir_filter_xxx_0_1, 0))
		self.connect((self.gr_multiply_const_vxx_0_0_0, 0), (self.gr_add_xx_0, 2))
		self.connect((self.gr_feedforward_agc_cc_0, 0), (self.gr_complex_to_real_0, 0))
		self.connect((self.gr_complex_to_real_0, 0), (self.gr_multiply_const_vxx_0_0, 0))
		self.connect((self.gr_multiply_const_vxx_2, 0), (self.gr_add_xx_0, 0))
		self.connect((self.gr_complex_to_mag_squared_0, 0), (self.gr_multiply_const_vxx_0_0_0, 0))
		self.connect((self.gr_multiply_const_vxx_0, 0), (self.display_probe, 0))
		self.connect((self.gr_multiply_const_vxx_0, 0), (self.rf_probe, 0))
		self.connect((self.gr_add_xx_0, 0), (self.gr_fractional_interpolator_xx_0, 0))
		self.connect((self.gr_add_xx_0, 0), (self.gr_wavfile_sink_0, 0))
		self.connect((self.gr_freq_xlating_fir_filter_xxx_0_1, 0), (self.gr_fft_filter_xxx_0, 0))
		self.connect((self.gr_keep_one_in_n_0, 0), (self.gr_file_sink_0, 0))
		self.connect((self.gr_freq_xlating_fir_filter_xxx_0_1, 0), (self.gr_fft_filter_xxx_3, 0))
		self.connect((self.gr_fft_filter_xxx_3, 0), (self.gr_keep_one_in_n_0_0, 0))
		self.connect((self.gr_keep_one_in_n_0_0, 0), (self.wxgui_fftsink2_0, 0))
		self.connect((self.gr_keep_one_in_n_0_0, 0), (self.wxgui_waterfallsink2_0, 0))
		self.connect((self.blks2_fm_deemph_0, 0), (self.gr_multiply_const_vxx_2, 0))
		self.connect((self.gr_quadrature_demod_cf_0, 0), (self.gr_fft_filter_xxx_2_0, 0))
		self.connect((self.gr_fft_filter_xxx_2, 0), (self.gr_keep_one_in_n_0, 0))
		self.connect((self.gr_fft_filter_xxx_2, 0), (self.gr_multiply_const_vxx_0, 0))
		self.connect((self.gr_fft_filter_xxx_0, 0), (self.gr_fft_filter_xxx_2, 0))
		self.connect((self.gr_keep_one_in_n_1, 0), (self.gr_feedforward_agc_cc_0, 0))
		self.connect((self.gr_fft_filter_xxx_2, 0), (self.gr_keep_one_in_n_1, 0))
		self.connect((self.gr_fft_filter_xxx_2, 0), (self.gr_quadrature_demod_cf_0, 0))
		self.connect((self.gr_fft_filter_xxx_2_0, 0), (self.blks2_fm_deemph_0, 0))
コード例 #8
0
ファイル: tp_modes.py プロジェクト: abelvdavid/SDR
	def __init__(self, ppm=30, srate=2.4e6, fftsize=8192):
		grc_wxgui.top_block_gui.__init__(self, title="Tp Modes")
		_icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
		self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

		##################################################
		# Parameters
		##################################################
		self.ppm = ppm
		self.srate = srate
		self.fftsize = fftsize

		##################################################
		# Variables
		##################################################
		self.prefix = prefix = "/home/superkuh/vsrt_"
		self.recfile = recfile = prefix + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".log"
		self.freq = freq = 1600e6
		self.bp_width = bp_width = 30e3
		self.bp_low = bp_low = 90e3
		self.actual_lower_freq = actual_lower_freq = 10.7e9
		self.IF_lower_freq = IF_lower_freq = 950e6
		self.scope_rate = scope_rate = 2.0
		self.record = record = False
		self.realfreq_display = realfreq_display = actual_lower_freq + (freq - IF_lower_freq)
		self.integ = integ = 1
		self.capture_file = capture_file = recfile
		self.bp_high = bp_high = bp_low+bp_width

		##################################################
		# Blocks
		##################################################
		self._record_check_box = forms.check_box(
			parent=self.GetWin(),
			value=self.record,
			callback=self.set_record,
			label="Record",
			true=True,
			false=False,
		)
		self.GridAdd(self._record_check_box, 0, 1, 1, 1)
		_integ_sizer = wx.BoxSizer(wx.VERTICAL)
		self._integ_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_integ_sizer,
			value=self.integ,
			callback=self.set_integ,
			label="Integration Time (Sec)",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._integ_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_integ_sizer,
			value=self.integ,
			callback=self.set_integ,
			minimum=1,
			maximum=30,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Add(_integ_sizer)
		self._capture_file_text_box = forms.text_box(
			parent=self.GetWin(),
			value=self.capture_file,
			callback=self.set_capture_file,
			label=" ",
			converter=forms.str_converter(),
		)
		self.GridAdd(self._capture_file_text_box, 0, 2, 1, 1)
		_bp_low_sizer = wx.BoxSizer(wx.VERTICAL)
		self._bp_low_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_bp_low_sizer,
			value=self.bp_low,
			callback=self.set_bp_low,
			label="Bandpass Low End",
			converter=forms.int_converter(),
			proportion=0,
		)
		self._bp_low_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_bp_low_sizer,
			value=self.bp_low,
			callback=self.set_bp_low,
			minimum=80e3,
			maximum=100e3,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=int,
			proportion=1,
		)
		self.Add(_bp_low_sizer)
		self.wxgui_scopesink2_0_0 = scopesink2.scope_sink_f(
			self.GetWin(),
			title="count of LNBF beat frequency bins",
			sample_rate=scope_rate,
			v_scale=0,
			v_offset=0,
			t_scale=450,
			ac_couple=False,
			xy_mode=False,
			num_inputs=1,
			trig_mode=gr.gr_TRIG_MODE_AUTO,
			y_axis_label="Counts",
		)
		self.Add(self.wxgui_scopesink2_0_0.win)
		self.wxgui_fftsink2_0 = fftsink2.fft_sink_f(
			self.GetWin(),
			baseband_freq=0,
			y_per_div=10,
			y_divs=10,
			ref_level=0,
			ref_scale=2.0,
			sample_rate=srate,
			fft_size=2048,
			fft_rate=15,
			average=False,
			avg_alpha=None,
			title="Total Power FFT Spectrum",
			peak_hold=False,
		)
		self.Add(self.wxgui_fftsink2_0.win)
		self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(1.0/((srate/10)*integ), 1)
		self.rtl2832_source_0 = baz.rtl_source_c(defer_creation=True, output_size=gr.sizeof_gr_complex)
		self.rtl2832_source_0.set_verbose(True)
		self.rtl2832_source_0.set_vid(0x0)
		self.rtl2832_source_0.set_pid(0x0)
		self.rtl2832_source_0.set_tuner_name("r820t")
		self.rtl2832_source_0.set_default_timeout(0)
		self.rtl2832_source_0.set_use_buffer(True)
		self.rtl2832_source_0.set_fir_coefficients(([]))
		
		self.rtl2832_source_0.set_read_length(0)
		
		
		
		
		if self.rtl2832_source_0.create() == False: raise Exception("Failed to create RTL2832 Source: rtl2832_source_0")
		
		
		self.rtl2832_source_0.set_sample_rate(scope_rate)
		
		self.rtl2832_source_0.set_frequency(IF_lower_freq)
		
		
		
		self.rtl2832_source_0.set_auto_gain_mode(True)
		self.rtl2832_source_0.set_relative_gain(True)
		self.rtl2832_source_0.set_gain(0)
		  
		self._realfreq_display_static_text = forms.static_text(
			parent=self.GetWin(),
			value=self.realfreq_display,
			callback=self.set_realfreq_display,
			label="Actual Frequency",
			converter=forms.float_converter(),
		)
		self.GridAdd(self._realfreq_display_static_text, 0, 0, 1, 1)
		self.low_pass_filter_0 = gr.fir_filter_fff(int(srate/24e4), firdes.low_pass(
			1, srate, 200e3, 24e3, firdes.WIN_HAMMING, 6.76))
		_freq_sizer = wx.BoxSizer(wx.VERTICAL)
		self._freq_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_freq_sizer,
			value=self.freq,
			callback=self.set_freq,
			label="Frequency",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._freq_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_freq_sizer,
			value=self.freq,
			callback=self.set_freq,
			minimum=950e6,
			maximum=2150e6,
			num_steps=1000,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Add(_freq_sizer)
		self._bp_width_text_box = forms.text_box(
			parent=self.GetWin(),
			value=self.bp_width,
			callback=self.set_bp_width,
			label="BP Width",
			converter=forms.int_converter(),
		)
		self.GridAdd(self._bp_width_text_box, 0, 4, 1, 1)
		self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
		self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_float*1, int(srate/20))
		self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_float*1, "/dev/null" if record == False else capture_file)
		self.blocks_file_sink_1.set_unbuffered(True)
		self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
		self.band_pass_filter_0 = gr.fir_filter_fff(1, firdes.band_pass(
			1, srate/5, bp_low, bp_high, 24e3, firdes.WIN_HAMMING, 6.76))

		##################################################
		# Connections
		##################################################
		self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.wxgui_fftsink2_0, 0))
		self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.low_pass_filter_0, 0))
		self.connect((self.band_pass_filter_0, 0), (self.blocks_multiply_xx_0, 1))
		self.connect((self.band_pass_filter_0, 0), (self.blocks_multiply_xx_0, 0))
		self.connect((self.blocks_multiply_xx_0, 0), (self.single_pole_iir_filter_xx_0, 0))
		self.connect((self.low_pass_filter_0, 0), (self.band_pass_filter_0, 0))
		self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_keep_one_in_n_0, 0))
		self.connect((self.blocks_keep_one_in_n_0, 0), (self.wxgui_scopesink2_0_0, 0))
		self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_file_sink_1, 0))
		self.connect((self.rtl2832_source_0, 0), (self.blocks_complex_to_mag_squared_0, 0))
コード例 #9
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Example Tx Ii")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 8000000
        self.running = running = False
        self.command = command = 10

        ##################################################
        # Blocks
        ##################################################
        self._running_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.running,
        	callback=self.set_running,
        	label='running',
        	true=True,
        	false=False,
        )
        self.Add(self._running_check_box)
        self._command_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.command,
        	callback=self.set_command,
        	label='command',
        	choices=[58,64,28,34,10,22,40,46,52],
        	labels=['<-','->','<^','^>','^','^^','v','v>','<v'],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._command_chooser)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
        	self.GetWin(),
        	title="Scope Plot",
        	sample_rate=samp_rate,
        	v_scale=0,
        	v_offset=0,
        	t_scale=2e-3,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_FREE,
        	y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.remotecar_RemoteCarIIBaseBand_0 = remotecar.RemoteCarIIBaseBand(samp_rate,running, command)
        self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "" )
        self.osmosdr_sink_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0.set_center_freq(27.15e6, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(14, 0)
        self.osmosdr_sink_0.set_if_gain(40, 0)
        self.osmosdr_sink_0.set_bb_gain(20, 0)
        self.osmosdr_sink_0.set_antenna("", 0)
        self.osmosdr_sink_0.set_bandwidth(0, 0)
          
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.remotecar_RemoteCarIIBaseBand_0, 0), (self.wxgui_scopesink2_0, 0))
        self.connect((self.remotecar_RemoteCarIIBaseBand_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.remotecar_RemoteCarIIBaseBand_0, 0), (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_float_to_complex_0, 0), (self.osmosdr_sink_0, 0))
コード例 #10
0
  def __init__(self, subdev="A:0", devid="type=usrp1", frequency=216928000, ant="TX/RX", gain=10, enable_filter=0, rate=3.2e6):
		grc_wxgui.top_block_gui.__init__(self, title="DAB VHF Baseband Player for UHD (USRP)")
		_icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
		self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

		##################################################
		# Parameters
		##################################################
		self.subdev = subdev
		self.devid = devid
		self.frequency = frequency
		self.ant = ant
		self.gain = gain
		self.enable_filter = enable_filter
		self.rate = rate

		##################################################
		# Variables
		##################################################
		self.transition0 = transition0 = 150000
		self.switch2 = switch2 = 1
		self.switch1 = switch1 = enable_filter
		self.switch0 = switch0 = False
		self.samp_rate = samp_rate = int(rate)
		self.gain0 = gain0 = gain
		self.frequency0 = frequency0 = frequency
		self.dgain = dgain = 1.0/32768
		self.cutoff0 = cutoff0 = 810000

		##################################################
		# Blocks
		##################################################
		_transition0_sizer = wx.BoxSizer(wx.VERTICAL)
		self._transition0_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_transition0_sizer,
			value=self.transition0,
			callback=self.set_transition0,
			label="Transition frequency",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._transition0_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_transition0_sizer,
			value=self.transition0,
			callback=self.set_transition0,
			minimum=100,
			maximum=1000000,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_transition0_sizer, 6, 0, 1, 20)
		self._switch2_check_box = forms.check_box(
			parent=self.GetWin(),
			value=self.switch2,
			callback=self.set_switch2,
			label="Spectrum display mute",
			true=1,
			false=0,
		)
		self.GridAdd(self._switch2_check_box, 3, 0, 1, 1)
		self._switch1_check_box = forms.check_box(
			parent=self.GetWin(),
			value=self.switch1,
			callback=self.set_switch1,
			label="Filter",
			true=1,
			false=0,
		)
		self.GridAdd(self._switch1_check_box, 4, 0, 1, 1)
		self._switch0_check_box = forms.check_box(
			parent=self.GetWin(),
			value=self.switch0,
			callback=self.set_switch0,
			label="Clean carrier (Modulator Off)",
			true=1.0,
			false=0,
		)
		self.GridAdd(self._switch0_check_box, 2, 0, 1, 1)
		_gain0_sizer = wx.BoxSizer(wx.VERTICAL)
		self._gain0_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_gain0_sizer,
			value=self.gain0,
			callback=self.set_gain0,
			label="Gain",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._gain0_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_gain0_sizer,
			value=self.gain0,
			callback=self.set_gain0,
			minimum=0,
			maximum=20,
			num_steps=40,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_gain0_sizer, 1, 0, 1, 20)
		self._frequency0_chooser = forms.drop_down(
			parent=self.GetWin(),
			value=self.frequency0,
			callback=self.set_frequency0,
			label="Channel frequency",
			choices=[174928000, 176640000, 178352000, 180064000, 181936000, 183648000, 185360000, 187072000, 188928000, 190640000, 192352000, 194064000, 195936000, 197648000, 199360000, 201072000, 202928000, 204640000, 206352000, 208064000, 209936000, 211648000, 213360000, 215072000, 216928000, 218640000, 220352000, 222064000, 223936000, 225648000, 227360000, 229072000, 230784000, 232496000, 234208000, 235776000, 237488000, 239200000],
			labels=["5A", "5B", "5C", "5D", "6A", "6B", "6C", "6D", "7A", "7B", "7C", "7D", "8A", "8B", "8C", "8D", "9A", "9B", "9C", "9D", "10A", "10B", "10C", "10D", "11A", "11B", "11C", "11D", "12A", "12B", "12C", "12D", "13A", "13B", "13C", "13D", "13E", "13F"],
		)
		self.GridAdd(self._frequency0_chooser, 0, 0, 1, 1)
		_dgain_sizer = wx.BoxSizer(wx.VERTICAL)
		self._dgain_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_dgain_sizer,
			value=self.dgain,
			callback=self.set_dgain,
			label="Digital Gain",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._dgain_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_dgain_sizer,
			value=self.dgain,
			callback=self.set_dgain,
			minimum=0,
			maximum=1.0/10000,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_dgain_sizer, 7, 0, 1, 20)
		_cutoff0_sizer = wx.BoxSizer(wx.VERTICAL)
		self._cutoff0_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_cutoff0_sizer,
			value=self.cutoff0,
			callback=self.set_cutoff0,
			label="Cutoff Frequency",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._cutoff0_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_cutoff0_sizer,
			value=self.cutoff0,
			callback=self.set_cutoff0,
			minimum=1,
			maximum=1500000,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_cutoff0_sizer, 5, 0, 1, 20)
		self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
			self.GetWin(),
			baseband_freq=0,
			y_per_div=5,
			y_divs=15,
			ref_level=60,
			ref_scale=2.0,
			sample_rate=samp_rate,
			fft_size=1024,
			fft_rate=5,
			average=True,
			avg_alpha=None,
			title="FFT Plot",
			peak_hold=False,
		)
		self.Add(self.wxgui_fftsink2_0.win)
		self.uhd_usrp_sink_0 = uhd.usrp_sink(
			device_addr=devid,
			stream_args=uhd.stream_args(
				cpu_format="fc32",
				channels=range(1),
			),
		)
		self.uhd_usrp_sink_0.set_subdev_spec(subdev, 0)
		self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
		self.uhd_usrp_sink_0.set_center_freq(frequency0, 0)
		self.uhd_usrp_sink_0.set_gain(gain0, 0)
		self.uhd_usrp_sink_0.set_antenna(ant, 0)
		self.low_pass_filter_0 = gr.fir_filter_ccf(1, firdes.low_pass(
			1, samp_rate, cutoff0, transition0, firdes.WIN_HAMMING, 6.76))
		self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc((dgain, ))
		self.gr_file_source_0 = gr.file_source(gr.sizeof_gr_complex*1, "/dev/stdin", False)
		self.blks2_valve_1_0 = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(switch0))
		self.blks2_valve_1 = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(switch2))
		self.blks2_selector_1 = grc_blks2.selector(
			item_size=gr.sizeof_gr_complex*1,
			num_inputs=2,
			num_outputs=1,
			input_index=switch1,
			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=switch1,
		)

		##################################################
		# Connections
		##################################################
		self.connect((self.blks2_valve_1, 0), (self.wxgui_fftsink2_0, 0))
		self.connect((self.blks2_selector_1, 0), (self.blks2_valve_1, 0))
		self.connect((self.low_pass_filter_0, 0), (self.blks2_selector_1, 1))
		self.connect((self.blks2_selector_0, 0), (self.blks2_selector_1, 0))
		self.connect((self.blks2_selector_0, 1), (self.low_pass_filter_0, 0))
		self.connect((self.gr_file_source_0, 0), (self.blks2_selector_0, 0))
		self.connect((self.blks2_selector_1, 0), (self.blks2_valve_1_0, 0))
		self.connect((self.blks2_valve_1_0, 0), (self.gr_multiply_const_vxx_0, 0))
		self.connect((self.gr_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0))
コード例 #11
0
ファイル: dssdr_rxtx_nav.py プロジェクト: bpkempke/DSSDRFlow
    def __init__(self, options):
	grc_wxgui.top_block_gui.__init__(self, title="DSSDR")

	self.initialized = False
	self.stopped = False

	self.options = copy.copy(options)
	self._constellation = digital.constellation_bpsk()
	self._excess_bw = options.excess_bw
	self._phase_bw = options.phase_bw
	self._freq_bw = options.freq_bw
	self._timing_bw = options.timing_bw
	self._if_freq = options.if_freq
	self._timing_max_dev= 1.5
	self._demod_class = digital.bpsk_demod  # the demodulator_class we're using
	self._chbw_factor = options.chbw_factor # channel filter bandwidth factor
	self._samples_per_second = 2e6
	self._nav_samples_per_second = 16e6
	self._down_decim = 1
	self._down_samples_per_second = self._scope_sample_rate = self._samples_per_second/self._down_decim
	self._up_samples_per_second = 1e6
	self._asm_threshold = 0
	self._access_code = None
	self._tm_packet_id = 4
	self._timestamp_id = 5
	self._down_bitrate = options.bitrate
	self._up_bitrate = options.up_bitrate
	self._up_samples_per_symbol = self._up_samples_per_second/self._up_bitrate
	self._samples_per_symbol = self._samples_per_second/self._down_decim/self._down_bitrate
	self._down_sub_freq = options.down_sub_freq
	self._up_sub_freq = 25e3
	self._tm_len = 8920
	self._up_tm_len = 8920
	self._coding_method = options.coding_method
	self._up_coding_method = 'None'
	self._up_subcarrier = 'Square'
	self._rs_i = 1
	self._ccsds_channel = 38
	self._uhd_carrier_offset = 10e3
	self._turn_div = 749
	self._turn_mult = 880
	self._modulation_index = 'pi/3'
	self._up_modulation_index = 1.047
	self._max_carrier_offset = 0.1
	self._dssdr_mixer_freq = options.rf_freq
	self._up_coding_rate = '1'
	self._down_coding_rate = '1'
	self._down_conv_en = "False"
	self._down_randomizer_en = options.down_randomizer_en
	self._down_manchester_en = options.down_manchester_en
	self._up_conv_en = "False"
	self._up_idle_sequence = "\\x55"
	self._down_default_gain = 64
	self._up_default_gain = 44
	self._up_en = True

        if self._access_code is None:
            self._access_code = packet_utils.default_access_code

	#Construct the lookup table for parameter-setting functions
	self.param_setters = {
		"DSSDR_CHANNEL": self.setChannel,
		"DSSDR_LO_FREQ": self.setLOFreq,
		"DSSDR_REF_FREQ": self.setRefFreq,
		"DSSDR_TURN_MULT": self.setTurnMult,
		"DSSDR_TURN_DIV": self.setTurnDiv,
		"DSSDR_UP_GAIN": self.setUpGain,
		"DSSDR_DOWN_GAIN": self.setDownGain,
		"DSSDR_UP_BITRATE": self.setUpBitrate,
		"DSSDR_DOWN_BITRATE": self.setDownBitrate,
		"DSSDR_DOWN_SAMPLE_RATE": self.setSampRate,
		"DSSDR_UP_SUB_FREQ": self.setUpSubFreq,
		"DSSDR_DOWN_SUB_FREQ": self.setDownSubFreq,
		"DSSDR_DOPPLER_REPORT": self.dopplerReport,
		"DSSDR_PN_RANGE": self.rangePN,
		"DSSDR_SEQUENTIAL_RANGE": self.rangeSequential,
		"DSSDR_DOWN_CODING_METHOD": self.setDownCodingMethod,
		"DSSDR_UP_CODING_METHOD": self.setUpCodingMethod,
		"DSSDR_DOWN_TM_LEN": self.setTMLen,
		"DSSDR_UP_TM_LEN": self.setUpTMLen,
		"DSSDR_DOWN_MOD_IDX": self.setDownModulationIndex,
		"DSSDR_UP_MOD_IDX": self.setUpModulationIndex,
		"DSSDR_DOWN_CONV_EN": self.setDownConvEn,
		"DSSDR_UP_CONV_EN": self.setUpConvEn,
		"DSSDR_ASM_TOL": self.setASMThreshold,
		"DSSDR_UP_SWEEP": self.freqSweep,
		"DSSDR_UP_IDLE": self.setUpIdleSequence,
		"DSSDR_UP_EN": self.setUpEn,
		"DSSDR_SYNC_TIME": self.syncSDRTime,
		"DSSDR_UP_SWEEP": self.freqSweep,
		"DSSDR_DOWN_ACQUIRE": self.acquireCarrier,
		"DSSDR_INPUT_SELECT": self.setPanelSelect,
		"DSSDR_REF_SELECT": self.setRefSelect,
		"DSSDR_PPS_SELECT": self.setPPSSelect
	}

	#TODO:Add status fields for things like DSSDR_REF_LOCK

	self._dssdr_channels = {
		3: [7149597994, 8400061729],
		4: [7150753857, 8401419752],
		5: [7151909723, 8402777779],
		6: [7153065586, 8404135802],
		7: [7154221449, 8405493825],
		8: [7155377316, 8406851853],
		9: [7156533179, 8408209877],
		10: [7157689045, 8409567903],
		11: [7158844908, 8410925927],
		12: [7160000771, 8412283950],
		13: [7161156637, 8413641977],
		14: [7162312500, 8415000000],
		15: [7163468363, 8416358023],
		16: [7164624229, 8417716050],
		17: [7165780092, 8419074073],
		18: [7166935955, 8420432097],
		19: [7168091821, 8421790123],
		20: [7169247684, 8423148147],
		21: [7170403551, 8424506175],
		22: [7171559414, 8425864198],
		23: [7172715277, 8427222221],
		24: [7173871143, 8428580248],
		25: [7175027006, 8429938271],
		26: [7176182869, 8431296295],
		27: [7177338735, 8432654321],
		28: [7178494598, 8434012345],
		29: [7179650464, 8435370372],
		30: [7180806327, 8436728395],
		31: [7181962190, 8438086418],
		32: [7183118057, 8439444446],
		33: [7184273920, 8440802469],
		34: [7185429783, 8442160493],
		35: [7186585649, 8443518520],
		36: [7187741512, 8444876543],
		37: [7188897378, 8446234570],
		38: [7190000000, 8450000000],
	}

	#FLOWGRAPH STUFF
	if options.test == True:
		self.u = blks2.tcp_source(
			itemsize=gr.sizeof_gr_complex*1,
			addr="",
			port=12905,
			server=True
		)
	elif options.fromfile == True:
		self.u2 = blocks.file_meta_source("iq_in.dat")
		self.u = blocks.throttle(gr.sizeof_gr_complex*1, self._samples_per_second)
	elif options.frombitlog == True:
		self.u3 = blocks.file_source(gr.sizeof_char, "bitstream_recording.in", True)
		self.u2 = blocks.uchar_to_float()
		self.u1 = blocks.throttle(gr.sizeof_float*1, self._down_bitrate)
		self.u = blocks.add_const_ff(-0.5)
	else:
		self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32'))
		self.u.set_clock_source("external")
		self.u.set_time_source("external")
		self.u.set_samp_rate(self._samples_per_second)
		self.u.set_antenna("RX2")
		self.u.set_gain(self._down_default_gain)

		self.frontend = dfi.dssdrFrontendInterface(self.u)

	if options.debug_pps == True:
		self.debug_pps = blocks.tag_debug(gr.sizeof_gr_complex, "debug-pps", "rx_time")

	if options.tofile == True:
		self.u_tx = blocks.file_meta_sink(gr.sizeof_gr_complex, "iq_out.dat", self._up_samples_per_second)
	elif options.tonull == True:
		self.u_tx = blocks.null_sink(gr.sizeof_gr_complex)
	else:
		self.u_tx = uhd.usrp_sink(device_addr=options.args, stream_args=uhd.stream_args('fc32'))
		self.u_tx.set_clock_source("external")
		self.u_tx.set_time_source("external")
		self.u_tx.set_samp_rate(self._up_samples_per_second)
		self.u_tx.set_antenna("TX/RX")
		self.u_tx.set_gain(self._up_default_gain)

	#GUI STUFF
	if options.graphics == True:
		self.nb0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
		self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "RX")
		self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "TX")
		self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "Nav")
		self.Add(self.nb0)
		self.constellation_scope = scopesink2.scope_sink_c(
			self.nb0.GetPage(0).GetWin(),
			title="Scope Plot",
			sample_rate=self._scope_sample_rate,
			v_scale=0,
			v_offset=0,
			t_scale=0,
			ac_couple=False,
			xy_mode=True,
			num_inputs=1,
			trig_mode=wxgui.TRIG_MODE_AUTO,
			y_axis_label="Counts",
		)
	        self.nb0.GetPage(0).Add(self.constellation_scope.win)
		#self.constellation_scope.win.set_marker('plus')
		self._scope_is_fft = False
		self.time_scope = scopesink2.scope_sink_f(
			self.nb0.GetPage(0).GetWin(),
			title="Scope Plot",
			sample_rate=self._scope_sample_rate,
			v_scale=0,
			v_offset=0,
			t_scale=.005,
			ac_couple=False,
			xy_mode=False,
			num_inputs=1,
			trig_mode=wxgui.TRIG_MODE_AUTO,
			y_axis_label="Counts",
		)
		self.nb0.GetPage(0).Add(self.time_scope.win)
		self.nb0.GetPage(0).GetWin()._box.Hide(self.time_scope.win)
		self.fft_scope = fftsink2.fft_sink_c(
			self.nb0.GetPage(0).GetWin(),
			baseband_freq=0,
			y_per_div=10,
			y_divs=10,
			ref_level=0,
			ref_scale=2.0,
			sample_rate=self._scope_sample_rate,
			fft_size=1024,
		 	fft_rate=15,
			average=False,
			avg_alpha=None,
			title="FFT Plot",
			peak_hold=False,
		)
		self.nb0.GetPage(0).Add(self.fft_scope.win)
		self.nb0.GetPage(0).GetWin()._box.Hide(self.fft_scope.win)
	
		self.row1_sizer = wx.BoxSizer(wx.HORIZONTAL)
		self.recording_onoff_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(0).GetWin(),
			value='Off',
			callback=self.setRecording,
			label="IQ Recording",
			choices=['Off','On'],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)
		self.front_panel_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(0).GetWin(),
			value='RF',
			callback=self.setPanelSelect,
			label="Input Select",
			choices=['RF','IF'],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)
		self.ref_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(0).GetWin(),
			value='Internal',
			callback=self.setRefSelect,
			label="Ref Select",
			choices=['Internal','External'],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)
		self.pps_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(0).GetWin(),
			value='Internal',
			callback=self.setPPSSelect,
			label="PPS Select",
			choices=['Internal','External'],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)

		self.sync_button = forms.button(
			parent=self.nb0.GetPage(0).GetWin(),
			value='Sync to PPS',
			callback=self.syncSDRTime,
			choices=['Sync to PPS'],
			style=wx.RA_HORIZONTAL,
		)
		self.ref_locked_text = forms.static_text(
			parent=self.nb0.GetPage(0).GetWin(),
			value="",
			callback=self.setRefLocked,
			label="",
			converter=forms.str_converter(),
		)
		self.row1_sizer.Add(self.recording_onoff_chooser, flag=wx.ALIGN_CENTER)
		self.row1_sizer.Add(self.front_panel_chooser, flag=wx.ALIGN_CENTER)
		self.row1_sizer.Add(self.ref_chooser, flag=wx.ALIGN_CENTER)
		self.row1_sizer.Add(self.pps_chooser, flag=wx.ALIGN_CENTER)
		self.row1_sizer.Add(self.sync_button, flag=wx.ALIGN_CENTER)
		self.row1_sizer.Add(self.ref_locked_text, flag=wx.ALIGN_CENTER)
		self.nb0.GetPage(0).Add(self.row1_sizer)
		self.complex_scope_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(0).GetWin(),
			value='Constellation',
			callback=self.setComplexScopeStyle,
			label="Complex Scope",
			choices=['Constellation','FFT'],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)
		self.nb0.GetPage(0).Add(self.complex_scope_chooser)
		self.scope_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(0).GetWin(),
			value='USRP',
			callback=self.setScopePoint,
			label="Scope Probe Point",
			choices=['USRP','Carrier Tracking','Sub-Carrier Costas','Sub-Carrier Sync','Data Sync'],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)
		self.nb0.GetPage(0).Add(self.scope_chooser)
		self._bitrate_text_box = forms.text_box(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._down_bitrate,
			callback=self.setDownBitrate,
			label="Symbol Rate",
			converter=forms.float_converter(),
		)
		self.nb0.GetPage(0).Add(self._bitrate_text_box)
		self._samprate_text_box = forms.text_box(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._samples_per_second,
			callback=self.setSampRate,
			label="Sampling Rate",
			converter=forms.float_converter(),
		)
		self.nb0.GetPage(0).Add(self._samprate_text_box)
		self._subcfreq_text_box = forms.text_box(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._down_sub_freq,
			callback=self.setDownSubFreq,
			label="Downlink Subcarrier Frequency",
			converter=forms.float_converter(),
		)
		self.nb0.GetPage(0).Add(self._subcfreq_text_box)
		self._mod_index_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._modulation_index,
			callback=self.setDownModulationIndex,
			label="Modulation Index",
			choices=['pi/2', 'pi/3'],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)
		self.nb0.GetPage(0).Add(self._mod_index_chooser)
		self._pktlen_text_box = forms.text_box(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._tm_len,
			callback=self.setTMLen,
			label="Downlink Packet Length (bits)",
			converter=forms.float_converter(),
		)
		self.nb0.GetPage(0).Add(self._pktlen_text_box)
		self._coding_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._coding_method,
			callback=self.setDownCodingMethod,
			label="Coding",
			choices=['None', 'RS', 'Turbo 1/2', 'Turbo 1/3', 'Turbo 1/4', 'Turbo 1/6'],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)
		self.nb0.GetPage(0).Add(self._coding_chooser)
		self._down_conv_check_box = forms.check_box(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._down_conv_en,
			callback=self.setDownConvEn,
			label="Convolutional Decode",
			true="True",
			false="False",
		)
		self.nb0.GetPage(0).Add(self._down_conv_check_box)
		self._down_randomizer_check_box = forms.check_box(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._down_randomizer_en,
			callback=self.setDownRandomizerEn,
			label="De-randomizer",
			true=True,
			false=False,
		)
		self.nb0.GetPage(0).Add(self._down_randomizer_check_box)
		self._down_manchester_check_box = forms.check_box(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._down_manchester_en,
			callback=self.setDownManchesterEn,
			label="Manchester Decode",
			true=True,
			false=False,
		)
		self.nb0.GetPage(0).Add(self._down_manchester_check_box)
		self._pktlen_text_box = forms.text_box(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._asm_threshold,
			callback=self.setASMThreshold,
			label="ASM Error Tolerance (bits)",
			converter=forms.float_converter(),
		)
		self.nb0.GetPage(0).Add(self._pktlen_text_box)
		self._coding_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._rs_i,
			callback=self.setRSI,
			label="Reed-Solomon Interleaving Depth",
			choices=[1,5],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)
		self.nb0.GetPage(0).Add(self._coding_chooser)
		self._ccsds_chan_text_box = forms.text_box(
			parent=self.nb0.GetPage(0).GetWin(),
			value=self._ccsds_channel,
			callback=self.setChannel,
			label="CCSDS Channel",
			converter=forms.int_converter(),
		)
		self.nb0.GetPage(0).Add(self._ccsds_chan_text_box)
		self.setChannel(self._ccsds_channel)
	
		if options.test == True or options.fromfile == True or options.frombitlog == True:
			glow = 0.0
			ghigh = 1.0
			cur_g = 0.5
		else:
			g = self.u.get_gain_range()
			cur_g = self._down_default_gain
		
			# some configurations don't have gain control
			if g.stop() <= g.start():
				glow = 0.0
				ghigh = 1.0
		
			else:
				glow = g.start()
				ghigh = g.stop()
		
		self._uhd_gain_slider = wx.BoxSizer(wx.HORIZONTAL)
		form.slider_field(
			parent=self.nb0.GetPage(0).GetWin(),
			sizer=self._uhd_gain_slider,
			label="USRP RX Gain",
			weight=3,
			min=int(glow), 
			max=int(ghigh),
			value=cur_g,
			callback=self.setDownGain
		)
		self.nb0.GetPage(0).Add(self._uhd_gain_slider)

		#TX chain GUI components
		if options.test == True or options.tofile == True or options.tonull == True:
			gtxlow = 0.0
			gtxhigh = 1.0
			cur_gtx = 0.5
		else:
			gtx = self.u_tx.get_gain_range()
			cur_gtx = self._up_default_gain
		
			# some configurations don't have gain control
			if gtx.stop() <= gtx.start():
				gtxlow = 0.0
				gtxhigh = 1.0
		
			else:
				gtxlow = gtx.start()
				gtxhigh = gtx.stop()

		self._up_en_chooser = forms.check_box(
			parent=self.nb0.GetPage(1).GetWin(),
			value='True',
			callback=self.setUpEn,
			label="TX Enable",
			true='True',
			false='False',
		)
		self.nb0.GetPage(1).Add(self._up_en_chooser)

		self._uhd_tx_gain_slider = wx.BoxSizer(wx.HORIZONTAL)
		form.slider_field(
			parent=self.nb0.GetPage(1).GetWin(),
			sizer=self._uhd_tx_gain_slider,
			label="USRP TX Gain",
			weight=3,
			min=int(gtxlow), 
			max=int(gtxhigh),
			value=cur_gtx,
			callback=self.setUpGain
		)
		self.nb0.GetPage(1).Add(self._uhd_tx_gain_slider)
		self._subcfreq_up_text_box = forms.text_box(
			parent=self.nb0.GetPage(1).GetWin(),
			value=self._up_sub_freq,
			callback=self.setUpSubFreq,
			label="Uplink Subcarrier Frequency",
			converter=forms.float_converter(),
		)
		self.nb0.GetPage(1).Add(self._subcfreq_up_text_box)
		self._up_bitrate_text_box = forms.text_box(
			parent=self.nb0.GetPage(1).GetWin(),
			value=self._up_bitrate,
			callback=self.setUpBitrate,
			label="Uplink Bitrate",
			converter=forms.float_converter(),
		)
		self.nb0.GetPage(1).Add(self._up_bitrate_text_box)
		self._up_data_text_box = forms.text_box(
			parent=self.nb0.GetPage(1).GetWin(),
			value="1234ABCD",
			callback=self.txData,
			label="TX Data",
			converter=forms.str_converter(),
		)
		self.nb0.GetPage(1).Add(self._up_data_text_box)
		self._up_mod_index_chooser = forms.text_box(
			parent=self.nb0.GetPage(1).GetWin(),
			value=self._up_modulation_index,
			callback=self.setUpModulationIndex,
			label="Uplink Modulation Index",
			converter=forms.float_converter(),
		)
		self.nb0.GetPage(1).Add(self._up_mod_index_chooser)
		self._up_coding_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(1).GetWin(),
			value=self._up_coding_method,
			callback=self.setUpCodingMethod,
			label="Coding",
			choices=['None', 'RS'],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)
		self.nb0.GetPage(1).Add(self._up_coding_chooser)
		self._subcarrier_chooser = forms.radio_buttons(
			parent=self.nb0.GetPage(1).GetWin(),
			value=self._up_subcarrier,
			callback=self.setUpSubcarrier,
			label="Subcarrier Type",
			choices=['Square','Sine'],
			labels=[],
			style=wx.RA_HORIZONTAL,
		)
		self.nb0.GetPage(1).Add(self._subcarrier_chooser)
		self._up_conv_check_box = forms.check_box(
			parent=self.nb0.GetPage(1).GetWin(),
			value=self._up_conv_en,
			callback=self.setUpConvEn,
			label="Convolutional Encode",
			true="True",
			false="False",
		)
		self.nb0.GetPage(1).Add(self._up_conv_check_box)
		self._up_pktlen_text_box = forms.text_box(
			parent=self.nb0.GetPage(1).GetWin(),
			value=self._up_tm_len,
			callback=self.setUpTMLen,
			label="Uplink Packet Length (bits)",
			converter=forms.float_converter(),
		)
		self.nb0.GetPage(1).Add(self._up_pktlen_text_box)
		self._uhd_offset_text_box = forms.text_box(
			parent=self.nb0.GetPage(1).GetWin(),
			value=self._uhd_carrier_offset,
			callback=self.setUHDCarrierOffset,
			label="USRP Offset Frequency (Hz)",
			converter=forms.float_converter(),
		)
		self.nb0.GetPage(1).Add(self._uhd_offset_text_box)
		self._sweep_gen_text_box = forms.text_box(
			parent=self.nb0.GetPage(1).GetWin(),
			value="rf2_1",
			callback=self.freqSweep,
			label="Frequency Sweep Profile",
			converter=forms.str_converter(),
		)
		self.nb0.GetPage(1).Add(self._sweep_gen_text_box)
		self._idle_sequence_text_box = forms.text_box(
			parent=self.nb0.GetPage(1).GetWin(),
			value=self._up_idle_sequence,
			callback=self.setUpIdleSequence,
			label="Uplink Idle Sequence",
			converter=forms.str_converter(),
		)
		self.nb0.GetPage(1).Add(self._idle_sequence_text_box)
		self._pn_ranging_text_box = forms.text_box(
			parent=self.nb0.GetPage(2).GetWin(),
			value="",
			callback=self.rangePN,
			label="Queue PN Ranging",
			converter=forms.str_converter(),
		)
		self.nb0.GetPage(2).Add(self._pn_ranging_text_box)
		self._sequential_ranging_text_box = forms.text_box(
			parent=self.nb0.GetPage(2).GetWin(),
			value="",
			callback=self.rangeSequential,
			label="Queue Sequential Ranging",
			converter=forms.str_converter(),
		)
		self.nb0.GetPage(2).Add(self._sequential_ranging_text_box)
		self.row2_sizer = wx.BoxSizer(wx.HORIZONTAL)
		self.freq_acq_button = forms.button(
			parent=self.nb0.GetPage(2).GetWin(),
			value='Acquire Carrier Offset',
			callback=self.acquireCarrier,
			choices=['Acquire Carrier Offset'],
			style=wx.RA_HORIZONTAL,
		)
		self.carrier_offset_text = forms.static_text(
			parent=self.nb0.GetPage(2).GetWin(),
			value="",
			label="",
			converter=forms.str_converter(),
		)
		self.row2_sizer.Add(self.freq_acq_button, flag=wx.ALIGN_CENTER)
		self.row2_sizer.Add(self.carrier_offset_text, flag=wx.ALIGN_CENTER)
		self.nb0.GetPage(2).Add(self.row2_sizer)


	self.file_sink = blocks.file_meta_sink(gr.sizeof_gr_complex, "iq_recording.dat", self._samples_per_second)
	self.file_sink.close()
	self.iq_recording_ctr = 0

	# Selection logic to switch between recording and normal flowgraph routes
	# NOTE: u_valve logic is implemented backwards in GNURadio....
	#self.u_valve = blks2.valve(
	#	item_size=gr.sizeof_gr_complex,
	#	open=False
	#)

	# Temporary code used to verify coherent turnaround
	self.turnaround_mixer = blocks.multiply_cc()
	self.turnaround_mixer_source = analog.sig_source_c(self._down_samples_per_second, analog.GR_SIN_WAVE, -25e3, 1.0)
	self.turnaround_iir = filter.single_pole_iir_filter_cc(0.0001)
	self.turnaround_null = blocks.null_sink(gr.sizeof_float)

	# PLL and associated carrier for tracking carrier frequency if residual carrier is used
	self.carrier_tracking = sdrp.pll_freq_acq_cc(math.pi/2000, math.pi, -math.pi, int(options.acq_samples))
	self.imag_to_float = blocks.complex_to_imag()

	#Suppressed carrier requires costas after subcarrier mixer
	self.subcarrier_costas = digital.costas_loop_cc(0.001, 2)
	self.real_to_float = blocks.complex_to_real()

	#Square wave subcarrier sync
	self.subcarrier_sync = sdrp.square_sub_tracker_ff(0.001, 2*self._down_sub_freq/self._down_samples_per_second*1.0001, 2*self._down_sub_freq/self._down_samples_per_second*0.9999)

	#Data sync
	self.data_sync = sdrp.square_data_tracker_ff(0.001, self._down_bitrate/self._down_samples_per_second*1.001, self._down_bitrate/self._down_samples_per_second*0.999)

	#Data framing
	self.soft_correlator = sdrp.correlate_soft_access_tag_ff(conv_packed_binary_string_to_1_0_string('\x1A\xCF\xFC\x1D'), self._asm_threshold, "asm_corr")
	self.conv_decoder = sdrp.ccsds_tm_conv_decoder("asm_corr")
	self.de_randomizer = sdrp.ccsds_tm_derandomizer("asm_corr")
	self.tm_framer = sdrp.ccsds_tm_framer(self._tm_packet_id, self._timestamp_id, "asm_corr", "rx_time", self._down_bitrate)
	self.tm_framer.setFrameLength(self._tm_len)

	self._current_scope_block = None
	self._current_scoped_block = self.u
	self._current_scoped_block_port = 0

	self._recording = 'Off'

	#TX path in flowgraph
	self.pkt_gen_msgq = gr.msg_queue(10)
        self.pkt_gen = sdrp.ccsds_tm_tx(self._tm_packet_id, self._timestamp_id, 1.0, 16, self.pkt_gen_msgq)
	self.conj = blocks.conjugate_cc()

	#Sweep generator for transponder lock
	self.sweep_gen = sdrp.sweep_generator_cc(self._up_samples_per_second)

	# DSSDR subcarrier mixer (either 25 kHz or 0 kHz depending on baud rate)
	self.up_subcarrier_mixer = blocks.multiply_ff()
	self.subcarrier_mixer_source_tx = analog.sig_source_f(self._up_samples_per_second, analog.GR_SQR_WAVE, 25e3, 2.0, -1.0)
	self.phase_mod_tx = analog.phase_modulator_fc(self._up_modulation_index)
	self.tx_attenuator = blocks.multiply_const_cc((0.1+0.0j))

	#Add in bit recorder if needed
	if self.options.bitlog:
		self.bit_slicer = digital.binary_slicer_fb()
		self.bit_recorder = blocks.file_sink(1, "bitstream_recording.out")


	self.setDownCodingMethod(self._coding_method)
	self.setUpCodingMethod("None")
	self.setUpSubcarrier(self._up_subcarrier)
	self.setDownBitrate(self._down_bitrate)
	self.setUpBitrate(self._up_bitrate)
	self.setDownModulationIndex(self._modulation_index)
	self.setUpModulationIndex(self._up_modulation_index)
	self.setDownConvEn(self._down_conv_en)
	self.setUpConvEn(self._up_conv_en)
	self.setUpIdleSequence(self._up_idle_sequence)
	self.setDownRandomizerEn(self._down_randomizer_en)
	self.setDownManchesterEn(self._down_manchester_en)

	#Connection to outside world
	self.socket_pdu = blocks.socket_pdu("TCP_SERVER", "127.0.0.1", "12902", 10000)
	self.sdrp_interpreter = sdrp.sdrp_packet_interpreter()
	self.msg_connect(self.tm_framer, "tm_frame_out", self.sdrp_interpreter, "sdrp_pdu_in")
	self.msg_connect(self.sdrp_interpreter, "socket_pdu_out", self.socket_pdu, "pdus")
	self.msg_connect(self.socket_pdu, "pdus", self.sdrp_interpreter, "socket_pdu_in")
	self.msg_connect(self.sdrp_interpreter,"sdrp_pdu_out", self.pkt_gen, "ccsds_tx_msg_in")

	if options.test == False and options.fromfile == False and options.frombitlog == False:
		_threading.Thread(target=self.watchRef).start()

	self.initialized = True
	print "DS-SDR Initialized"
コード例 #12
0
    def __init__(self,
                 subdev="A:0",
                 frequency=216928000,
                 ant="TX/RX",
                 gain=10,
                 enable_filter=0,
                 rate=3.2e6,
                 devid="type=b100"):
        grc_wxgui.top_block_gui.__init__(
            self, title="DAB VHF Baseband Player for UHD (USRP)")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Parameters
        ##################################################
        self.subdev = subdev
        self.frequency = frequency
        self.ant = ant
        self.gain = gain
        self.enable_filter = enable_filter
        self.rate = rate
        self.devid = devid

        ##################################################
        # Variables
        ##################################################
        self.transition0 = transition0 = 150000
        self.switch2 = switch2 = 1
        self.switch1 = switch1 = enable_filter
        self.switch0 = switch0 = False
        self.samp_rate = samp_rate = int(rate)
        self.gain0 = gain0 = gain
        self.frequency0 = frequency0 = frequency
        self.dgain = dgain = 1.0 / 32768
        self.cutoff0 = cutoff0 = 810000

        ##################################################
        # Blocks
        ##################################################
        _transition0_sizer = wx.BoxSizer(wx.VERTICAL)
        self._transition0_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_transition0_sizer,
            value=self.transition0,
            callback=self.set_transition0,
            label="Transition frequency",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._transition0_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_transition0_sizer,
            value=self.transition0,
            callback=self.set_transition0,
            minimum=100,
            maximum=1000000,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_transition0_sizer, 6, 0, 1, 20)
        self._switch2_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.switch2,
            callback=self.set_switch2,
            label="Spectrum display mute",
            true=1,
            false=0,
        )
        self.GridAdd(self._switch2_check_box, 3, 0, 1, 1)
        self._switch1_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.switch1,
            callback=self.set_switch1,
            label="Filter",
            true=1,
            false=0,
        )
        self.GridAdd(self._switch1_check_box, 4, 0, 1, 1)
        self._switch0_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.switch0,
            callback=self.set_switch0,
            label="Clean carrier (Modulator Off)",
            true=1.0,
            false=0,
        )
        self.GridAdd(self._switch0_check_box, 2, 0, 1, 1)
        _gain0_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain0_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_gain0_sizer,
            value=self.gain0,
            callback=self.set_gain0,
            label="Gain",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._gain0_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_gain0_sizer,
            value=self.gain0,
            callback=self.set_gain0,
            minimum=0,
            maximum=20,
            num_steps=40,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_gain0_sizer, 1, 0, 1, 20)
        self._frequency0_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.frequency0,
            callback=self.set_frequency0,
            label="Channel frequency",
            choices=[
                174928000, 176640000, 178352000, 180064000, 181936000,
                183648000, 185360000, 187072000, 188928000, 190640000,
                192352000, 194064000, 195936000, 197648000, 199360000,
                201072000, 202928000, 204640000, 206352000, 208064000,
                209936000, 211648000, 213360000, 215072000, 216928000,
                218640000, 220352000, 222064000, 223936000, 225648000,
                227360000, 229072000, 230784000, 232496000, 234208000,
                235776000, 237488000, 239200000
            ],
            labels=[
                "5A", "5B", "5C", "5D", "6A", "6B", "6C", "6D", "7A", "7B",
                "7C", "7D", "8A", "8B", "8C", "8D", "9A", "9B", "9C", "9D",
                "10A", "10B", "10C", "10D", "11A", "11B", "11C", "11D", "12A",
                "12B", "12C", "12D", "13A", "13B", "13C", "13D", "13E", "13F"
            ],
        )
        self.GridAdd(self._frequency0_chooser, 0, 0, 1, 1)
        _dgain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._dgain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_dgain_sizer,
            value=self.dgain,
            callback=self.set_dgain,
            label="Digital Gain",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._dgain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_dgain_sizer,
            value=self.dgain,
            callback=self.set_dgain,
            minimum=0,
            maximum=1.0 / 10000,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_dgain_sizer, 7, 0, 1, 20)
        _cutoff0_sizer = wx.BoxSizer(wx.VERTICAL)
        self._cutoff0_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_cutoff0_sizer,
            value=self.cutoff0,
            callback=self.set_cutoff0,
            label="Cutoff Frequency",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._cutoff0_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_cutoff0_sizer,
            value=self.cutoff0,
            callback=self.set_cutoff0,
            minimum=1,
            maximum=1500000,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_cutoff0_sizer, 5, 0, 1, 20)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=0,
            y_per_div=5,
            y_divs=15,
            ref_level=60,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=5,
            average=True,
            avg_alpha=None,
            title="FFT Plot",
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            device_addr=devid,
            stream_args=uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_subdev_spec(subdev, 0)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(frequency0, 0)
        self.uhd_usrp_sink_0.set_gain(gain0, 0)
        self.uhd_usrp_sink_0.set_antenna(ant, 0)
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, cutoff0, transition0,
                            firdes.WIN_HAMMING, 6.76))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((dgain, ))
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1, "/dev/stdin", False)
        self.blks2_valve_1_0 = grc_blks2.valve(item_size=gr.sizeof_gr_complex *
                                               1,
                                               open=bool(switch0))
        self.blks2_valve_1 = grc_blks2.valve(item_size=gr.sizeof_gr_complex *
                                             1,
                                             open=bool(switch2))
        self.blks2_selector_1 = grc_blks2.selector(
            item_size=gr.sizeof_gr_complex * 1,
            num_inputs=2,
            num_outputs=1,
            input_index=switch1,
            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=switch1,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blks2_valve_1, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.blks2_selector_1, 0), (self.blks2_valve_1, 0))
        self.connect((self.low_pass_filter_0, 0), (self.blks2_selector_1, 1))
        self.connect((self.blks2_selector_0, 0), (self.blks2_selector_1, 0))
        self.connect((self.blks2_selector_0, 1), (self.low_pass_filter_0, 0))
        self.connect((self.blks2_selector_1, 0), (self.blks2_valve_1_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blks2_selector_0, 0))
        self.connect((self.blks2_valve_1_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.uhd_usrp_sink_0, 0))
コード例 #13
0
    def __init__(
            self,
            decim=50,
            satellite='Meteor-M-N1',
            frames_file=os.environ['HOME'] + '/MN1_hrpt_frames.hmf',
            baseband_file="/home/martin/GNURadioData/hrpt/baseband/HRPT_Meteor-M-N1_2011-02-27_09-30-46_UTC_U2_d50.sam",
            symb_rate=600 * 1109,
            clock_alpha=0.050,
            pll_alpha=0.05,
            deframer_outsync_frames=100,
            deframer_insync_frames=3,
            deframer_sync_check=False):
        grc_wxgui.top_block_gui.__init__(
            self, title="Meteor M-N1 HRPT Receiver from baseband file")
        _icon_path = "/home/martin/.local/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Parameters
        ##################################################
        self.decim = decim
        self.satellite = satellite
        self.frames_file = frames_file
        self.baseband_file = baseband_file
        self.symb_rate = symb_rate
        self.clock_alpha = clock_alpha
        self.pll_alpha = pll_alpha
        self.deframer_outsync_frames = deframer_outsync_frames
        self.deframer_insync_frames = deframer_insync_frames
        self.deframer_sync_check = deframer_sync_check

        ##################################################
        # Variables
        ##################################################
        self.decim_tb = decim_tb = decim
        self.symb_rate_tb = symb_rate_tb = symb_rate
        self.samp_rate = samp_rate = 100e6 / decim_tb
        self.sps = sps = samp_rate / symb_rate_tb
        self.v = v = True
        self.satellite_text = satellite_text = satellite
        self.samp_rate_st = samp_rate_st = samp_rate
        self.pll_alpha_sl = pll_alpha_sl = pll_alpha
        self.max_clock_offset = max_clock_offset = 0.1
        self.max_carrier_offset = max_carrier_offset = 2 * math.pi * 100e3 / samp_rate
        self.hs = hs = int(sps / 2.0)
        self.frames_file_text_inf = frames_file_text_inf = frames_file
        self.deframer_sync_after_text = deframer_sync_after_text = deframer_insync_frames
        self.deframer_nosync_after_text = deframer_nosync_after_text = deframer_outsync_frames
        self.deframer_check_sync_text = deframer_check_sync_text = deframer_sync_check
        self.datetime_text = datetime_text = strftime("%A, %B %d %Y %H:%M:%S",
                                                      localtime())
        self.clock_alpha_sl = clock_alpha_sl = clock_alpha
        self.baseband_file_text_inf = baseband_file_text_inf = baseband_file

        ##################################################
        # Blocks
        ##################################################
        self.rx_ntb = self.rx_ntb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Input baseband")
        self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb),
                            "PLL demodulator and Clock sync")
        self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Deframer")
        self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Output")
        self.Add(self.rx_ntb)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
            self.GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=gr.gr_TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink1 = fftsink2.fft_sink_c(
            self.rx_ntb.GetPage(0).GetWin(),
            baseband_freq=0,
            y_per_div=5,
            y_divs=10,
            ref_level=50,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=30,
            average=True,
            avg_alpha=0.1,
            title="Not filtered spectrum",
            peak_hold=False,
        )
        self.rx_ntb.GetPage(0).Add(self.wxgui_fftsink1.win)
        self._v_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.v,
            callback=self.set_v,
            label="Open",
            true=True,
            false=False,
        )
        self.Add(self._v_check_box)
        self._symb_rate_tb_text_box = forms.text_box(
            parent=self.rx_ntb.GetPage(1).GetWin(),
            value=self.symb_rate_tb,
            callback=self.set_symb_rate_tb,
            label="Symbol rate",
            converter=forms.int_converter(),
        )
        self.rx_ntb.GetPage(1).GridAdd(self._symb_rate_tb_text_box, 2, 1, 1, 1)
        self._satellite_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(0).GetWin(),
            value=self.satellite_text,
            callback=self.set_satellite_text,
            label="Sat ",
            converter=forms.str_converter(),
        )
        self.rx_ntb.GetPage(0).GridAdd(self._satellite_text_static_text, 1, 0,
                                       1, 1)
        self._samp_rate_st_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(0).GetWin(),
            value=self.samp_rate_st,
            callback=self.set_samp_rate_st,
            label="Sample rate",
            converter=forms.float_converter(),
        )
        self.rx_ntb.GetPage(0).GridAdd(self._samp_rate_st_static_text, 1, 4, 1,
                                       1)
        self.poesweather_meteor_cadu_deframer_0 = poesweather.meteor_cadu_deframer(
            deframer_sync_check, 256, deframer_insync_frames,
            deframer_outsync_frames)
        _pll_alpha_sl_sizer = wx.BoxSizer(wx.VERTICAL)
        self._pll_alpha_sl_text_box = forms.text_box(
            parent=self.rx_ntb.GetPage(1).GetWin(),
            sizer=_pll_alpha_sl_sizer,
            value=self.pll_alpha_sl,
            callback=self.set_pll_alpha_sl,
            label="PLL Alpha",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._pll_alpha_sl_slider = forms.slider(
            parent=self.rx_ntb.GetPage(1).GetWin(),
            sizer=_pll_alpha_sl_sizer,
            value=self.pll_alpha_sl,
            callback=self.set_pll_alpha_sl,
            minimum=0.001,
            maximum=0.1,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.rx_ntb.GetPage(1).GridAdd(_pll_alpha_sl_sizer, 1, 0, 1, 1)
        self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2 / 4.0,
                                    max_carrier_offset)
        self.gr_throttle_0 = gr.throttle(gr.sizeof_short * 1, samp_rate * 10)
        self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((-1, ))
        self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0 / hs, 4000)
        self.gr_file_source_0_0 = gr.file_source(
            gr.sizeof_short * 1,
            "/home/martin/hrpt/baseband/METEOR-M-1/2011/07/24/METEOR-M-1_2011-07-24T113448_U2d50.sam",
            False)
        self.gr_file_sink_0_0_0 = gr.file_sink(gr.sizeof_char * 1,
                                               "frames.mn1")
        self.gr_file_sink_0_0_0.set_unbuffered(False)
        self.gr_clock_recovery_mm_xx_0 = gr.clock_recovery_mm_ff(
            sps / 2.0, clock_alpha**2 / 4.0, 0.5, clock_alpha,
            max_clock_offset)
        self.gr_binary_slicer_fb_0 = gr.binary_slicer_fb()
        self.gr_agc_xx_0_0 = gr.agc_cc(10e-6, 1, 1.0 / 32767.0, 1.0)
        self._frames_file_text_inf_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(3).GetWin(),
            value=self.frames_file_text_inf,
            callback=self.set_frames_file_text_inf,
            label="Frames filename",
            converter=forms.str_converter(),
        )
        self.rx_ntb.GetPage(3).GridAdd(self._frames_file_text_inf_static_text,
                                       3, 0, 1, 1)
        self._deframer_sync_after_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(2).GetWin(),
            value=self.deframer_sync_after_text,
            callback=self.set_deframer_sync_after_text,
            label="Deframe sync after",
            converter=forms.float_converter(),
        )
        self.rx_ntb.GetPage(2).GridAdd(
            self._deframer_sync_after_text_static_text, 3, 0, 1, 1)
        self._deframer_nosync_after_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(2).GetWin(),
            value=self.deframer_nosync_after_text,
            callback=self.set_deframer_nosync_after_text,
            label="Deframer out of sync after",
            converter=forms.float_converter(),
        )
        self.rx_ntb.GetPage(2).GridAdd(
            self._deframer_nosync_after_text_static_text, 4, 0, 1, 1)
        self._deframer_check_sync_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(2).GetWin(),
            value=self.deframer_check_sync_text,
            callback=self.set_deframer_check_sync_text,
            label="Deframer check sync enable",
            converter=forms.str_converter(),
        )
        self.rx_ntb.GetPage(2).GridAdd(
            self._deframer_check_sync_text_static_text, 2, 0, 1, 1)
        self._decim_tb_text_box = forms.text_box(
            parent=self.rx_ntb.GetPage(0).GetWin(),
            value=self.decim_tb,
            callback=self.set_decim_tb,
            label="Decimation",
            converter=forms.int_converter(),
        )
        self.rx_ntb.GetPage(0).GridAdd(self._decim_tb_text_box, 1, 3, 1, 1)
        self._datetime_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(3).GetWin(),
            value=self.datetime_text,
            callback=self.set_datetime_text,
            label="Local time of aquisition start",
            converter=forms.str_converter(),
        )
        self.rx_ntb.GetPage(3).GridAdd(self._datetime_text_static_text, 1, 0,
                                       1, 1)
        self.cs2cf = gr.interleaved_short_to_complex()
        _clock_alpha_sl_sizer = wx.BoxSizer(wx.VERTICAL)
        self._clock_alpha_sl_text_box = forms.text_box(
            parent=self.rx_ntb.GetPage(1).GetWin(),
            sizer=_clock_alpha_sl_sizer,
            value=self.clock_alpha_sl,
            callback=self.set_clock_alpha_sl,
            label="Clock alpha",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._clock_alpha_sl_slider = forms.slider(
            parent=self.rx_ntb.GetPage(1).GetWin(),
            sizer=_clock_alpha_sl_sizer,
            value=self.clock_alpha_sl,
            callback=self.set_clock_alpha_sl,
            minimum=0.001,
            maximum=0.1,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.rx_ntb.GetPage(1).GridAdd(_clock_alpha_sl_sizer, 1, 1, 1, 1)
        self._baseband_file_text_inf_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(3).GetWin(),
            value=self.baseband_file_text_inf,
            callback=self.set_baseband_file_text_inf,
            label="Baseband filename",
            converter=forms.str_converter(),
        )
        self.rx_ntb.GetPage(3).GridAdd(
            self._baseband_file_text_inf_static_text, 4, 0, 1, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.gr_throttle_0, 0), (self.cs2cf, 0))
        self.connect((self.pll, 0), (self.gr_moving_average_xx_0, 0))
        self.connect((self.gr_moving_average_xx_0, 0),
                     (self.gr_clock_recovery_mm_xx_0, 0))
        self.connect((self.cs2cf, 0), (self.gr_agc_xx_0_0, 0))
        self.connect((self.gr_agc_xx_0_0, 0), (self.pll, 0))
        self.connect((self.cs2cf, 0), (self.wxgui_fftsink1, 0))
        self.connect((self.gr_multiply_const_vxx_0, 0),
                     (self.gr_binary_slicer_fb_0, 0))
        self.connect((self.gr_clock_recovery_mm_xx_0, 0),
                     (self.gr_multiply_const_vxx_0, 0))
        self.connect((self.poesweather_meteor_cadu_deframer_0, 0),
                     (self.gr_file_sink_0_0_0, 0))
        self.connect((self.gr_binary_slicer_fb_0, 0),
                     (self.poesweather_meteor_cadu_deframer_0, 0))
        self.connect((self.gr_file_source_0_0, 0), (self.gr_throttle_0, 0))
        self.connect((self.gr_clock_recovery_mm_xx_0, 0),
                     (self.wxgui_scopesink2_0, 0))
コード例 #14
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "C:\Program Files\GNURadio-3.7\share\icons\hicolor\scalable/apps\gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.freq_tune = freq_tune = 0
        self.band_select = band_select = 95e6
        self.transm_freq = transm_freq = band_select + freq_tune
        self.samp_rate = samp_rate = 44000
        self.rf_samp_rate = rf_samp_rate = 2400000
        self.rf_gain = rf_gain = False

        ##################################################
        # Blocks
        ##################################################
        self._rf_gain_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.rf_gain,
            callback=self.set_rf_gain,
            label='rf_gain',
            true=14,
            false=0,
        )
        self.Add(self._rf_gain_check_box)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=transm_freq,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=rf_samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='FFT Plot',
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
            interpolation=rf_samp_rate,
            decimation=2 * samp_rate,
            taps=None,
            fractional_bw=0.4,
        )
        self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " +
                                           'hackrf=2e12c3')
        self.osmosdr_sink_0.set_sample_rate(rf_samp_rate)
        self.osmosdr_sink_0.set_center_freq(transm_freq, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(rf_gain, 0)
        self.osmosdr_sink_0.set_if_gain(20, 0)
        self.osmosdr_sink_0.set_bb_gain(20, 0)
        self.osmosdr_sink_0.set_antenna('', 0)
        self.osmosdr_sink_0.set_bandwidth(0, 0)

        _freq_tune_sizer = wx.BoxSizer(wx.VERTICAL)
        self._freq_tune_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_freq_tune_sizer,
            value=self.freq_tune,
            callback=self.set_freq_tune,
            label='FREQ',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._freq_tune_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_freq_tune_sizer,
            value=self.freq_tune,
            callback=self.set_freq_tune,
            minimum=-10e6,
            maximum=10e6,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_freq_tune_sizer)
        self.blocks_wavfile_source_0 = blocks.wavfile_source(
            'C:\\Users\\andro\\Downloads\\9bb7baf38e7564.wav', True)
        self._band_select_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.band_select,
            callback=self.set_band_select,
            label='BAND',
            choices=[95e6, 130e6, 433e6],
            labels=[],
        )
        self.Add(self._band_select_chooser)
        self.analog_wfm_tx_0 = analog.wfm_tx(
            audio_rate=samp_rate,
            quad_rate=2 * samp_rate,
            tau=75e-6,
            max_dev=75e3,
            fh=-1.0,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_wfm_tx_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.analog_wfm_tx_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.osmosdr_sink_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.wxgui_fftsink2_0, 0))
コード例 #15
0
ファイル: top_block.py プロジェクト: masterCopipaster/diplom
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "C:\Program Files\GNURadio-3.7\share\icons\hicolor\scalable/apps\gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000
        self.rf_samp_rate = rf_samp_rate = 2048000
        self.rf_gain = rf_gain = 0
        self.freq = freq = 434040000
        self.base = base = 0x9F78B0
        self.D = D = 0
        self.C = C = 0
        self.B = B = 0
        self.A = A = 0

        ##################################################
        # Blocks
        ##################################################
        self._rf_gain_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.rf_gain,
        	callback=self.set_rf_gain,
        	label='rf_gain',
        	true=14,
        	false=0,
        )
        self.Add(self._rf_gain_check_box)
        self._freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.freq,
        	callback=self.set_freq,
        	label='Freq',
        	converter=forms.float_converter(),
        )
        self.Add(self._freq_text_box)
        self._D_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.D,
        	callback=self.set_D,
        	label='D',
        	true=8,
        	false=0,
        )
        self.Add(self._D_check_box)
        self._C_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.C,
        	callback=self.set_C,
        	label='C',
        	true=4,
        	false=0,
        )
        self.Add(self._C_check_box)
        self._B_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.B,
        	callback=self.set_B,
        	label='B',
        	true=2,
        	false=0,
        )
        self.Add(self._B_check_box)
        self._A_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.A,
        	callback=self.set_A,
        	label='A',
        	true=1,
        	false=0,
        )
        self.Add(self._A_check_box)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
        	self.GetWin(),
        	title='Scope Plot',
        	sample_rate=samp_rate,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label='Counts',
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=rf_samp_rate,
                decimation=samp_rate,
                taps=None,
                fractional_bw=None,
        )
        self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + 'hackrf=2e12c3,buffers=2' )
        self.osmosdr_sink_0.set_sample_rate(rf_samp_rate)
        self.osmosdr_sink_0.set_center_freq(freq, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(rf_gain, 0)
        self.osmosdr_sink_0.set_if_gain(20, 0)
        self.osmosdr_sink_0.set_bb_gain(20, 0)
        self.osmosdr_sink_0.set_antenna('', 0)
        self.osmosdr_sink_0.set_bandwidth(0, 0)

        self.epy_block_0 = epy_block_0.blk(sample_rate=samp_rate, short_impulse_len=0.0003, long_impulse_len=0.0011, packet_separator_len=0.005, packet_len=24, data=A + B + C + D + base)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.epy_block_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.epy_block_0, 0), (self.wxgui_scopesink2_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.osmosdr_sink_0, 0))
コード例 #16
0
	def __init__(self, freq=1698e6, rate=2e6, frames_file=os.environ['HOME'] + '/data/noaa/frames/NOAA-XX.hrpt', rtlsdr="rtl=0", ifgain=20, satellite='NOAA-XX', sync_check=False, rfgain=40):
		grc_wxgui.top_block_gui.__init__(self, title="Enhanced NOAA HRPT Receiver using USB DVB-T Dongles")
		_icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
		self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

		##################################################
		# Parameters
		##################################################
		self.freq = freq
		self.rate = rate
		self.frames_file = frames_file
		self.rtlsdr = rtlsdr
		self.ifgain = ifgain
		self.satellite = satellite
		self.sync_check = sync_check
		self.rfgain = rfgain

		##################################################
		# Variables
		##################################################
		self.sym_rate = sym_rate = 600*1109
		self.samp_rate = samp_rate = rate
		self.config_filename = config_filename = os.environ['HOME']+'/.gnuradio/rtlsdr_noaa_hrpt.conf'
		self.sps = sps = samp_rate/sym_rate
		self._saved_pll_alpha_config = ConfigParser.ConfigParser()
		self._saved_pll_alpha_config.read(config_filename)
		try: saved_pll_alpha = self._saved_pll_alpha_config.getfloat(satellite, 'pll_alpha')
		except: saved_pll_alpha = 0.005
		self.saved_pll_alpha = saved_pll_alpha
		self._saved_clock_alpha_config = ConfigParser.ConfigParser()
		self._saved_clock_alpha_config.read(config_filename)
		try: saved_clock_alpha = self._saved_clock_alpha_config.getfloat(satellite, 'clock_alpha')
		except: saved_clock_alpha = 0.001
		self.saved_clock_alpha = saved_clock_alpha
		self.sync_check_cb = sync_check_cb = sync_check
		self._saved_rf_gain_config = ConfigParser.ConfigParser()
		self._saved_rf_gain_config.read(config_filename)
		try: saved_rf_gain = self._saved_rf_gain_config.getfloat(satellite, 'rf-gain')
		except: saved_rf_gain = rfgain
		self.saved_rf_gain = saved_rf_gain
		self._saved_if_gain_config = ConfigParser.ConfigParser()
		self._saved_if_gain_config.read(config_filename)
		try: saved_if_gain = self._saved_if_gain_config.getfloat(satellite, 'if-gain')
		except: saved_if_gain = ifgain
		self.saved_if_gain = saved_if_gain
		self.satellite_text = satellite_text = satellite
		self.sample_rate_text = sample_rate_text = samp_rate
		self.rf_gain_slider = rf_gain_slider = rfgain
		self.rate_tb = rate_tb = rate
		self.pll_alpha = pll_alpha = saved_pll_alpha
		self.max_clock_offset = max_clock_offset = 0.1
		self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/samp_rate
		self.if_gain_slider = if_gain_slider = ifgain
		self.hs = hs = int(sps/2.0)
		self.freq_tb = freq_tb = freq
		self.frames_outfile_text = frames_outfile_text = frames_file
		self.datetime_text = datetime_text = strftime("%A, %B %d %Y %H:%M:%S", localtime())
		self.clock_alpha = clock_alpha = saved_clock_alpha

		##################################################
		# Blocks
		##################################################
		_rf_gain_slider_sizer = wx.BoxSizer(wx.VERTICAL)
		self._rf_gain_slider_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_rf_gain_slider_sizer,
			value=self.rf_gain_slider,
			callback=self.set_rf_gain_slider,
			label="RF Gain",
			converter=forms.int_converter(),
			proportion=0,
		)
		self._rf_gain_slider_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_rf_gain_slider_sizer,
			value=self.rf_gain_slider,
			callback=self.set_rf_gain_slider,
			minimum=0,
			maximum=100,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=int,
			proportion=1,
		)
		self.GridAdd(_rf_gain_slider_sizer, 2, 0, 1, 1)
		_if_gain_slider_sizer = wx.BoxSizer(wx.VERTICAL)
		self._if_gain_slider_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_if_gain_slider_sizer,
			value=self.if_gain_slider,
			callback=self.set_if_gain_slider,
			label="IF Gain",
			converter=forms.int_converter(),
			proportion=0,
		)
		self._if_gain_slider_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_if_gain_slider_sizer,
			value=self.if_gain_slider,
			callback=self.set_if_gain_slider,
			minimum=0,
			maximum=100,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=int,
			proportion=1,
		)
		self.GridAdd(_if_gain_slider_sizer, 2, 1, 1, 1)
		self.displays = self.displays = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
		self.displays.AddPage(grc_wxgui.Panel(self.displays), "RX NOAA HRPT")
		self.displays.AddPage(grc_wxgui.Panel(self.displays), "Information")
		self.Add(self.displays)
		_clock_alpha_sizer = wx.BoxSizer(wx.VERTICAL)
		self._clock_alpha_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_clock_alpha_sizer,
			value=self.clock_alpha,
			callback=self.set_clock_alpha,
			label="Clock alpha",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._clock_alpha_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_clock_alpha_sizer,
			value=self.clock_alpha,
			callback=self.set_clock_alpha,
			minimum=0.001,
			maximum=0.1,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_clock_alpha_sizer, 2, 3, 1, 1)
		self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
			self.displays.GetPage(0).GetWin(),
			baseband_freq=0,
			y_per_div=5,
			y_divs=10,
			ref_level=-30,
			ref_scale=2.0,
			sample_rate=samp_rate,
			fft_size=512,
			fft_rate=5,
			average=True,
			avg_alpha=0.4,
			title="NOAA HRPT FFT Spectrum",
			peak_hold=False,
		)
		self.displays.GetPage(0).Add(self.wxgui_fftsink2_0.win)
		self._sync_check_cb_check_box = forms.check_box(
			parent=self.GetWin(),
			value=self.sync_check_cb,
			callback=self.set_sync_check_cb,
			label="Continuous sync check",
			true=True,
			false=False,
		)
		self.GridAdd(self._sync_check_cb_check_box, 1, 2, 1, 1)
		self._satellite_text_static_text = forms.static_text(
			parent=self.GetWin(),
			value=self.satellite_text,
			callback=self.set_satellite_text,
			label="Satellite",
			converter=forms.str_converter(),
		)
		self.GridAdd(self._satellite_text_static_text, 0, 1, 1, 1)
		self._sample_rate_text_static_text = forms.static_text(
			parent=self.displays.GetPage(1).GetWin(),
			value=self.sample_rate_text,
			callback=self.set_sample_rate_text,
			label="Sample rate",
			converter=forms.float_converter(),
		)
		self.displays.GetPage(1).GridAdd(self._sample_rate_text_static_text, 3, 0, 1, 1)
		self._rate_tb_text_box = forms.text_box(
			parent=self.GetWin(),
			value=self.rate_tb,
			callback=self.set_rate_tb,
			label="Sample rate",
			converter=forms.float_converter(),
		)
		self.GridAdd(self._rate_tb_text_box, 1, 0, 1, 1)
		self.poesweather_noaa_hrpt_deframer_0 = poesweather.noaa_hrpt_deframer(False)
		_pll_alpha_sizer = wx.BoxSizer(wx.VERTICAL)
		self._pll_alpha_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_pll_alpha_sizer,
			value=self.pll_alpha,
			callback=self.set_pll_alpha,
			label="PLL Alpha",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._pll_alpha_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_pll_alpha_sizer,
			value=self.pll_alpha,
			callback=self.set_pll_alpha,
			minimum=0.005,
			maximum=0.5,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_pll_alpha_sizer, 2, 2, 1, 1)
		self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset)
		self.osmosdr_source_c_0 = osmosdr.source_c( args="nchan=" + str(1) + " " + rtlsdr )
		self.osmosdr_source_c_0.set_sample_rate(samp_rate)
		self.osmosdr_source_c_0.set_center_freq(freq, 0)
		self.osmosdr_source_c_0.set_freq_corr(0, 0)
		self.osmosdr_source_c_0.set_iq_balance_mode(0, 0)
		self.osmosdr_source_c_0.set_gain_mode(0, 0)
		self.osmosdr_source_c_0.set_gain(rf_gain_slider, 0)
		self.osmosdr_source_c_0.set_if_gain(if_gain_slider, 0)
			
		self._freq_tb_text_box = forms.text_box(
			parent=self.GetWin(),
			value=self.freq_tb,
			callback=self.set_freq_tb,
			label="Frequency",
			converter=forms.float_converter(),
		)
		self.GridAdd(self._freq_tb_text_box, 1, 1, 1, 1)
		self._frames_outfile_text_static_text = forms.static_text(
			parent=self.displays.GetPage(1).GetWin(),
			value=self.frames_outfile_text,
			callback=self.set_frames_outfile_text,
			label="Frames filename",
			converter=forms.str_converter(),
		)
		self.displays.GetPage(1).GridAdd(self._frames_outfile_text_static_text, 4, 0, 1, 1)
		self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(sps/2.0, clock_alpha**2/4.0, 0.5, clock_alpha, max_clock_offset)
		self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
		self._datetime_text_static_text = forms.static_text(
			parent=self.displays.GetPage(1).GetWin(),
			value=self.datetime_text,
			callback=self.set_datetime_text,
			label="Acquisition start",
			converter=forms.str_converter(),
		)
		self.displays.GetPage(1).GridAdd(self._datetime_text_static_text, 2, 0, 1, 1)
		self.blocks_moving_average_xx_0 = blocks.moving_average_ff(hs, 1.0/hs, 4000)
		self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_short*1, frames_file)
		self.blocks_file_sink_0.set_unbuffered(False)
		self.analog_agc_xx_0 = analog.agc_cc(1e-5, 1.0, 1.0/32768.0, 1.0)

		##################################################
		# Connections
		##################################################
		self.connect((self.analog_agc_xx_0, 0), (self.pll, 0))
		self.connect((self.pll, 0), (self.blocks_moving_average_xx_0, 0))
		self.connect((self.blocks_moving_average_xx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))
		self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0))
		self.connect((self.poesweather_noaa_hrpt_deframer_0, 0), (self.blocks_file_sink_0, 0))
		self.connect((self.digital_binary_slicer_fb_0, 0), (self.poesweather_noaa_hrpt_deframer_0, 0))
		self.connect((self.osmosdr_source_c_0, 0), (self.wxgui_fftsink2_0, 0))
		self.connect((self.osmosdr_source_c_0, 0), (self.analog_agc_xx_0, 0))
コード例 #17
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.audio_rate = audio_rate = 48000
        self.usb_on = usb_on = True
        self.samp_rate = samp_rate = audio_rate * 40
        self.q_offset = q_offset = 0
        self.phase = phase = 0
        self.magnitude = magnitude = -0.1
        self.lsb_on = lsb_on = True
        self.i_offset = i_offset = 0
        self.center_freq = center_freq = 432125000

        ##################################################
        # Blocks
        ##################################################
        self._usb_on_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.usb_on,
            callback=self.set_usb_on,
            label='USB',
            true=True,
            false=False,
        )
        self.GridAdd(self._usb_on_check_box, 4, 4, 1, 1)
        self._lsb_on_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.lsb_on,
            callback=self.set_lsb_on,
            label='LSB',
            true=True,
            false=False,
        )
        self.GridAdd(self._lsb_on_check_box, 4, 3, 1, 1)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=center_freq,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=4096,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='FFT Plot',
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.rational_resampler_xxx_2 = filter.rational_resampler_ccc(
            interpolation=samp_rate,
            decimation=audio_rate,
            taps=None,
            fractional_bw=None,
        )
        _q_offset_sizer = wx.BoxSizer(wx.VERTICAL)
        self._q_offset_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_q_offset_sizer,
            value=self.q_offset,
            callback=self.set_q_offset,
            label='DC offset Q',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._q_offset_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_q_offset_sizer,
            value=self.q_offset,
            callback=self.set_q_offset,
            minimum=-0.1,
            maximum=0.1,
            num_steps=200,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_q_offset_sizer, 3, 0, 1, 7)
        _phase_sizer = wx.BoxSizer(wx.VERTICAL)
        self._phase_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_phase_sizer,
            value=self.phase,
            callback=self.set_phase,
            label='Phase correction',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._phase_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_phase_sizer,
            value=self.phase,
            callback=self.set_phase,
            minimum=-0.1,
            maximum=0.1,
            num_steps=200,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_phase_sizer, 0, 0, 1, 7)
        _magnitude_sizer = wx.BoxSizer(wx.VERTICAL)
        self._magnitude_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_magnitude_sizer,
            value=self.magnitude,
            callback=self.set_magnitude,
            label='Magnitude correction',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._magnitude_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_magnitude_sizer,
            value=self.magnitude,
            callback=self.set_magnitude,
            minimum=-0.1,
            maximum=0.1,
            num_steps=200,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_magnitude_sizer, 1, 0, 1, 7)
        _i_offset_sizer = wx.BoxSizer(wx.VERTICAL)
        self._i_offset_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_i_offset_sizer,
            value=self.i_offset,
            callback=self.set_i_offset,
            label='DC offset I',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._i_offset_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_i_offset_sizer,
            value=self.i_offset,
            callback=self.set_i_offset,
            minimum=-0.1,
            maximum=0.1,
            num_steps=200,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_i_offset_sizer, 2, 0, 1, 7)
        self.blocks_multiply_xx_4 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_3_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_3 = blocks.multiply_vcc(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_add_xx_1 = blocks.add_vcc(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.band_pass_filter_0_0 = filter.interp_fir_filter_ccc(
            1,
            firdes.complex_band_pass(1, audio_rate, -6000, -200, 200,
                                     firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0 = filter.interp_fir_filter_ccc(
            1,
            firdes.complex_band_pass(1, audio_rate, 200, 6000, 200,
                                     firdes.WIN_HAMMING, 6.76))
        self.analog_sig_source_x_4 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 0, 1, 0)
        self.analog_sig_source_x_3_0 = analog.sig_source_c(
            audio_rate, analog.GR_COS_WAVE, 11000, 1.8 if lsb_on else 0, 0)
        self.analog_sig_source_x_3 = analog.sig_source_c(
            audio_rate, analog.GR_COS_WAVE, 25000, 1.8 if usb_on else 0, 0)
        self.analog_sig_source_x_1_0 = analog.sig_source_c(
            samp_rate, analog.GR_SIN_WAVE, 5000, 5, 1.0472)
        self.analog_sig_source_x_1 = analog.sig_source_c(
            samp_rate, analog.GR_SIN_WAVE, 4000, 2, 0.7854)
        self.analog_sig_source_x_0_0 = analog.sig_source_c(
            samp_rate, analog.GR_SIN_WAVE, 3000, 3, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_SIN_WAVE, 2000, 1, 1.5708)
        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.analog_sig_source_x_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.analog_sig_source_x_1, 0),
                     (self.blocks_add_xx_0, 2))
        self.connect((self.analog_sig_source_x_1_0, 0),
                     (self.blocks_add_xx_0, 3))
        self.connect((self.analog_sig_source_x_3, 0),
                     (self.blocks_multiply_xx_3, 1))
        self.connect((self.analog_sig_source_x_3_0, 0),
                     (self.blocks_multiply_xx_3_0, 1))
        self.connect((self.analog_sig_source_x_4, 0),
                     (self.blocks_multiply_xx_4, 1))
        self.connect((self.band_pass_filter_0, 0),
                     (self.blocks_multiply_xx_3, 0))
        self.connect((self.band_pass_filter_0_0, 0),
                     (self.blocks_multiply_xx_3_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_add_xx_1, 0),
                     (self.rational_resampler_xxx_2, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.band_pass_filter_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.band_pass_filter_0_0, 0))
        self.connect((self.blocks_multiply_xx_3, 0), (self.blocks_add_xx_1, 1))
        self.connect((self.blocks_multiply_xx_3_0, 0),
                     (self.blocks_add_xx_1, 0))
        self.connect((self.blocks_multiply_xx_4, 0),
                     (self.wxgui_fftsink2_0, 0))
        self.connect((self.rational_resampler_xxx_2, 0),
                     (self.blocks_multiply_xx_4, 0))
コード例 #18
0
    def __init__(self,
                 freq=1698e6,
                 rate=2e6,
                 frames_file=os.environ['HOME'] +
                 '/data/noaa/frames/NOAA-XX.hrpt',
                 rtlsdr="rtl=0",
                 ifgain=20,
                 satellite='NOAA-XX',
                 sync_check=False,
                 rfgain=40):
        grc_wxgui.top_block_gui.__init__(
            self, title="Enhanced NOAA HRPT Receiver using USB DVB-T Dongles")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Parameters
        ##################################################
        self.freq = freq
        self.rate = rate
        self.frames_file = frames_file
        self.rtlsdr = rtlsdr
        self.ifgain = ifgain
        self.satellite = satellite
        self.sync_check = sync_check
        self.rfgain = rfgain

        ##################################################
        # Variables
        ##################################################
        self.sym_rate = sym_rate = 600 * 1109
        self.samp_rate = samp_rate = rate
        self.config_filename = config_filename = os.environ[
            'HOME'] + '/.gnuradio/rtlsdr_noaa_hrpt.conf'
        self.sps = sps = samp_rate / sym_rate
        self._saved_pll_alpha_config = ConfigParser.ConfigParser()
        self._saved_pll_alpha_config.read(config_filename)
        try:
            saved_pll_alpha = self._saved_pll_alpha_config.getfloat(
                satellite, 'pll_alpha')
        except:
            saved_pll_alpha = 0.005
        self.saved_pll_alpha = saved_pll_alpha
        self._saved_clock_alpha_config = ConfigParser.ConfigParser()
        self._saved_clock_alpha_config.read(config_filename)
        try:
            saved_clock_alpha = self._saved_clock_alpha_config.getfloat(
                satellite, 'clock_alpha')
        except:
            saved_clock_alpha = 0.001
        self.saved_clock_alpha = saved_clock_alpha
        self.sync_check_cb = sync_check_cb = sync_check
        self._saved_rf_gain_config = ConfigParser.ConfigParser()
        self._saved_rf_gain_config.read(config_filename)
        try:
            saved_rf_gain = self._saved_rf_gain_config.getfloat(
                satellite, 'rf-gain')
        except:
            saved_rf_gain = rfgain
        self.saved_rf_gain = saved_rf_gain
        self._saved_if_gain_config = ConfigParser.ConfigParser()
        self._saved_if_gain_config.read(config_filename)
        try:
            saved_if_gain = self._saved_if_gain_config.getfloat(
                satellite, 'if-gain')
        except:
            saved_if_gain = ifgain
        self.saved_if_gain = saved_if_gain
        self.satellite_text = satellite_text = satellite
        self.sample_rate_text = sample_rate_text = samp_rate
        self.rf_gain_slider = rf_gain_slider = rfgain
        self.rate_tb = rate_tb = rate
        self.pll_alpha = pll_alpha = saved_pll_alpha
        self.max_clock_offset = max_clock_offset = 0.1
        self.max_carrier_offset = max_carrier_offset = 2 * math.pi * 100e3 / samp_rate
        self.if_gain_slider = if_gain_slider = ifgain
        self.hs = hs = int(sps / 2.0)
        self.freq_tb = freq_tb = freq
        self.frames_outfile_text = frames_outfile_text = frames_file
        self.datetime_text = datetime_text = strftime("%A, %B %d %Y %H:%M:%S",
                                                      localtime())
        self.clock_alpha = clock_alpha = saved_clock_alpha

        ##################################################
        # Blocks
        ##################################################
        _rf_gain_slider_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rf_gain_slider_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rf_gain_slider_sizer,
            value=self.rf_gain_slider,
            callback=self.set_rf_gain_slider,
            label="RF Gain",
            converter=forms.int_converter(),
            proportion=0,
        )
        self._rf_gain_slider_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rf_gain_slider_sizer,
            value=self.rf_gain_slider,
            callback=self.set_rf_gain_slider,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.GridAdd(_rf_gain_slider_sizer, 2, 0, 1, 1)
        _if_gain_slider_sizer = wx.BoxSizer(wx.VERTICAL)
        self._if_gain_slider_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_if_gain_slider_sizer,
            value=self.if_gain_slider,
            callback=self.set_if_gain_slider,
            label="IF Gain",
            converter=forms.int_converter(),
            proportion=0,
        )
        self._if_gain_slider_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_if_gain_slider_sizer,
            value=self.if_gain_slider,
            callback=self.set_if_gain_slider,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.GridAdd(_if_gain_slider_sizer, 2, 1, 1, 1)
        self.displays = self.displays = wx.Notebook(self.GetWin(),
                                                    style=wx.NB_TOP)
        self.displays.AddPage(grc_wxgui.Panel(self.displays), "RX NOAA HRPT")
        self.displays.AddPage(grc_wxgui.Panel(self.displays), "Information")
        self.Add(self.displays)
        _clock_alpha_sizer = wx.BoxSizer(wx.VERTICAL)
        self._clock_alpha_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_clock_alpha_sizer,
            value=self.clock_alpha,
            callback=self.set_clock_alpha,
            label="Clock alpha",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._clock_alpha_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_clock_alpha_sizer,
            value=self.clock_alpha,
            callback=self.set_clock_alpha,
            minimum=0.001,
            maximum=0.1,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_clock_alpha_sizer, 2, 3, 1, 1)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.displays.GetPage(0).GetWin(),
            baseband_freq=0,
            y_per_div=5,
            y_divs=10,
            ref_level=-30,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=512,
            fft_rate=5,
            average=True,
            avg_alpha=0.4,
            title="NOAA HRPT FFT Spectrum",
            peak_hold=False,
        )
        self.displays.GetPage(0).Add(self.wxgui_fftsink2_0.win)
        self._sync_check_cb_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.sync_check_cb,
            callback=self.set_sync_check_cb,
            label="Continuous sync check",
            true=True,
            false=False,
        )
        self.GridAdd(self._sync_check_cb_check_box, 1, 2, 1, 1)
        self._satellite_text_static_text = forms.static_text(
            parent=self.GetWin(),
            value=self.satellite_text,
            callback=self.set_satellite_text,
            label="Satellite",
            converter=forms.str_converter(),
        )
        self.GridAdd(self._satellite_text_static_text, 0, 1, 1, 1)
        self._sample_rate_text_static_text = forms.static_text(
            parent=self.displays.GetPage(1).GetWin(),
            value=self.sample_rate_text,
            callback=self.set_sample_rate_text,
            label="Sample rate",
            converter=forms.float_converter(),
        )
        self.displays.GetPage(1).GridAdd(self._sample_rate_text_static_text, 3,
                                         0, 1, 1)
        self._rate_tb_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.rate_tb,
            callback=self.set_rate_tb,
            label="Sample rate",
            converter=forms.float_converter(),
        )
        self.GridAdd(self._rate_tb_text_box, 1, 0, 1, 1)
        self.poesweather_noaa_hrpt_deframer_0 = poesweather.noaa_hrpt_deframer(
            False)
        _pll_alpha_sizer = wx.BoxSizer(wx.VERTICAL)
        self._pll_alpha_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_pll_alpha_sizer,
            value=self.pll_alpha,
            callback=self.set_pll_alpha,
            label="PLL Alpha",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._pll_alpha_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_pll_alpha_sizer,
            value=self.pll_alpha,
            callback=self.set_pll_alpha,
            minimum=0.005,
            maximum=0.5,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_pll_alpha_sizer, 2, 2, 1, 1)
        self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2 / 4.0,
                                    max_carrier_offset)
        self.osmosdr_source_c_0 = osmosdr.source_c(args="nchan=" + str(1) +
                                                   " " + rtlsdr)
        self.osmosdr_source_c_0.set_sample_rate(samp_rate)
        self.osmosdr_source_c_0.set_center_freq(freq, 0)
        self.osmosdr_source_c_0.set_freq_corr(0, 0)
        self.osmosdr_source_c_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_c_0.set_gain_mode(0, 0)
        self.osmosdr_source_c_0.set_gain(rf_gain_slider, 0)
        self.osmosdr_source_c_0.set_if_gain(if_gain_slider, 0)

        self._freq_tb_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.freq_tb,
            callback=self.set_freq_tb,
            label="Frequency",
            converter=forms.float_converter(),
        )
        self.GridAdd(self._freq_tb_text_box, 1, 1, 1, 1)
        self._frames_outfile_text_static_text = forms.static_text(
            parent=self.displays.GetPage(1).GetWin(),
            value=self.frames_outfile_text,
            callback=self.set_frames_outfile_text,
            label="Frames filename",
            converter=forms.str_converter(),
        )
        self.displays.GetPage(1).GridAdd(self._frames_outfile_text_static_text,
                                         4, 0, 1, 1)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            sps / 2.0, clock_alpha**2 / 4.0, 0.5, clock_alpha,
            max_clock_offset)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self._datetime_text_static_text = forms.static_text(
            parent=self.displays.GetPage(1).GetWin(),
            value=self.datetime_text,
            callback=self.set_datetime_text,
            label="Acquisition start",
            converter=forms.str_converter(),
        )
        self.displays.GetPage(1).GridAdd(self._datetime_text_static_text, 2, 0,
                                         1, 1)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            hs, 1.0 / hs, 4000)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_short * 1,
                                                   frames_file)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.analog_agc_xx_0 = analog.agc_cc(1e-5, 1.0, 1.0 / 32768.0, 1.0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc_xx_0, 0), (self.pll, 0))
        self.connect((self.pll, 0), (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.poesweather_noaa_hrpt_deframer_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.poesweather_noaa_hrpt_deframer_0, 0))
        self.connect((self.osmosdr_source_c_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.osmosdr_source_c_0, 0), (self.analog_agc_xx_0, 0))
コード例 #19
0
ファイル: cp03a.py プロジェクト: mr0w1/cp
    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))    
コード例 #20
0
ファイル: simple_trx.py プロジェクト: c177pilot/oa
    def __init__(self,
                 antenna="TX/RX",
                 rx_gain=30,
                 vor_samp_rate=250e3,
                 com_freq_1=135.275e6,
                 gain=21,
                 vor_freq_1=115e6):
        grc_wxgui.top_block_gui.__init__(self, title="Simple Trx")

        ##################################################
        # Parameters
        ##################################################
        self.antenna = antenna
        self.rx_gain = rx_gain
        self.vor_samp_rate = vor_samp_rate
        self.com_freq_1 = com_freq_1
        self.gain = gain
        self.vor_freq_1 = vor_freq_1

        ##################################################
        # Variables
        ##################################################
        self.obs_decimation = obs_decimation = 25
        self.ils_decimation = ils_decimation = 50
        self.am_sample_rate = am_sample_rate = 12.5e3
        self.vor_volume_slider = vor_volume_slider = 5
        self.vor_ident = vor_ident = False
        self.vor_freq_entry_1 = vor_freq_entry_1 = vor_freq_1
        self.vor_center_freq_0 = vor_center_freq_0 = (117.95e6 -
                                                      108.00e6) / 2 + 117.95e6
        self.system_center_freq = system_center_freq = 133.9e6
        self.squelch_slider = squelch_slider = -85
        self.samp_rate = samp_rate = 250e3
        self.rxgain = rxgain = 15
        self.phase_correction = phase_correction = 5
        self.obs_sample_rate = obs_sample_rate = am_sample_rate / obs_decimation
        self.ils_sample_rate = ils_sample_rate = am_sample_rate / ils_decimation
        self.gain_slider = gain_slider = gain
        self.correction_gain = correction_gain = 0.8
        self.com_volume_slider = com_volume_slider = 1
        self.com_freq_entry_1 = com_freq_entry_1 = com_freq_1
        self.com_enable = com_enable = True
        self.audio_select = audio_select = 0
        self.audio_sample_rate = audio_sample_rate = 48e3
        self.am_decimation = am_decimation = 1

        ##################################################
        # Blocks
        ##################################################
        _vor_volume_slider_sizer = wx.BoxSizer(wx.VERTICAL)
        self._vor_volume_slider_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_vor_volume_slider_sizer,
            value=self.vor_volume_slider,
            callback=self.set_vor_volume_slider,
            label='vor_volume_slider',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._vor_volume_slider_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_vor_volume_slider_sizer,
            value=self.vor_volume_slider,
            callback=self.set_vor_volume_slider,
            minimum=0,
            maximum=10,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_vor_volume_slider_sizer, 1, 4, 1, 1)
        self._vor_ident_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.vor_ident,
            callback=self.set_vor_ident,
            label='vor_ident',
            true=1,
            false=0,
        )
        self.GridAdd(self._vor_ident_check_box, 0, 3, 1, 1)
        self._vor_freq_entry_1_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.vor_freq_entry_1,
            callback=self.set_vor_freq_entry_1,
            label='vor_freq_entry_1',
            converter=forms.float_converter(),
        )
        self.GridAdd(self._vor_freq_entry_1_text_box, 0, 1, 1, 1)
        self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(),
                                                        style=wx.NB_TOP)
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0),
                                "RF Analyzer")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0),
                                "Channel FFT")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0),
                                "Demod Audio FFT")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0),
                                "Ref and Phase Scope")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0),
                                "Manipulated Ref and Phase")
        self.Add(self.notebook_0)
        _com_volume_slider_sizer = wx.BoxSizer(wx.VERTICAL)
        self._com_volume_slider_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_com_volume_slider_sizer,
            value=self.com_volume_slider,
            callback=self.set_com_volume_slider,
            label='com_volume_slider',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._com_volume_slider_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_com_volume_slider_sizer,
            value=self.com_volume_slider,
            callback=self.set_com_volume_slider,
            minimum=0,
            maximum=10,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_com_volume_slider_sizer, 1, 5, 1, 1)
        self._com_freq_entry_1_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.com_freq_entry_1,
            callback=self.set_com_freq_entry_1,
            label='com_freq_entry_1',
            converter=forms.float_converter(),
        )
        self.GridAdd(self._com_freq_entry_1_text_box, 0, 0, 1, 1)
        self._com_enable_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.com_enable,
            callback=self.set_com_enable,
            label='com_enable',
            true=1,
            false=0,
        )
        self.GridAdd(self._com_enable_check_box, 2, 3, 1, 1)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
            self.notebook_0.GetPage(3).GetWin(),
            title="Scope Plot",
            sample_rate=12.5e3,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=2,
            trig_mode=gr.gr_TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.notebook_0.GetPage(3).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
            self.GetWin(),
            unit="Units",
            minval=-200,
            maxval=200,
            factor=1.0,
            decimal_places=10,
            ref_level=0,
            sample_rate=25e3 / 2000,
            number_rate=15,
            average=True,
            avg_alpha=0.02,
            label="Number Plot",
            peak_hold=False,
            show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_0.win)
        self.wxgui_fftsink2_0_1 = fftsink2.fft_sink_c(
            self.notebook_0.GetPage(0).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=25e3,
            fft_size=1024,
            fft_rate=5,
            average=False,
            avg_alpha=None,
            title="FFT Plot",
            peak_hold=False,
        )
        self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_0_1.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.notebook_0.GetPage(1).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=12.5e3,
            fft_size=1024,
            fft_rate=5,
            average=False,
            avg_alpha=None,
            title="FFT Plot",
            peak_hold=False,
        )
        self.notebook_0.GetPage(1).Add(self.wxgui_fftsink2_0.win)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            device_addr="",
            stream_args=uhd.stream_args(
                cpu_format="fc32",
                channels=range(2),
            ),
        )
        self.uhd_usrp_source_0.set_clock_source("internal", 0)
        self.uhd_usrp_source_0.set_subdev_spec("A:0 A:0", 0)
        self.uhd_usrp_source_0.set_samp_rate(vor_samp_rate)
        self.uhd_usrp_source_0.set_center_freq(
            uhd.tune_request(com_freq_entry_1,
                             rf_freq=system_center_freq,
                             rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_source_0.set_antenna("RX2", 0)
        self.uhd_usrp_source_0.set_center_freq(
            uhd.tune_request(vor_freq_entry_1,
                             rf_freq=system_center_freq,
                             rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 1)
        self.uhd_usrp_source_0.set_gain(rx_gain, 1)
        self.uhd_usrp_source_0.set_antenna("RX2", 1)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            device_addr="",
            stream_args=uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_samp_rate(250e3)
        self.uhd_usrp_sink_0.set_center_freq(com_freq_entry_1, 0)
        self.uhd_usrp_sink_0.set_gain(25, 0)
        self.uhd_usrp_sink_0.set_antenna("TX/RX", 0)
        _squelch_slider_sizer = wx.BoxSizer(wx.VERTICAL)
        self._squelch_slider_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_squelch_slider_sizer,
            value=self.squelch_slider,
            callback=self.set_squelch_slider,
            label='squelch_slider',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._squelch_slider_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_squelch_slider_sizer,
            value=self.squelch_slider,
            callback=self.set_squelch_slider,
            minimum=-100,
            maximum=0,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_squelch_slider_sizer, 1, 0, 1, 1)
        self.squelch = gr.pwr_squelch_cc(squelch_slider, 0.01, 20, False)
        self.openavionics_joystick_interface_0 = openavionics.joystick_interface(
        )
        self.openavionics_audio_ptt_0 = openavionics.audio_ptt()
        self.low_pass_filter_3_0 = filter.fir_filter_fff(
            5, firdes.low_pass(1, 25e3, 200, 50, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_3 = filter.fir_filter_fff(
            5, firdes.low_pass(1, 25e3, 200, 50, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_2 = filter.fir_filter_ccf(
            1, firdes.low_pass(1, 25e3, 3e3, 500, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_1 = filter.interp_fir_filter_fff(
            1, firdes.low_pass(1, 12.5e3, 3e3, 1e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            int(250e3 / 25e3),
            firdes.low_pass(1, vor_samp_rate, 11e3, 1e3, firdes.WIN_HAMMING,
                            6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            int(250e3 / 12.5e3),
            firdes.low_pass(1, vor_samp_rate, 10e3, 1e3, firdes.WIN_HAMMING,
                            6.76))
        self.gr_sig_source_x_0 = gr.sig_source_c(25e3, gr.GR_COS_WAVE, 9960, 1,
                                                 0)
        self.gr_quadrature_demod_cf_0 = gr.quadrature_demod_cf(1)
        self.gr_pwr_squelch_xx_0 = gr.pwr_squelch_ff(-50, 0.5, 1, False)
        self.gr_null_sink_0_0 = gr.null_sink(gr.sizeof_gr_complex * 1)
        self.gr_multiply_xx_0_0_1 = gr.multiply_vff(1)
        self.gr_multiply_xx_0_0_0_0 = gr.multiply_vcc(1)
        self.gr_multiply_xx_0 = gr.multiply_vcc(1)
        self.gr_float_to_complex_0_0_0 = gr.float_to_complex(1)
        self.gr_float_to_complex_0 = gr.float_to_complex(1)
        self.gr_agc2_xx_0_0 = gr.agc2_cc(1, 1, 0.75, 1.0, 0.0)
        self.gr_agc2_xx_0 = gr.agc2_cc(1, 1, 0.75, 1.0, 0.0)
        self.gr_add_xx_0_0_0 = gr.add_vff(1)
        _gain_slider_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_slider_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_gain_slider_sizer,
            value=self.gain_slider,
            callback=self.set_gain_slider,
            label='gain_slider',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._gain_slider_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_gain_slider_sizer,
            value=self.gain_slider,
            callback=self.set_gain_slider,
            minimum=0,
            maximum=30,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_gain_slider_sizer, 1, 1, 1, 1)
        self.fft_tone_to_angle_0 = fft_tone_to_angle(
            fft_bin=12,
            fft_size=2000,
        )
        self.const_source_x_0_1 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0,
                                                  0.450)
        self.const_source_x_0_0_1 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0,
                                                    0.550)
        self.const_source_x_0_0_0_0 = gr.sig_source_c(0, gr.GR_CONST_WAVE, 0,
                                                      0, 0.450)
        self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_float * 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (180.0 / 3.1415, ))
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.blks2_rational_resampler_xxx_2_0 = blks2.rational_resampler_fff(
            interpolation=250,
            decimation=48,
            taps=None,
            fractional_bw=None,
        )
        self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_fff(
            interpolation=480,
            decimation=125,
            taps=None,
            fractional_bw=None,
        )
        self.blks2_am_demod_cf_0_0 = blks2.am_demod_cf(
            channel_rate=25e3,
            audio_decim=am_decimation,
            audio_pass=11.5e3,
            audio_stop=12.250e3,
        )
        self.blks2_am_demod_cf_0 = blks2.am_demod_cf(
            channel_rate=am_sample_rate,
            audio_decim=am_decimation,
            audio_pass=3e3,
            audio_stop=4e3,
        )
        self.band_pass_filter_0 = gr.fir_filter_fff(
            2,
            firdes.band_pass(1, 25000, 980, 1150, 50, firdes.WIN_HAMMING,
                             6.76))
        self.audio_sink_0 = audio.sink(int(audio_sample_rate), "", True)
        self._audio_select_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.audio_select,
            callback=self.set_audio_select,
            label='audio_select',
            choices=[0, 1],
            labels=['AM Voice', 'VOR Subcarrier'],
        )
        self.GridAdd(self._audio_select_chooser, 0, 2, 1, 1)
        self.analog_sig_source_x_0_0 = analog.sig_source_f(
            48000, analog.GR_COS_WAVE, 1000, 1, 0)
        self.adsf_0 = blocks.multiply_const_vff(
            (com_enable * com_volume_slider, ))
        self.adsf = blocks.multiply_const_vff(
            (vor_ident * vor_volume_slider, ))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.gr_float_to_complex_0, 0),
                     (self.gr_multiply_xx_0, 0))
        self.connect((self.blks2_rational_resampler_xxx_1, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blks2_am_demod_cf_0, 0),
                     (self.low_pass_filter_1, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.uhd_usrp_source_0, 1), (self.gr_null_sink_0_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.squelch, 0))
        self.connect((self.squelch, 0), (self.gr_agc2_xx_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.gr_agc2_xx_0, 0), (self.blks2_am_demod_cf_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.wxgui_fftsink2_0_1, 0))
        self.connect((self.gr_agc2_xx_0_0, 0), (self.blks2_am_demod_cf_0_0, 0))
        self.connect((self.uhd_usrp_source_0, 1),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.blks2_am_demod_cf_0_0, 0),
                     (self.gr_float_to_complex_0, 0))
        self.connect((self.fft_tone_to_angle_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.wxgui_numbersink2_0, 0))
        self.connect((self.fft_tone_to_angle_0, 1),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.fft_tone_to_angle_0, 2),
                     (self.blocks_null_sink_1, 0))
        self.connect((self.low_pass_filter_0_0, 0), (self.gr_agc2_xx_0_0, 0))
        self.connect((self.gr_quadrature_demod_cf_0, 0),
                     (self.low_pass_filter_3, 0))
        self.connect((self.low_pass_filter_3, 0),
                     (self.fft_tone_to_angle_0, 0))
        self.connect((self.low_pass_filter_3_0, 0),
                     (self.fft_tone_to_angle_0, 1))
        self.connect((self.blks2_am_demod_cf_0_0, 0),
                     (self.low_pass_filter_3_0, 0))
        self.connect((self.blks2_am_demod_cf_0_0, 0),
                     (self.gr_float_to_complex_0, 1))
        self.connect((self.gr_multiply_xx_0, 0), (self.low_pass_filter_2, 0))
        self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 1))
        self.connect((self.low_pass_filter_2, 0),
                     (self.gr_quadrature_demod_cf_0, 0))
        self.connect((self.blks2_am_demod_cf_0_0, 0),
                     (self.band_pass_filter_0, 0))
        self.connect((self.adsf, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blks2_rational_resampler_xxx_1, 0))
        self.connect((self.adsf, 0), (self.wxgui_scopesink2_0, 1))
        self.connect((self.low_pass_filter_1, 0), (self.adsf_0, 0))
        self.connect((self.adsf_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.adsf_0, 0), (self.wxgui_scopesink2_0, 0))
        self.connect((self.band_pass_filter_0, 0),
                     (self.gr_pwr_squelch_xx_0, 0))
        self.connect((self.gr_pwr_squelch_xx_0, 0), (self.adsf, 0))
        self.connect((self.const_source_x_0_0_0_0, 0),
                     (self.gr_multiply_xx_0_0_0_0, 1))
        self.connect((self.gr_float_to_complex_0_0_0, 0),
                     (self.gr_multiply_xx_0_0_0_0, 0))
        self.connect((self.gr_add_xx_0_0_0, 0),
                     (self.gr_float_to_complex_0_0_0, 1))
        self.connect((self.gr_add_xx_0_0_0, 0),
                     (self.gr_float_to_complex_0_0_0, 0))
        self.connect((self.const_source_x_0_0_1, 0), (self.gr_add_xx_0_0_0, 1))
        self.connect((self.gr_multiply_xx_0_0_1, 0), (self.gr_add_xx_0_0_0, 0))
        self.connect((self.const_source_x_0_1, 0),
                     (self.gr_multiply_xx_0_0_1, 1))
        self.connect((self.gr_multiply_xx_0_0_0_0, 0),
                     (self.uhd_usrp_sink_0, 0))
        self.connect((self.blks2_rational_resampler_xxx_2_0, 0),
                     (self.openavionics_audio_ptt_0, 0))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blks2_rational_resampler_xxx_2_0, 0))
        self.connect((self.openavionics_audio_ptt_0, 0),
                     (self.gr_multiply_xx_0_0_1, 0))

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self.openavionics_joystick_interface_0, "out",
                         self.openavionics_audio_ptt_0, "in2")
コード例 #21
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        options = get_options()

        self.tune_corrector_callback = tune_corrector(self)
        self.synchronizer_callback = synchronizer(self)
        self.converter = blocks.vector_to_stream(gr.sizeof_float, 142)

        self.ifreq = options.frequency
        self.rfgain = options.gain

        self.src = osmosdr.source(options.args)

        # added by scateu @ 2014-1-9
        self.src.set_freq_corr(0, 0)
        self.src.set_dc_offset_mode(1, 0)
        self.src.set_iq_balance_mode(0, 0)
        self.src.set_gain_mode(0, 0)
        self.src.set_gain(14, 0)
        self.src.set_if_gain(58, 0)
        self.src.set_bb_gain(20, 0)
        self.src.set_antenna("", 0)
        self.src.set_bandwidth(0, 0)

        self.src.set_center_freq(self.ifreq)
        self.src.set_sample_rate(int(options.sample_rate))

        if self.rfgain is None:
            self.src.set_gain_mode(1)
            self.iagc = 1
            self.rfgain = 0
        else:
            self.iagc = 0
            self.src.set_gain_mode(0)
            self.src.set_gain(self.rfgain)

        # may differ from the requested rate
        sample_rate = self.src.get_sample_rate()
        sys.stderr.write("sample rate: %d\n" % (sample_rate))

        gsm_symb_rate = 1625000.0 / 6.0
        sps = sample_rate / gsm_symb_rate / 4
        out_sample_rate = gsm_symb_rate * 4

        self.offset = 0

        taps = firdes.low_pass(1.0, sample_rate, 145e3, 10e3, firdes.WIN_HANN)
        self.tuner = freq_xlating_fir_filter_ccf(1, taps, self.offset,
                                                 sample_rate)

        self.interpolator = fractional_interpolator_cc(0, sps)

        self.receiver = gsm.receiver_cf(self.tune_corrector_callback,
                                        self.synchronizer_callback, 4,
                                        options.key.replace(' ', '').lower(),
                                        options.configuration.upper())

        self.output = blocks.file_sink(gr.sizeof_float, options.output_file)

        self.connect(self.src, self.tuner, self.interpolator, self.receiver,
                     self.converter, self.output)

        def set_ifreq(ifreq):
            self.ifreq = ifreq
            self._ifreq_text_box.set_value(self.ifreq)
            self.src.set_center_freq(self.ifreq)

        self._ifreq_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.ifreq,
            callback=set_ifreq,
            label="Center Frequency",
            converter=forms.float_converter(),
        )
        self.Add(self._ifreq_text_box)

        def set_iagc(iagc):
            self.iagc = iagc
            self._agc_check_box.set_value(self.iagc)
            self.src.set_gain_mode(self.iagc, 0)
            self.src.set_gain(0 if self.iagc == 1 else self.rfgain, 0)

        self._agc_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.iagc,
            callback=set_iagc,
            label="Automatic Gain",
            true=1,
            false=0,
        )

        self.Add(self._agc_check_box)

        def set_rfgain(rfgain):
            self.rfgain = rfgain
            self._rfgain_slider.set_value(self.rfgain)
            self._rfgain_text_box.set_value(self.rfgain)
            self.src.set_gain(0 if self.iagc == 1 else self.rfgain, 0)

        _rfgain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rfgain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rfgain_sizer,
            value=self.rfgain,
            callback=set_rfgain,
            label="RF Gain",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rfgain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rfgain_sizer,
            value=self.rfgain,
            callback=set_rfgain,
            minimum=0,
            maximum=50,
            num_steps=200,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )

        self.Add(_rfgain_sizer)

        def fftsink2_callback(x, y):
            if abs(x / (sample_rate / 2)) > 0.9:
                set_ifreq(self.ifreq + x / 2)
            else:
                sys.stderr.write("coarse tuned to: %d Hz\n" % x)
                self.offset = -x
                self.tuner.set_center_freq(self.offset)

        self.scope = fftsink2.fft_sink_c(
            self.GetWin(),
            title="Wideband Spectrum (click to coarse tune)",
            fft_size=1024,
            sample_rate=sample_rate,
            ref_scale=2.0,
            ref_level=0,
            y_divs=10,
            fft_rate=10,
            average=False,
            avg_alpha=0.3)

        self.Add(self.scope.win)
        self.scope.set_callback(fftsink2_callback)

        self.connect(self.src, self.scope)

        def fftsink2_callback2(x, y):
            self.offset = self.offset - (x / 10)
            sys.stderr.write("fine tuned to: %d Hz\n" % self.offset)
            self.tuner.set_center_freq(self.offset)

        self.scope2 = fftsink2.fft_sink_c(
            self.GetWin(),
            title="Channel Spectrum (click to fine tune)",
            fft_size=1024,
            sample_rate=gsm_symb_rate * 4,
            ref_scale=2.0,
            ref_level=-20,
            y_divs=10,
            fft_rate=10,
            average=False,
            avg_alpha=0.3)

        self.Add(self.scope2.win)
        self.scope2.set_callback(fftsink2_callback2)

        self.connect(self.interpolator, self.scope2)
コード例 #22
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Multi Tx")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.audio_rate = audio_rate = 48000
        self.wpm = wpm = 15
        self.wbfm_on = wbfm_on = True
        self.usb_on = usb_on = True
        self.samp_rate = samp_rate = audio_rate * 40
        self.q_offset = q_offset = 0
        self.psk_on = psk_on = True
        self.phase = phase = 0
        self.nbfm_on = nbfm_on = True
        self.magnitude = magnitude = 0
        self.lsb_on = lsb_on = True
        self.i_offset = i_offset = 0
        self.gain = gain = 25
        self.cw_on = cw_on = True
        self.center_freq = center_freq = 441000000
        self.am_on = am_on = True

        ##################################################
        # Blocks
        ##################################################
        self._wbfm_on_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.wbfm_on,
            callback=self.set_wbfm_on,
            label="WBFM",
            true=True,
            false=False,
        )
        self.GridAdd(self._wbfm_on_check_box, 4, 1, 1, 1)
        self._usb_on_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.usb_on,
            callback=self.set_usb_on,
            label="USB",
            true=True,
            false=False,
        )
        self.GridAdd(self._usb_on_check_box, 4, 4, 1, 1)
        _q_offset_sizer = wx.BoxSizer(wx.VERTICAL)
        self._q_offset_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_q_offset_sizer,
            value=self.q_offset,
            callback=self.set_q_offset,
            label="DC offset Q",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._q_offset_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_q_offset_sizer,
            value=self.q_offset,
            callback=self.set_q_offset,
            minimum=-0.1,
            maximum=0.1,
            num_steps=200,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_q_offset_sizer, 3, 0, 1, 7)
        self._psk_on_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.psk_on,
            callback=self.set_psk_on,
            label="PSK31",
            true=True,
            false=False,
        )
        self.GridAdd(self._psk_on_check_box, 4, 6, 1, 1)
        _phase_sizer = wx.BoxSizer(wx.VERTICAL)
        self._phase_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_phase_sizer,
            value=self.phase,
            callback=self.set_phase,
            label="Phase correction",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._phase_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_phase_sizer,
            value=self.phase,
            callback=self.set_phase,
            minimum=-0.1,
            maximum=0.1,
            num_steps=200,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_phase_sizer, 0, 0, 1, 7)
        self._nbfm_on_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.nbfm_on,
            callback=self.set_nbfm_on,
            label="NBFM",
            true=True,
            false=False,
        )
        self.GridAdd(self._nbfm_on_check_box, 4, 0, 1, 1)
        _magnitude_sizer = wx.BoxSizer(wx.VERTICAL)
        self._magnitude_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_magnitude_sizer,
            value=self.magnitude,
            callback=self.set_magnitude,
            label="Magnitude correction",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._magnitude_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_magnitude_sizer,
            value=self.magnitude,
            callback=self.set_magnitude,
            minimum=-0.1,
            maximum=0.1,
            num_steps=200,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_magnitude_sizer, 1, 0, 1, 7)
        self._lsb_on_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.lsb_on,
            callback=self.set_lsb_on,
            label="LSB",
            true=True,
            false=False,
        )
        self.GridAdd(self._lsb_on_check_box, 4, 3, 1, 1)
        _i_offset_sizer = wx.BoxSizer(wx.VERTICAL)
        self._i_offset_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_i_offset_sizer,
            value=self.i_offset,
            callback=self.set_i_offset,
            label="DC offset I",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._i_offset_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_i_offset_sizer,
            value=self.i_offset,
            callback=self.set_i_offset,
            minimum=-0.1,
            maximum=0.1,
            num_steps=200,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_i_offset_sizer, 2, 0, 1, 7)
        self._cw_on_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.cw_on,
            callback=self.set_cw_on,
            label="CW",
            true=True,
            false=False,
        )
        self.GridAdd(self._cw_on_check_box, 4, 5, 1, 1)
        self._am_on_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.am_on,
            callback=self.set_am_on,
            label="AM",
            true=True,
            false=False,
        )
        self.GridAdd(self._am_on_check_box, 4, 2, 1, 1)
        self.root_raised_cosine_filter_1 = filter.fir_filter_ccf(
            1, firdes.root_raised_cosine(1, audio_rate, 5, 0.35, 200))
        self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(
            1, firdes.root_raised_cosine(1, audio_rate, 5, 0.35, 200))
        self.rational_resampler_xxx_3 = filter.rational_resampler_ccc(
            interpolation=192,
            decimation=1,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_2 = filter.rational_resampler_ccc(
            interpolation=samp_rate,
            decimation=audio_rate,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
            interpolation=samp_rate / audio_rate / 2,
            decimation=1,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=samp_rate / audio_rate / 4,
            decimation=1,
            taps=None,
            fractional_bw=None,
        )
        self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " + "")
        self.osmosdr_sink_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0.set_center_freq(center_freq, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(gain, 0)
        self.osmosdr_sink_0.set_if_gain(20, 0)
        self.osmosdr_sink_0.set_bb_gain(20, 0)
        self.osmosdr_sink_0.set_antenna("", 0)
        self.osmosdr_sink_0.set_bandwidth(0, 0)

        self.low_pass_filter_1 = filter.interp_fir_filter_ccf(
            1,
            firdes.low_pass(0.5, audio_rate, 5000, 400, firdes.WIN_HAMMING,
                            6.76))
        self.iqbalance_fix_cc_0 = iqbalance.fix_cc(magnitude, phase)
        self.digital_psk_mod_0 = digital.psk.psk_mod(
            constellation_points=2,
            mod_code="none",
            differential=True,
            samples_per_symbol=8,
            excess_bw=0.35,
            verbose=False,
            log=False,
        )
        self.digital_map_bb_0 = digital.map_bb(([1, 0]))
        self.blocks_wavfile_source_0 = blocks.wavfile_source(
            "multi_tx.wav", True)
        self.blocks_vector_source_x_2 = blocks.vector_source_b(
            (0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0,
             1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1,
             1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0,
             1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1,
             0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0,
             1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1,
             0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0,
             0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1), True, 1, [])
        self.blocks_vector_source_x_0 = blocks.vector_source_c(
            (1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0,
             0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0,
             1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1,
             1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0,
             0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1,
             1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0,
             1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0,
             1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0), True,
            1, [])
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(
            1, gr.GR_MSB_FIRST)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex * 1,
                                             int(1.2 * audio_rate / wpm))
        self.blocks_multiply_xx_6 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_5 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_4 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_3_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_3 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_2 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_add_xx_1 = blocks.add_vcc(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.blocks_add_const_vxx_1 = blocks.add_const_vcc(
            (i_offset + 1j * q_offset, ))
        self.blocks_add_const_vxx_0 = blocks.add_const_vcc((0.5, ))
        self.band_pass_filter_0_0 = filter.interp_fir_filter_ccc(
            1,
            firdes.complex_band_pass(1, audio_rate, -2800, -200, 200,
                                     firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0 = filter.interp_fir_filter_ccc(
            1,
            firdes.complex_band_pass(1, audio_rate, 200, 2800, 200,
                                     firdes.WIN_HAMMING, 6.76))
        self.analog_wfm_tx_0 = analog.wfm_tx(
            audio_rate=audio_rate,
            quad_rate=audio_rate * 4,
            tau=75e-6,
            max_dev=75e3,
        )
        self.analog_sig_source_x_6 = analog.sig_source_c(
            audio_rate, analog.GR_COS_WAVE, 22000, 1 if psk_on else 0, 0)
        self.analog_sig_source_x_5 = analog.sig_source_c(
            audio_rate, analog.GR_COS_WAVE, 20000, 1 if cw_on else 0, 0)
        self.analog_sig_source_x_4 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 120000, 1.0 / 7, 0)
        self.analog_sig_source_x_3_0 = analog.sig_source_c(
            audio_rate, analog.GR_COS_WAVE, 11000, 1.8 if lsb_on else 0, 0)
        self.analog_sig_source_x_3 = analog.sig_source_c(
            audio_rate, analog.GR_COS_WAVE, 14000, 1.8 if usb_on else 0, 0)
        self.analog_sig_source_x_2 = analog.sig_source_c(
            audio_rate, analog.GR_COS_WAVE, 0, 1 if am_on else 0, 0)
        self.analog_sig_source_x_1 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 0, 1.0 / 7 if wbfm_on else 0, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, -100000, 1.0 / 7 if nbfm_on else 0,
            0)
        self.analog_nbfm_tx_0 = analog.nbfm_tx(
            audio_rate=audio_rate,
            quad_rate=audio_rate * 2,
            tau=75e-6,
            max_dev=5e3,
        )
        self.analog_const_source_x_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.analog_sig_source_x_1, 0),
                     (self.blocks_multiply_xx_1, 1))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.analog_nbfm_tx_0, 0))
        self.connect((self.analog_nbfm_tx_0, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_wfm_tx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.analog_wfm_tx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.blocks_multiply_xx_2, 0))
        self.connect((self.analog_sig_source_x_2, 0),
                     (self.blocks_multiply_xx_2, 1))
        self.connect((self.low_pass_filter_1, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.low_pass_filter_1, 0))
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_add_xx_1, 0))
        self.connect((self.blocks_add_xx_1, 0),
                     (self.rational_resampler_xxx_2, 0))
        self.connect((self.blocks_multiply_xx_4, 0), (self.blocks_add_xx_0, 2))
        self.connect((self.analog_sig_source_x_4, 0),
                     (self.blocks_multiply_xx_4, 1))
        self.connect((self.rational_resampler_xxx_2, 0),
                     (self.blocks_multiply_xx_4, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.band_pass_filter_0_0, 0))
        self.connect((self.analog_sig_source_x_3_0, 0),
                     (self.blocks_multiply_xx_3_0, 1))
        self.connect((self.band_pass_filter_0_0, 0),
                     (self.blocks_multiply_xx_3_0, 0))
        self.connect((self.blocks_multiply_xx_3_0, 0),
                     (self.blocks_add_xx_1, 1))
        self.connect((self.band_pass_filter_0, 0),
                     (self.blocks_multiply_xx_3, 0))
        self.connect((self.analog_sig_source_x_3, 0),
                     (self.blocks_multiply_xx_3, 1))
        self.connect((self.blocks_multiply_xx_3, 0), (self.blocks_add_xx_1, 2))
        self.connect((self.blocks_add_xx_0, 0), (self.iqbalance_fix_cc_0, 0))
        self.connect((self.blocks_multiply_xx_5, 0), (self.blocks_add_xx_1, 3))
        self.connect((self.analog_sig_source_x_5, 0),
                     (self.blocks_multiply_xx_5, 1))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.blocks_multiply_xx_5, 0))
        self.connect((self.analog_sig_source_x_6, 0),
                     (self.blocks_multiply_xx_6, 1))
        self.connect((self.blocks_multiply_xx_6, 0), (self.blocks_add_xx_1, 4))
        self.connect((self.rational_resampler_xxx_3, 0),
                     (self.blocks_multiply_xx_6, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0),
                     (self.digital_psk_mod_0, 0))
        self.connect((self.digital_psk_mod_0, 0),
                     (self.rational_resampler_xxx_3, 0))
        self.connect((self.blocks_vector_source_x_2, 0),
                     (self.digital_map_bb_0, 0))
        self.connect((self.digital_map_bb_0, 0),
                     (self.blocks_unpacked_to_packed_xx_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blocks_repeat_0, 0))
        self.connect((self.blocks_repeat_0, 0),
                     (self.root_raised_cosine_filter_1, 0))
        self.connect((self.root_raised_cosine_filter_1, 0),
                     (self.root_raised_cosine_filter_0, 0))
        self.connect((self.iqbalance_fix_cc_0, 0),
                     (self.blocks_add_const_vxx_1, 0))
        self.connect((self.blocks_add_const_vxx_1, 0),
                     (self.osmosdr_sink_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.band_pass_filter_0, 0))
コード例 #23
0
  def __init__(self):
    grc_wxgui.top_block_gui.__init__(self, title="Top Block")

    options = get_options()

    self.tune_corrector_callback = tune_corrector(self)
    self.synchronizer_callback = synchronizer(self)
    self.converter = gr.vector_to_stream(gr.sizeof_float, 142)

    self.ifreq = options.frequency
    self.rfgain = options.gain

    self.src = osmosdr.source_c(options.args)
    self.src.set_center_freq(self.ifreq)
    self.src.set_sample_rate(int(options.sample_rate))

    if self.rfgain is None:
        self.src.set_gain_mode(1)
        self.iagc = 1
        self.rfgain = 0
    else:
        self.iagc = 0
        self.src.set_gain_mode(0)
        self.src.set_gain(self.rfgain)

    # may differ from the requested rate
    sample_rate = self.src.get_sample_rate()
    sys.stderr.write("sample rate: %d\n" % (sample_rate))

    gsm_symb_rate = 1625000.0 / 6.0
    sps = sample_rate / gsm_symb_rate / 4
    out_sample_rate = gsm_symb_rate * 4

    self.offset = 0

    taps = gr.firdes.low_pass(1.0, sample_rate, 145e3, 10e3, gr.firdes.WIN_HANN)
    self.tuner = gr.freq_xlating_fir_filter_ccf(1, taps, self.offset, sample_rate)

    self.interpolator = gr.fractional_interpolator_cc(0, sps)

    self.receiver = gsm.receiver_cf(
        self.tune_corrector_callback, self.synchronizer_callback, 4,
        options.key.replace(' ', '').lower(),
        options.configuration.upper())

    self.output = gr.file_sink(gr.sizeof_float, options.output_file)

    self.connect(self.src, self.tuner, self.interpolator, self.receiver, self.converter, self.output)

    def set_ifreq(ifreq):
        self.ifreq = ifreq
        self._ifreq_text_box.set_value(self.ifreq)
        self.src.set_center_freq(self.ifreq)

    self._ifreq_text_box = forms.text_box(
        parent=self.GetWin(),
        value=self.ifreq,
        callback=set_ifreq,
        label="Center Frequency",
        converter=forms.float_converter(),
    )
    self.Add(self._ifreq_text_box)

    def set_iagc(iagc):
        self.iagc = iagc
        self._agc_check_box.set_value(self.iagc)
        self.src.set_gain_mode(self.iagc, 0)
        self.src.set_gain(0 if self.iagc == 1 else self.rfgain, 0)

    self._agc_check_box = forms.check_box(
        parent=self.GetWin(),
        value=self.iagc,
        callback=set_iagc,
        label="Automatic Gain",
        true=1,
        false=0,
    )

    self.Add(self._agc_check_box)

    def set_rfgain(rfgain):
        self.rfgain = rfgain
        self._rfgain_slider.set_value(self.rfgain)
        self._rfgain_text_box.set_value(self.rfgain)
        self.src.set_gain(0 if self.iagc == 1 else self.rfgain, 0)

    _rfgain_sizer = wx.BoxSizer(wx.VERTICAL)
    self._rfgain_text_box = forms.text_box(
        parent=self.GetWin(),
        sizer=_rfgain_sizer,
        value=self.rfgain,
        callback=set_rfgain,
        label="RF Gain",
        converter=forms.float_converter(),
        proportion=0,
    )
    self._rfgain_slider = forms.slider(
        parent=self.GetWin(),
        sizer=_rfgain_sizer,
        value=self.rfgain,
        callback=set_rfgain,
        minimum=0,
        maximum=50,
        num_steps=200,
        style=wx.SL_HORIZONTAL,
        cast=float,
        proportion=1,
    )

    self.Add(_rfgain_sizer)

    def fftsink2_callback(x, y):
        if abs(x / (sample_rate / 2)) > 0.9:
            set_ifreq(self.ifreq + x / 2)
        else:
            sys.stderr.write("coarse tuned to: %d Hz\n" % x)
            self.offset = -x
            self.tuner.set_center_freq(self.offset)

    self.scope = fftsink2.fft_sink_c(self.GetWin(),
        title="Wideband Spectrum (click to coarse tune)",
        fft_size=1024,
        sample_rate=sample_rate,
        ref_scale=2.0,
        ref_level=0,
        y_divs=10,
        fft_rate=10,
        average=False,
        avg_alpha=0.3)

    self.Add(self.scope.win)
    self.scope.set_callback(fftsink2_callback)

    self.connect(self.src, self.scope)

    def fftsink2_callback2(x, y):
        self.offset = self.offset - (x / 10)
        sys.stderr.write("fine tuned to: %d Hz\n" % self.offset)
        self.tuner.set_center_freq(self.offset)

    self.scope2 = fftsink2.fft_sink_c(self.GetWin(),
        title="Channel Spectrum (click to fine tune)",
        fft_size=1024,
        sample_rate=gsm_symb_rate * 4,
        ref_scale=2.0,
        ref_level=-20,
        y_divs=10,
        fft_rate=10,
        average=False,
        avg_alpha=0.3)

    self.Add(self.scope2.win)
    self.scope2.set_callback(fftsink2_callback2)

    self.connect(self.interpolator, self.scope2)
コード例 #24
0
ファイル: multi_tx.py プロジェクト: Asad-799/sdr-examples
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Multi Tx")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.audio_rate = audio_rate = 48000
        self.wpm = wpm = 15
        self.wbfm_on = wbfm_on = True
        self.usb_on = usb_on = True
        self.samp_rate = samp_rate = audio_rate * 40
        self.q_offset = q_offset = 0
        self.psk_on = psk_on = True
        self.phase = phase = 0
        self.nbfm_on = nbfm_on = True
        self.magnitude = magnitude = 0
        self.lsb_on = lsb_on = True
        self.i_offset = i_offset = 0
        self.gain = gain = 25
        self.cw_on = cw_on = True
        self.center_freq = center_freq = 441000000
        self.am_on = am_on = True

        ##################################################
        # Blocks
        ##################################################
        self._wbfm_on_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.wbfm_on,
        	callback=self.set_wbfm_on,
        	label="WBFM",
        	true=True,
        	false=False,
        )
        self.GridAdd(self._wbfm_on_check_box, 4, 1, 1, 1)
        self._usb_on_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.usb_on,
        	callback=self.set_usb_on,
        	label="USB",
        	true=True,
        	false=False,
        )
        self.GridAdd(self._usb_on_check_box, 4, 4, 1, 1)
        _q_offset_sizer = wx.BoxSizer(wx.VERTICAL)
        self._q_offset_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_q_offset_sizer,
        	value=self.q_offset,
        	callback=self.set_q_offset,
        	label="DC offset Q",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._q_offset_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_q_offset_sizer,
        	value=self.q_offset,
        	callback=self.set_q_offset,
        	minimum=-0.1,
        	maximum=0.1,
        	num_steps=200,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_q_offset_sizer, 3, 0, 1, 7)
        self._psk_on_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.psk_on,
        	callback=self.set_psk_on,
        	label="PSK31",
        	true=True,
        	false=False,
        )
        self.GridAdd(self._psk_on_check_box, 4, 6, 1, 1)
        _phase_sizer = wx.BoxSizer(wx.VERTICAL)
        self._phase_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_phase_sizer,
        	value=self.phase,
        	callback=self.set_phase,
        	label="Phase correction",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._phase_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_phase_sizer,
        	value=self.phase,
        	callback=self.set_phase,
        	minimum=-0.1,
        	maximum=0.1,
        	num_steps=200,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_phase_sizer, 0, 0, 1, 7)
        self._nbfm_on_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.nbfm_on,
        	callback=self.set_nbfm_on,
        	label="NBFM",
        	true=True,
        	false=False,
        )
        self.GridAdd(self._nbfm_on_check_box, 4, 0, 1, 1)
        _magnitude_sizer = wx.BoxSizer(wx.VERTICAL)
        self._magnitude_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_magnitude_sizer,
        	value=self.magnitude,
        	callback=self.set_magnitude,
        	label="Magnitude correction",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._magnitude_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_magnitude_sizer,
        	value=self.magnitude,
        	callback=self.set_magnitude,
        	minimum=-0.1,
        	maximum=0.1,
        	num_steps=200,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_magnitude_sizer, 1, 0, 1, 7)
        self._lsb_on_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.lsb_on,
        	callback=self.set_lsb_on,
        	label="LSB",
        	true=True,
        	false=False,
        )
        self.GridAdd(self._lsb_on_check_box, 4, 3, 1, 1)
        _i_offset_sizer = wx.BoxSizer(wx.VERTICAL)
        self._i_offset_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_i_offset_sizer,
        	value=self.i_offset,
        	callback=self.set_i_offset,
        	label="DC offset I",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._i_offset_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_i_offset_sizer,
        	value=self.i_offset,
        	callback=self.set_i_offset,
        	minimum=-0.1,
        	maximum=0.1,
        	num_steps=200,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_i_offset_sizer, 2, 0, 1, 7)
        self._cw_on_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.cw_on,
        	callback=self.set_cw_on,
        	label="CW",
        	true=True,
        	false=False,
        )
        self.GridAdd(self._cw_on_check_box, 4, 5, 1, 1)
        self._am_on_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.am_on,
        	callback=self.set_am_on,
        	label="AM",
        	true=True,
        	false=False,
        )
        self.GridAdd(self._am_on_check_box, 4, 2, 1, 1)
        self.root_raised_cosine_filter_1 = filter.fir_filter_ccf(1, firdes.root_raised_cosine(
        	1, audio_rate, 5, 0.35, 200))
        self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(1, firdes.root_raised_cosine(
        	1, audio_rate, 5, 0.35, 200))
        self.rational_resampler_xxx_3 = filter.rational_resampler_ccc(
                interpolation=192,
                decimation=1,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_2 = filter.rational_resampler_ccc(
                interpolation=samp_rate,
                decimation=audio_rate,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
                interpolation=samp_rate / audio_rate / 2,
                decimation=1,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=samp_rate / audio_rate / 4,
                decimation=1,
                taps=None,
                fractional_bw=None,
        )
        self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "" )
        self.osmosdr_sink_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0.set_center_freq(center_freq, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(gain, 0)
        self.osmosdr_sink_0.set_if_gain(20, 0)
        self.osmosdr_sink_0.set_bb_gain(20, 0)
        self.osmosdr_sink_0.set_antenna("", 0)
        self.osmosdr_sink_0.set_bandwidth(0, 0)
          
        self.low_pass_filter_1 = filter.interp_fir_filter_ccf(1, firdes.low_pass(
        	0.5, audio_rate, 5000, 400, firdes.WIN_HAMMING, 6.76))
        self.iqbalance_fix_cc_0 = iqbalance.fix_cc(magnitude, phase)
        self.digital_psk_mod_0 = digital.psk.psk_mod(
          constellation_points=2,
          mod_code="none",
          differential=True,
          samples_per_symbol=8,
          excess_bw=0.35,
          verbose=False,
          log=False,
          )
        self.digital_map_bb_0 = digital.map_bb(([1,0]))
        self.blocks_wavfile_source_0 = blocks.wavfile_source("multi_tx.wav", True)
        self.blocks_vector_source_x_2 = blocks.vector_source_b((0,0, 1,1,0,1,1,0,1, 0,0, 1,0,1,0,1,1, 0,0, 1,1,0,1, 0,0, 1,0,1,1,1, 0,0, 1, 0,0, 1,1,0,1, 0,0, 1,0,1,1,1, 0,0, 1, 0,0, 1,1,0,1,1,0,1,0,1, 0,0, 1,1,1,0,1,1,1, 0,0, 1,1,1,1,1,1,1,1, 0,0, 1,1,1,1,1,1,1, 0,0, 1,0,1,0,1,1,1,1, 0,0, 1,0,1,0,1,1,1,1, 0,0, 1, 0,0, 1,0,1, 0,0, 1,1, 0,0, 1,0,1,1,1, 0,0, 1,0,1, 0,0, 1,1,0,1, 0,0, 1,1,1,1, 0,0, 1,0,1,1,0,1,1, 0,0, 1,0,1,0,1,1,1, 0,0, 1,1,1,0,1), True, 1, [])
        self.blocks_vector_source_x_0 = blocks.vector_source_c((1,0,1,0,1,0,1,1,1, 0,0,0, 1,0,1,0,1,0,1,1,1, 0,0,0, 1,0,1,0,1,0,1,1,1, 0,0,0,0,0,0,0, 1,1,1,0,1,0,1, 0,0,0, 1, 0,0,0,0,0,0,0, 1,0,1,0,1,0,1,1,1, 0,0,0, 1, 0,0,0, 1,0,1,0,1,0,1,1,1,0,1,1,1, 0,0,0, 1,0,1, 0,0,0, 1,0,1,1,1,0,1, 0,0,0, 1,0,1,1,1,0,1, 0,0,0,0,0,0,0, 1,1,1, 0,0,0, 1, 0,0,0, 1,0,1,0,1, 0,0,0, 1,1,1, 0,0,0, 1,0,1, 0,0,0, 1,1,1,0,1, 0,0,0, 1,1,1,0,1,1,1,0,1, 0,0,0,0,0,0,0), True, 1, [])
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, int(1.2 * audio_rate / wpm))
        self.blocks_multiply_xx_6 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_5 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_4 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_3_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_3 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_2 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_add_xx_1 = blocks.add_vcc(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.blocks_add_const_vxx_1 = blocks.add_const_vcc((i_offset + 1j * q_offset, ))
        self.blocks_add_const_vxx_0 = blocks.add_const_vcc((0.5, ))
        self.band_pass_filter_0_0 = filter.interp_fir_filter_ccc(1, firdes.complex_band_pass(
        	1, audio_rate, -2800, -200, 200, firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0 = filter.interp_fir_filter_ccc(1, firdes.complex_band_pass(
        	1, audio_rate, 200, 2800, 200, firdes.WIN_HAMMING, 6.76))
        self.analog_wfm_tx_0 = analog.wfm_tx(
        	audio_rate=audio_rate,
        	quad_rate=audio_rate * 4,
        	tau=75e-6,
        	max_dev=75e3,
        )
        self.analog_sig_source_x_6 = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, 22000, 1 if psk_on else 0, 0)
        self.analog_sig_source_x_5 = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, 20000, 1 if cw_on else 0, 0)
        self.analog_sig_source_x_4 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 120000, 1.0 / 7, 0)
        self.analog_sig_source_x_3_0 = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, 11000, 1.8 if lsb_on else 0, 0)
        self.analog_sig_source_x_3 = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, 14000, 1.8 if usb_on else 0, 0)
        self.analog_sig_source_x_2 = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, 0, 1 if am_on else 0, 0)
        self.analog_sig_source_x_1 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 0, 1.0 / 7 if wbfm_on else 0, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -100000, 1.0 / 7 if nbfm_on else 0, 0)
        self.analog_nbfm_tx_0 = analog.nbfm_tx(
        	audio_rate=audio_rate,
        	quad_rate=audio_rate * 2,
        	tau=75e-6,
        	max_dev=5e3,
        )
        self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_1, 1))
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_wavfile_source_0, 0), (self.analog_nbfm_tx_0, 0))
        self.connect((self.analog_nbfm_tx_0, 0), (self.rational_resampler_xxx_1, 0))
        self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_wfm_tx_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0), (self.analog_wfm_tx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_xx_2, 0))
        self.connect((self.analog_sig_source_x_2, 0), (self.blocks_multiply_xx_2, 1))
        self.connect((self.low_pass_filter_1, 0), (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.low_pass_filter_1, 0))
        self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_add_xx_1, 0))
        self.connect((self.blocks_add_xx_1, 0), (self.rational_resampler_xxx_2, 0))
        self.connect((self.blocks_multiply_xx_4, 0), (self.blocks_add_xx_0, 2))
        self.connect((self.analog_sig_source_x_4, 0), (self.blocks_multiply_xx_4, 1))
        self.connect((self.rational_resampler_xxx_2, 0), (self.blocks_multiply_xx_4, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.band_pass_filter_0_0, 0))
        self.connect((self.analog_sig_source_x_3_0, 0), (self.blocks_multiply_xx_3_0, 1))
        self.connect((self.band_pass_filter_0_0, 0), (self.blocks_multiply_xx_3_0, 0))
        self.connect((self.blocks_multiply_xx_3_0, 0), (self.blocks_add_xx_1, 1))
        self.connect((self.band_pass_filter_0, 0), (self.blocks_multiply_xx_3, 0))
        self.connect((self.analog_sig_source_x_3, 0), (self.blocks_multiply_xx_3, 1))
        self.connect((self.blocks_multiply_xx_3, 0), (self.blocks_add_xx_1, 2))
        self.connect((self.blocks_add_xx_0, 0), (self.iqbalance_fix_cc_0, 0))
        self.connect((self.blocks_multiply_xx_5, 0), (self.blocks_add_xx_1, 3))
        self.connect((self.analog_sig_source_x_5, 0), (self.blocks_multiply_xx_5, 1))
        self.connect((self.root_raised_cosine_filter_0, 0), (self.blocks_multiply_xx_5, 0))
        self.connect((self.analog_sig_source_x_6, 0), (self.blocks_multiply_xx_6, 1))
        self.connect((self.blocks_multiply_xx_6, 0), (self.blocks_add_xx_1, 4))
        self.connect((self.rational_resampler_xxx_3, 0), (self.blocks_multiply_xx_6, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.digital_psk_mod_0, 0))
        self.connect((self.digital_psk_mod_0, 0), (self.rational_resampler_xxx_3, 0))
        self.connect((self.blocks_vector_source_x_2, 0), (self.digital_map_bb_0, 0))
        self.connect((self.digital_map_bb_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_repeat_0, 0))
        self.connect((self.blocks_repeat_0, 0), (self.root_raised_cosine_filter_1, 0))
        self.connect((self.root_raised_cosine_filter_1, 0), (self.root_raised_cosine_filter_0, 0))
        self.connect((self.iqbalance_fix_cc_0, 0), (self.blocks_add_const_vxx_1, 0))
        self.connect((self.blocks_add_const_vxx_1, 0), (self.osmosdr_sink_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.band_pass_filter_0, 0))
コード例 #25
0
  def __init__(self):
    grc_wxgui.top_block_gui.__init__(self, title="Top Block")

    options = get_options()

    self.ifreq = options.frequency
    self.rfgain = options.gain
    self.offset = options.frequency_offset

    self.src = osmosdr.source_c(options.args)
    self.src.set_center_freq(self.ifreq)
    self.src.set_sample_rate(int(options.sample_rate))

    if self.rfgain is None:
        self.src.set_gain_mode(1)
        self.iagc = 1
        self.rfgain = 0
    else:
        self.iagc = 0
        self.src.set_gain_mode(0)
        self.src.set_gain(self.rfgain)

    # may differ from the requested rate
    sample_rate = self.src.get_sample_rate()
    sys.stderr.write("sample rate: %d\n" % (sample_rate))

    symbol_rate = 18000
    sps = 2 # output rate will be 36,000
    out_sample_rate = symbol_rate * sps

    options.low_pass = options.low_pass / 2.0

    if sample_rate == 96000: # FunCube Dongle
        first_decim = 2
    else:
        first_decim = 10

    self.offset = 0

    taps = gr.firdes.low_pass(1.0, sample_rate, options.low_pass, options.low_pass * 0.2, gr.firdes.WIN_HANN)
    self.tuner = gr.freq_xlating_fir_filter_ccf(first_decim, taps, self.offset, sample_rate)

    self.demod = cqpsk.cqpsk_demod(
        samples_per_symbol = sps,
        excess_bw=0.35,
        costas_alpha=0.03,
        gain_mu=0.05,
        mu=0.05,
        omega_relative_limit=0.05,
        log=options.log,
        verbose=options.verbose)

    self.output = gr.file_sink(gr.sizeof_float, options.output_file)

    rerate = float(sample_rate / float(first_decim)) / float(out_sample_rate)
    sys.stderr.write("resampling factor: %f\n" % rerate)

    if rerate.is_integer():
        sys.stderr.write("using pfb decimator\n")
        self.resamp = blks2.pfb_decimator_ccf(int(rerate))
    else:
        sys.stderr.write("using pfb resampler\n")
        self.resamp = blks2.pfb_arb_resampler_ccf(1 / rerate)

    self.connect(self.src, self.tuner, self.resamp, self.demod, self.output)

    self.Main = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
    self.Main.AddPage(grc_wxgui.Panel(self.Main), "Wideband Spectrum")
    self.Main.AddPage(grc_wxgui.Panel(self.Main), "Channel Spectrum")
    self.Main.AddPage(grc_wxgui.Panel(self.Main), "Soft Bits")

    def set_ifreq(ifreq):
        self.ifreq = ifreq
        self._ifreq_text_box.set_value(self.ifreq)
        self.src.set_center_freq(self.ifreq)

    self._ifreq_text_box = forms.text_box(
        parent=self.GetWin(),
        value=self.ifreq,
        callback=set_ifreq,
        label="Center Frequency",
        converter=forms.float_converter(),
    )
    self.Add(self._ifreq_text_box)

    def set_iagc(iagc):
        self.iagc = iagc
        self._agc_check_box.set_value(self.iagc)
        self.src.set_gain_mode(self.iagc, 0)
        self.src.set_gain(0 if self.iagc == 1 else self.rfgain, 0)

    self._agc_check_box = forms.check_box(
        parent=self.GetWin(),
        value=self.iagc,
        callback=set_iagc,
        label="Automatic Gain",
        true=1,
        false=0,
    )

    self.Add(self._agc_check_box)

    def set_rfgain(rfgain):
        self.rfgain = rfgain
        self._rfgain_slider.set_value(self.rfgain)
        self._rfgain_text_box.set_value(self.rfgain)
        self.src.set_gain(0 if self.iagc == 1 else self.rfgain, 0)

    _rfgain_sizer = wx.BoxSizer(wx.VERTICAL)
    self._rfgain_text_box = forms.text_box(
        parent=self.GetWin(),
        sizer=_rfgain_sizer,
        value=self.rfgain,
        callback=set_rfgain,
        label="RF Gain",
        converter=forms.float_converter(),
        proportion=0,
    )
    self._rfgain_slider = forms.slider(
        parent=self.GetWin(),
        sizer=_rfgain_sizer,
        value=self.rfgain,
        callback=set_rfgain,
        minimum=0,
        maximum=50,
        num_steps=200,
        style=wx.SL_HORIZONTAL,
        cast=float,
        proportion=1,
    )

    self.Add(_rfgain_sizer)

    self.Add(self.Main)

    def fftsink2_callback(x, y):
        if abs(x / (sample_rate / 2)) > 0.9:
            set_ifreq(self.ifreq + x / 2)
        else:
            self.offset = -x
            sys.stderr.write("coarse tuned to: %d Hz => %d Hz\n" % (self.offset, (self.ifreq + self.offset)))
            self.tuner.set_center_freq(self.offset)

    self.scope = fftsink2.fft_sink_c(self.Main.GetPage(0).GetWin(),
        title="Wideband Spectrum (click to coarse tune)",
        fft_size=1024,
        sample_rate=sample_rate,
        ref_scale=2.0,
        ref_level=0,
        y_divs=10,
        fft_rate=10,
        average=False,
        avg_alpha=0.6)

    self.Main.GetPage(0).Add(self.scope.win)
    self.scope.set_callback(fftsink2_callback)

    self.connect(self.src, self.scope)

    def fftsink2_callback2(x, y):
        self.offset = self.offset - (x / 10)
        sys.stderr.write("fine tuned to: %d Hz => %d Hz\n" % (self.offset, (self.ifreq + self.offset)))
        self.tuner.set_center_freq(self.offset)

    self.scope2 = fftsink2.fft_sink_c(self.Main.GetPage(1).GetWin(),
        title="Channel Spectrum (click to fine tune)",
        fft_size=1024,
        sample_rate=out_sample_rate,
        ref_scale=2.0,
        ref_level=-20,
        y_divs=10,
        fft_rate=10,
        average=False,
        avg_alpha=0.6)

    self.Main.GetPage(1).Add(self.scope2.win)
    self.scope2.set_callback(fftsink2_callback2)

    self.connect(self.resamp, self.scope2)

    self.scope3 = scopesink2.scope_sink_f(
        self.Main.GetPage(2).GetWin(),
        title="Soft Bits",
        sample_rate=out_sample_rate,
        v_scale=0,
        v_offset=0,
        t_scale=0.001,
        ac_couple=False,
        xy_mode=False,
        num_inputs=1,
        trig_mode=gr.gr_TRIG_MODE_AUTO,
        y_axis_label="Counts",
	)
    self.Main.GetPage(2).Add(self.scope3.win)

    self.connect(self.demod, self.scope3)
コード例 #26
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2600000
        self.rf_tx = rf_tx = 0
        self.noise_amp = noise_amp = 0
        self.noise = noise = 0
        self.if_tx = if_tx = 30
        self.freq = freq = 1575420000

        ##################################################
        # Blocks
        ##################################################
        _rf_tx_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rf_tx_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rf_tx_sizer,
            value=self.rf_tx,
            callback=self.set_rf_tx,
            label='RF_AMP',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rf_tx_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rf_tx_sizer,
            value=self.rf_tx,
            callback=self.set_rf_tx,
            minimum=0,
            maximum=14,
            num_steps=14,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_rf_tx_sizer)
        _if_tx_sizer = wx.BoxSizer(wx.VERTICAL)
        self._if_tx_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_if_tx_sizer,
            value=self.if_tx,
            callback=self.set_if_tx,
            label='IF_AMP',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._if_tx_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_if_tx_sizer,
            value=self.if_tx,
            callback=self.set_if_tx,
            minimum=0,
            maximum=47,
            num_steps=47,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_if_tx_sizer)
        self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " +
                                           "serial=F4C33C")
        self.osmosdr_sink_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0.set_center_freq(freq, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(rf_tx, 0)
        self.osmosdr_sink_0.set_if_gain(if_tx, 0)
        self.osmosdr_sink_0.set_bb_gain(20, 0)
        self.osmosdr_sink_0.set_antenna('', 0)
        self.osmosdr_sink_0.set_bandwidth(2.5e6, 0)

        _noise_amp_sizer = wx.BoxSizer(wx.VERTICAL)
        self._noise_amp_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_noise_amp_sizer,
            value=self.noise_amp,
            callback=self.set_noise_amp,
            label='Noise',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._noise_amp_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_noise_amp_sizer,
            value=self.noise_amp,
            callback=self.set_noise_amp,
            minimum=0,
            maximum=10,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_noise_amp_sizer)
        self._noise_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.noise,
            callback=self.set_noise,
            label='noise',
            true=1,
            false=0,
        )
        self.Add(self._noise_check_box)
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_short * 1, '/home/james/Downloads/circle_hackrf.bin',
            True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_short_to_float_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.osmosdr_sink_0, 0))
        self.connect((self.blocks_short_to_float_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_short_to_float_0, 0),
                     (self.blocks_float_to_complex_0, 0))
コード例 #27
0
    def __init__(self, parent):
        """
        Create a new control panel.
        @param parent the wx parent window
        """
        self.parent = parent
        wx.Panel.__init__(self, parent, style=wx.SUNKEN_BORDER)
        parent[constants.SHOW_CONTROL_PANEL_KEY] = True
        parent.subscribe(constants.SHOW_CONTROL_PANEL_KEY, self.Show)
        control_box = wx.BoxSizer(wx.VERTICAL)
        control_box.AddStretchSpacer()
        #checkboxes for average and peak hold
        options_box = forms.static_box_sizer(
            parent=self, sizer=control_box, label='Trace Options',
            bold=True, orient=wx.VERTICAL,
        )
        forms.check_box(
            sizer=options_box, parent=self, label='Peak Hold',
            ps=parent, key=constants.PEAK_HOLD_KEY,
        )
        forms.check_box(
            sizer=options_box, parent=self, label='Average',
            ps=parent, key=constants.AVERAGE_KEY,
        )
        #static text and slider for averaging
        avg_alpha_text = forms.static_text(
            sizer=options_box, parent=self, label='Avg Alpha',
            converter=forms.float_converter(lambda x: '%.4f'%x),
            ps=parent, key=constants.AVG_ALPHA_KEY, width=50,
        )
        avg_alpha_slider = forms.log_slider(
            sizer=options_box, parent=self,
            min_exp=AVG_ALPHA_MIN_EXP,
            max_exp=AVG_ALPHA_MAX_EXP,
            num_steps=SLIDER_STEPS,
            ps=parent, key=constants.AVG_ALPHA_KEY,
        )
        for widget in (avg_alpha_text, avg_alpha_slider):
            parent.subscribe(constants.AVERAGE_KEY, widget.Enable)
            widget.Enable(parent[constants.AVERAGE_KEY])
            parent.subscribe(constants.AVERAGE_KEY, widget.ShowItems)
                        #allways show initially, so room is reserved for them
            widget.ShowItems(True) # (parent[AVERAGE_KEY])
            parent.subscribe(constants.AVERAGE_KEY, self._update_layout)

        forms.check_box(
            sizer=options_box, parent=self, label='Persistence',
            ps=parent, key=constants.USE_PERSISTENCE_KEY,
        )
        #static text and slider for persist alpha
        persist_alpha_text = forms.static_text(
            sizer=options_box, parent=self, label='Persist Alpha',
            converter=forms.float_converter(lambda x: '%.4f'%x),
            ps=parent, key=constants.PERSIST_ALPHA_KEY, width=50,
        )
        persist_alpha_slider = forms.log_slider(
            sizer=options_box, parent=self,
            min_exp=PERSIST_ALPHA_MIN_EXP,
            max_exp=PERSIST_ALPHA_MAX_EXP,
            num_steps=SLIDER_STEPS,
            ps=parent, key=constants.PERSIST_ALPHA_KEY,
        )
        for widget in (persist_alpha_text, persist_alpha_slider):
            parent.subscribe(constants.USE_PERSISTENCE_KEY, widget.Enable)
            widget.Enable(parent[constants.USE_PERSISTENCE_KEY])
            parent.subscribe(constants.USE_PERSISTENCE_KEY, widget.ShowItems)
                        #allways show initially, so room is reserved for them
            widget.ShowItems(True) # (parent[USE_PERSISTENCE_KEY])
            parent.subscribe(constants.USE_PERSISTENCE_KEY, self._update_layout)

        #trace menu
        for trace in TRACES:
            trace_box = wx.BoxSizer(wx.HORIZONTAL)
            options_box.Add(trace_box, 0, wx.EXPAND)
            forms.check_box(
                sizer=trace_box, parent=self,
                ps=parent, key=constants.TRACE_SHOW_KEY+trace,
                label='Trace %s'%trace,
            )
            trace_box.AddSpacer(10)
            forms.single_button(
                sizer=trace_box, parent=self,
                ps=parent, key=constants.TRACE_STORE_KEY+trace,
                label='Store', style=wx.BU_EXACTFIT,
            )
            trace_box.AddSpacer(10)
        #radio buttons for div size
        control_box.AddStretchSpacer()
        y_ctrl_box = forms.static_box_sizer(
            parent=self, sizer=control_box, label='Axis Options',
            bold=True, orient=wx.VERTICAL,
        )
        forms.incr_decr_buttons(
            parent=self, sizer=y_ctrl_box, label='dB/Div',
            on_incr=self._on_incr_db_div, on_decr=self._on_decr_db_div,
        )
        #ref lvl buttons
        forms.incr_decr_buttons(
            parent=self, sizer=y_ctrl_box, label='Ref Level',
            on_incr=self._on_incr_ref_level, on_decr=self._on_decr_ref_level,
        )
        y_ctrl_box.AddSpacer(2)
        #autoscale
        forms.single_button(
            sizer=y_ctrl_box, parent=self, label='Autoscale',
            callback=self.parent.autoscale,
        )
        #run/stop
        control_box.AddStretchSpacer()
        forms.toggle_button(
            sizer=control_box, parent=self,
            true_label='Stop', false_label='Run',
            ps=parent, key=constants.RUNNING_KEY,
        )
        #set sizer
        self.SetSizerAndFit(control_box)

        def on_mouse_wheel(event):
            """ Mouse wheel event """
            if event.GetWheelRotation() < 0: self._on_incr_ref_level(event)
            else: self._on_decr_ref_level(event)
        parent.plotter.Bind(wx.EVT_MOUSEWHEEL, on_mouse_wheel)
コード例 #28
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))    
コード例 #29
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self,
                                         title="Non Linear Junction Detector")

        ##################################################
        # Variables
        ##################################################
        self.volume = volume = -19
        self.variable_check_box_0 = variable_check_box_0 = 0
        self.samp_rate = samp_rate = 4000000
        self.demod_rate = demod_rate = 40000
        self.audio_rate = audio_rate = 48000

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_f(
            self.GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=audio_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='FFT Plot',
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        _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=-20,
            maximum=10,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_volume_sizer)
        self._variable_check_box_0_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.variable_check_box_0,
            callback=self.set_variable_check_box_0,
            label='rf_on_off',
            true=60,
            false=0,
        )
        self.Add(self._variable_check_box_0_check_box)
        self.sdr_source_0 = sdr.source({}, "CF32", ([0]), {})
        self.sdr_source_0.set_samp_rate(samp_rate)
        self.sdr_source_0.set_center_freq(999000000, 0)
        self.sdr_source_0.set_gain(10, 0)
        self.sdr_sink_0 = sdr.sink({}, "CF32", ([0]), {})
        self.sdr_sink_0.set_samp_rate(samp_rate)
        self.sdr_sink_0.set_center_freq(5875000000, 0)
        self.sdr_sink_0.set_gain(0, 0)
        self.sdr_sink_0.set_antenna('TX/RX', 0)
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=48,
            decimation=40,
            taps=None,
            fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.fir_filter_fff(
            100,
            firdes.low_pass(3, samp_rate, 10000, 5000, firdes.WIN_HAMMING,
                            6.76))
        self.high_pass_filter_0 = filter.fir_filter_fff(
            1, firdes.high_pass(2, demod_rate, 100, 50, firdes.WIN_HANN, 6.76))
        self.fosphor_wx_sink_c_0 = fosphor.wx_sink_c(self.GetWin())
        self.fosphor_wx_sink_c_0.set_fft_window(window.WIN_BLACKMAN_hARRIS)
        self.fosphor_wx_sink_c_0.set_frequency_range(999000000, samp_rate)
        self.Add(self.fosphor_wx_sink_c_0.win)
        self.blocks_null_source_0 = blocks.null_source(gr.sizeof_float * 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0, ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_abs_xx_0 = blocks.abs_ii(1)
        self.audio_sink_0 = audio.sink(audio_rate, '', True)
        self.analog_sig_source_x_1 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, -1000000, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            100000, analog.GR_COS_WAVE, 0, 2, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.analog_sig_source_x_1, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_abs_xx_0, 0), (self.high_pass_filter_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.sdr_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.wxgui_fftsink2_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.blocks_null_source_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.high_pass_filter_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.blocks_abs_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.sdr_source_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.sdr_source_0, 0), (self.fosphor_wx_sink_c_0, 0))
コード例 #30
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Arduino")

        ##################################################
        # Variables
        ##################################################
        self.variable_check_box_0 = variable_check_box_0 = True
        self.variable_any_code_0 = variable_any_code_0 = None
        self.variable_0 = variable_0 = 0
        self.samp_rate = samp_rate = 32000

        ##################################################
        # Blocks
        ##################################################
        self._variable_check_box_0_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.variable_check_box_0,
        	callback=self.set_variable_check_box_0,
        	label='variable_check_box_0',
        	true=True,
        	false=False,
        )
        self.Add(self._variable_check_box_0_check_box)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,	fft_in=False,
        	always_run=False,
        	fft_out=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        if not hasattr(self, '_post_any_code_evaluators'):
        	self._post_any_code_evaluators = []
        	self.wxEVT_AnyCode = wxEVT_AnyCode = wx.NewEventType()
        	def _run_evaluators(event):
        		_post_any_code_evaluators = self._post_any_code_evaluators
        		if len(_post_any_code_evaluators) > 0:
        			for id, evaluator in _post_any_code_evaluators:
        				try:
        					evaluator()
        				except Exception, e:
        					print "Exception while running Any Code evaluator for '%s':" % (id), e
        			del  _post_any_code_evaluators[0:len(_post_any_code_evaluators)]
        	self._run_evaluators = _run_evaluators
        	try:
        		self.GetWin().Connect(-1, -1, wxEVT_AnyCode, _run_evaluators)
        	except:
        		pass	# FIXME
        	def _run_evaluators_later(evaluator=None):
        		if evaluator is not None:
        			self._post_any_code_evaluators += [evaluator]
        		try:
        			de = wx.PyEvent()
        			de.SetEventType(wxEVT_AnyCode)
        			wx.PostEvent(self.GetWin(), de)
        		except TypeError: 
        			pass
        		except AttributeError:	# FIXME
        			print "Cannot post message"
        	self._run_evaluators_later = _run_evaluators_later
        	_run_evaluators_later()
コード例 #31
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        options = get_options()

        self.ifreq = options.frequency
        self.rfgain = options.gain
        self.offset = options.frequency_offset

        self.src = osmosdr.source(options.args)
        self.src.set_center_freq(self.ifreq)
        self.src.set_sample_rate(int(options.sample_rate))

        if self.rfgain is None:
            self.src.set_gain_mode(1)
            self.iagc = 1
            self.rfgain = 0
        else:
            self.iagc = 0
            self.src.set_gain_mode(0)
            self.src.set_gain(self.rfgain)

        # may differ from the requested rate
        sample_rate = self.src.get_sample_rate()
        sys.stderr.write("sample rate: %d\n" % (sample_rate))

        symbol_rate = 18000
        sps = 2  # output rate will be 36,000
        out_sample_rate = symbol_rate * sps

        options.low_pass = options.low_pass / 2.0

        if sample_rate == 96000:  # FunCube Dongle
            first_decim = 2
        else:
            first_decim = 10

        self.offset = 0

        taps = firdes.low_pass(1.0, sample_rate, options.low_pass,
                               options.low_pass * 0.2, firdes.WIN_HANN)
        self.tuner = filter.freq_xlating_fir_filter_ccf(
            first_decim, taps, self.offset, sample_rate)

        self.demod = cqpsk.cqpsk_demod(samples_per_symbol=sps,
                                       excess_bw=0.35,
                                       costas_alpha=0.03,
                                       gain_mu=0.05,
                                       mu=0.05,
                                       omega_relative_limit=0.05,
                                       log=options.log,
                                       verbose=options.verbose)

        self.output = blocks.file_sink(gr.sizeof_float, options.output_file)

        rerate = float(sample_rate) / float(first_decim) / float(
            out_sample_rate)
        sys.stderr.write("resampling factor: %f\n" % rerate)

        if rerate.is_integer():
            sys.stderr.write("using pfb decimator\n")
            #self.resamp = filter.pfb_decimator_ccf(int(rerate), firdes.low_pass(1,int(sample_rate), 50000,5000), 1)
            self.resamp = filter.fir_filter_ccf(
                int(rerate),
                firdes.low_pass(1, int(sample_rate / first_decim), 50000,
                                5000))
        else:
            sys.stderr.write("using pfb resampler\n")
            t = filter.firdes.low_pass_2(
                32,
                32.0 * sample_rate / first_decim,
                60000,
                5000,
                attenuation_dB=3,
                window=filter.firdes.WIN_BLACKMAN_hARRIS)
            self.resamp = filter.pfb_arb_resampler_ccf(1.0 / rerate, t, 32)

        self.connect(self.src, self.tuner, self.resamp, self.demod,
                     self.output)

        self.Main = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.Main.AddPage(grc_wxgui.Panel(self.Main), "Wideband Spectrum")
        self.Main.AddPage(grc_wxgui.Panel(self.Main), "Channel Spectrum")
        self.Main.AddPage(grc_wxgui.Panel(self.Main), "Soft Bits")

        def set_ifreq(ifreq):
            self.ifreq = ifreq
            self._ifreq_text_box.set_value(self.ifreq)
            self.src.set_center_freq(self.ifreq)

        self._ifreq_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.ifreq,
            callback=set_ifreq,
            label="Center Frequency",
            converter=forms.float_converter(),
        )
        self.Add(self._ifreq_text_box)

        def set_iagc(iagc):
            self.iagc = iagc
            self._agc_check_box.set_value(self.iagc)
            self.src.set_gain_mode(self.iagc, 0)
            self.src.set_gain(0 if self.iagc == 1 else self.rfgain, 0)

        self._agc_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.iagc,
            callback=set_iagc,
            label="Automatic Gain",
            true=1,
            false=0,
        )

        self.Add(self._agc_check_box)

        def set_rfgain(rfgain):
            self.rfgain = rfgain
            self._rfgain_slider.set_value(self.rfgain)
            self._rfgain_text_box.set_value(self.rfgain)
            self.src.set_gain(0 if self.iagc == 1 else self.rfgain, 0)

        _rfgain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rfgain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rfgain_sizer,
            value=self.rfgain,
            callback=set_rfgain,
            label="RF Gain",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rfgain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rfgain_sizer,
            value=self.rfgain,
            callback=set_rfgain,
            minimum=0,
            maximum=50,
            num_steps=200,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )

        self.Add(_rfgain_sizer)

        self.Add(self.Main)

        def fftsink2_callback(x, y):
            if abs(x / (sample_rate / 2)) > 0.9:
                set_ifreq(self.ifreq + x / 2)
            else:
                self.offset = -x
                sys.stderr.write("coarse tuned to: %d Hz => %d Hz\n" %
                                 (self.offset, (self.ifreq + self.offset)))
                self.tuner.set_center_freq(self.offset)

        self.scope = fftsink2.fft_sink_c(
            self.Main.GetPage(0).GetWin(),
            title="Wideband Spectrum (click to coarse tune)",
            fft_size=1024,
            sample_rate=sample_rate,
            ref_scale=2.0,
            ref_level=0,
            y_divs=10,
            fft_rate=10,
            average=False,
            avg_alpha=0.6)

        self.Main.GetPage(0).Add(self.scope.win)
        self.scope.set_callback(fftsink2_callback)

        self.connect(self.src, self.scope)

        def fftsink2_callback2(x, y):
            self.offset = self.offset - (x / 10)
            sys.stderr.write("fine tuned to: %d Hz => %d Hz\n" %
                             (self.offset, (self.ifreq + self.offset)))
            self.tuner.set_center_freq(self.offset)

        self.scope2 = fftsink2.fft_sink_c(
            self.Main.GetPage(1).GetWin(),
            title="Channel Spectrum (click to fine tune)",
            fft_size=1024,
            sample_rate=out_sample_rate,
            ref_scale=2.0,
            ref_level=-20,
            y_divs=10,
            fft_rate=10,
            average=False,
            avg_alpha=0.6)

        self.Main.GetPage(1).Add(self.scope2.win)
        self.scope2.set_callback(fftsink2_callback2)

        self.connect(self.resamp, self.scope2)

        self.scope3 = scopesink2.scope_sink_f(
            self.Main.GetPage(2).GetWin(),
            title="Soft Bits",
            sample_rate=out_sample_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0.001,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.Main.GetPage(2).Add(self.scope3.win)

        self.connect(self.demod, self.scope3)
コード例 #32
0
ファイル: simple_trx.py プロジェクト: jmalsbury/oa
	def __init__(self, antenna="TX/RX", rx_gain=30, vor_samp_rate=250e3, com_freq_1=135.275e6, gain=21, vor_freq_1=115e6):
		grc_wxgui.top_block_gui.__init__(self, title="Simple Trx")

		##################################################
		# Parameters
		##################################################
		self.antenna = antenna
		self.rx_gain = rx_gain
		self.vor_samp_rate = vor_samp_rate
		self.com_freq_1 = com_freq_1
		self.gain = gain
		self.vor_freq_1 = vor_freq_1

		##################################################
		# Variables
		##################################################
		self.obs_decimation = obs_decimation = 25
		self.ils_decimation = ils_decimation = 50
		self.am_sample_rate = am_sample_rate = 12.5e3
		self.vor_volume_slider = vor_volume_slider = 5
		self.vor_ident = vor_ident = False
		self.vor_freq_entry_1 = vor_freq_entry_1 = vor_freq_1
		self.vor_center_freq_0 = vor_center_freq_0 = (117.95e6-108.00e6)/2+117.95e6
		self.system_center_freq = system_center_freq = 133.9e6
		self.squelch_slider = squelch_slider = -85
		self.samp_rate = samp_rate = 250e3
		self.rxgain = rxgain = 15
		self.phase_correction = phase_correction = 5
		self.obs_sample_rate = obs_sample_rate = am_sample_rate/obs_decimation
		self.ils_sample_rate = ils_sample_rate = am_sample_rate/ils_decimation
		self.gain_slider = gain_slider = gain
		self.correction_gain = correction_gain = 0.8
		self.com_volume_slider = com_volume_slider = 1
		self.com_freq_entry_1 = com_freq_entry_1 = com_freq_1
		self.com_enable = com_enable = True
		self.audio_select = audio_select = 0
		self.audio_sample_rate = audio_sample_rate = 48e3
		self.am_decimation = am_decimation = 1

		##################################################
		# Blocks
		##################################################
		_vor_volume_slider_sizer = wx.BoxSizer(wx.VERTICAL)
		self._vor_volume_slider_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_vor_volume_slider_sizer,
			value=self.vor_volume_slider,
			callback=self.set_vor_volume_slider,
			label='vor_volume_slider',
			converter=forms.float_converter(),
			proportion=0,
		)
		self._vor_volume_slider_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_vor_volume_slider_sizer,
			value=self.vor_volume_slider,
			callback=self.set_vor_volume_slider,
			minimum=0,
			maximum=10,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_vor_volume_slider_sizer, 1, 4, 1, 1)
		self._vor_ident_check_box = forms.check_box(
			parent=self.GetWin(),
			value=self.vor_ident,
			callback=self.set_vor_ident,
			label='vor_ident',
			true=1,
			false=0,
		)
		self.GridAdd(self._vor_ident_check_box, 0, 3, 1, 1)
		self._vor_freq_entry_1_text_box = forms.text_box(
			parent=self.GetWin(),
			value=self.vor_freq_entry_1,
			callback=self.set_vor_freq_entry_1,
			label='vor_freq_entry_1',
			converter=forms.float_converter(),
		)
		self.GridAdd(self._vor_freq_entry_1_text_box, 0, 1, 1, 1)
		self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
		self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "RF Analyzer")
		self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Channel FFT")
		self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Demod Audio FFT")
		self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Ref and Phase Scope")
		self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Manipulated Ref and Phase")
		self.Add(self.notebook_0)
		_com_volume_slider_sizer = wx.BoxSizer(wx.VERTICAL)
		self._com_volume_slider_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_com_volume_slider_sizer,
			value=self.com_volume_slider,
			callback=self.set_com_volume_slider,
			label='com_volume_slider',
			converter=forms.float_converter(),
			proportion=0,
		)
		self._com_volume_slider_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_com_volume_slider_sizer,
			value=self.com_volume_slider,
			callback=self.set_com_volume_slider,
			minimum=0,
			maximum=10,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_com_volume_slider_sizer, 1, 5, 1, 1)
		self._com_freq_entry_1_text_box = forms.text_box(
			parent=self.GetWin(),
			value=self.com_freq_entry_1,
			callback=self.set_com_freq_entry_1,
			label='com_freq_entry_1',
			converter=forms.float_converter(),
		)
		self.GridAdd(self._com_freq_entry_1_text_box, 0, 0, 1, 1)
		self._com_enable_check_box = forms.check_box(
			parent=self.GetWin(),
			value=self.com_enable,
			callback=self.set_com_enable,
			label='com_enable',
			true=1,
			false=0,
		)
		self.GridAdd(self._com_enable_check_box, 2, 3, 1, 1)
		self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
			self.notebook_0.GetPage(3).GetWin(),
			title="Scope Plot",
			sample_rate=12.5e3,
			v_scale=0,
			v_offset=0,
			t_scale=0,
			ac_couple=False,
			xy_mode=False,
			num_inputs=2,
			trig_mode=gr.gr_TRIG_MODE_AUTO,
			y_axis_label="Counts",
		)
		self.notebook_0.GetPage(3).Add(self.wxgui_scopesink2_0.win)
		self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
			self.GetWin(),
			unit="Units",
			minval=-200,
			maxval=200,
			factor=1.0,
			decimal_places=10,
			ref_level=0,
			sample_rate=25e3/2000,
			number_rate=15,
			average=True,
			avg_alpha=0.02,
			label="Number Plot",
			peak_hold=False,
			show_gauge=True,
		)
		self.Add(self.wxgui_numbersink2_0.win)
		self.wxgui_fftsink2_0_1 = fftsink2.fft_sink_c(
			self.notebook_0.GetPage(0).GetWin(),
			baseband_freq=0,
			y_per_div=10,
			y_divs=10,
			ref_level=0,
			ref_scale=2.0,
			sample_rate=25e3,
			fft_size=1024,
			fft_rate=5,
			average=False,
			avg_alpha=None,
			title="FFT Plot",
			peak_hold=False,
		)
		self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_0_1.win)
		self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
			self.notebook_0.GetPage(1).GetWin(),
			baseband_freq=0,
			y_per_div=10,
			y_divs=10,
			ref_level=0,
			ref_scale=2.0,
			sample_rate=12.5e3,
			fft_size=1024,
			fft_rate=5,
			average=False,
			avg_alpha=None,
			title="FFT Plot",
			peak_hold=False,
		)
		self.notebook_0.GetPage(1).Add(self.wxgui_fftsink2_0.win)
		self.uhd_usrp_source_0 = uhd.usrp_source(
			device_addr="",
			stream_args=uhd.stream_args(
				cpu_format="fc32",
				channels=range(2),
			),
		)
		self.uhd_usrp_source_0.set_clock_source("internal", 0)
		self.uhd_usrp_source_0.set_subdev_spec("A:0 A:0", 0)
		self.uhd_usrp_source_0.set_samp_rate(vor_samp_rate)
		self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(com_freq_entry_1, rf_freq=system_center_freq, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
		self.uhd_usrp_source_0.set_gain(rx_gain, 0)
		self.uhd_usrp_source_0.set_antenna("RX2", 0)
		self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(vor_freq_entry_1, rf_freq=system_center_freq, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 1)
		self.uhd_usrp_source_0.set_gain(rx_gain, 1)
		self.uhd_usrp_source_0.set_antenna("RX2", 1)
		self.uhd_usrp_sink_0 = uhd.usrp_sink(
			device_addr="",
			stream_args=uhd.stream_args(
				cpu_format="fc32",
				channels=range(1),
			),
		)
		self.uhd_usrp_sink_0.set_samp_rate(250e3)
		self.uhd_usrp_sink_0.set_center_freq(com_freq_entry_1, 0)
		self.uhd_usrp_sink_0.set_gain(25, 0)
		self.uhd_usrp_sink_0.set_antenna("TX/RX", 0)
		_squelch_slider_sizer = wx.BoxSizer(wx.VERTICAL)
		self._squelch_slider_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_squelch_slider_sizer,
			value=self.squelch_slider,
			callback=self.set_squelch_slider,
			label='squelch_slider',
			converter=forms.float_converter(),
			proportion=0,
		)
		self._squelch_slider_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_squelch_slider_sizer,
			value=self.squelch_slider,
			callback=self.set_squelch_slider,
			minimum=-100,
			maximum=0,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_squelch_slider_sizer, 1, 0, 1, 1)
		self.squelch = gr.pwr_squelch_cc(squelch_slider, 0.01, 20, False)
		self.openavionics_joystick_interface_0 = openavionics.joystick_interface()
		self.openavionics_audio_ptt_0 = openavionics.audio_ptt()
		self.low_pass_filter_3_0 = filter.fir_filter_fff(5, firdes.low_pass(
			1, 25e3, 200, 50, firdes.WIN_HAMMING, 6.76))
		self.low_pass_filter_3 = filter.fir_filter_fff(5, firdes.low_pass(
			1, 25e3, 200, 50, firdes.WIN_HAMMING, 6.76))
		self.low_pass_filter_2 = filter.fir_filter_ccf(1, firdes.low_pass(
			1, 25e3, 3e3, 500, firdes.WIN_HAMMING, 6.76))
		self.low_pass_filter_1 = filter.interp_fir_filter_fff(1, firdes.low_pass(
			1, 12.5e3, 3e3, 1e3, firdes.WIN_HAMMING, 6.76))
		self.low_pass_filter_0_0 = filter.fir_filter_ccf(int(250e3/25e3), firdes.low_pass(
			1, vor_samp_rate, 11e3, 1e3, firdes.WIN_HAMMING, 6.76))
		self.low_pass_filter_0 = filter.fir_filter_ccf(int(250e3/12.5e3), firdes.low_pass(
			1, vor_samp_rate, 10e3, 1e3, firdes.WIN_HAMMING, 6.76))
		self.gr_sig_source_x_0 = gr.sig_source_c(25e3, gr.GR_COS_WAVE, 9960, 1, 0)
		self.gr_quadrature_demod_cf_0 = gr.quadrature_demod_cf(1)
		self.gr_pwr_squelch_xx_0 = gr.pwr_squelch_ff(-50, 0.5, 1, False)
		self.gr_null_sink_0_0 = gr.null_sink(gr.sizeof_gr_complex*1)
		self.gr_multiply_xx_0_0_1 = gr.multiply_vff(1)
		self.gr_multiply_xx_0_0_0_0 = gr.multiply_vcc(1)
		self.gr_multiply_xx_0 = gr.multiply_vcc(1)
		self.gr_float_to_complex_0_0_0 = gr.float_to_complex(1)
		self.gr_float_to_complex_0 = gr.float_to_complex(1)
		self.gr_agc2_xx_0_0 = gr.agc2_cc(1, 1, 0.75, 1.0, 0.0)
		self.gr_agc2_xx_0 = gr.agc2_cc(1, 1, 0.75, 1.0, 0.0)
		self.gr_add_xx_0_0_0 = gr.add_vff(1)
		_gain_slider_sizer = wx.BoxSizer(wx.VERTICAL)
		self._gain_slider_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_gain_slider_sizer,
			value=self.gain_slider,
			callback=self.set_gain_slider,
			label='gain_slider',
			converter=forms.float_converter(),
			proportion=0,
		)
		self._gain_slider_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_gain_slider_sizer,
			value=self.gain_slider,
			callback=self.set_gain_slider,
			minimum=0,
			maximum=30,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_gain_slider_sizer, 1, 1, 1, 1)
		self.fft_tone_to_angle_0 = fft_tone_to_angle(
			fft_bin=12,
			fft_size=2000,
		)
		self.const_source_x_0_1 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 0.450)
		self.const_source_x_0_0_1 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 0.550)
		self.const_source_x_0_0_0_0 = gr.sig_source_c(0, gr.GR_CONST_WAVE, 0, 0, 0.450)
		self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_float*1)
		self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1)
		self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((180.0/3.1415, ))
		self.blocks_add_xx_0 = blocks.add_vff(1)
		self.blks2_rational_resampler_xxx_2_0 = blks2.rational_resampler_fff(
			interpolation=250,
			decimation=48,
			taps=None,
			fractional_bw=None,
		)
		self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_fff(
			interpolation=480,
			decimation=125,
			taps=None,
			fractional_bw=None,
		)
		self.blks2_am_demod_cf_0_0 = blks2.am_demod_cf(
			channel_rate=25e3,
			audio_decim=am_decimation,
			audio_pass=11.5e3,
			audio_stop=12.250e3,
		)
		self.blks2_am_demod_cf_0 = blks2.am_demod_cf(
			channel_rate=am_sample_rate,
			audio_decim=am_decimation,
			audio_pass=3e3,
			audio_stop=4e3,
		)
		self.band_pass_filter_0 = gr.fir_filter_fff(2, firdes.band_pass(
			1, 25000, 980, 1150, 50, firdes.WIN_HAMMING, 6.76))
		self.audio_sink_0 = audio.sink(int(audio_sample_rate), "", True)
		self._audio_select_chooser = forms.drop_down(
			parent=self.GetWin(),
			value=self.audio_select,
			callback=self.set_audio_select,
			label='audio_select',
			choices=[0, 1],
			labels=['AM Voice','VOR Subcarrier'],
		)
		self.GridAdd(self._audio_select_chooser, 0, 2, 1, 1)
		self.analog_sig_source_x_0_0 = analog.sig_source_f(48000, analog.GR_COS_WAVE, 1000, 1, 0)
		self.adsf_0 = blocks.multiply_const_vff((com_enable*com_volume_slider, ))
		self.adsf = blocks.multiply_const_vff((vor_ident*vor_volume_slider, ))

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_float_to_complex_0, 0), (self.gr_multiply_xx_0, 0))
		self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.audio_sink_0, 0))
		self.connect((self.blks2_am_demod_cf_0, 0), (self.low_pass_filter_1, 0))
		self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0))
		self.connect((self.uhd_usrp_source_0, 1), (self.gr_null_sink_0_0, 0))
		self.connect((self.low_pass_filter_0, 0), (self.squelch, 0))
		self.connect((self.squelch, 0), (self.gr_agc2_xx_0, 0))
		self.connect((self.low_pass_filter_0, 0), (self.wxgui_fftsink2_0, 0))
		self.connect((self.gr_agc2_xx_0, 0), (self.blks2_am_demod_cf_0, 0))
		self.connect((self.low_pass_filter_0_0, 0), (self.wxgui_fftsink2_0_1, 0))
		self.connect((self.gr_agc2_xx_0_0, 0), (self.blks2_am_demod_cf_0_0, 0))
		self.connect((self.uhd_usrp_source_0, 1), (self.low_pass_filter_0_0, 0))
		self.connect((self.blks2_am_demod_cf_0_0, 0), (self.gr_float_to_complex_0, 0))
		self.connect((self.fft_tone_to_angle_0, 0), (self.blocks_multiply_const_vxx_0, 0))
		self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_numbersink2_0, 0))
		self.connect((self.fft_tone_to_angle_0, 1), (self.blocks_null_sink_0, 0))
		self.connect((self.fft_tone_to_angle_0, 2), (self.blocks_null_sink_1, 0))
		self.connect((self.low_pass_filter_0_0, 0), (self.gr_agc2_xx_0_0, 0))
		self.connect((self.gr_quadrature_demod_cf_0, 0), (self.low_pass_filter_3, 0))
		self.connect((self.low_pass_filter_3, 0), (self.fft_tone_to_angle_0, 0))
		self.connect((self.low_pass_filter_3_0, 0), (self.fft_tone_to_angle_0, 1))
		self.connect((self.blks2_am_demod_cf_0_0, 0), (self.low_pass_filter_3_0, 0))
		self.connect((self.blks2_am_demod_cf_0_0, 0), (self.gr_float_to_complex_0, 1))
		self.connect((self.gr_multiply_xx_0, 0), (self.low_pass_filter_2, 0))
		self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 1))
		self.connect((self.low_pass_filter_2, 0), (self.gr_quadrature_demod_cf_0, 0))
		self.connect((self.blks2_am_demod_cf_0_0, 0), (self.band_pass_filter_0, 0))
		self.connect((self.adsf, 0), (self.blocks_add_xx_0, 1))
		self.connect((self.blocks_add_xx_0, 0), (self.blks2_rational_resampler_xxx_1, 0))
		self.connect((self.adsf, 0), (self.wxgui_scopesink2_0, 1))
		self.connect((self.low_pass_filter_1, 0), (self.adsf_0, 0))
		self.connect((self.adsf_0, 0), (self.blocks_add_xx_0, 0))
		self.connect((self.adsf_0, 0), (self.wxgui_scopesink2_0, 0))
		self.connect((self.band_pass_filter_0, 0), (self.gr_pwr_squelch_xx_0, 0))
		self.connect((self.gr_pwr_squelch_xx_0, 0), (self.adsf, 0))
		self.connect((self.const_source_x_0_0_0_0, 0), (self.gr_multiply_xx_0_0_0_0, 1))
		self.connect((self.gr_float_to_complex_0_0_0, 0), (self.gr_multiply_xx_0_0_0_0, 0))
		self.connect((self.gr_add_xx_0_0_0, 0), (self.gr_float_to_complex_0_0_0, 1))
		self.connect((self.gr_add_xx_0_0_0, 0), (self.gr_float_to_complex_0_0_0, 0))
		self.connect((self.const_source_x_0_0_1, 0), (self.gr_add_xx_0_0_0, 1))
		self.connect((self.gr_multiply_xx_0_0_1, 0), (self.gr_add_xx_0_0_0, 0))
		self.connect((self.const_source_x_0_1, 0), (self.gr_multiply_xx_0_0_1, 1))
		self.connect((self.gr_multiply_xx_0_0_0_0, 0), (self.uhd_usrp_sink_0, 0))
		self.connect((self.blks2_rational_resampler_xxx_2_0, 0), (self.openavionics_audio_ptt_0, 0))
		self.connect((self.analog_sig_source_x_0_0, 0), (self.blks2_rational_resampler_xxx_2_0, 0))
		self.connect((self.openavionics_audio_ptt_0, 0), (self.gr_multiply_xx_0_0_1, 0))

		##################################################
		# Asynch Message Connections
		##################################################
		self.msg_connect(self.openavionics_joystick_interface_0, "out", self.openavionics_audio_ptt_0, "in2")