示例#1
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self,
                                         title="Space AIS Receiver Simulation")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 326531
        self.send_interval_freq_0 = send_interval_freq_0 = 0.2
        self.send_interval_freq = send_interval_freq = 0.2
        self.func_doppler_0 = func_doppler_0 = 0
        self.func_doppler = func_doppler = 0
        self.func_burst_out_0 = func_burst_out_0 = 0
        self.func_burst_out = func_burst_out = 0
        self.doppler_sensitivity = doppler_sensitivity = 30000
        self.doppler_control_freq1 = doppler_control_freq1 = 0.1
        self.channel_select = channel_select = 0
        self.bit_rate = bit_rate = 9600
        self.ais_burst_duration = ais_burst_duration = samp_rate / 5

        ##################################################
        # Blocks
        ##################################################
        self.probe_doppler_0 = blocks.probe_signal_i()
        self.probe_doppler = blocks.probe_signal_i()
        self.probe_burst = blocks.probe_signal_i()
        self.probe_burst_0 = blocks.probe_signal_i()

        def _func_doppler_0_probe():
            while True:
                val = self.probe_doppler_0.level()
                try:
                    self.set_func_doppler_0(val)
                except AttributeError, e:
                    pass
                time.sleep(1.0 / (samp_rate))
    def __init__(self,
                 angle=0,
                 samp_rate=1e6,
                 fft_len=pow(2, 20),
                 samp_rate_sink=8000,
                 tx_amp=10e-3,
                 max_num_of_targets=10,
                 lowpass_cutoff_freq=1700,
                 RF=2.49e9,
                 speed_samp_rate=1,
                 DC_filter_num_elements=4,
                 threshold_dB=-70,
                 rx_gain=0,
                 highpass_cutoff_freq=0,
                 doppler_signal_bw=20):
        grc_wxgui.top_block_gui.__init__(
            self, title="CW Doppler Radar Simulator Multiple Targets")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Parameters
        ##################################################
        self.angle = angle
        self.samp_rate = samp_rate
        self.fft_len = fft_len
        self.samp_rate_sink = samp_rate_sink
        self.tx_amp = tx_amp
        self.max_num_of_targets = max_num_of_targets
        self.lowpass_cutoff_freq = lowpass_cutoff_freq
        self.RF = RF
        self.speed_samp_rate = speed_samp_rate
        self.DC_filter_num_elements = DC_filter_num_elements
        self.threshold_dB = threshold_dB
        self.rx_gain = rx_gain
        self.highpass_cutoff_freq = highpass_cutoff_freq
        self.doppler_signal_bw = doppler_signal_bw

        ##################################################
        # Variables
        ##################################################
        self.target_speed_vector = target_speed_vector = 0
        self.target_direction_vector = target_direction_vector = 0
        self.num_targets = num_targets = 0
        self.tx_amp_tuner = tx_amp_tuner = tx_amp
        self.threshold_dB_tuner = threshold_dB_tuner = threshold_dB
        self.speed_textbox = speed_textbox = target_speed_vector
        self.rx_gain_tuner = rx_gain_tuner = rx_gain
        self.num_targets_textbox = num_targets_textbox = num_targets
        self.max_num_of_targets_tuner = max_num_of_targets_tuner = max_num_of_targets
        self.lowpass_cutoff_freq_tuner = lowpass_cutoff_freq_tuner = lowpass_cutoff_freq
        self.highpass_cutoff_freq_tuner = highpass_cutoff_freq_tuner = highpass_cutoff_freq
        self.doppler_signal_bw_tuner = doppler_signal_bw_tuner = doppler_signal_bw
        self.doppler_freq_sim_tuner = doppler_freq_sim_tuner = 100
        self.direction_textbox = direction_textbox = target_direction_vector
        self.angle_tuner = angle_tuner = angle
        self.RF_tuner = RF_tuner = RF

        ##################################################
        # Blocks
        ##################################################
        _tx_amp_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tx_amp_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_tx_amp_tuner_sizer,
            value=self.tx_amp_tuner,
            callback=self.set_tx_amp_tuner,
            label="TX Signal Amp",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._tx_amp_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_tx_amp_tuner_sizer,
            value=self.tx_amp_tuner,
            callback=self.set_tx_amp_tuner,
            minimum=0,
            maximum=100e-3,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_tx_amp_tuner_sizer, 0, 8, 1, 21)
        _threshold_dB_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._threshold_dB_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_threshold_dB_tuner_sizer,
            value=self.threshold_dB_tuner,
            callback=self.set_threshold_dB_tuner,
            label="Detected Target Threshold (dB)",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._threshold_dB_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_threshold_dB_tuner_sizer,
            value=self.threshold_dB_tuner,
            callback=self.set_threshold_dB_tuner,
            minimum=-90,
            maximum=-30,
            num_steps=60,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_threshold_dB_tuner_sizer, 2, 0, 1, 8)
        self.speed_vector_probe = blocks.probe_signal_vf(max_num_of_targets)
        self.notebook = self.notebook = wx.Notebook(self.GetWin(),
                                                    style=wx.NB_TOP)
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook),
                              "FFT CW Doppler Radar Receiver")
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook),
                              "Frequency/Time CW Doppler Radar Receiver")
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook),
                              "FFT CW Doppler Radar Receiver Full Spectrum")
        self.GridAdd(self.notebook, 6, 0, 13, 53)
        _max_num_of_targets_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._max_num_of_targets_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_max_num_of_targets_tuner_sizer,
            value=self.max_num_of_targets_tuner,
            callback=self.set_max_num_of_targets_tuner,
            label="Maximum Number of Targets",
            converter=forms.int_converter(),
            proportion=0,
        )
        self._max_num_of_targets_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_max_num_of_targets_tuner_sizer,
            value=self.max_num_of_targets_tuner,
            callback=self.set_max_num_of_targets_tuner,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.GridAdd(_max_num_of_targets_tuner_sizer, 2, 8, 1, 21)
        _lowpass_cutoff_freq_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._lowpass_cutoff_freq_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_lowpass_cutoff_freq_tuner_sizer,
            value=self.lowpass_cutoff_freq_tuner,
            callback=self.set_lowpass_cutoff_freq_tuner,
            label="Low-Pass Cutoff Frequency (Hz)",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._lowpass_cutoff_freq_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_lowpass_cutoff_freq_tuner_sizer,
            value=self.lowpass_cutoff_freq_tuner,
            callback=self.set_lowpass_cutoff_freq_tuner,
            minimum=0,
            maximum=3000,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_lowpass_cutoff_freq_tuner_sizer, 1, 29, 1, 24)
        _highpass_cutoff_freq_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._highpass_cutoff_freq_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_highpass_cutoff_freq_tuner_sizer,
            value=self.highpass_cutoff_freq_tuner,
            callback=self.set_highpass_cutoff_freq_tuner,
            label="High-Pass Cutoff Frequency (Hz)",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._highpass_cutoff_freq_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_highpass_cutoff_freq_tuner_sizer,
            value=self.highpass_cutoff_freq_tuner,
            callback=self.set_highpass_cutoff_freq_tuner,
            minimum=0,
            maximum=1600,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_highpass_cutoff_freq_tuner_sizer, 0, 29, 1, 24)
        _doppler_signal_bw_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._doppler_signal_bw_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_doppler_signal_bw_tuner_sizer,
            value=self.doppler_signal_bw_tuner,
            callback=self.set_doppler_signal_bw_tuner,
            label="Doppler Spectrum Bandwidth (Hz)",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._doppler_signal_bw_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_doppler_signal_bw_tuner_sizer,
            value=self.doppler_signal_bw_tuner,
            callback=self.set_doppler_signal_bw_tuner,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_doppler_signal_bw_tuner_sizer, 2, 29, 1, 24)
        _doppler_freq_sim_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._doppler_freq_sim_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_doppler_freq_sim_tuner_sizer,
            value=self.doppler_freq_sim_tuner,
            callback=self.set_doppler_freq_sim_tuner,
            label="Doppler Frequency Simulator (Hz)",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._doppler_freq_sim_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_doppler_freq_sim_tuner_sizer,
            value=self.doppler_freq_sim_tuner,
            callback=self.set_doppler_freq_sim_tuner,
            minimum=-2000,
            maximum=2000,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_doppler_freq_sim_tuner_sizer, 3, 29, 1, 24)
        self.direction_vector_probe = blocks.probe_signal_vi(
            max_num_of_targets)
        _angle_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._angle_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_angle_tuner_sizer,
            value=self.angle_tuner,
            callback=self.set_angle_tuner,
            label="Angle of Approach of the Target (Deg)",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._angle_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_angle_tuner_sizer,
            value=self.angle_tuner,
            callback=self.set_angle_tuner,
            minimum=0,
            maximum=89,
            num_steps=890,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_angle_tuner_sizer, 1, 8, 1, 21)
        _RF_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._RF_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_RF_tuner_sizer,
            value=self.RF_tuner,
            callback=self.set_RF_tuner,
            label="Radar Frequency (Hz)",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._RF_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_RF_tuner_sizer,
            value=self.RF_tuner,
            callback=self.set_RF_tuner,
            minimum=2.4e9,
            maximum=2.5e9,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_RF_tuner_sizer, 1, 0, 1, 8)
        self.wxgui_waterfallsink2_time_frequency = waterfallsink2.waterfall_sink_c(
            self.notebook.GetPage(1).GetWin(),
            baseband_freq=0,
            dynamic_range=100,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate_sink,
            fft_size=1024,
            fft_rate=15,
            average=True,
            avg_alpha=None,
            title="Time/Frequency CW Doppler Radar Receiver",
            win=window.blackmanharris,
        )
        self.notebook.GetPage(1).Add(
            self.wxgui_waterfallsink2_time_frequency.win)
        self.wxgui_fftsink2_full_spectrum = fftsink2.fft_sink_c(
            self.notebook.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=4096,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="FFT CW Doppler Radar Receiver Full Spectrum",
            peak_hold=False,
            win=window.blackmanharris,
        )
        self.notebook.GetPage(2).Add(self.wxgui_fftsink2_full_spectrum.win)
        self.wxgui_fftsink2 = fftsink2.fft_sink_c(
            self.notebook.GetPage(0).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate_sink,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="FFT CW Doppler Radar Receiver ",
            peak_hold=False,
            win=window.blackmanharris,
        )
        self.notebook.GetPage(0).Add(self.wxgui_fftsink2.win)
        self.vector_to_stream_positive = blocks.vector_to_stream(
            gr.sizeof_float * 1, fft_len)
        self.vector_to_stream_negative = blocks.vector_to_stream(
            gr.sizeof_float * 1, fft_len)
        self.tx_signal = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 0,
                                             1, 0)
        self.throtle_block = blocks.throttle(gr.sizeof_gr_complex * 1,
                                             samp_rate, True)

        def _target_speed_vector_probe():
            while True:
                val = self.speed_vector_probe.level()
                try:
                    self.set_target_speed_vector(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (speed_samp_rate))

        _target_speed_vector_thread = threading.Thread(
            target=_target_speed_vector_probe)
        _target_speed_vector_thread.daemon = True
        _target_speed_vector_thread.start()

        def _target_direction_vector_probe():
            while True:
                val = self.direction_vector_probe.level()
                try:
                    self.set_target_direction_vector(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (speed_samp_rate))

        _target_direction_vector_thread = threading.Thread(
            target=_target_direction_vector_probe)
        _target_direction_vector_thread.daemon = True
        _target_direction_vector_thread.start()
        self.stream_to_vector_positive = blocks.stream_to_vector(
            gr.sizeof_float * 1, fft_len / 2)
        self.stream_to_vector_negative = blocks.stream_to_vector(
            gr.sizeof_float * 1, fft_len / 2)
        self.stream_to_vector_for_fft = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, fft_len)
        self._speed_textbox_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.speed_textbox,
            callback=self.set_speed_textbox,
            label="Targets Speed (Kph)",
            converter=forms.str_converter(),
        )
        self.GridAdd(self._speed_textbox_text_box, 4, 0, 1, 53)
        self.rx_signal_2 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE,
                                               doppler_freq_sim_tuner + 15,
                                               tx_amp_tuner - 5e-3, 0)
        self.rx_signal_1 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE,
                                               doppler_freq_sim_tuner - 1300,
                                               tx_amp + 10e-3, 0)
        self.rx_signal_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE,
                                               doppler_freq_sim_tuner,
                                               tx_amp_tuner, 0)
        _rx_gain_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_gain_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rx_gain_tuner_sizer,
            value=self.rx_gain_tuner,
            callback=self.set_rx_gain_tuner,
            label="USRP RX Gain (dB)",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rx_gain_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rx_gain_tuner_sizer,
            value=self.rx_gain_tuner,
            callback=self.set_rx_gain_tuner,
            minimum=0,
            maximum=70,
            num_steps=70,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_rx_gain_tuner_sizer, 0, 0, 1, 8)
        self.rational_resampler = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=int(samp_rate / samp_rate_sink),
            taps=None,
            fractional_bw=None,
        )
        self._num_targets_textbox_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.num_targets_textbox,
            callback=self.set_num_targets_textbox,
            label="Number of Targets Detected",
            converter=forms.int_converter(),
        )
        self.GridAdd(self._num_targets_textbox_text_box, 3, 0, 1, 4)
        self.num_targets_probe = blocks.probe_signal_i()

        def _num_targets_probe():
            while True:
                val = self.num_targets_probe.level()
                try:
                    self.set_num_targets(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (speed_samp_rate))

        _num_targets_thread = threading.Thread(target=_num_targets_probe)
        _num_targets_thread.daemon = True
        _num_targets_thread.start()
        self.mixer = blocks.multiply_vcc(1)
        self.keep_m_in_n_positive = blocks.keep_m_in_n(gr.sizeof_float,
                                                       fft_len / 2, fft_len,
                                                       fft_len / 2)
        self.keep_m_in_n_negative = blocks.keep_m_in_n(gr.sizeof_float,
                                                       fft_len / 2, fft_len, 0)
        self.fft_vxx_0 = fft.fft_vcc(fft_len, True,
                                     (window.blackmanharris(fft_len)), True, 1)
        self._direction_textbox_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.direction_textbox,
            callback=self.set_direction_textbox,
            label="Targets Direction",
            converter=forms.str_converter(),
        )
        self.GridAdd(self._direction_textbox_text_box, 5, 0, 1, 53)
        self.cwradar_vector_flip_ff = cwradar.vector_flip_ff(fft_len / 2)
        self.cwradar_doppler_velocity_multiple_targets_ff = cwradar.doppler_velocity_multiple_targets_ff(
            fft_len / 2, samp_rate, RF_tuner, threshold_dB_tuner, angle_tuner,
            lowpass_cutoff_freq_tuner, highpass_cutoff_freq_tuner,
            max_num_of_targets_tuner, doppler_signal_bw_tuner)
        self.blocks_complex_to_mag = blocks.complex_to_mag(fft_len)
        self.awgn_channel_simulator = analog.noise_source_c(
            analog.GR_GAUSSIAN, 1e-3, 0)
        self.adder_2 = blocks.add_vcc(1)
        self.adder_1 = blocks.add_vcc(1)
        self.DC_filter_positive = blocks.multiply_const_vff(
            ([0] * DC_filter_num_elements + [1] *
             ((fft_len / 2) - DC_filter_num_elements)))
        self.DC_filter_negative = blocks.multiply_const_vff(
            ([0] * DC_filter_num_elements + [1] *
             ((fft_len / 2) - DC_filter_num_elements)))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.DC_filter_negative, 0),
                     (self.cwradar_doppler_velocity_multiple_targets_ff, 0))
        self.connect((self.DC_filter_positive, 0),
                     (self.cwradar_doppler_velocity_multiple_targets_ff, 1))
        self.connect((self.cwradar_doppler_velocity_multiple_targets_ff, 2),
                     (self.num_targets_probe, 0))
        self.connect((self.cwradar_doppler_velocity_multiple_targets_ff, 1),
                     (self.direction_vector_probe, 0))
        self.connect((self.cwradar_doppler_velocity_multiple_targets_ff, 0),
                     (self.speed_vector_probe, 0))
        self.connect((self.awgn_channel_simulator, 0), (self.adder_2, 0))
        self.connect((self.tx_signal, 0), (self.adder_2, 1))
        self.connect((self.adder_2, 0), (self.mixer, 0))
        self.connect((self.awgn_channel_simulator, 0), (self.adder_1, 0))
        self.connect((self.mixer, 0), (self.throtle_block, 0))
        self.connect((self.mixer, 0), (self.stream_to_vector_for_fft, 0))
        self.connect((self.throtle_block, 0),
                     (self.wxgui_fftsink2_full_spectrum, 0))
        self.connect((self.throtle_block, 0), (self.rational_resampler, 0))
        self.connect((self.adder_1, 0), (self.mixer, 1))
        self.connect((self.rational_resampler, 0),
                     (self.wxgui_waterfallsink2_time_frequency, 0))
        self.connect((self.stream_to_vector_for_fft, 0), (self.fft_vxx_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag, 0))
        self.connect((self.blocks_complex_to_mag, 0),
                     (self.vector_to_stream_negative, 0))
        self.connect((self.blocks_complex_to_mag, 0),
                     (self.vector_to_stream_positive, 0))
        self.connect((self.vector_to_stream_positive, 0),
                     (self.keep_m_in_n_positive, 0))
        self.connect((self.keep_m_in_n_negative, 0),
                     (self.stream_to_vector_negative, 0))
        self.connect((self.keep_m_in_n_positive, 0),
                     (self.stream_to_vector_positive, 0))
        self.connect((self.vector_to_stream_negative, 0),
                     (self.keep_m_in_n_negative, 0))
        self.connect((self.stream_to_vector_positive, 0),
                     (self.DC_filter_positive, 0))
        self.connect((self.stream_to_vector_negative, 0),
                     (self.cwradar_vector_flip_ff, 0))
        self.connect((self.cwradar_vector_flip_ff, 0),
                     (self.DC_filter_negative, 0))
        self.connect((self.rx_signal_1, 0), (self.adder_1, 3))
        self.connect((self.rx_signal_0, 0), (self.adder_1, 2))
        self.connect((self.tx_signal, 0), (self.adder_1, 1))
        self.connect((self.rx_signal_2, 0), (self.adder_1, 4))
        self.connect((self.rational_resampler, 0), (self.wxgui_fftsink2, 0))
    def __init__(self, lo_offset_freq=1e6, threshold_dB=-70, RF=2.49e9, DC_filter_num_elements=4, speed_samp_rate=1, samp_rate=1e6, highpass_cutoff_freq=0, lowpass_cutoff_freq=1700, fft_len=pow(2,20), samp_rate_sink=8000, angle=0, tx_amp=1, rx_gain=30.5):
        grc_wxgui.top_block_gui.__init__(self, title="CW Radar Single Target")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Parameters
        ##################################################
        self.lo_offset_freq = lo_offset_freq
        self.threshold_dB = threshold_dB
        self.RF = RF
        self.DC_filter_num_elements = DC_filter_num_elements
        self.speed_samp_rate = speed_samp_rate
        self.samp_rate = samp_rate
        self.highpass_cutoff_freq = highpass_cutoff_freq
        self.lowpass_cutoff_freq = lowpass_cutoff_freq
        self.fft_len = fft_len
        self.samp_rate_sink = samp_rate_sink
        self.angle = angle
        self.tx_amp = tx_amp
        self.rx_gain = rx_gain

        ##################################################
        # Variables
        ##################################################
        self.target_speed = target_speed = 0
        self.target_direction = target_direction = 0
        self.tx_amp_tuner = tx_amp_tuner = tx_amp
        self.threshold_dB_tuner = threshold_dB_tuner = threshold_dB
        self.speed_textbox = speed_textbox = target_speed
        self.rx_gain_tuner = rx_gain_tuner = rx_gain
        self.lowpass_cutoff_freq_tuner = lowpass_cutoff_freq_tuner = lowpass_cutoff_freq
        self.highpass_cutoff_freq_tuner = highpass_cutoff_freq_tuner = highpass_cutoff_freq
        self.direction_textbox = direction_textbox = target_direction
        self.angle_tuner = angle_tuner = angle
        self.RF_tuner = RF_tuner = RF

        ##################################################
        # Blocks
        ##################################################
        _tx_amp_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tx_amp_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_tx_amp_tuner_sizer,
        	value=self.tx_amp_tuner,
        	callback=self.set_tx_amp_tuner,
        	label="TX Signal Amp",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._tx_amp_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_tx_amp_tuner_sizer,
        	value=self.tx_amp_tuner,
        	callback=self.set_tx_amp_tuner,
        	minimum=0,
        	maximum=1,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_tx_amp_tuner_sizer, 0, 17, 1, 26)
        _threshold_dB_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._threshold_dB_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_threshold_dB_tuner_sizer,
        	value=self.threshold_dB_tuner,
        	callback=self.set_threshold_dB_tuner,
        	label="Detected Target Threshold (dB)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._threshold_dB_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_threshold_dB_tuner_sizer,
        	value=self.threshold_dB_tuner,
        	callback=self.set_threshold_dB_tuner,
        	minimum=-90,
        	maximum=-30,
        	num_steps=60,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_threshold_dB_tuner_sizer, 2, 0, 1, 17)
        self.speed_probe = blocks.probe_signal_f()
        _rx_gain_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_gain_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_rx_gain_tuner_sizer,
        	value=self.rx_gain_tuner,
        	callback=self.set_rx_gain_tuner,
        	label="USRP RX Gain (dB)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._rx_gain_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_rx_gain_tuner_sizer,
        	value=self.rx_gain_tuner,
        	callback=self.set_rx_gain_tuner,
        	minimum=0,
        	maximum=30.5 + 62,
        	num_steps=185,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_rx_gain_tuner_sizer, 0, 0, 1, 17)
        self.notebook = self.notebook = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "FFT CW Doppler Radar Receiver")
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "Frequency/Time CW Doppler Radar Receiver")
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "FFT CW Doppler Radar Receiver Full Spectrum")
        self.GridAdd(self.notebook, 5, 0, 13, 75)
        _lowpass_cutoff_freq_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._lowpass_cutoff_freq_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_lowpass_cutoff_freq_tuner_sizer,
        	value=self.lowpass_cutoff_freq_tuner,
        	callback=self.set_lowpass_cutoff_freq_tuner,
        	label="Lowpass Cutoff Frequency (Hz)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._lowpass_cutoff_freq_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_lowpass_cutoff_freq_tuner_sizer,
        	value=self.lowpass_cutoff_freq_tuner,
        	callback=self.set_lowpass_cutoff_freq_tuner,
        	minimum=0,
        	maximum=3000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_lowpass_cutoff_freq_tuner_sizer, 1, 43, 1, 32)
        _highpass_cutoff_freq_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._highpass_cutoff_freq_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_highpass_cutoff_freq_tuner_sizer,
        	value=self.highpass_cutoff_freq_tuner,
        	callback=self.set_highpass_cutoff_freq_tuner,
        	label="High-Pass Cutoff Frequency (Hz)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._highpass_cutoff_freq_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_highpass_cutoff_freq_tuner_sizer,
        	value=self.highpass_cutoff_freq_tuner,
        	callback=self.set_highpass_cutoff_freq_tuner,
        	minimum=0,
        	maximum=1600,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_highpass_cutoff_freq_tuner_sizer, 0, 43, 1, 32)
        self.direction_probe = blocks.probe_signal_i()
        _angle_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._angle_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_angle_tuner_sizer,
        	value=self.angle_tuner,
        	callback=self.set_angle_tuner,
        	label="Angle of Approach of the Target (Deg)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._angle_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_angle_tuner_sizer,
        	value=self.angle_tuner,
        	callback=self.set_angle_tuner,
        	minimum=0,
        	maximum=89,
        	num_steps=890,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_angle_tuner_sizer, 1, 17, 1, 26)
        _RF_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._RF_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_RF_tuner_sizer,
        	value=self.RF_tuner,
        	callback=self.set_RF_tuner,
        	label="Radar Frequency (Hz)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._RF_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_RF_tuner_sizer,
        	value=self.RF_tuner,
        	callback=self.set_RF_tuner,
        	minimum=2.4e9,
        	maximum=2.5e9,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_RF_tuner_sizer, 1, 0, 1, 17)
        self.wxgui_waterfallsink = waterfallsink2.waterfall_sink_c(
        	self.notebook.GetPage(1).GetWin(),
        	baseband_freq=0,
        	dynamic_range=100,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate_sink,
        	fft_size=1024,
        	fft_rate=100,
        	average=False,
        	avg_alpha=None,
        	title="Time/Frequency CW Doppler Radar",
        	win=window.blackmanharris,
        )
        self.notebook.GetPage(1).Add(self.wxgui_waterfallsink.win)
        self.wxgui_fftsink2_full_spectrum = fftsink2.fft_sink_c(
        	self.notebook.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=4096,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="FFT CW Doppler Radar Receiver Full Spectrum",
        	peak_hold=False,
        	win=window.blackmanharris,
        )
        self.notebook.GetPage(2).Add(self.wxgui_fftsink2_full_spectrum.win)
        self.wxgui_fftsink = fftsink2.fft_sink_c(
        	self.notebook.GetPage(0).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate_sink,
        	fft_size=1024,
        	fft_rate=100,
        	average=False,
        	avg_alpha=None,
        	title="FFT CW Doppler Radar Receiver ",
        	peak_hold=False,
        	win=window.blackmanharris,
        )
        self.notebook.GetPage(0).Add(self.wxgui_fftsink.win)
        self.usrp_transmitter = uhd.usrp_sink(
        	",".join(('addr=192.168.10.2', "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.usrp_transmitter.set_clock_source("internal", 0)
        self.usrp_transmitter.set_samp_rate(samp_rate)
        self.usrp_transmitter.set_center_freq(RF_tuner, 0)
        self.usrp_transmitter.set_gain(0, 0)
        self.usrp_transmitter.set_antenna('TX/RX', 0)
        self.usrp_receiver = uhd.usrp_source(
        	",".join(('addr=192.168.10.3', "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.usrp_receiver.set_clock_source("mimo", 0)
        self.usrp_receiver.set_time_source("mimo", 0)
        self.usrp_receiver.set_samp_rate(samp_rate)
        self.usrp_receiver.set_center_freq(uhd.tune_request(RF_tuner, lo_offset_freq), 0)
        self.usrp_receiver.set_gain(rx_gain_tuner, 0)
        self.usrp_receiver.set_antenna("J1", 0)
        self.usrp_receiver.set_bandwidth(15e6, 0)
        def _target_speed_probe():
            while True:
                val = self.speed_probe.level()
                try:
                    self.set_target_speed(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (2))
        _target_speed_thread = threading.Thread(target=_target_speed_probe)
        _target_speed_thread.daemon = True
        _target_speed_thread.start()
        def _target_direction_probe():
            while True:
                val = self.direction_probe.level()
                try:
                    self.set_target_direction(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (2))
        _target_direction_thread = threading.Thread(target=_target_direction_probe)
        _target_direction_thread.daemon = True
        _target_direction_thread.start()
        self._speed_textbox_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.speed_textbox,
        	callback=self.set_speed_textbox,
        	label="Target Speed (Kph)",
        	converter=forms.float_converter(),
        )
        self.GridAdd(self._speed_textbox_text_box, 3, 0, 1, 17)
        self.rational_resampler = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=int(samp_rate/samp_rate_sink),
                taps=None,
                fractional_bw=None,
        )
        self.fft_vxx_0 = fft.fft_vcc(fft_len, True, (window.blackmanharris(fft_len)), True, 1)
        self._direction_textbox_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.direction_textbox,
        	callback=self.set_direction_textbox,
        	label="Target Direction",
        	converter=forms.str_converter(),
        )
        self.GridAdd(self._direction_textbox_text_box, 4, 0, 1, 17)
        self.cwradar_vector_flip_ff = cwradar.vector_flip_ff(fft_len/2)
        self.cwradar_doppler_velocity_single_target_ff_0 = cwradar.doppler_velocity_single_target_ff(fft_len/2, samp_rate, RF_tuner, threshold_dB_tuner, angle_tuner, lowpass_cutoff_freq_tuner, highpass_cutoff_freq_tuner)
        self.complex_to_mag = blocks.complex_to_mag(fft_len)
        self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream(gr.sizeof_float*1, fft_len)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_float*1, fft_len)
        self.blocks_stream_to_vector_1_0 = blocks.stream_to_vector(gr.sizeof_float*1, fft_len/2)
        self.blocks_stream_to_vector_1 = blocks.stream_to_vector(gr.sizeof_float*1, fft_len/2)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fft_len)
        self.blocks_keep_m_in_n_0_0 = blocks.keep_m_in_n(gr.sizeof_float, fft_len/2, fft_len, fft_len/2)
        self.blocks_keep_m_in_n_0 = blocks.keep_m_in_n(gr.sizeof_float, fft_len/2, fft_len, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 0, tx_amp_tuner, 0)
        self.DC_filter_0 = blocks.multiply_const_vff(([0]*DC_filter_num_elements+[1]*((fft_len/2)-DC_filter_num_elements)))
        self.DC_filter = blocks.multiply_const_vff(([0]*DC_filter_num_elements+[1]*((fft_len/2)-DC_filter_num_elements)))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_vector_to_stream_0_0, 0), (self.blocks_keep_m_in_n_0_0, 0))
        self.connect((self.blocks_keep_m_in_n_0, 0), (self.blocks_stream_to_vector_1, 0))
        self.connect((self.blocks_keep_m_in_n_0_0, 0), (self.blocks_stream_to_vector_1_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_keep_m_in_n_0, 0))
        self.connect((self.blocks_stream_to_vector_1_0, 0), (self.DC_filter_0, 0))
        self.connect((self.blocks_stream_to_vector_1, 0), (self.cwradar_vector_flip_ff, 0))
        self.connect((self.cwradar_vector_flip_ff, 0), (self.DC_filter, 0))
        self.connect((self.rational_resampler, 0), (self.wxgui_waterfallsink, 0))
        self.connect((self.rational_resampler, 0), (self.wxgui_fftsink, 0))
        self.connect((self.fft_vxx_0, 0), (self.complex_to_mag, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.complex_to_mag, 0), (self.blocks_vector_to_stream_0, 0))
        self.connect((self.complex_to_mag, 0), (self.blocks_vector_to_stream_0_0, 0))
        self.connect((self.DC_filter_0, 0), (self.cwradar_doppler_velocity_single_target_ff_0, 1))
        self.connect((self.DC_filter, 0), (self.cwradar_doppler_velocity_single_target_ff_0, 0))
        self.connect((self.cwradar_doppler_velocity_single_target_ff_0, 0), (self.speed_probe, 0))
        self.connect((self.cwradar_doppler_velocity_single_target_ff_0, 1), (self.direction_probe, 0))
        self.connect((self.usrp_receiver, 0), (self.wxgui_fftsink2_full_spectrum, 0))
        self.connect((self.usrp_receiver, 0), (self.rational_resampler, 0))
        self.connect((self.usrp_receiver, 0), (self.blocks_stream_to_vector_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.usrp_transmitter, 0))
    def __init__(self, tx_gain=0, index=0):
        gr.top_block.__init__(self, "uhd_b200_tx_rand_freq_hop")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("uhd_b200_tx_rand_freq_hop")
        try:
             self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
             pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "uhd_b200_tx_rand_freq_hop")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Parameters
        ##################################################
        self.tx_gain = tx_gain
        self.index = index

        ##################################################
        # Variables
        ##################################################
        self.freq_list = freq_list = [902e6,928e6,910e6,906e6,912e6,922e6,923e6,907e6,918e6,909e6,911e6,916e6]
        self.freq_index = freq_index = index
        self.variable_qtgui_label = variable_qtgui_label = freq_list[freq_index]
        self.samp_rate = samp_rate = 4e6

        ##################################################
        # Blocks
        ##################################################
        self.probe_index = blocks.probe_signal_i()
        def _freq_index_probe():
            while True:
                val = self.probe_index.level()
                try:
                    self.set_freq_index(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (20))
        _freq_index_thread = threading.Thread(target=_freq_index_probe)
        _freq_index_thread.daemon = True
        _freq_index_thread.start()
        self._variable_qtgui_label_tool_bar = Qt.QToolBar(self)
        
        if None:
          self._variable_qtgui_label_formatter = None
        else:
          self._variable_qtgui_label_formatter = lambda x: x
        
        self._variable_qtgui_label_tool_bar.addWidget(Qt.QLabel("Center_Frequency"+": "))
        self._variable_qtgui_label_label = Qt.QLabel(str(self._variable_qtgui_label_formatter(self.variable_qtgui_label)))
        self._variable_qtgui_label_tool_bar.addWidget(self._variable_qtgui_label_label)
        self.top_layout.addWidget(self._variable_qtgui_label_tool_bar)
          
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(freq_list[freq_index], 0)
        self.uhd_usrp_sink_0.set_gain(tx_gain, 0)
        self.uhd_usrp_sink_0.set_antenna("TX/RX", 0)
        self.analog_sig_source_x_1 = analog.sig_source_i(samp_rate, analog.GR_SAW_WAVE, 10, len(freq_list), 0)
        self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_noise_source_x_0, 0), (self.uhd_usrp_sink_0, 0))    
        self.connect((self.analog_sig_source_x_1, 0), (self.probe_index, 0))    
    def __init__(self, angle=0, samp_rate=1e6, fft_len=pow(2,20), samp_rate_sink=8000, tx_amp=10e-3, max_num_of_targets=10, lowpass_cutoff_freq=1700, RF=2.49e9, speed_samp_rate=1, DC_filter_num_elements=4, threshold_dB=-70, rx_gain=0, highpass_cutoff_freq=0, doppler_signal_bw=20):
        grc_wxgui.top_block_gui.__init__(self, title="CW Doppler Radar Simulator Multiple Targets")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Parameters
        ##################################################
        self.angle = angle
        self.samp_rate = samp_rate
        self.fft_len = fft_len
        self.samp_rate_sink = samp_rate_sink
        self.tx_amp = tx_amp
        self.max_num_of_targets = max_num_of_targets
        self.lowpass_cutoff_freq = lowpass_cutoff_freq
        self.RF = RF
        self.speed_samp_rate = speed_samp_rate
        self.DC_filter_num_elements = DC_filter_num_elements
        self.threshold_dB = threshold_dB
        self.rx_gain = rx_gain
        self.highpass_cutoff_freq = highpass_cutoff_freq
        self.doppler_signal_bw = doppler_signal_bw

        ##################################################
        # Variables
        ##################################################
        self.target_speed_vector = target_speed_vector = 0
        self.target_direction_vector = target_direction_vector = 0
        self.num_targets = num_targets = 0
        self.tx_amp_tuner = tx_amp_tuner = tx_amp
        self.threshold_dB_tuner = threshold_dB_tuner = threshold_dB
        self.speed_textbox = speed_textbox = target_speed_vector
        self.rx_gain_tuner = rx_gain_tuner = rx_gain
        self.num_targets_textbox = num_targets_textbox = num_targets
        self.max_num_of_targets_tuner = max_num_of_targets_tuner = max_num_of_targets
        self.lowpass_cutoff_freq_tuner = lowpass_cutoff_freq_tuner = lowpass_cutoff_freq
        self.highpass_cutoff_freq_tuner = highpass_cutoff_freq_tuner = highpass_cutoff_freq
        self.doppler_signal_bw_tuner = doppler_signal_bw_tuner = doppler_signal_bw
        self.doppler_freq_sim_tuner = doppler_freq_sim_tuner = 100
        self.direction_textbox = direction_textbox = target_direction_vector
        self.angle_tuner = angle_tuner = angle
        self.RF_tuner = RF_tuner = RF

        ##################################################
        # Blocks
        ##################################################
        _tx_amp_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tx_amp_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_tx_amp_tuner_sizer,
        	value=self.tx_amp_tuner,
        	callback=self.set_tx_amp_tuner,
        	label="TX Signal Amp",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._tx_amp_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_tx_amp_tuner_sizer,
        	value=self.tx_amp_tuner,
        	callback=self.set_tx_amp_tuner,
        	minimum=0,
        	maximum=100e-3,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_tx_amp_tuner_sizer, 0, 8, 1, 21)
        _threshold_dB_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._threshold_dB_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_threshold_dB_tuner_sizer,
        	value=self.threshold_dB_tuner,
        	callback=self.set_threshold_dB_tuner,
        	label="Detected Target Threshold (dB)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._threshold_dB_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_threshold_dB_tuner_sizer,
        	value=self.threshold_dB_tuner,
        	callback=self.set_threshold_dB_tuner,
        	minimum=-90,
        	maximum=-30,
        	num_steps=60,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_threshold_dB_tuner_sizer, 2, 0, 1, 8)
        self.speed_vector_probe = blocks.probe_signal_vf(max_num_of_targets)
        self.notebook = self.notebook = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "FFT CW Doppler Radar Receiver")
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "Frequency/Time CW Doppler Radar Receiver")
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "FFT CW Doppler Radar Receiver Full Spectrum")
        self.GridAdd(self.notebook, 6, 0, 13, 53)
        _max_num_of_targets_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._max_num_of_targets_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_max_num_of_targets_tuner_sizer,
        	value=self.max_num_of_targets_tuner,
        	callback=self.set_max_num_of_targets_tuner,
        	label="Maximum Number of Targets",
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._max_num_of_targets_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_max_num_of_targets_tuner_sizer,
        	value=self.max_num_of_targets_tuner,
        	callback=self.set_max_num_of_targets_tuner,
        	minimum=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.GridAdd(_max_num_of_targets_tuner_sizer, 2, 8, 1, 21)
        _lowpass_cutoff_freq_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._lowpass_cutoff_freq_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_lowpass_cutoff_freq_tuner_sizer,
        	value=self.lowpass_cutoff_freq_tuner,
        	callback=self.set_lowpass_cutoff_freq_tuner,
        	label="Low-Pass Cutoff Frequency (Hz)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._lowpass_cutoff_freq_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_lowpass_cutoff_freq_tuner_sizer,
        	value=self.lowpass_cutoff_freq_tuner,
        	callback=self.set_lowpass_cutoff_freq_tuner,
        	minimum=0,
        	maximum=3000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_lowpass_cutoff_freq_tuner_sizer, 1, 29, 1, 24)
        _highpass_cutoff_freq_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._highpass_cutoff_freq_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_highpass_cutoff_freq_tuner_sizer,
        	value=self.highpass_cutoff_freq_tuner,
        	callback=self.set_highpass_cutoff_freq_tuner,
        	label="High-Pass Cutoff Frequency (Hz)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._highpass_cutoff_freq_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_highpass_cutoff_freq_tuner_sizer,
        	value=self.highpass_cutoff_freq_tuner,
        	callback=self.set_highpass_cutoff_freq_tuner,
        	minimum=0,
        	maximum=1600,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_highpass_cutoff_freq_tuner_sizer, 0, 29, 1, 24)
        _doppler_signal_bw_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._doppler_signal_bw_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_doppler_signal_bw_tuner_sizer,
        	value=self.doppler_signal_bw_tuner,
        	callback=self.set_doppler_signal_bw_tuner,
        	label="Doppler Spectrum Bandwidth (Hz)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._doppler_signal_bw_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_doppler_signal_bw_tuner_sizer,
        	value=self.doppler_signal_bw_tuner,
        	callback=self.set_doppler_signal_bw_tuner,
        	minimum=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_doppler_signal_bw_tuner_sizer, 2, 29, 1, 24)
        _doppler_freq_sim_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._doppler_freq_sim_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_doppler_freq_sim_tuner_sizer,
        	value=self.doppler_freq_sim_tuner,
        	callback=self.set_doppler_freq_sim_tuner,
        	label="Doppler Frequency Simulator (Hz)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._doppler_freq_sim_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_doppler_freq_sim_tuner_sizer,
        	value=self.doppler_freq_sim_tuner,
        	callback=self.set_doppler_freq_sim_tuner,
        	minimum=-2000,
        	maximum=2000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_doppler_freq_sim_tuner_sizer, 3, 29, 1, 24)
        self.direction_vector_probe = blocks.probe_signal_vi(max_num_of_targets)
        _angle_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._angle_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_angle_tuner_sizer,
        	value=self.angle_tuner,
        	callback=self.set_angle_tuner,
        	label="Angle of Approach of the Target (Deg)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._angle_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_angle_tuner_sizer,
        	value=self.angle_tuner,
        	callback=self.set_angle_tuner,
        	minimum=0,
        	maximum=89,
        	num_steps=890,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_angle_tuner_sizer, 1, 8, 1, 21)
        _RF_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._RF_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_RF_tuner_sizer,
        	value=self.RF_tuner,
        	callback=self.set_RF_tuner,
        	label="Radar Frequency (Hz)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._RF_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_RF_tuner_sizer,
        	value=self.RF_tuner,
        	callback=self.set_RF_tuner,
        	minimum=2.4e9,
        	maximum=2.5e9,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_RF_tuner_sizer, 1, 0, 1, 8)
        self.wxgui_waterfallsink2_time_frequency = waterfallsink2.waterfall_sink_c(
        	self.notebook.GetPage(1).GetWin(),
        	baseband_freq=0,
        	dynamic_range=100,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate_sink,
        	fft_size=1024,
        	fft_rate=15,
        	average=True,
        	avg_alpha=None,
        	title="Time/Frequency CW Doppler Radar Receiver",
        	win=window.blackmanharris,
        )
        self.notebook.GetPage(1).Add(self.wxgui_waterfallsink2_time_frequency.win)
        self.wxgui_fftsink2_full_spectrum = fftsink2.fft_sink_c(
        	self.notebook.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=4096,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="FFT CW Doppler Radar Receiver Full Spectrum",
        	peak_hold=False,
        	win=window.blackmanharris,
        )
        self.notebook.GetPage(2).Add(self.wxgui_fftsink2_full_spectrum.win)
        self.wxgui_fftsink2 = fftsink2.fft_sink_c(
        	self.notebook.GetPage(0).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate_sink,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="FFT CW Doppler Radar Receiver ",
        	peak_hold=False,
        	win=window.blackmanharris,
        )
        self.notebook.GetPage(0).Add(self.wxgui_fftsink2.win)
        self.vector_to_stream_positive = blocks.vector_to_stream(gr.sizeof_float*1, fft_len)
        self.vector_to_stream_negative = blocks.vector_to_stream(gr.sizeof_float*1, fft_len)
        self.tx_signal = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 0, 1, 0)
        self.throtle_block = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        def _target_speed_vector_probe():
            while True:
                val = self.speed_vector_probe.level()
                try:
                    self.set_target_speed_vector(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (speed_samp_rate))
        _target_speed_vector_thread = threading.Thread(target=_target_speed_vector_probe)
        _target_speed_vector_thread.daemon = True
        _target_speed_vector_thread.start()
        def _target_direction_vector_probe():
            while True:
                val = self.direction_vector_probe.level()
                try:
                    self.set_target_direction_vector(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (speed_samp_rate))
        _target_direction_vector_thread = threading.Thread(target=_target_direction_vector_probe)
        _target_direction_vector_thread.daemon = True
        _target_direction_vector_thread.start()
        self.stream_to_vector_positive = blocks.stream_to_vector(gr.sizeof_float*1, fft_len/2)
        self.stream_to_vector_negative = blocks.stream_to_vector(gr.sizeof_float*1, fft_len/2)
        self.stream_to_vector_for_fft = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fft_len)
        self._speed_textbox_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.speed_textbox,
        	callback=self.set_speed_textbox,
        	label="Targets Speed (Kph)",
        	converter=forms.str_converter(),
        )
        self.GridAdd(self._speed_textbox_text_box, 4, 0, 1, 53)
        self.rx_signal_2 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, doppler_freq_sim_tuner+15, tx_amp_tuner-5e-3, 0)
        self.rx_signal_1 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, doppler_freq_sim_tuner-1300, tx_amp+10e-3, 0)
        self.rx_signal_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, doppler_freq_sim_tuner, tx_amp_tuner, 0)
        _rx_gain_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_gain_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_rx_gain_tuner_sizer,
        	value=self.rx_gain_tuner,
        	callback=self.set_rx_gain_tuner,
        	label="USRP RX Gain (dB)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._rx_gain_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_rx_gain_tuner_sizer,
        	value=self.rx_gain_tuner,
        	callback=self.set_rx_gain_tuner,
        	minimum=0,
        	maximum=70,
        	num_steps=70,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_rx_gain_tuner_sizer, 0, 0, 1, 8)
        self.rational_resampler = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=int(samp_rate/samp_rate_sink),
                taps=None,
                fractional_bw=None,
        )
        self._num_targets_textbox_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.num_targets_textbox,
        	callback=self.set_num_targets_textbox,
        	label="Number of Targets Detected",
        	converter=forms.int_converter(),
        )
        self.GridAdd(self._num_targets_textbox_text_box, 3, 0, 1, 4)
        self.num_targets_probe = blocks.probe_signal_i()
        def _num_targets_probe():
            while True:
                val = self.num_targets_probe.level()
                try:
                    self.set_num_targets(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (speed_samp_rate))
        _num_targets_thread = threading.Thread(target=_num_targets_probe)
        _num_targets_thread.daemon = True
        _num_targets_thread.start()
        self.mixer = blocks.multiply_vcc(1)
        self.keep_m_in_n_positive = blocks.keep_m_in_n(gr.sizeof_float, fft_len/2, fft_len, fft_len/2)
        self.keep_m_in_n_negative = blocks.keep_m_in_n(gr.sizeof_float, fft_len/2, fft_len, 0)
        self.fft_vxx_0 = fft.fft_vcc(fft_len, True, (window.blackmanharris(fft_len)), True, 1)
        self._direction_textbox_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.direction_textbox,
        	callback=self.set_direction_textbox,
        	label="Targets Direction",
        	converter=forms.str_converter(),
        )
        self.GridAdd(self._direction_textbox_text_box, 5, 0, 1, 53)
        self.cwradar_vector_flip_ff = cwradar.vector_flip_ff(fft_len/2)
        self.cwradar_doppler_velocity_multiple_targets_ff = cwradar.doppler_velocity_multiple_targets_ff(fft_len/2, samp_rate, RF_tuner, threshold_dB_tuner, angle_tuner, lowpass_cutoff_freq_tuner, highpass_cutoff_freq_tuner, max_num_of_targets_tuner, doppler_signal_bw_tuner)
        self.blocks_complex_to_mag = blocks.complex_to_mag(fft_len)
        self.awgn_channel_simulator = analog.noise_source_c(analog.GR_GAUSSIAN, 1e-3, 0)
        self.adder_2 = blocks.add_vcc(1)
        self.adder_1 = blocks.add_vcc(1)
        self.DC_filter_positive = blocks.multiply_const_vff(([0]*DC_filter_num_elements+[1]*((fft_len/2)-DC_filter_num_elements)))
        self.DC_filter_negative = blocks.multiply_const_vff(([0]*DC_filter_num_elements+[1]*((fft_len/2)-DC_filter_num_elements)))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.DC_filter_negative, 0), (self.cwradar_doppler_velocity_multiple_targets_ff, 0))
        self.connect((self.DC_filter_positive, 0), (self.cwradar_doppler_velocity_multiple_targets_ff, 1))
        self.connect((self.cwradar_doppler_velocity_multiple_targets_ff, 2), (self.num_targets_probe, 0))
        self.connect((self.cwradar_doppler_velocity_multiple_targets_ff, 1), (self.direction_vector_probe, 0))
        self.connect((self.cwradar_doppler_velocity_multiple_targets_ff, 0), (self.speed_vector_probe, 0))
        self.connect((self.awgn_channel_simulator, 0), (self.adder_2, 0))
        self.connect((self.tx_signal, 0), (self.adder_2, 1))
        self.connect((self.adder_2, 0), (self.mixer, 0))
        self.connect((self.awgn_channel_simulator, 0), (self.adder_1, 0))
        self.connect((self.mixer, 0), (self.throtle_block, 0))
        self.connect((self.mixer, 0), (self.stream_to_vector_for_fft, 0))
        self.connect((self.throtle_block, 0), (self.wxgui_fftsink2_full_spectrum, 0))
        self.connect((self.throtle_block, 0), (self.rational_resampler, 0))
        self.connect((self.adder_1, 0), (self.mixer, 1))
        self.connect((self.rational_resampler, 0), (self.wxgui_waterfallsink2_time_frequency, 0))
        self.connect((self.stream_to_vector_for_fft, 0), (self.fft_vxx_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag, 0))
        self.connect((self.blocks_complex_to_mag, 0), (self.vector_to_stream_negative, 0))
        self.connect((self.blocks_complex_to_mag, 0), (self.vector_to_stream_positive, 0))
        self.connect((self.vector_to_stream_positive, 0), (self.keep_m_in_n_positive, 0))
        self.connect((self.keep_m_in_n_negative, 0), (self.stream_to_vector_negative, 0))
        self.connect((self.keep_m_in_n_positive, 0), (self.stream_to_vector_positive, 0))
        self.connect((self.vector_to_stream_negative, 0), (self.keep_m_in_n_negative, 0))
        self.connect((self.stream_to_vector_positive, 0), (self.DC_filter_positive, 0))
        self.connect((self.stream_to_vector_negative, 0), (self.cwradar_vector_flip_ff, 0))
        self.connect((self.cwradar_vector_flip_ff, 0), (self.DC_filter_negative, 0))
        self.connect((self.rx_signal_1, 0), (self.adder_1, 3))
        self.connect((self.rx_signal_0, 0), (self.adder_1, 2))
        self.connect((self.tx_signal, 0), (self.adder_1, 1))
        self.connect((self.rx_signal_2, 0), (self.adder_1, 4))
        self.connect((self.rational_resampler, 0), (self.wxgui_fftsink2, 0))
示例#6
0
    def __init__(self):
        gr.hier_block2.__init__(
            self,
            "signal_probe_delay",
            gr.io_signature(1, 1, gr.sizeof_float * 1),
            gr.io_signature(1, 1, gr.sizeof_int * 1),
        )

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 8e5
        self.flag_acq_est_0_0 = flag_acq_est_0_0 = 0
        self.flag_acq_est_0 = flag_acq_est_0 = 0
        self.once = 0
        ##################################################
        # Blocks
        ##################################################

        self.blocks_probe_flag_nondelayed_0 = blocks.probe_signal_i()

        def _flag_acq_est_0_0_probe():
            while True:
                val = self.blocks_probe_flag_nondelayed_0.level()
                self.val0 = val
                try:
                    self.set_flag_acq_est_0_0(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (16e3))

        _flag_acq_est_0_0_thread = threading.Thread(
            target=_flag_acq_est_0_0_probe)
        _flag_acq_est_0_0_thread.daemon = True
        _flag_acq_est_0_0_thread.start()

        self.blocks_probe_flag_nondelayed = blocks.probe_signal_i()

        def _flag_acq_est_0_probe():

            while True:

                val = self.blocks_probe_flag_nondelayed.level()
                if self.once == 0:
                    if self.val0 != val:
                        self.val1 = val
                        print "hello"
                        self.once = 1

                try:
                    self.set_flag_acq_est_0(self.val1)
                except AttributeError:
                    pass
                #time.sleep(1.0 / (1e6))

        _flag_acq_est_0_thread = threading.Thread(target=_flag_acq_est_0_probe)
        _flag_acq_est_0_thread.daemon = True
        _flag_acq_est_0_thread.start()

        self.blocks_float_to_int_0 = blocks.float_to_int(1, 1)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_int * 1, 2)
        self.analog_const_source_x_0 = analog.sig_source_i(
            0, analog.GR_CONST_WAVE, 0, 0, flag_acq_est_0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0), (self, 0))
        self.connect((self.blocks_delay_0, 0),
                     (self.blocks_probe_flag_nondelayed_0, 0))
        self.connect((self.blocks_float_to_int_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_float_to_int_0, 0),
                     (self.blocks_probe_flag_nondelayed, 0))
        self.connect((self, 0), (self.blocks_float_to_int_0, 0))
示例#7
0
    def __init__(self):
        gr.top_block.__init__(self, "RKE Analyzer")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("RKE Analyzer")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "garage")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Variables
        ##################################################
        self.sps1 = sps1 = 1
        self.sdr_rate = sdr_rate = 2e6
        self.my_seq = my_seq = 0
        self.my_encoder = my_encoder = 0
        self.freqdetectada = freqdetectada = 292e6
        self.decim = decim = 20
        self.variable_qtgui_label_0_2 = variable_qtgui_label_0_2 = freqdetectada
        self.variable_qtgui_label_0_1_0 = variable_qtgui_label_0_1_0 = my_seq
        self.variable_qtgui_label_0_1 = variable_qtgui_label_0_1 = my_encoder
        self.variable_qtgui_label_0_0 = variable_qtgui_label_0_0 = sps1
        self.sps = sps = 44
        self.samp_rate = samp_rate = sdr_rate / decim
        self.gain = gain = 0.01
        self.freq_list = freq_list = (292000000, 299000000, 315000000, 434000000)
        self.freq = freq = 0
        self.fft_n = fft_n = 2048
        self.encoder_length = encoder_length = ((12,"HT12E - M1E-N"),(28,"HT6P20B"),(9,"HT6026 - MC145026"))
        self.encoder_code = encoder_code = ((([((0,0,0,0,0,0,0,1), 'P'), ((0,1,1), 0), ((0,0,1), 1)])),(([((0,0,0,0,0,0,0,1), 'P'), ((0,1,1), 0), ((0,0,1), 1)])),(([((0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), 'P'),((0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1), 1),((0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0), 0),((0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0), "Z")])))

        ##################################################
        # Blocks
        ##################################################
        self.sumx = sumx.summ(limiar_db=25, freq_list=freq_list, sample_rate=sdr_rate, len_fft=fft_n)
        self.crossing = crossing.crossing(sample_rate=samp_rate, threshold=10)

        def _sps_probe():
            while True:
                val = self.crossing.retorna_sps()
                try:
                    self.set_sps(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (5))
        _sps_thread = threading.Thread(target=_sps_probe)
        _sps_thread.daemon = True
        _sps_thread.start()


        def _freqdetectada_probe():
            while True:
                val = self.sumx.freq_detectada()
                try:
                    self.set_freqdetectada(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (5))
        _freqdetectada_thread = threading.Thread(target=_freqdetectada_probe)
        _freqdetectada_thread.daemon = True
        _freqdetectada_thread.start()


        def _freq_probe():
            while True:
                val = self.sumx.freq_ativa()
                try:
                    self.set_freq(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (5))
        _freq_thread = threading.Thread(target=_freq_probe)
        _freq_thread.daemon = True
        _freq_thread.start()

        self.detectorx = detectorx.blkfinal(decoders_list=encoder_code, decoders_length=encoder_length)
        self._variable_qtgui_label_0_2_tool_bar = Qt.QToolBar(self)

        if None:
          self._variable_qtgui_label_0_2_formatter = None
        else:
          self._variable_qtgui_label_0_2_formatter = lambda x: eng_notation.num_to_str(x)

        self._variable_qtgui_label_0_2_tool_bar.addWidget(Qt.QLabel('Frequencia Detectada'+": "))
        self._variable_qtgui_label_0_2_label = Qt.QLabel(str(self._variable_qtgui_label_0_2_formatter(self.variable_qtgui_label_0_2)))
        self._variable_qtgui_label_0_2_tool_bar.addWidget(self._variable_qtgui_label_0_2_label)
        self.top_grid_layout.addWidget(self._variable_qtgui_label_0_2_tool_bar)
        self._variable_qtgui_label_0_1_0_tool_bar = Qt.QToolBar(self)

        if None:
          self._variable_qtgui_label_0_1_0_formatter = None
        else:
          self._variable_qtgui_label_0_1_0_formatter = lambda x: repr(x)

        self._variable_qtgui_label_0_1_0_tool_bar.addWidget(Qt.QLabel('Quadro'+": "))
        self._variable_qtgui_label_0_1_0_label = Qt.QLabel(str(self._variable_qtgui_label_0_1_0_formatter(self.variable_qtgui_label_0_1_0)))
        self._variable_qtgui_label_0_1_0_tool_bar.addWidget(self._variable_qtgui_label_0_1_0_label)
        self.top_grid_layout.addWidget(self._variable_qtgui_label_0_1_0_tool_bar)
        self._variable_qtgui_label_0_1_tool_bar = Qt.QToolBar(self)

        if None:
          self._variable_qtgui_label_0_1_formatter = None
        else:
          self._variable_qtgui_label_0_1_formatter = lambda x: repr(x)

        self._variable_qtgui_label_0_1_tool_bar.addWidget(Qt.QLabel('Codificador'+": "))
        self._variable_qtgui_label_0_1_label = Qt.QLabel(str(self._variable_qtgui_label_0_1_formatter(self.variable_qtgui_label_0_1)))
        self._variable_qtgui_label_0_1_tool_bar.addWidget(self._variable_qtgui_label_0_1_label)
        self.top_grid_layout.addWidget(self._variable_qtgui_label_0_1_tool_bar)
        self._variable_qtgui_label_0_0_tool_bar = Qt.QToolBar(self)

        if None:
          self._variable_qtgui_label_0_0_formatter = None
        else:
          self._variable_qtgui_label_0_0_formatter = lambda x: str(x)

        self._variable_qtgui_label_0_0_tool_bar.addWidget(Qt.QLabel('Frequencia do clock'+": "))
        self._variable_qtgui_label_0_0_label = Qt.QLabel(str(self._variable_qtgui_label_0_0_formatter(self.variable_qtgui_label_0_0)))
        self._variable_qtgui_label_0_0_tool_bar.addWidget(self._variable_qtgui_label_0_0_label)
        self.top_grid_layout.addWidget(self._variable_qtgui_label_0_0_tool_bar)

        def _sps1_probe():
            while True:
                val = self.crossing.retorna_freq()
                try:
                    self.set_sps1(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (1))
        _sps1_thread = threading.Thread(target=_sps1_probe)
        _sps1_thread.daemon = True
        _sps1_thread.start()

        self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' )
        self.rtlsdr_source_0.set_sample_rate(sdr_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(20, 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('00', 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)

        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	sdr_rate, #bw
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not False:
          self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.probe = blocks.probe_signal_i()

        def _my_seq_probe():
            while True:
                val = self.detectorx.retorna_sequencia_detectada()
                try:
                    self.set_my_seq(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))
        _my_seq_thread = threading.Thread(target=_my_seq_probe)
        _my_seq_thread.daemon = True
        _my_seq_thread.start()


        def _my_encoder_probe():
            while True:
                val = self.detectorx.retorna_codificador_detectado()
                try:
                    self.set_my_encoder(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))
        _my_encoder_thread = threading.Thread(target=_my_encoder_probe)
        _my_encoder_thread.daemon = True
        _my_encoder_thread.start()

        self.insert_tag = insert_tag.clock_reset(sps=sps)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(decim, (1, ), freqdetectada - freq, sdr_rate)
        self.fir_filter_xxx_0 = filter.fir_filter_fff(1, (np.ones(sps) / (sps)))
        self.fir_filter_xxx_0.declare_sample_delay(0)
        self.fft = fft.fft_vcc(fft_n, True, (window.blackmanharris(fft_n)), True, 1)
        self.divide = divide.divide(threshold=0.1)
        self.digital_symbol_sync_xx_0 = digital.symbol_sync_ff(digital.TED_ZERO_CROSSING, 40, 0.1, 1.0, gain, 35, 1, digital.constellation_bpsk().base(), digital.IR_MMSE_8TAP, 128, ([]))
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fft_n)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1)
        self.blocks_float_to_int_0 = blocks.float_to_int(1, 1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(fft_n)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_0, 0), (self.divide, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.sumx, 0))
        self.connect((self.blocks_float_to_int_0, 0), (self.probe, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.detectorx, 0))
        self.connect((self.digital_symbol_sync_xx_0, 3), (self.blocks_float_to_int_0, 0))
        self.connect((self.digital_symbol_sync_xx_0, 2), (self.blocks_null_sink_0, 1))
        self.connect((self.digital_symbol_sync_xx_0, 1), (self.blocks_null_sink_0, 0))
        self.connect((self.digital_symbol_sync_xx_0, 0), (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.divide, 0), (self.crossing, 0))
        self.connect((self.divide, 0), (self.fir_filter_xxx_0, 0))
        self.connect((self.fft, 0), (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.fir_filter_xxx_0, 0), (self.insert_tag, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_complex_to_mag_0, 0))
        self.connect((self.insert_tag, 0), (self.digital_symbol_sync_xx_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.blocks_stream_to_vector_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
示例#8
0
    def __init__(self,
                 DC_filter_num_elements=4,
                 samp_rate_sink=8000,
                 lo_offset_freq=1e6,
                 highpass_cutoff_freq=0,
                 doppler_signal_bw=20,
                 rx_gain=30.5,
                 tx_amp=1,
                 max_num_of_targets=10,
                 angle=0,
                 speed_samp_rate=1,
                 lowpass_cutoff_freq=1700,
                 fft_len=pow(2, 20),
                 RF=2.49e9,
                 samp_rate=1e6,
                 threshold_dB=-70):
        grc_wxgui.top_block_gui.__init__(self,
                                         title="CW Radar Multiple Targets")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Parameters
        ##################################################
        self.DC_filter_num_elements = DC_filter_num_elements
        self.samp_rate_sink = samp_rate_sink
        self.lo_offset_freq = lo_offset_freq
        self.highpass_cutoff_freq = highpass_cutoff_freq
        self.doppler_signal_bw = doppler_signal_bw
        self.rx_gain = rx_gain
        self.tx_amp = tx_amp
        self.max_num_of_targets = max_num_of_targets
        self.angle = angle
        self.speed_samp_rate = speed_samp_rate
        self.lowpass_cutoff_freq = lowpass_cutoff_freq
        self.fft_len = fft_len
        self.RF = RF
        self.samp_rate = samp_rate
        self.threshold_dB = threshold_dB

        ##################################################
        # Variables
        ##################################################
        self.target_speed_vector = target_speed_vector = 0
        self.target_direction_vector = target_direction_vector = 0
        self.num_targets = num_targets = 0
        self.tx_amp_tuner = tx_amp_tuner = tx_amp
        self.threshold_dB_tuner = threshold_dB_tuner = threshold_dB
        self.speed_textbox = speed_textbox = target_speed_vector
        self.rx_gain_tuner = rx_gain_tuner = rx_gain
        self.num_targets_textbox = num_targets_textbox = num_targets
        self.max_num_of_targets_tuner = max_num_of_targets_tuner = max_num_of_targets
        self.lowpass_cutoff_freq_tuner = lowpass_cutoff_freq_tuner = lowpass_cutoff_freq
        self.highpass_cutoff_freq_tuner = highpass_cutoff_freq_tuner = highpass_cutoff_freq
        self.doppler_signal_bw_tuner = doppler_signal_bw_tuner = doppler_signal_bw
        self.direction_textbox = direction_textbox = target_direction_vector
        self.angle_tuner = angle_tuner = angle
        self.RF_tuner = RF_tuner = RF

        ##################################################
        # Blocks
        ##################################################
        _tx_amp_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tx_amp_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_tx_amp_tuner_sizer,
            value=self.tx_amp_tuner,
            callback=self.set_tx_amp_tuner,
            label="TX Signal Amp",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._tx_amp_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_tx_amp_tuner_sizer,
            value=self.tx_amp_tuner,
            callback=self.set_tx_amp_tuner,
            minimum=0,
            maximum=1,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_tx_amp_tuner_sizer, 0, 8, 1, 21)
        _threshold_dB_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._threshold_dB_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_threshold_dB_tuner_sizer,
            value=self.threshold_dB_tuner,
            callback=self.set_threshold_dB_tuner,
            label="Detected Target Threshold (dB)",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._threshold_dB_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_threshold_dB_tuner_sizer,
            value=self.threshold_dB_tuner,
            callback=self.set_threshold_dB_tuner,
            minimum=-90,
            maximum=-30,
            num_steps=60,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_threshold_dB_tuner_sizer, 2, 0, 1, 8)
        self.speed_vector_probe = blocks.probe_signal_vf(max_num_of_targets)
        _rx_gain_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_gain_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rx_gain_tuner_sizer,
            value=self.rx_gain_tuner,
            callback=self.set_rx_gain_tuner,
            label="USRP RX Gain (dB)",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rx_gain_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rx_gain_tuner_sizer,
            value=self.rx_gain_tuner,
            callback=self.set_rx_gain_tuner,
            minimum=0,
            maximum=30.5 + 62,
            num_steps=185,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_rx_gain_tuner_sizer, 0, 0, 1, 8)
        self.notebook = self.notebook = wx.Notebook(self.GetWin(),
                                                    style=wx.NB_TOP)
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook),
                              "FFT CW Doppler Radar Receiver")
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook),
                              "Frequency/Time CW Doppler Radar Receiver")
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook),
                              "FFT CW Doppler Radar Receiver Full Spectrum")
        self.GridAdd(self.notebook, 6, 0, 13, 53)
        _max_num_of_targets_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._max_num_of_targets_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_max_num_of_targets_tuner_sizer,
            value=self.max_num_of_targets_tuner,
            callback=self.set_max_num_of_targets_tuner,
            label="Maximum Number of Targets",
            converter=forms.int_converter(),
            proportion=0,
        )
        self._max_num_of_targets_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_max_num_of_targets_tuner_sizer,
            value=self.max_num_of_targets_tuner,
            callback=self.set_max_num_of_targets_tuner,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.GridAdd(_max_num_of_targets_tuner_sizer, 2, 8, 1, 21)
        _lowpass_cutoff_freq_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._lowpass_cutoff_freq_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_lowpass_cutoff_freq_tuner_sizer,
            value=self.lowpass_cutoff_freq_tuner,
            callback=self.set_lowpass_cutoff_freq_tuner,
            label="Low-Pass Cutoff Frequency (Hz)",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._lowpass_cutoff_freq_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_lowpass_cutoff_freq_tuner_sizer,
            value=self.lowpass_cutoff_freq_tuner,
            callback=self.set_lowpass_cutoff_freq_tuner,
            minimum=0,
            maximum=3000,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_lowpass_cutoff_freq_tuner_sizer, 1, 29, 1, 24)
        _highpass_cutoff_freq_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._highpass_cutoff_freq_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_highpass_cutoff_freq_tuner_sizer,
            value=self.highpass_cutoff_freq_tuner,
            callback=self.set_highpass_cutoff_freq_tuner,
            label="High-Pass Cutoff Frequency (Hz)",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._highpass_cutoff_freq_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_highpass_cutoff_freq_tuner_sizer,
            value=self.highpass_cutoff_freq_tuner,
            callback=self.set_highpass_cutoff_freq_tuner,
            minimum=0,
            maximum=1600,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_highpass_cutoff_freq_tuner_sizer, 0, 29, 1, 24)
        _doppler_signal_bw_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._doppler_signal_bw_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_doppler_signal_bw_tuner_sizer,
            value=self.doppler_signal_bw_tuner,
            callback=self.set_doppler_signal_bw_tuner,
            label="Doppler Spectrum Bandwidth (Hz)",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._doppler_signal_bw_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_doppler_signal_bw_tuner_sizer,
            value=self.doppler_signal_bw_tuner,
            callback=self.set_doppler_signal_bw_tuner,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_doppler_signal_bw_tuner_sizer, 2, 29, 1, 24)
        self.direction_vector_probe = blocks.probe_signal_vi(
            max_num_of_targets)
        _angle_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._angle_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_angle_tuner_sizer,
            value=self.angle_tuner,
            callback=self.set_angle_tuner,
            label="Angle of Approach of the Target (Deg)",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._angle_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_angle_tuner_sizer,
            value=self.angle_tuner,
            callback=self.set_angle_tuner,
            minimum=0,
            maximum=89,
            num_steps=890,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_angle_tuner_sizer, 1, 8, 1, 21)
        _RF_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._RF_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_RF_tuner_sizer,
            value=self.RF_tuner,
            callback=self.set_RF_tuner,
            label="Radar Frequency (Hz)",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._RF_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_RF_tuner_sizer,
            value=self.RF_tuner,
            callback=self.set_RF_tuner,
            minimum=2.4e9,
            maximum=2.5e9,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_RF_tuner_sizer, 1, 0, 1, 8)
        self.wxgui_waterfallsink = waterfallsink2.waterfall_sink_c(
            self.notebook.GetPage(1).GetWin(),
            baseband_freq=0,
            dynamic_range=100,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate_sink,
            fft_size=1024,
            fft_rate=100,
            average=False,
            avg_alpha=None,
            title="Time/Frequency CW Doppler Radar Receiver",
            win=window.blackmanharris,
        )
        self.notebook.GetPage(1).Add(self.wxgui_waterfallsink.win)
        self.wxgui_fftsink2_full_spectrum = fftsink2.fft_sink_c(
            self.notebook.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=4096,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="FFT CW Doppler Radar Receiver Full Spectrum",
            peak_hold=False,
            win=window.blackmanharris,
        )
        self.notebook.GetPage(2).Add(self.wxgui_fftsink2_full_spectrum.win)
        self.wxgui_fftsink = fftsink2.fft_sink_c(
            self.notebook.GetPage(0).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate_sink,
            fft_size=1024,
            fft_rate=100,
            average=False,
            avg_alpha=None,
            title="FFT CW Doppler Radar Receiver ",
            peak_hold=False,
            win=window.blackmanharris,
        )
        self.notebook.GetPage(0).Add(self.wxgui_fftsink.win)
        self.usrp_transmitter = uhd.usrp_sink(
            ",".join(('addr=192.168.10.2', "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.usrp_transmitter.set_clock_source("internal", 0)
        self.usrp_transmitter.set_samp_rate(samp_rate)
        self.usrp_transmitter.set_center_freq(RF_tuner, 0)
        self.usrp_transmitter.set_gain(0, 0)
        self.usrp_transmitter.set_antenna("TX/RX", 0)
        self.usrp_receiver = uhd.usrp_source(
            ",".join(('addr=192.168.10.3', "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.usrp_receiver.set_clock_source("mimo", 0)
        self.usrp_receiver.set_time_source("mimo", 0)
        self.usrp_receiver.set_samp_rate(samp_rate)
        self.usrp_receiver.set_center_freq(
            uhd.tune_request(RF_tuner, lo_offset_freq), 0)
        self.usrp_receiver.set_gain(rx_gain_tuner, 0)
        self.usrp_receiver.set_antenna("J1", 0)
        self.usrp_receiver.set_bandwidth(15e6, 0)

        def _target_speed_vector_probe():
            while True:
                val = self.speed_vector_probe.level()
                try:
                    ########################################################
                    #Code to tranlate the vector of speeds to strings:
                    speed = ""
                    if val[0] == 0:  #if the value is 0 there is no target in sight.
                        speed = "No Target Detected"
                    elif val[0] != 0:
                        for i in range(len(val)):
                            if val[i] != 0:
                                speed = speed + "Target " + str(
                                    i + 1) + ": " + str(round(val[i],
                                                              2)) + " Kph\t"
                    self.set_target_speed_vector(speed)
                    ########################################################
                except AttributeError:
                    pass
                time.sleep(1.0 / (speed_samp_rate))

        _target_speed_vector_thread = threading.Thread(
            target=_target_speed_vector_probe)
        _target_speed_vector_thread.daemon = True
        _target_speed_vector_thread.start()

        def _target_direction_vector_probe():
            while True:
                val = self.direction_vector_probe.level()
                try:
                    ########################################################
                    #Code to tranlate the vector of directions to strings:
                    direction = ""
                    if val[0] == 0:
                        direction = "No Target Detected"
                    elif val[0] != 0:  #if the value is 0 there is no target in sight.
                        for i in range(len(val)):
                            if val[i] == 1:  #if the value is 1 the target is approaching.
                                direction = direction + "Target " + str(
                                    i + 1) + ": " + "Approaching\t"
                            elif val[
                                    i] == 2:  #if the value is 2 the target is receding.
                                direction = direction + "Target " + str(
                                    i + 1) + ": " + "Receding\t"
                    self.set_target_direction_vector(direction)
                    ########################################################
                except AttributeError:
                    pass
                time.sleep(1.0 / (speed_samp_rate))

        _target_direction_vector_thread = threading.Thread(
            target=_target_direction_vector_probe)
        _target_direction_vector_thread.daemon = True
        _target_direction_vector_thread.start()
        self._speed_textbox_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.speed_textbox,
            callback=self.set_speed_textbox,
            label="Targets Speed (Kph)",
            converter=forms.str_converter(),
        )
        self.GridAdd(self._speed_textbox_text_box, 4, 0, 1, 53)
        self.rational_resampler = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=int(samp_rate / samp_rate_sink),
            taps=None,
            fractional_bw=None,
        )
        self._num_targets_textbox_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.num_targets_textbox,
            callback=self.set_num_targets_textbox,
            label="Number of Targets Detected",
            converter=forms.int_converter(),
        )
        self.GridAdd(self._num_targets_textbox_text_box, 3, 0, 1, 4)
        self.num_targets_probe = blocks.probe_signal_i()

        def _num_targets_probe():
            while True:
                val = self.num_targets_probe.level()
                try:
                    self.set_num_targets(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (speed_samp_rate))

        _num_targets_thread = threading.Thread(target=_num_targets_probe)
        _num_targets_thread.daemon = True
        _num_targets_thread.start()
        self.fft_vxx_0 = fft.fft_vcc(fft_len, True,
                                     (window.blackmanharris(fft_len)), True, 1)
        self._direction_textbox_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.direction_textbox,
            callback=self.set_direction_textbox,
            label="Targets Direction",
            converter=forms.str_converter(),
        )
        self.GridAdd(self._direction_textbox_text_box, 5, 0, 1, 53)
        self.cwradar_vector_flip_ff = cwradar.vector_flip_ff(fft_len / 2)
        self.cwradar_doppler_velocity_multiple_targets_ff_0 = cwradar.doppler_velocity_multiple_targets_ff(
            fft_len / 2, samp_rate, RF_tuner, threshold_dB_tuner, angle_tuner,
            lowpass_cutoff_freq_tuner, highpass_cutoff_freq_tuner,
            max_num_of_targets_tuner, doppler_signal_bw_tuner)
        self.complex_to_mag = blocks.complex_to_mag(fft_len)
        self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream(
            gr.sizeof_float * 1, fft_len)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_float * 1, fft_len)
        self.blocks_stream_to_vector_1_0 = blocks.stream_to_vector(
            gr.sizeof_float * 1, fft_len / 2)
        self.blocks_stream_to_vector_1 = blocks.stream_to_vector(
            gr.sizeof_float * 1, fft_len / 2)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, fft_len)
        self.blocks_keep_m_in_n_0_0 = blocks.keep_m_in_n(
            gr.sizeof_float, fft_len / 2, fft_len, fft_len / 2)
        self.blocks_keep_m_in_n_0 = blocks.keep_m_in_n(gr.sizeof_float,
                                                       fft_len / 2, fft_len, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 0, tx_amp_tuner, 0)
        self.DC_filter_0 = blocks.multiply_const_vff(
            ([0] * DC_filter_num_elements + [1] *
             ((fft_len / 2) - DC_filter_num_elements)))
        self.DC_filter = blocks.multiply_const_vff(
            ([0] * DC_filter_num_elements + [1] *
             ((fft_len / 2) - DC_filter_num_elements)))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.complex_to_mag, 0),
                     (self.blocks_vector_to_stream_0_0, 0))
        self.connect((self.complex_to_mag, 0),
                     (self.blocks_vector_to_stream_0, 0))
        self.connect((self.DC_filter, 0),
                     (self.cwradar_doppler_velocity_multiple_targets_ff_0, 0))
        self.connect((self.DC_filter_0, 0),
                     (self.cwradar_doppler_velocity_multiple_targets_ff_0, 1))
        self.connect((self.cwradar_doppler_velocity_multiple_targets_ff_0, 2),
                     (self.num_targets_probe, 0))
        self.connect((self.cwradar_doppler_velocity_multiple_targets_ff_0, 1),
                     (self.direction_vector_probe, 0))
        self.connect((self.cwradar_doppler_velocity_multiple_targets_ff_0, 0),
                     (self.speed_vector_probe, 0))
        self.connect((self.blocks_vector_to_stream_0_0, 0),
                     (self.blocks_keep_m_in_n_0_0, 0))
        self.connect((self.blocks_keep_m_in_n_0, 0),
                     (self.blocks_stream_to_vector_1, 0))
        self.connect((self.blocks_keep_m_in_n_0_0, 0),
                     (self.blocks_stream_to_vector_1_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.blocks_keep_m_in_n_0, 0))
        self.connect((self.blocks_stream_to_vector_1_0, 0),
                     (self.DC_filter_0, 0))
        self.connect((self.blocks_stream_to_vector_1, 0),
                     (self.cwradar_vector_flip_ff, 0))
        self.connect((self.cwradar_vector_flip_ff, 0), (self.DC_filter, 0))
        self.connect((self.usrp_receiver, 0),
                     (self.wxgui_fftsink2_full_spectrum, 0))
        self.connect((self.usrp_receiver, 0), (self.rational_resampler, 0))
        self.connect((self.rational_resampler, 0),
                     (self.wxgui_waterfallsink, 0))
        self.connect((self.rational_resampler, 0), (self.wxgui_fftsink, 0))
        self.connect((self.fft_vxx_0, 0), (self.complex_to_mag, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.usrp_receiver, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.usrp_transmitter, 0))
    def __init__(self, RF=2.49e9, lowpass_cutoff_freq=1700, speed_samp_rate=1, fft_len=pow(2,20), angle=0, DC_filter_num_elements=4, samp_rate_sink=8000, samp_rate=1e6, max_num_of_targets=10, lo_offset_freq=1e6, highpass_cutoff_freq=0, doppler_signal_bw=20, threshold_dB=-70, rx_gain=30.5, tx_amp=0):
        grc_wxgui.top_block_gui.__init__(self, title="CW Radar Multiple Targets Receiver")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Parameters
        ##################################################
        self.RF = RF
        self.lowpass_cutoff_freq = lowpass_cutoff_freq
        self.speed_samp_rate = speed_samp_rate
        self.fft_len = fft_len
        self.angle = angle
        self.DC_filter_num_elements = DC_filter_num_elements
        self.samp_rate_sink = samp_rate_sink
        self.samp_rate = samp_rate
        self.max_num_of_targets = max_num_of_targets
        self.lo_offset_freq = lo_offset_freq
        self.highpass_cutoff_freq = highpass_cutoff_freq
        self.doppler_signal_bw = doppler_signal_bw
        self.threshold_dB = threshold_dB
        self.rx_gain = rx_gain
        self.tx_amp = tx_amp

        ##################################################
        # Variables
        ##################################################
        self.target_speed_vector = target_speed_vector = 0
        self.target_direction_vector = target_direction_vector = 0
        self.num_targets = num_targets = 0
        self.tx_amp_tuner = tx_amp_tuner = tx_amp
        self.threshold_dB_tuner = threshold_dB_tuner = threshold_dB
        self.speed_textbox = speed_textbox = target_speed_vector
        self.rx_gain_tuner = rx_gain_tuner = rx_gain
        self.num_targets_textbox = num_targets_textbox = num_targets
        self.max_num_of_targets_tuner = max_num_of_targets_tuner = max_num_of_targets
        self.lowpass_cutoff_freq_tuner = lowpass_cutoff_freq_tuner = lowpass_cutoff_freq
        self.highpass_cutoff_freq_tuner = highpass_cutoff_freq_tuner = highpass_cutoff_freq
        self.doppler_signal_bw_tuner = doppler_signal_bw_tuner = doppler_signal_bw
        self.direction_textbox = direction_textbox = target_direction_vector
        self.angle_tuner = angle_tuner = angle
        self.RF_tuner = RF_tuner = RF

        ##################################################
        # Blocks
        ##################################################
        _threshold_dB_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._threshold_dB_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_threshold_dB_tuner_sizer,
        	value=self.threshold_dB_tuner,
        	callback=self.set_threshold_dB_tuner,
        	label="Detected Target Threshold (dB)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._threshold_dB_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_threshold_dB_tuner_sizer,
        	value=self.threshold_dB_tuner,
        	callback=self.set_threshold_dB_tuner,
        	minimum=-90,
        	maximum=-30,
        	num_steps=60,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_threshold_dB_tuner_sizer, 2, 0, 1, 8)
        self.speed_vector_probe = blocks.probe_signal_vf(max_num_of_targets)
        _rx_gain_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_gain_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_rx_gain_tuner_sizer,
        	value=self.rx_gain_tuner,
        	callback=self.set_rx_gain_tuner,
        	label="USRP RX Gain (dB)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._rx_gain_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_rx_gain_tuner_sizer,
        	value=self.rx_gain_tuner,
        	callback=self.set_rx_gain_tuner,
        	minimum=0,
        	maximum=30.5 + 62,
        	num_steps=185,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_rx_gain_tuner_sizer, 0, 0, 1, 8)
        self.notebook = self.notebook = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "FFT CW Doppler Radar Receiver")
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "Frequency/Time CW Doppler Radar Receiver")
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "FFT CW Doppler Radar Receiver Full Spectrum")
        self.GridAdd(self.notebook, 6, 0, 13, 53)
        _max_num_of_targets_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._max_num_of_targets_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_max_num_of_targets_tuner_sizer,
        	value=self.max_num_of_targets_tuner,
        	callback=self.set_max_num_of_targets_tuner,
        	label="Maximum Number of Targets",
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._max_num_of_targets_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_max_num_of_targets_tuner_sizer,
        	value=self.max_num_of_targets_tuner,
        	callback=self.set_max_num_of_targets_tuner,
        	minimum=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.GridAdd(_max_num_of_targets_tuner_sizer, 2, 8, 1, 21)
        _lowpass_cutoff_freq_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._lowpass_cutoff_freq_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_lowpass_cutoff_freq_tuner_sizer,
        	value=self.lowpass_cutoff_freq_tuner,
        	callback=self.set_lowpass_cutoff_freq_tuner,
        	label="Low-Pass Cutoff Frequency (Hz)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._lowpass_cutoff_freq_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_lowpass_cutoff_freq_tuner_sizer,
        	value=self.lowpass_cutoff_freq_tuner,
        	callback=self.set_lowpass_cutoff_freq_tuner,
        	minimum=0,
        	maximum=3000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_lowpass_cutoff_freq_tuner_sizer, 1, 29, 1, 24)
        _highpass_cutoff_freq_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._highpass_cutoff_freq_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_highpass_cutoff_freq_tuner_sizer,
        	value=self.highpass_cutoff_freq_tuner,
        	callback=self.set_highpass_cutoff_freq_tuner,
        	label="High-Pass Cutoff Frequency (Hz)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._highpass_cutoff_freq_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_highpass_cutoff_freq_tuner_sizer,
        	value=self.highpass_cutoff_freq_tuner,
        	callback=self.set_highpass_cutoff_freq_tuner,
        	minimum=0,
        	maximum=1600,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_highpass_cutoff_freq_tuner_sizer, 0, 29, 1, 24)
        _doppler_signal_bw_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._doppler_signal_bw_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_doppler_signal_bw_tuner_sizer,
        	value=self.doppler_signal_bw_tuner,
        	callback=self.set_doppler_signal_bw_tuner,
        	label="Doppler Spectrum Bandwidth (Hz)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._doppler_signal_bw_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_doppler_signal_bw_tuner_sizer,
        	value=self.doppler_signal_bw_tuner,
        	callback=self.set_doppler_signal_bw_tuner,
        	minimum=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_doppler_signal_bw_tuner_sizer, 2, 29, 1, 24)
        self.direction_vector_probe = blocks.probe_signal_vi(max_num_of_targets)
        _angle_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._angle_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_angle_tuner_sizer,
        	value=self.angle_tuner,
        	callback=self.set_angle_tuner,
        	label="Angle of Approach of the Target (Deg)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._angle_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_angle_tuner_sizer,
        	value=self.angle_tuner,
        	callback=self.set_angle_tuner,
        	minimum=0,
        	maximum=89,
        	num_steps=890,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_angle_tuner_sizer, 1, 8, 1, 21)
        _RF_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._RF_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_RF_tuner_sizer,
        	value=self.RF_tuner,
        	callback=self.set_RF_tuner,
        	label="Radar Frequency (Hz)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._RF_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_RF_tuner_sizer,
        	value=self.RF_tuner,
        	callback=self.set_RF_tuner,
        	minimum=2.4e9,
        	maximum=2.5e9,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_RF_tuner_sizer, 1, 0, 1, 8)
        self.wxgui_waterfallsink = waterfallsink2.waterfall_sink_c(
        	self.notebook.GetPage(1).GetWin(),
        	baseband_freq=0,
        	dynamic_range=100,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate_sink,
        	fft_size=1024,
        	fft_rate=100,
        	average=False,
        	avg_alpha=None,
        	title="Time/Frequency CW Doppler Radar Receiver",
        	win=window.blackmanharris,
        )
        self.notebook.GetPage(1).Add(self.wxgui_waterfallsink.win)
        self.wxgui_fftsink2_full_spectrum = fftsink2.fft_sink_c(
        	self.notebook.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=4096,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="FFT CW Doppler Radar Receiver Full Spectrum",
        	peak_hold=False,
        	win=window.blackmanharris,
        )
        self.notebook.GetPage(2).Add(self.wxgui_fftsink2_full_spectrum.win)
        self.wxgui_fftsink = fftsink2.fft_sink_c(
        	self.notebook.GetPage(0).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate_sink,
        	fft_size=1024,
        	fft_rate=100,
        	average=False,
        	avg_alpha=None,
        	title="FFT CW Doppler Radar Receiver ",
        	peak_hold=False,
        	win=window.blackmanharris,
        )
        self.notebook.GetPage(0).Add(self.wxgui_fftsink.win)
        self.usrp_receiver = uhd.usrp_source(
        	",".join(('addr=192.168.10.3', "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.usrp_receiver.set_clock_source("external", 0)
        self.usrp_receiver.set_samp_rate(samp_rate)
        self.usrp_receiver.set_center_freq(uhd.tune_request(RF_tuner, lo_offset_freq), 0)
        self.usrp_receiver.set_gain(rx_gain_tuner, 0)
        self.usrp_receiver.set_antenna("J1", 0)
        _tx_amp_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tx_amp_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_tx_amp_tuner_sizer,
        	value=self.tx_amp_tuner,
        	callback=self.set_tx_amp_tuner,
        	label="TX Signal Amp",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._tx_amp_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_tx_amp_tuner_sizer,
        	value=self.tx_amp_tuner,
        	callback=self.set_tx_amp_tuner,
        	minimum=0,
        	maximum=1,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_tx_amp_tuner_sizer, 0, 8, 1, 21)
        def _target_speed_vector_probe():
            while True:
                val = self.speed_vector_probe.level()
                try:
                    ########################################################
                    #Code to tranlate the vector of speeds to strings:
                    speed = ""
                    if val[0] == 0: #if the value is 0 there is no target in sight.
                        speed = "No Target Detected"
                    elif val[0] != 0:
                        for i in range(len(val)):
                            if val[i] != 0:
                                speed = speed + "Target " + str(i+1) + ": " + str(round(val[i],2)) + " Kph\t"
                    self.set_target_speed_vector(speed)
                    ########################################################
                except AttributeError:
                    pass
                time.sleep(1.0 / (speed_samp_rate))
        _target_speed_vector_thread = threading.Thread(target=_target_speed_vector_probe)
        _target_speed_vector_thread.daemon = True
        _target_speed_vector_thread.start()
        def _target_direction_vector_probe():
            while True:
                val = self.direction_vector_probe.level()
                try:
                    ########################################################
                    #Code to tranlate the vector of directions to strings:
                    direction = ""
                    if val[0] == 0:
                            direction = "No Target Detected"
                    elif val[0] != 0: #if the value is 0 there is no target in sight.
                        for i in range(len(val)):
                            if val[i] == 1:   #if the value is 1 the target is approaching.
                                direction = direction + "Target " + str(i+1) + ": " + "Approaching\t"
                            elif val[i] == 2: #if the value is 2 the target is receding.
                                direction = direction + "Target " + str(i+1) + ": " + "Receding\t"
                    self.set_target_direction_vector(direction)
                    ########################################################
                except AttributeError:
                    pass
                time.sleep(1.0 / (speed_samp_rate))
        _target_direction_vector_thread = threading.Thread(target=_target_direction_vector_probe)
        _target_direction_vector_thread.daemon = True
        _target_direction_vector_thread.start()
        self._speed_textbox_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.speed_textbox,
        	callback=self.set_speed_textbox,
        	label="Targets Speed (Kph)",
        	converter=forms.str_converter(),
        )
        self.GridAdd(self._speed_textbox_text_box, 4, 0, 1, 53)
        self.rational_resampler = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=int(samp_rate/samp_rate_sink),
                taps=None,
                fractional_bw=None,
        )
        self._num_targets_textbox_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.num_targets_textbox,
        	callback=self.set_num_targets_textbox,
        	label="Number of Targets Detected",
        	converter=forms.int_converter(),
        )
        self.GridAdd(self._num_targets_textbox_text_box, 3, 0, 1, 4)
        self.num_targets_probe = blocks.probe_signal_i()
        def _num_targets_probe():
            while True:
                val = self.num_targets_probe.level()
                try:
                    self.set_num_targets(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (speed_samp_rate))
        _num_targets_thread = threading.Thread(target=_num_targets_probe)
        _num_targets_thread.daemon = True
        _num_targets_thread.start()
        self.fft_vxx_0 = fft.fft_vcc(fft_len, True, (window.blackmanharris(fft_len)), True, 1)
        self._direction_textbox_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.direction_textbox,
        	callback=self.set_direction_textbox,
        	label="Targets Direction",
        	converter=forms.str_converter(),
        )
        self.GridAdd(self._direction_textbox_text_box, 5, 0, 1, 53)
        self.cwradar_vector_flip_ff = cwradar.vector_flip_ff(fft_len/2)
        self.cwradar_doppler_velocity_multiple_targets_ff_0 = cwradar.doppler_velocity_multiple_targets_ff(fft_len/2, samp_rate, RF_tuner, threshold_dB_tuner, angle_tuner, lowpass_cutoff_freq_tuner, highpass_cutoff_freq_tuner, max_num_of_targets_tuner, doppler_signal_bw_tuner)
        self.complex_to_mag = blocks.complex_to_mag(fft_len)
        self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream(gr.sizeof_float*1, fft_len)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_float*1, fft_len)
        self.blocks_stream_to_vector_1_0 = blocks.stream_to_vector(gr.sizeof_float*1, fft_len/2)
        self.blocks_stream_to_vector_1 = blocks.stream_to_vector(gr.sizeof_float*1, fft_len/2)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fft_len)
        self.blocks_keep_m_in_n_0_0 = blocks.keep_m_in_n(gr.sizeof_float, fft_len/2, fft_len, fft_len/2)
        self.blocks_keep_m_in_n_0 = blocks.keep_m_in_n(gr.sizeof_float, fft_len/2, fft_len, 0)
        self.DC_filter_0 = blocks.multiply_const_vff(([0]*DC_filter_num_elements+[1]*((fft_len/2)-DC_filter_num_elements)))
        self.DC_filter = blocks.multiply_const_vff(([0]*DC_filter_num_elements+[1]*((fft_len/2)-DC_filter_num_elements)))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.complex_to_mag, 0), (self.blocks_vector_to_stream_0_0, 0))
        self.connect((self.complex_to_mag, 0), (self.blocks_vector_to_stream_0, 0))
        self.connect((self.usrp_receiver, 0), (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.complex_to_mag, 0))
        self.connect((self.rational_resampler, 0), (self.wxgui_fftsink, 0))
        self.connect((self.rational_resampler, 0), (self.wxgui_waterfallsink, 0))
        self.connect((self.usrp_receiver, 0), (self.rational_resampler, 0))
        self.connect((self.usrp_receiver, 0), (self.wxgui_fftsink2_full_spectrum, 0))
        self.connect((self.DC_filter, 0), (self.cwradar_doppler_velocity_multiple_targets_ff_0, 0))
        self.connect((self.DC_filter_0, 0), (self.cwradar_doppler_velocity_multiple_targets_ff_0, 1))
        self.connect((self.cwradar_doppler_velocity_multiple_targets_ff_0, 2), (self.num_targets_probe, 0))
        self.connect((self.cwradar_doppler_velocity_multiple_targets_ff_0, 1), (self.direction_vector_probe, 0))
        self.connect((self.cwradar_doppler_velocity_multiple_targets_ff_0, 0), (self.speed_vector_probe, 0))
        self.connect((self.blocks_vector_to_stream_0_0, 0), (self.blocks_keep_m_in_n_0_0, 0))
        self.connect((self.blocks_keep_m_in_n_0, 0), (self.blocks_stream_to_vector_1, 0))
        self.connect((self.blocks_keep_m_in_n_0_0, 0), (self.blocks_stream_to_vector_1_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_keep_m_in_n_0, 0))
        self.connect((self.blocks_stream_to_vector_1_0, 0), (self.DC_filter_0, 0))
        self.connect((self.blocks_stream_to_vector_1, 0), (self.cwradar_vector_flip_ff, 0))
        self.connect((self.cwradar_vector_flip_ff, 0), (self.DC_filter, 0))