Beispiel #1
0
    def __init__(self, device_name, sample_rate, channel_mapping):
        self.__device_name = device_name
        self.__sample_rate = sample_rate

        if len(channel_mapping) == 2:
            self.__signal_type = SignalType(kind='IQ',
                                            sample_rate=self.__sample_rate)
            # TODO should be configurable
            self.__usable_bandwidth = RangeT([(-self.__sample_rate / 2,
                                               self.__sample_rate / 2)])
        else:
            self.__signal_type = SignalType(
                kind=
                'USB',  # TODO obtain correct type from config (or say hamlib)
                sample_rate=self.__sample_rate)
            self.__usable_bandwidth = RangeT([(500, 2500)])

        gr.hier_block2.__init__(
            self,
            type(self).__name__,
            gr.io_signature(0, 0, 0),
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
        )

        self.__source = audio.source(self.__sample_rate,
                                     device_name=self.__device_name,
                                     ok_to_block=True)

        channel_matrix = blocks.multiply_matrix_ff(channel_mapping)
        combine = blocks.float_to_complex(1)
        for i in xrange(0, len(channel_mapping[0])):
            self.connect((self.__source, i), (channel_matrix, i))
        for i in xrange(0, len(channel_mapping)):
            self.connect((channel_matrix, i), (combine, i))
        self.connect(combine, self)
Beispiel #2
0
 def __init__(self, context):
     gr.hier_block2.__init__(
         self, type(self).__name__,
         gr.io_signature(1, 1, gr.sizeof_float * 1),
         gr.io_signature(1, 1, gr.sizeof_float * 1),
     )
     
     def receive(line):
         message = parse_tnc2(line, time.time(), log=self.__log)
         context.output_message(message)
     
     self.__mm_demod = MultimonNGDemodulator(
         multimon_demod_args=['-A'],
         protocol=APRSProcessProtocol(receive),
         context=context)
     
     # APRS Voice Alert squelch -- see http://www.aprs.org/VoiceAlert3.html
     self.__squelch_mode = None
     self.__squelch_block = analog.ctcss_squelch_ff(
         rate=int(self.__mm_demod.get_output_type().get_sample_rate()),
         freq=100.0,  # TODO: should allow the other Voice Alert tones
         level=0.05,  # amplitude of tone -- TODO: sometimes opens for noise, needs adjustment
         len=0,  # use default
         ramp=0,  # no ramping
         gate=False)
     self.__router = blocks.multiply_matrix_ff([[0, 0]])
     self.set_squelch(u'ctcss')
     
     self.connect(
         self,
         self.__mm_demod,
         self.__squelch_block,
         self.__router,
         self)
     self.connect(self.__mm_demod, (self.__router, 1))
 def run_once(self, X_in, A, tpp=gr.TPP_DONT, A2=None, tags=None, msg_A=None):
     """ Run the test for given input-, output- and matrix values.
     Every row from X_in is considered an input signal on a port. """
     X_in = numpy.matrix(X_in)
     A_matrix = numpy.matrix(A)
     (N, M) = A_matrix.shape
     self.assertTrue(N == X_in.shape[0])
     # Calc expected
     Y_out_exp = numpy.matrix(numpy.zeros((M, X_in.shape[1])))
     self.multiplier = blocks.multiply_matrix_ff(A, tpp)
     if A2 is not None:
         self.multiplier.set_A(A2)
         A = A2
         A_matrix = numpy.matrix(A)
     for i in xrange(N):
         if tags is None:
             these_tags = ()
         else:
             these_tags = (tags[i],)
         self.tb.connect(blocks.vector_source_f(X_in[i].tolist()[0], tags=these_tags), (self.multiplier, i))
     sinks = []
     for i in xrange(M):
         sinks.append(blocks.vector_sink_f())
         self.tb.connect((self.multiplier, i), sinks[i])
     # Run and check
     self.tb.run()
     for i in xrange(X_in.shape[1]):
         Y_out_exp[:,i] = A_matrix * X_in[:,i]
     Y_out = [list(x.data()) for x in sinks]
     if tags is not None:
         self.the_tags = []
         for i in xrange(M):
             self.the_tags.append(sinks[i].tags())
     self.assertEqual(list(Y_out), Y_out_exp.tolist())
Beispiel #4
0
    def __do_connect(self, reason):
        # log.msg(u'receiver do_connect: %s' % (reason,))
        self.context.lock()
        try:
            self.disconnect_all()

            # Connect input of demodulator
            if self.__demod_tunable:
                self.connect(self, self.__demodulator)
            else:
                self.connect(self, self.__rotator, self.__demodulator)

            if self.__demod_output:
                # Construct stereo-to-mono conversion (used at least for level probe)
                if self.__demod_stereo:
                    splitter = blocks.vector_to_streams(gr.sizeof_float, 2)
                    mono_audio = blocks.multiply_matrix_ff(((0.5, 0.5), ))
                    self.connect(self.__demodulator, splitter)
                    self.connect((splitter, 0), (mono_audio, 0))
                    self.connect((splitter, 1), (mono_audio, 1))
                else:
                    mono_audio = self.__demodulator

                # Connect mono audio to level probe
                self.connect(mono_audio, self.probe_audio)

                # Connect demodulator to output gain control, converting as needed
                if (self.__audio_channels == 2) == self.__demod_stereo:
                    # stereo to stereo or mono to mono
                    self.connect(self.__demodulator, self.__audio_gain_block)
                elif self.__audio_channels == 2 and not self.__demod_stereo:
                    # mono to stereo
                    duplicator = blocks.streams_to_vector(gr.sizeof_float, 2)
                    self.connect(self.__demodulator, (duplicator, 0))
                    self.connect(self.__demodulator, (duplicator, 1))
                    self.connect(duplicator, self.__audio_gain_block)
                elif self.__audio_channels == 1 and self.__demod_stereo:
                    # stereo to mono
                    self.connect(mono_audio, self.__audio_gain_block)
                else:
                    raise Exception('shouldn\'t happen')

                # Connect gain control to output of receiver
                self.connect(self.__audio_gain_block, self)
            else:
                # Dummy output, ignored by containing block
                self.connect(
                    blocks.vector_source_f([], vlen=self.__audio_channels),
                    self)

            if self.__output_type != self.__last_output_type:
                self.__last_output_type = self.__output_type
                self.context.changed_needed_connections(u'changed output type')
        finally:
            self.context.unlock()
Beispiel #5
0
 def __do_connect(self, reason):
     # log.msg(u'receiver do_connect: %s' % (reason,))
     self.context.lock()
     try:
         self.disconnect_all()
         
         # Connect input of demodulator
         if self.__demod_tunable:
             self.connect(self, self.__demodulator)
         else:
             self.connect(self, self.__rotator, self.__demodulator)
         
         if self.__demod_output:
             # Construct stereo-to-mono conversion (used at least for level probe)
             if self.__demod_stereo:
                 splitter = blocks.vector_to_streams(gr.sizeof_float, 2)
                 mono_audio = blocks.multiply_matrix_ff(((0.5, 0.5),))
                 self.connect(self.__demodulator, splitter)
                 self.connect((splitter, 0), (mono_audio, 0))
                 self.connect((splitter, 1), (mono_audio, 1))
             else:
                 mono_audio = self.__demodulator
             
             # Connect mono audio to level probe
             self.connect(mono_audio, self.probe_audio)
             
             # Connect demodulator to output gain control, converting as needed
             if (self.__audio_channels == 2) == self.__demod_stereo:
                 # stereo to stereo or mono to mono
                 self.connect(self.__demodulator, self.__audio_gain_block)
             elif self.__audio_channels == 2 and not self.__demod_stereo:
                 # mono to stereo
                 duplicator = blocks.streams_to_vector(gr.sizeof_float, 2)
                 self.connect(self.__demodulator, (duplicator, 0))
                 self.connect(self.__demodulator, (duplicator, 1))
                 self.connect(duplicator, self.__audio_gain_block)
             elif self.__audio_channels == 1 and self.__demod_stereo:
                 # stereo to mono
                 self.connect(mono_audio, self.__audio_gain_block)
             else:
                 raise Exception('shouldn\'t happen')
                 
             # Connect gain control to output of receiver
             self.connect(self.__audio_gain_block, self)
         else:
             # Dummy output, ignored by containing block
             self.connect(
                 blocks.vector_source_f([], vlen=self.__audio_channels),
                 self)
         
         if self.__output_type != self.__last_output_type:
             self.__last_output_type = self.__output_type
             self.context.changed_needed_connections(u'changed output type')
     finally:
         self.context.unlock()
Beispiel #6
0
 def __init__(self,
         device_name,
         sample_rate,
         channel_mapping,
         usable_bandwidth,
         audio_module):
     self.__device_name = device_name
     self.__sample_rate = sample_rate
     
     if len(channel_mapping) == 2:
         self.__signal_type = SignalType(
             kind='IQ',
             sample_rate=self.__sample_rate)
         if usable_bandwidth is not None:
             ub_low, ub_high = usable_bandwidth
             assert ub_high > 0
             if ub_low <= 0:
                 self.__usable_bandwidth = RangeT([(-ub_high, ub_high)])
             else:
                 self.__usable_bandwidth = RangeT([(-ub_high, -ub_low), (ub_low, ub_high)])
         else:
             self.__usable_bandwidth = RangeT([(-self.__sample_rate / 2, self.__sample_rate / 2)])
     else:
         self.__signal_type = SignalType(
             kind='USB',  # TODO obtain correct type from config (or say hamlib)
             sample_rate=self.__sample_rate)
         self.__usable_bandwidth = RangeT([(500, 2500)])
     
     gr.hier_block2.__init__(
         self, type(self).__name__,
         gr.io_signature(0, 0, 0),
         gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
     )
     
     self.__source = audio_module.source(
         self.__sample_rate,
         device_name=self.__device_name,
         ok_to_block=True)
     
     channel_matrix = blocks.multiply_matrix_ff(channel_mapping)
     combine = blocks.float_to_complex(1)
     # TODO: min() is to support mono sources with default channel mapping. Handle this better, and give a warning if an explicit mapping is too big.
     for i in xrange(0, min(len(channel_mapping[0]),
                            self.__source.output_signature().max_streams())):
         self.connect((self.__source, i), (channel_matrix, i))
     for i in xrange(0, len(channel_mapping)):
         self.connect((channel_matrix, i), (combine, i))
     self.connect(combine, self)
Beispiel #7
0
 def init_source():
     self.__source = None
     self.disconnect_all()
 
     self.__source = audio_module.source(
         self.__sample_rate,
         device_name=self.__device_name,
         ok_to_block=True)
 
     channel_matrix = blocks.multiply_matrix_ff(channel_mapping)
     combine = blocks.float_to_complex(1)
     # TODO: min() is to support mono sources with default channel mapping. Handle this better, and give a warning if an explicit mapping is too big.
     for i in xrange(0, min(len(channel_mapping[0]),
                            self.__source.output_signature().max_streams())):
         self.connect((self.__source, i), (channel_matrix, i))
     for i in xrange(0, len(channel_mapping)):
         self.connect((channel_matrix, i), (combine, i))
     self.connect(combine, self)
Beispiel #8
0
 def __init__(self, aprs_information=None, context=None):
     gr.hier_block2.__init__(
         self, self.__class__.__name__,
         gr.io_signature(1, 1, gr.sizeof_float * 1),
         gr.io_signature(1, 1, gr.sizeof_float * 1),
     )
     
     if aprs_information is not None:
         self.__information = aprs_information
     else:
         self.__information = APRSInformation()
     
     def receive(line):
         # %r here provides robustness against arbitrary bytes.
         log.msg(u'APRS: %r' % (line,))
         message = parse_tnc2(line, time.time())
         log.msg(u'   -> %s' % (message,))
         self.__information.receive(message)
     
     self.__mm_demod = MultimonNGDemodulator(
         multimon_demod_args=['-A'],
         protocol=APRSProcessProtocol(receive),
         context=context)
     
     # APRS Voice Alert squelch -- see http://www.aprs.org/VoiceAlert3.html
     self.__squelch_mode = None
     self.__squelch_block = analog.ctcss_squelch_ff(
         rate=int(self.__mm_demod.get_output_type().get_sample_rate()),
         freq=100.0,  # TODO: should allow the other Voice Alert tones
         level=0.05,  # amplitude of tone -- TODO: sometimes opens for noise, needs adjustment
         len=0,  # use default
         ramp=0,  # no ramping
         gate=False)
     self.__router = blocks.multiply_matrix_ff([[0, 0]])
     self.set_squelch(u'ctcss')
     
     self.connect(
         self,
         self.__mm_demod,
         self.__squelch_block,
         self.__router,
         self)
     self.connect(self.__mm_demod, (self.__router, 1))
Beispiel #9
0
 def run_once(self,
              X_in,
              A,
              tpp=gr.TPP_DONT,
              A2=None,
              tags=None,
              msg_A=None):
     """ Run the test for given input-, output- and matrix values.
     Every row from X_in is considered an input signal on a port. """
     X_in = numpy.matrix(X_in)
     A_matrix = numpy.matrix(A)
     (N, M) = A_matrix.shape
     self.assertTrue(N == X_in.shape[0])
     # Calc expected
     Y_out_exp = numpy.matrix(numpy.zeros((M, X_in.shape[1])))
     self.multiplier = blocks.multiply_matrix_ff(A, tpp)
     if A2 is not None:
         self.multiplier.set_A(A2)
         A = A2
         A_matrix = numpy.matrix(A)
     for i in xrange(N):
         if tags is None:
             these_tags = ()
         else:
             these_tags = (tags[i], )
         self.tb.connect(
             blocks.vector_source_f(X_in[i].tolist()[0], tags=these_tags),
             (self.multiplier, i))
     sinks = []
     for i in xrange(M):
         sinks.append(blocks.vector_sink_f())
         self.tb.connect((self.multiplier, i), sinks[i])
     # Run and check
     self.tb.run()
     for i in xrange(X_in.shape[1]):
         Y_out_exp[:, i] = A_matrix * X_in[:, i]
     Y_out = [list(x.data()) for x in sinks]
     if tags is not None:
         self.the_tags = []
         for i in xrange(M):
             self.the_tags.append(sinks[i].tags())
     self.assertEqual(list(Y_out), Y_out_exp.tolist())
Beispiel #10
0
    def __init__(self, aprs_information=None, context=None):
        gr.hier_block2.__init__(
            self,
            self.__class__.__name__,
            gr.io_signature(1, 1, gr.sizeof_float * 1),
            gr.io_signature(1, 1, gr.sizeof_float * 1),
        )

        if aprs_information is not None:
            self.__information = aprs_information
        else:
            self.__information = APRSInformation()

        def receive(line):
            # %r here provides robustness against arbitrary bytes.
            log.msg(u'APRS: %r' % (line, ))
            message = parse_tnc2(line, time.time())
            log.msg(u'   -> %s' % (message, ))
            self.__information.receive(message)

        self.__mm_demod = MultimonNGDemodulator(
            multimon_demod_args=['-A'],
            protocol=APRSProcessProtocol(receive),
            context=context)

        # APRS Voice Alert squelch -- see http://www.aprs.org/VoiceAlert3.html
        self.__squelch_mode = None
        self.__squelch_block = analog.ctcss_squelch_ff(
            rate=int(self.__mm_demod.get_output_type().get_sample_rate()),
            freq=100.0,  # TODO: should allow the other Voice Alert tones
            level=
            0.05,  # amplitude of tone -- TODO: sometimes opens for noise, needs adjustment
            len=0,  # use default
            ramp=0,  # no ramping
            gate=False)
        self.__router = blocks.multiply_matrix_ff([[0, 0]])
        self.set_squelch(u'ctcss')

        self.connect(self, self.__mm_demod, self.__squelch_block,
                     self.__router, self)
        self.connect(self.__mm_demod, (self.__router, 1))
Beispiel #11
0
 def __init__(self,
         device_name,
         sample_rate,
         channel_mapping,
         audio_module):
     self.__device_name = device_name
     self.__sample_rate = sample_rate
     
     if len(channel_mapping) == 2:
         self.__signal_type = SignalType(
             kind='IQ',
             sample_rate=self.__sample_rate)
         # TODO should be configurable
         self.__usable_bandwidth = RangeT([(-self.__sample_rate / 2, self.__sample_rate / 2)])
     else:
         self.__signal_type = SignalType(
             kind='USB',  # TODO obtain correct type from config (or say hamlib)
             sample_rate=self.__sample_rate)
         self.__usable_bandwidth = RangeT([(500, 2500)])
     
     gr.hier_block2.__init__(
         self, type(self).__name__,
         gr.io_signature(0, 0, 0),
         gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
     )
     
     self.__source = audio_module.source(
         self.__sample_rate,
         device_name=self.__device_name,
         ok_to_block=True)
     
     channel_matrix = blocks.multiply_matrix_ff(channel_mapping)
     combine = blocks.float_to_complex(1)
     # TODO: min() is to support mono sources with default channel mapping. Handle this better, and give a warning if an explicit mapping is too big.
     for i in xrange(0, min(len(channel_mapping[0]),
                            self.__source.output_signature().max_streams())):
         self.connect((self.__source, i), (channel_matrix, i))
     for i in xrange(0, len(channel_mapping)):
         self.connect((channel_matrix, i), (combine, i))
     self.connect(combine, self)
Beispiel #12
0
    def __init__(self):
        gr.top_block.__init__(self, "Uhd Hf Am")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Uhd Hf Am")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2.5e6
        self.rx_freq = rx_freq = 1.0e6
        self.fine_freq = fine_freq = 0
        self.coarse_freq = coarse_freq = 0
        self.volume = volume = 1
        self.usb_lsb = usb_lsb = -1
        self.ssb_am = ssb_am = 0
        self.selection = selection = ((1, 0, 0), (0, 1, 0), (0, 0, 1))
        self.pll_lbw = pll_lbw = 200
        self.pll_freq = pll_freq = 100
        self.lpf_cutoff = lpf_cutoff = 2e3
        self.interp = interp = 48
        self.freq_label = freq_label = rx_freq + fine_freq + coarse_freq
        self.decim = decim = samp_rate / 1e3
        self.decay_rate = decay_rate = 100e-6
        self.audio_ref = audio_ref = 1
        self.audio_max_gain = audio_max_gain = 1
        self.audio_gain = audio_gain = 1
        self.audio_decay = audio_decay = 100
        self.audio_attack = audio_attack = 1000

        ##################################################
        # Blocks
        ##################################################
        self._volume_range = Range(0, 100, .1, 1, 200)
        self._volume_win = RangeWidget(self._volume_range, self.set_volume,
                                       "volume", "counter_slider", float)
        self.top_grid_layout.addWidget(self._volume_win, 7, 0, 1, 4)
        for r in range(7, 8):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._usb_lsb_options = (
            -1,
            1,
        )
        self._usb_lsb_labels = (
            'USB',
            'LSB',
        )
        self._usb_lsb_group_box = Qt.QGroupBox("usb_lsb")
        self._usb_lsb_box = Qt.QHBoxLayout()

        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)

            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)

        self._usb_lsb_button_group = variable_chooser_button_group()
        self._usb_lsb_group_box.setLayout(self._usb_lsb_box)
        for i, label in enumerate(self._usb_lsb_labels):
            radio_button = Qt.QRadioButton(label)
            self._usb_lsb_box.addWidget(radio_button)
            self._usb_lsb_button_group.addButton(radio_button, i)
        self._usb_lsb_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._usb_lsb_button_group, "updateButtonChecked",
            Qt.Q_ARG("int", self._usb_lsb_options.index(i)))
        self._usb_lsb_callback(self.usb_lsb)
        self._usb_lsb_button_group.buttonClicked[int].connect(
            lambda i: self.set_usb_lsb(self._usb_lsb_options[i]))
        self.top_grid_layout.addWidget(self._usb_lsb_group_box, 5, 5, 1, 1)
        for r in range(5, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(5, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._ssb_am_options = (
            0,
            1,
            2,
        )
        self._ssb_am_labels = (
            'SSB',
            'AM',
            'AM*',
        )
        self._ssb_am_group_box = Qt.QGroupBox("ssb_am")
        self._ssb_am_box = Qt.QHBoxLayout()

        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)

            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)

        self._ssb_am_button_group = variable_chooser_button_group()
        self._ssb_am_group_box.setLayout(self._ssb_am_box)
        for i, label in enumerate(self._ssb_am_labels):
            radio_button = Qt.QRadioButton(label)
            self._ssb_am_box.addWidget(radio_button)
            self._ssb_am_button_group.addButton(radio_button, i)
        self._ssb_am_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._ssb_am_button_group, "updateButtonChecked",
            Qt.Q_ARG("int", self._ssb_am_options.index(i)))
        self._ssb_am_callback(self.ssb_am)
        self._ssb_am_button_group.buttonClicked[int].connect(
            lambda i: self.set_ssb_am(self._ssb_am_options[i]))
        self.top_grid_layout.addWidget(self._ssb_am_group_box, 4, 4, 1, 1)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 5):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_freq_range = Range(.2e6, 100e6, 100e3, 1.0e6, 200)
        self._rx_freq_win = RangeWidget(self._rx_freq_range, self.set_rx_freq,
                                        "rx_freq", "counter_slider", float)
        self.top_grid_layout.addWidget(self._rx_freq_win, 4, 0, 1, 4)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._pll_lbw_tool_bar = Qt.QToolBar(self)
        self._pll_lbw_tool_bar.addWidget(Qt.QLabel("pll_lbw" + ": "))
        self._pll_lbw_line_edit = Qt.QLineEdit(str(self.pll_lbw))
        self._pll_lbw_tool_bar.addWidget(self._pll_lbw_line_edit)
        self._pll_lbw_line_edit.returnPressed.connect(lambda: self.set_pll_lbw(
            eng_notation.str_to_num(
                str(self._pll_lbw_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._pll_lbw_tool_bar, 9, 7, 1, 1)
        for r in range(9, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(7, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._pll_freq_tool_bar = Qt.QToolBar(self)
        self._pll_freq_tool_bar.addWidget(Qt.QLabel("pll_freq" + ": "))
        self._pll_freq_line_edit = Qt.QLineEdit(str(self.pll_freq))
        self._pll_freq_tool_bar.addWidget(self._pll_freq_line_edit)
        self._pll_freq_line_edit.returnPressed.connect(
            lambda: self.set_pll_freq(
                eng_notation.str_to_num(
                    str(self._pll_freq_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._pll_freq_tool_bar, 9, 6, 1, 1)
        for r in range(9, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(6, 7):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._lpf_cutoff_options = (
            2e3,
            3e3,
            4e3,
            8e3,
        )
        self._lpf_cutoff_labels = (
            str(self._lpf_cutoff_options[0]),
            str(self._lpf_cutoff_options[1]),
            str(self._lpf_cutoff_options[2]),
            str(self._lpf_cutoff_options[3]),
        )
        self._lpf_cutoff_tool_bar = Qt.QToolBar(self)
        self._lpf_cutoff_tool_bar.addWidget(Qt.QLabel("lpf_cutoff" + ": "))
        self._lpf_cutoff_combo_box = Qt.QComboBox()
        self._lpf_cutoff_tool_bar.addWidget(self._lpf_cutoff_combo_box)
        for label in self._lpf_cutoff_labels:
            self._lpf_cutoff_combo_box.addItem(label)
        self._lpf_cutoff_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._lpf_cutoff_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._lpf_cutoff_options.index(i)))
        self._lpf_cutoff_callback(self.lpf_cutoff)
        self._lpf_cutoff_combo_box.currentIndexChanged.connect(
            lambda i: self.set_lpf_cutoff(self._lpf_cutoff_options[i]))
        self.top_grid_layout.addWidget(self._lpf_cutoff_tool_bar, 4, 5, 1, 1)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(5, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._fine_freq_range = Range(-1e3, 1e3, 1, 0, 200)
        self._fine_freq_win = RangeWidget(self._fine_freq_range,
                                          self.set_fine_freq, "fine_freq",
                                          "counter_slider", float)
        self.top_grid_layout.addWidget(self._fine_freq_win, 6, 0, 1, 4)
        for r in range(6, 7):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._decay_rate_options = (
            100e-6,
            65e-3,
            20e-3,
        )
        self._decay_rate_labels = (
            'Fast',
            'Medium',
            'Slow',
        )
        self._decay_rate_group_box = Qt.QGroupBox("decay_rate")
        self._decay_rate_box = Qt.QHBoxLayout()

        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)

            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)

        self._decay_rate_button_group = variable_chooser_button_group()
        self._decay_rate_group_box.setLayout(self._decay_rate_box)
        for i, label in enumerate(self._decay_rate_labels):
            radio_button = Qt.QRadioButton(label)
            self._decay_rate_box.addWidget(radio_button)
            self._decay_rate_button_group.addButton(radio_button, i)
        self._decay_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._decay_rate_button_group, "updateButtonChecked",
            Qt.Q_ARG("int", self._decay_rate_options.index(i)))
        self._decay_rate_callback(self.decay_rate)
        self._decay_rate_button_group.buttonClicked[int].connect(
            lambda i: self.set_decay_rate(self._decay_rate_options[i]))
        self.top_grid_layout.addWidget(self._decay_rate_group_box, 4, 6, 1, 1)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(6, 7):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._coarse_freq_range = Range(-100e3, 100e3, 1, 0, 200)
        self._coarse_freq_win = RangeWidget(self._coarse_freq_range,
                                            self.set_coarse_freq,
                                            "coarse_freq", "counter_slider",
                                            float)
        self.top_grid_layout.addWidget(self._coarse_freq_win, 5, 0, 1, 4)
        for r in range(5, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._audio_ref_tool_bar = Qt.QToolBar(self)
        self._audio_ref_tool_bar.addWidget(Qt.QLabel("audio_ref" + ": "))
        self._audio_ref_line_edit = Qt.QLineEdit(str(self.audio_ref))
        self._audio_ref_tool_bar.addWidget(self._audio_ref_line_edit)
        self._audio_ref_line_edit.returnPressed.connect(
            lambda: self.set_audio_ref(
                eng_notation.str_to_num(
                    str(self._audio_ref_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._audio_ref_tool_bar, 9, 3, 1, 1)
        for r in range(9, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._audio_max_gain_tool_bar = Qt.QToolBar(self)
        self._audio_max_gain_tool_bar.addWidget(
            Qt.QLabel("audio_max_gain" + ": "))
        self._audio_max_gain_line_edit = Qt.QLineEdit(str(self.audio_max_gain))
        self._audio_max_gain_tool_bar.addWidget(self._audio_max_gain_line_edit)
        self._audio_max_gain_line_edit.returnPressed.connect(
            lambda: self.set_audio_max_gain(
                eng_notation.str_to_num(
                    str(self._audio_max_gain_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._audio_max_gain_tool_bar, 9, 5, 1,
                                       1)
        for r in range(9, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(5, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._audio_gain_tool_bar = Qt.QToolBar(self)
        self._audio_gain_tool_bar.addWidget(Qt.QLabel("audio_gain" + ": "))
        self._audio_gain_line_edit = Qt.QLineEdit(str(self.audio_gain))
        self._audio_gain_tool_bar.addWidget(self._audio_gain_line_edit)
        self._audio_gain_line_edit.returnPressed.connect(
            lambda: self.set_audio_gain(
                eng_notation.str_to_num(
                    str(self._audio_gain_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._audio_gain_tool_bar, 9, 4, 1, 1)
        for r in range(9, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 5):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._audio_decay_tool_bar = Qt.QToolBar(self)
        self._audio_decay_tool_bar.addWidget(Qt.QLabel("audio_decay" + ": "))
        self._audio_decay_line_edit = Qt.QLineEdit(str(self.audio_decay))
        self._audio_decay_tool_bar.addWidget(self._audio_decay_line_edit)
        self._audio_decay_line_edit.returnPressed.connect(
            lambda: self.set_audio_decay(
                eng_notation.str_to_num(
                    str(self._audio_decay_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._audio_decay_tool_bar, 9, 2, 1, 1)
        for r in range(9, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._audio_attack_tool_bar = Qt.QToolBar(self)
        self._audio_attack_tool_bar.addWidget(Qt.QLabel("audio_attack" + ": "))
        self._audio_attack_line_edit = Qt.QLineEdit(str(self.audio_attack))
        self._audio_attack_tool_bar.addWidget(self._audio_attack_line_edit)
        self._audio_attack_line_edit.returnPressed.connect(
            lambda: self.set_audio_attack(
                eng_notation.str_to_num(
                    str(self._audio_attack_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._audio_attack_tool_bar, 9, 1, 1, 1)
        for r in range(9, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.uhd_usrp_source_1 = uhd.usrp_source(
            ",".join(("addr=192.168.10.2", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_1.set_clock_source('external', 0)
        self.uhd_usrp_source_1.set_time_source('external', 0)
        self.uhd_usrp_source_1.set_subdev_spec('A:AB', 0)
        self.uhd_usrp_source_1.set_samp_rate(samp_rate)
        self.uhd_usrp_source_1.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)
        self.uhd_usrp_source_1.set_center_freq(uhd.tune_request(rx_freq, ), 0)
        self.uhd_usrp_source_1.set_gain(0, 0)
        self.uhd_usrp_source_1.set_auto_dc_offset(True, 0)
        self.uhd_usrp_source_1.set_auto_iq_balance(True, 0)
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=4,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
            interpolation=200,
            decimation=int(samp_rate / 1e3),
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=interp,
            decimation=int(decim),
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate / decim * interp / 3,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 8, 0, 1,
                                       4)
        for r in range(8, 9):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_HORIZ, 1)
        self.qtgui_number_sink_0.set_update_time(0.010)
        self.qtgui_number_sink_0.set_title('')

        labels = ["RSSI", '', '', '', '', '', '', '', '', '']
        units = ['', '', '', '', '', '', '', '', '', '']
        colors = [("blue", "red"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black")]
        factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        for i in xrange(1):
            self.qtgui_number_sink_0.set_min(i, 0)
            self.qtgui_number_sink_0.set_max(i, 50)
            self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0.set_label(i, labels[i])
            self.qtgui_number_sink_0.set_unit(i, units[i])
            self.qtgui_number_sink_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0.enable_autoscale(False)
        self._qtgui_number_sink_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 5, 6, 1,
                                       1)
        for r in range(5, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(6, 7):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / decim * interp / 3,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0_0.set_update_time(0.0010)
        self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0,
                                                    0, "")
        self.qtgui_freq_sink_x_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0.enable_grid(True)
        self.qtgui_freq_sink_x_0_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_0_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 6, 4,
                                       3, 2)
        for r in range(6, 9):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / decim * interp,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.010)
        self.qtgui_freq_sink_x_0.set_y_axis(-120, -10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 4, 4,
                                       4)
        for r in range(0, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.low_pass_filter_0_1 = filter.interp_fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate / decim * interp / 3, 1.5e3, 100,
                            firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            3,
            firdes.low_pass(1, samp_rate / decim * interp, lpf_cutoff, 100,
                            firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.interp_fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate / decim * interp / 3, 1.5e3, 100,
                            firdes.WIN_HAMMING, 6.76))
        self._freq_label_tool_bar = Qt.QToolBar(self)

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

        self._freq_label_tool_bar.addWidget(Qt.QLabel('Tuned Freq' + ": "))
        self._freq_label_label = Qt.QLabel(
            str(self._freq_label_formatter(self.freq_label)))
        self._freq_label_tool_bar.addWidget(self._freq_label_label)
        self.top_grid_layout.addWidget(self._freq_label_tool_bar, 5, 4, 1, 1)
        for r in range(5, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 5):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.fosphor_qt_sink_c_0 = fosphor.qt_sink_c()
        self.fosphor_qt_sink_c_0.set_fft_window(window.WIN_BLACKMAN_hARRIS)
        self.fosphor_qt_sink_c_0.set_frequency_range(
            rx_freq, samp_rate / int(samp_rate / 1e3) * 200)
        self._fosphor_qt_sink_c_0_win = sip.wrapinstance(
            self.fosphor_qt_sink_c_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._fosphor_qt_sink_c_0_win, 0, 0, 4,
                                       4)
        for r in range(0, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.blocks_multiply_xx_1_0 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_matrix_xx_0_0_0 = blocks.multiply_matrix_cc(
            (selection[ssb_am], ), gr.TPP_ALL_TO_ALL)
        self.blocks_multiply_matrix_xx_0 = blocks.multiply_matrix_ff(
            (selection[ssb_am], ), gr.TPP_ALL_TO_ALL)
        self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff(
            (100000, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff(
            (usb_lsb, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (volume, ))
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            1000, 1 / 1000.0, 4000, 1)
        self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.audio_sink_0 = audio.sink(16000, '', True)
        self.analog_sig_source_x_0_0_0 = analog.sig_source_f(
            samp_rate / decim * interp / 3, analog.GR_SIN_WAVE, 1.5e3, 1, 0)
        self.analog_sig_source_x_0_0 = analog.sig_source_f(
            samp_rate / decim * interp / 3, analog.GR_COS_WAVE, 1.5e3, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, -1 * (fine_freq + coarse_freq), 1,
            0)
        self.analog_pll_carriertracking_cc_0 = analog.pll_carriertracking_cc(
            math.pi / pll_lbw, math.pi / pll_freq, -math.pi / pll_freq)
        self.analog_agc2_xx_0_0 = analog.agc2_ff(audio_attack, audio_decay,
                                                 audio_ref, audio_gain)
        self.analog_agc2_xx_0_0.set_max_gain(audio_max_gain)
        self.analog_agc2_xx_0 = analog.agc2_cc(0.1, decay_rate, .3, 1000)
        self.analog_agc2_xx_0.set_max_gain(65000)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc2_xx_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.analog_agc2_xx_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.analog_agc2_xx_0_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.analog_pll_carriertracking_cc_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.analog_pll_carriertracking_cc_0, 0),
                     (self.blocks_multiply_matrix_xx_0_0_0, 2))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_xx_1, 1))
        self.connect((self.analog_sig_source_x_0_0_0, 0),
                     (self.blocks_multiply_xx_1_0, 1))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blocks_multiply_matrix_xx_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.low_pass_filter_0_1, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_multiply_matrix_xx_0, 2))
        self.connect((self.blocks_complex_to_real_0_0, 0),
                     (self.blocks_multiply_matrix_xx_0, 1))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_multiply_const_vxx_1_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.qtgui_number_sink_0, 0))
        self.connect((self.blocks_multiply_matrix_xx_0, 0),
                     (self.analog_agc2_xx_0_0, 0))
        self.connect((self.blocks_multiply_matrix_xx_0_0_0, 0),
                     (self.qtgui_freq_sink_x_0_0, 0))
        self.connect((self.blocks_multiply_matrix_xx_0_0_0, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_xx_1_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.blocks_multiply_xx_1, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.analog_pll_carriertracking_cc_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.blocks_complex_to_real_0_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.blocks_multiply_matrix_xx_0_0_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.blocks_multiply_matrix_xx_0_0_0, 1))
        self.connect((self.low_pass_filter_0_1, 0),
                     (self.blocks_multiply_xx_1_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.fosphor_qt_sink_c_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.uhd_usrp_source_1, 0), (self.analog_agc2_xx_0, 0))
Beispiel #13
0
    def __init__(self):
        gr.top_block.__init__(self, "Symbol Sync Test (Float)")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Symbol Sync Test (Float)")
        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", "symbol_sync_test_float")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.zeta = zeta = 1.0
        self.omega_n_norm = omega_n_norm = 0.125
        self.ted_gain = ted_gain = 0.28365
        self.omega_d_norm = omega_d_norm = omega_n_norm * math.sqrt(
            (zeta * zeta - 1.0) if zeta > 1.0 else (1.0 - zeta * zeta))
        self.proportional_gain = proportional_gain = 2.0 / ted_gain * math.exp(
            -zeta * omega_n_norm) * math.sinh(zeta * omega_n_norm)
        self.integral_gain = integral_gain = 2.0 / ted_gain * (
            1.0 - math.exp(-zeta * omega_n_norm) *
            (math.sinh(zeta * omega_n_norm) +
             (math.cosh(omega_d_norm)
              if zeta > 1.0 else math.cos(omega_d_norm))))
        self.sps = sps = 7
        self.proportional_gain_label = proportional_gain_label = "%8.6f" % proportional_gain
        self.packet_time_est_tag = packet_time_est_tag = gr.tag_utils.python_to_tag(
            (9, pmt.intern("test"), pmt.from_double(0.0),
             pmt.intern("packet_vector_source")))
        self.osps = osps = 1
        self.integral_gain_label = integral_gain_label = "%8.6f" % integral_gain
        self.data_src = data_src = (0, 0, 0, 0, 1)
        self.baud_rate = baud_rate = 1200.0

        ##################################################
        # Blocks
        ##################################################
        self._zeta_range = Range(0.1, 5.0, 0.1, 1.0, 200)
        self._zeta_win = RangeWidget(self._zeta_range, self.set_zeta,
                                     'Damping Factor', "counter_slider", float)
        self.top_grid_layout.addWidget(self._zeta_win, 0, 1, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._ted_gain_range = Range(0.05, 5.0, 0.01, 0.28365, 200)
        self._ted_gain_win = RangeWidget(self._ted_gain_range,
                                         self.set_ted_gain,
                                         'Expected TED Gain', "counter_slider",
                                         float)
        self.top_grid_layout.addWidget(self._ted_gain_win, 1, 0, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._omega_n_norm_range = Range(0.0, 2.0 * math.pi * 0.25, 0.001,
                                         0.125, 200)
        self._omega_n_norm_win = RangeWidget(self._omega_n_norm_range,
                                             self.set_omega_n_norm,
                                             'Normalized Bandwidth',
                                             "counter_slider", float)
        self.top_grid_layout.addWidget(self._omega_n_norm_win, 1, 1, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._data_src_options = (
            (1, 0, 0, 0, 0),
            (0, 1, 0, 0, 0),
            (0, 0, 1, 0, 0),
            (0, 0, 0, 1, 0),
            (0, 0, 0, 0, 1),
        )
        self._data_src_labels = (
            'Random',
            'Low freq',
            'Dot Pattern',
            'Pulse',
            'Packets',
        )
        self._data_src_tool_bar = Qt.QToolBar(self)
        self._data_src_tool_bar.addWidget(Qt.QLabel('Data Source' + ": "))
        self._data_src_combo_box = Qt.QComboBox()
        self._data_src_tool_bar.addWidget(self._data_src_combo_box)
        for label in self._data_src_labels:
            self._data_src_combo_box.addItem(label)
        self._data_src_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._data_src_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._data_src_options.index(i)))
        self._data_src_callback(self.data_src)
        self._data_src_combo_box.currentIndexChanged.connect(
            lambda i: self.set_data_src(self._data_src_options[i]))
        self.top_grid_layout.addWidget(self._data_src_tool_bar, 0, 0, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=10,
            decimation=21,
            taps=None,
            fractional_bw=0.45,
        )
        self.qtgui_time_sink_x_0_1_0 = qtgui.time_sink_f(
            1024 * 3,  #size
            baud_rate * sps,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_1_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_1_0.set_y_axis(-1.5, 1.5)

        self.qtgui_time_sink_x_0_1_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0_1_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_1_0.set_trigger_mode(qtgui.TRIG_MODE_NORM,
                                                      qtgui.TRIG_SLOPE_POS,
                                                      0.1, 0.01, 0, '')
        self.qtgui_time_sink_x_0_1_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0_1_0.enable_grid(True)
        self.qtgui_time_sink_x_0_1_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_1_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0_1_0.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_0_1_0.disable_legend()

        labels = ['', '', '', '', 'Baseband', 'Abs(Corr)', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "dark green", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_1_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_1_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_1_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_1_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_1_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_1_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_1_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_1_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_0_win, 3, 0,
                                       1, 1)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0_0_0_0_0 = qtgui.time_sink_f(
            256 * osps,  #size
            baud_rate * osps,  #samp_rate
            'Symbol Synched Output and Debug',  #name
            4  #number of inputs
        )
        self.qtgui_time_sink_x_0_0_0_0_0.set_update_time(0.1)
        self.qtgui_time_sink_x_0_0_0_0_0.set_y_axis(-1.5, sps + 2)

        self.qtgui_time_sink_x_0_0_0_0_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0_0_0_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_0_0_0_0.set_trigger_mode(
            qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, 0.1, 0.01, 0,
            "time_est")
        self.qtgui_time_sink_x_0_0_0_0_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0_0_0_0_0.enable_grid(False)
        self.qtgui_time_sink_x_0_0_0_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_0_0_0_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0_0_0_0_0.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_0_0_0_0_0.disable_legend()

        labels = [
            'Soft Bits', 'Error', 'Instantaneous Period', 'Average Period', '',
            '', '', '', '', ''
        ]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [0, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(4):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_0_0_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0_0_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0_0_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0_0_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0_0_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0_0_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0_0_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_0_0_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_0_0_0_win,
                                       3, 1, 1, 2)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._proportional_gain_label_tool_bar = Qt.QToolBar(self)

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

        self._proportional_gain_label_tool_bar.addWidget(
            Qt.QLabel('Proportional Gain' + ": "))
        self._proportional_gain_label_label = Qt.QLabel(
            str(
                self._proportional_gain_label_formatter(
                    self.proportional_gain_label)))
        self._proportional_gain_label_tool_bar.addWidget(
            self._proportional_gain_label_label)
        self.top_grid_layout.addWidget(self._proportional_gain_label_tool_bar,
                                       1, 2, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._integral_gain_label_tool_bar = Qt.QToolBar(self)

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

        self._integral_gain_label_tool_bar.addWidget(
            Qt.QLabel('Integral Gain' + ": "))
        self._integral_gain_label_label = Qt.QLabel(
            str(self._integral_gain_label_formatter(self.integral_gain_label)))
        self._integral_gain_label_tool_bar.addWidget(
            self._integral_gain_label_label)
        self.top_grid_layout.addWidget(self._integral_gain_label_tool_bar, 0,
                                       2, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.fir_filter_xxx_0_1_0_0_0 = filter.fir_filter_fff(
            1, ([1.0 / float(sps)] * sps))
        self.fir_filter_xxx_0_1_0_0_0.declare_sample_delay(
            int((sps - 1.0) / 2.0) + 4)
        self.epy_block_0 = epy_block_0.ConstMap()
        self.digital_symbol_sync_xx_0 = digital.symbol_sync_ff(
            digital.TED_MUELLER_AND_MULLER, sps, omega_n_norm, zeta, ted_gain,
            1.5, osps,
            digital.constellation_bpsk().base(), digital.IR_MMSE_8TAP, 128,
            ([]))
        self.blocks_vector_source_x_0_0_1_0 = blocks.vector_source_f(
            [1, 0] * (4 * 12 * 0) + [1, 1, 0, 1, 0, 1, 0, 1] * 12 +
            [1, 0, 1, 1, 1, 1, 1, 0, 0, 1] + [1, 1, 1, 1, 0, 1, 1, 0, 0, 1] +
            [1, 0, 1, 1, 1, 1, 1, 0, 0, 1] + [0, 1, 1, 1, 0, 1, 1, 0, 1, 0] +
            [0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0] +
            [2] * 128, True, 1, [packet_time_est_tag])
        self.blocks_vector_source_x_0_0_1 = blocks.vector_source_f(
            [1] + [0] * 7, True, 1, [])
        self.blocks_vector_source_x_0_0_0 = blocks.vector_source_f(
            (0, 0, 0, 0, 1, 1, 1, 1), True, 1, [])
        self.blocks_vector_source_x_0_0 = blocks.vector_source_f(
            (0, 1, 0, 1, 0, 1, 0, 1), True, 1, [])
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1,
                                                 baud_rate * 10, True)
        self.blocks_short_to_float_1 = blocks.short_to_float(1, 1)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float * 1, sps * 2)
        self.blocks_multiply_matrix_xx_0 = blocks.multiply_matrix_ff(
            (data_src, ), gr.TPP_ALL_TO_ALL)
        self.analog_random_source_x_0 = blocks.vector_source_s(
            map(int, numpy.random.randint(0, 2, 16384)), True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_0, 0),
                     (self.blocks_short_to_float_1, 0))
        self.connect((self.blocks_multiply_matrix_xx_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_repeat_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_short_to_float_1, 0),
                     (self.blocks_multiply_matrix_xx_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.epy_block_0, 0))
        self.connect((self.blocks_vector_source_x_0_0, 0),
                     (self.blocks_multiply_matrix_xx_0, 2))
        self.connect((self.blocks_vector_source_x_0_0_0, 0),
                     (self.blocks_multiply_matrix_xx_0, 1))
        self.connect((self.blocks_vector_source_x_0_0_1, 0),
                     (self.blocks_multiply_matrix_xx_0, 3))
        self.connect((self.blocks_vector_source_x_0_0_1_0, 0),
                     (self.blocks_multiply_matrix_xx_0, 4))
        self.connect((self.digital_symbol_sync_xx_0, 3),
                     (self.qtgui_time_sink_x_0_0_0_0_0, 3))
        self.connect((self.digital_symbol_sync_xx_0, 2),
                     (self.qtgui_time_sink_x_0_0_0_0_0, 2))
        self.connect((self.digital_symbol_sync_xx_0, 1),
                     (self.qtgui_time_sink_x_0_0_0_0_0, 1))
        self.connect((self.digital_symbol_sync_xx_0, 0),
                     (self.qtgui_time_sink_x_0_0_0_0_0, 0))
        self.connect((self.epy_block_0, 0), (self.blocks_repeat_0, 0))
        self.connect((self.fir_filter_xxx_0_1_0_0_0, 0),
                     (self.digital_symbol_sync_xx_0, 0))
        self.connect((self.fir_filter_xxx_0_1_0_0_0, 0),
                     (self.qtgui_time_sink_x_0_1_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.fir_filter_xxx_0_1_0_0_0, 0))